| Index: content/browser/resources/media/new/hover.js
|
| diff --git a/content/browser/resources/media/new/hover.js b/content/browser/resources/media/new/hover.js
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..28638b8530c058249069f0380f481b83b1e8227b
|
| --- /dev/null
|
| +++ b/content/browser/resources/media/new/hover.js
|
| @@ -0,0 +1,49 @@
|
| +// 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.
|
| +
|
| +
|
| +/**
|
| + * A function-object for displaying a tooltip.
|
| + * usage:
|
| + *
|
| + * hover("hi there!");
|
| + * hover.set(100,250);
|
| + * hover.stop();
|
| + */
|
| +var hover = (function () {
|
| + "use strict";
|
| +
|
| + // Make a div to hold our tooltip.
|
| + // There will only be one globally, so we can close over
|
| + // a single one.
|
| + var hoverElement = document.createElement('div');
|
| + document.querySelector('body').appendChild(hoverElement);
|
| +
|
| + // The visible style is what we will see when the hover is applied.
|
| + var visibleStyle = "position:absolute; display: block; padding:10px; " +
|
| + "border: 1px solid black; background: white; " +
|
| + "padding-top: 3px; padding-bottom: 3px;";
|
| +
|
| +// Set the text for the tooltip
|
| + var hover = function (text) {
|
| + hoverElement.setAttribute('style', visibleStyle);
|
| + removeChildren(hoverElement);
|
| + hoverElement.appendChild(document.createTextNode(text));
|
| + };
|
| +
|
| +// Make the tooltip disapear
|
| + hover.stop = function () {
|
| + hoverElement.setAttribute('style', "display:none;");
|
| + };
|
| +
|
| +// Set the position of the tooltip
|
| + hover.set = function (x, y) {
|
| + x += 15;
|
| + y -= 20;
|
| + hoverElement.setAttribute('style', visibleStyle +
|
| + " left: " + x + "px; top: " + y + ";");
|
| + };
|
| +
|
| + return hover;
|
| +}());
|
|
|