lib/assets/javascripts/up/tooltip.js.coffee in upjs-rails-0.3.3 vs lib/assets/javascripts/up/tooltip.js.coffee in upjs-rails-0.4.0
- old
+ new
@@ -29,11 +29,11 @@
top: linkBox.top - tooltipBox.height
when "bottom"
left: linkBox.left + 0.5 * (linkBox.width - tooltipBox.width)
top: linkBox.top + linkBox.height
else
- u.error("Unknown origin", origin)
+ u.error("Unknown origin %o", origin)
$tooltip.attr('up-origin', origin)
$tooltip.css(css)
createElement = (html) ->
u.$createElementFromSelector('.up-tooltip')
@@ -49,11 +49,11 @@
@param {String} [options.origin='top']
@param {String} [options.animation]
###
open = (linkOrSelector, options = {}) ->
$link = $(linkOrSelector)
- html = u.option(options.html, $link.attr('up-tooltip'))
+ html = u.option(options.html, $link.attr('up-tooltip'), $link.attr('title'))
origin = u.option(options.origin, $link.attr('up-origin'), 'top')
animation = u.option(options.animation, $link.attr('up-animation'), 'fade-in')
close()
$tooltip = createElement(html)
position($link, $tooltip, origin)
@@ -76,9 +76,13 @@
###*
Displays a tooltip when hovering the mouse over this element:
<a href="/decks" up-tooltip="Show all decks">Decks</a>
+
+ You can also make an existing `title` attribute appear as a tooltip:
+
+ <a href="/decks" title="Show all decks" up-tooltip>Decks</a>
@method [up-tooltip]
@ujs
###
up.awaken('[up-tooltip]', ($link) ->