Module: TooltipHelper

Defined in:
app/helpers/tooltip_helper.rb

Instance Method Summary collapse

Instance Method Details

#tooltip_for(id, tip) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/helpers/tooltip_helper.rb', line 2

def tooltip_for(id, tip)
  
 js = "   Event.observe($('\#{id}'), 'mouseover', function () { \n      $('tooltip').innerHTML= \"\#{tip}\"\n      $('tooltip').show()\n      return false\n    });\n\n    Event.observe($('\#{id}'), 'mouseout',  function (){\n      $('tooltip').hide()\n    });\n    \n    document.observe('mousemove', function (e) {\n      if ($('tooltip').visible())\n        {\n          $('tooltip').setStyle('left: ' + e.pointerX() + 'px;');\n          $('tooltip').setStyle('top: ' + (e.pointerY() - 30) + 'px;');\n        }\n    });\n  EOJS\n  content_for :javascript do\n    javascript_tag js\n  end\n  \n  content_for :head do \n    stylesheet_link_tag 'tooltip'\n  end\n  \n  \"<div id='tooltip' style='display: none'></div>\"\nend\n"