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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « netlog_viewer/modules_view.js ('k') | netlog_viewer/prerender_view.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: netlog_viewer/mouse_over_help.js
diff --git a/netlog_viewer/mouse_over_help.js b/netlog_viewer/mouse_over_help.js
new file mode 100644
index 0000000000000000000000000000000000000000..f4a33e95e74614f0947a3757bebe250372878ba3
--- /dev/null
+++ b/netlog_viewer/mouse_over_help.js
@@ -0,0 +1,65 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+/**
+ * Class to handle display and placement of a div that appears under the cursor
+ * when it overs over a specied element. The div always appears below and to
+ * the left of the cursor.
+ */
+var MouseOverHelp = (function() {
+ 'use strict';
+
+ /**
+ * @param {string} helpDivId Name of the div to position and display
+ * @param {string} mouseOverElementId Name the element that displays the
+ * |helpDivId| div on mouse over.
+ * @constructor
+ */
+ function MouseOverHelp(helpDivId, mouseOverElementId) {
+ this.node_ = $(helpDivId);
+
+ $(mouseOverElementId).onmouseover = this.onMouseOver.bind(this);
+ $(mouseOverElementId).onmouseout = this.onMouseOut.bind(this);
+
+ this.show(false);
+ }
+
+ MouseOverHelp.prototype = {
+ /**
+ * Positions and displays the div, if not already visible.
+ * @param {MouseEvent} event Mouse event that triggered the call.
+ */
+ onMouseOver: function(event) {
+ if (this.isVisible_)
+ return;
+
+ this.node_.style.position = 'absolute';
+
+ this.show(true);
+
+ this.node_.style.left = (event.clientX + 15).toFixed(0) + 'px';
+ this.node_.style.top = event.clientY.toFixed(0) + 'px';
+ },
+
+ /**
+ * Hides the div when the cursor leaves the hover element.
+ * @param {MouseEvent} event Mouse event that triggered the call.
+ */
+ onMouseOut: function(event) {
+ this.show(false);
+ },
+
+ /**
+ * Sets the div's visibility.
+ * @param {boolean} isVisible True if the help div should be shown.
+ */
+ show: function(isVisible) {
+ setNodeDisplay(this.node_, isVisible);
+ this.isVisible_ = isVisible;
+ },
+ };
+
+ return MouseOverHelp;
+})();
+
« 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