1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
6 * Class to handle display and placement of a div that appears under the cursor
7 * when it overs over a specied element. The div always appears below and to
8 * the left of the cursor.
10 var MouseOverHelp
= (function() {
14 * @param {string} helpDivId Name of the div to position and display
15 * @param {string} mouseOverElementId Name the element that displays the
16 * |helpDivId| div on mouse over.
19 function MouseOverHelp(helpDivId
, mouseOverElementId
) {
20 this.node_
= $(helpDivId
);
22 $(mouseOverElementId
).onmouseover
= this.onMouseOver
.bind(this);
23 $(mouseOverElementId
).onmouseout
= this.onMouseOut
.bind(this);
28 MouseOverHelp
.prototype = {
30 * Positions and displays the div, if not already visible.
31 * @param {MouseEvent} event Mouse event that triggered the call.
33 onMouseOver: function(event
) {
37 this.node_
.style
.position
= 'absolute';
41 this.node_
.style
.left
= (event
.clientX
+ 15).toFixed(0) + 'px';
42 this.node_
.style
.top
= event
.clientY
.toFixed(0) + 'px';
46 * Hides the div when the cursor leaves the hover element.
47 * @param {MouseEvent} event Mouse event that triggered the call.
49 onMouseOut: function(event
) {
54 * Sets the div's visibility.
55 * @param {boolean} isVisible True if the help div should be shown.
57 show: function(isVisible
) {
58 setNodeDisplay(this.node_
, isVisible
);
59 this.isVisible_
= isVisible
;