Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(898)

Side by Side Diff: netlog_viewer/mouse_over_help.js

Issue 2162963002: [polymer] Merge of master into polymer10-migration (Closed) Base URL: git@github.com:catapult-project/catapult.git@polymer10-migration
Patch Set: Merge polymer10-migration int polymer10-merge Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « netlog_viewer/modules_view.js ('k') | netlog_viewer/prerender_view.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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.
4
5 /**
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.
9 */
10 var MouseOverHelp = (function() {
11 'use strict';
12
13 /**
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.
17 * @constructor
18 */
19 function MouseOverHelp(helpDivId, mouseOverElementId) {
20 this.node_ = $(helpDivId);
21
22 $(mouseOverElementId).onmouseover = this.onMouseOver.bind(this);
23 $(mouseOverElementId).onmouseout = this.onMouseOut.bind(this);
24
25 this.show(false);
26 }
27
28 MouseOverHelp.prototype = {
29 /**
30 * Positions and displays the div, if not already visible.
31 * @param {MouseEvent} event Mouse event that triggered the call.
32 */
33 onMouseOver: function(event) {
34 if (this.isVisible_)
35 return;
36
37 this.node_.style.position = 'absolute';
38
39 this.show(true);
40
41 this.node_.style.left = (event.clientX + 15).toFixed(0) + 'px';
42 this.node_.style.top = event.clientY.toFixed(0) + 'px';
43 },
44
45 /**
46 * Hides the div when the cursor leaves the hover element.
47 * @param {MouseEvent} event Mouse event that triggered the call.
48 */
49 onMouseOut: function(event) {
50 this.show(false);
51 },
52
53 /**
54 * Sets the div's visibility.
55 * @param {boolean} isVisible True if the help div should be shown.
56 */
57 show: function(isVisible) {
58 setNodeDisplay(this.node_, isVisible);
59 this.isVisible_ = isVisible;
60 },
61 };
62
63 return MouseOverHelp;
64 })();
65
OLDNEW
« no previous file with comments | « netlog_viewer/modules_view.js ('k') | netlog_viewer/prerender_view.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698