| OLD | NEW | 
|    1 /* |    1 /* | 
|    2  * Copyright (C) 2009 Google Inc. All rights reserved. |    2  * Copyright (C) 2009 Google Inc. All rights reserved. | 
|    3  * |    3  * | 
|    4  * Redistribution and use in source and binary forms, with or without |    4  * Redistribution and use in source and binary forms, with or without | 
|    5  * modification, are permitted provided that the following conditions are |    5  * modification, are permitted provided that the following conditions are | 
|    6  * met: |    6  * met: | 
|    7  * |    7  * | 
|    8  *     * Redistributions of source code must retain the above copyright |    8  *     * Redistributions of source code must retain the above copyright | 
|    9  * notice, this list of conditions and the following disclaimer. |    9  * notice, this list of conditions and the following disclaimer. | 
|   10  *     * Redistributions in binary form must reproduce the above |   10  *     * Redistributions in binary form must reproduce the above | 
| (...skipping 20 matching lines...) Expand all  Loading... | 
|   31 /** |   31 /** | 
|   32  * @constructor |   32  * @constructor | 
|   33  * @extends {WebInspector.View} |   33  * @extends {WebInspector.View} | 
|   34  * @param {!WebInspector.PopoverHelper=} popoverHelper |   34  * @param {!WebInspector.PopoverHelper=} popoverHelper | 
|   35  */ |   35  */ | 
|   36 WebInspector.Popover = function(popoverHelper) |   36 WebInspector.Popover = function(popoverHelper) | 
|   37 { |   37 { | 
|   38     WebInspector.View.call(this); |   38     WebInspector.View.call(this); | 
|   39     this.markAsRoot(); |   39     this.markAsRoot(); | 
|   40     this.element.className = WebInspector.Popover._classNamePrefix; // Override |   40     this.element.className = WebInspector.Popover._classNamePrefix; // Override | 
 |   41     WebInspector.installComponentRootStyles(this.element); | 
|   41     this._containerElement = createElementWithClass("div", "fill popover-contain
     er"); |   42     this._containerElement = createElementWithClass("div", "fill popover-contain
     er"); | 
|   42  |   43  | 
|   43     this._popupArrowElement = this.element.createChild("div", "arrow"); |   44     this._popupArrowElement = this.element.createChild("div", "arrow"); | 
|   44     this._contentDiv = this.element.createChild("div", "content"); |   45     this._contentDiv = this.element.createChild("div", "content"); | 
|   45  |   46  | 
|   46     this._popoverHelper = popoverHelper; |   47     this._popoverHelper = popoverHelper; | 
|   47     this._hideBound = this.hide.bind(this); |   48     this._hideBound = this.hide.bind(this); | 
|   48 } |   49 } | 
|   49  |   50  | 
|   50 WebInspector.Popover._classNamePrefix = "popover component-root custom-popup-ver
     tical-scroll custom-popup-horizontal-scroll"; |   51 WebInspector.Popover._classNamePrefix = "popover custom-popup-vertical-scroll cu
     stom-popup-horizontal-scroll"; | 
|   51  |   52  | 
|   52 WebInspector.Popover.prototype = { |   53 WebInspector.Popover.prototype = { | 
|   53     /** |   54     /** | 
|   54      * @param {!Element} element |   55      * @param {!Element} element | 
|   55      * @param {!Element|!AnchorBox} anchor |   56      * @param {!Element|!AnchorBox} anchor | 
|   56      * @param {?number=} preferredWidth |   57      * @param {?number=} preferredWidth | 
|   57      * @param {?number=} preferredHeight |   58      * @param {?number=} preferredHeight | 
|   58      * @param {?WebInspector.Popover.Orientation=} arrowDirection |   59      * @param {?WebInspector.Popover.Orientation=} arrowDirection | 
|   59      */ |   60      */ | 
|   60     show: function(element, anchor, preferredWidth, preferredHeight, arrowDirect
     ion) |   61     show: function(element, anchor, preferredWidth, preferredHeight, arrowDirect
     ion) | 
| (...skipping 17 matching lines...) Expand all  Loading... | 
|   78      * @param {!Element} contentElement |   79      * @param {!Element} contentElement | 
|   79      * @param {!Element|!AnchorBox} anchor |   80      * @param {!Element|!AnchorBox} anchor | 
|   80      * @param {?number=} preferredWidth |   81      * @param {?number=} preferredWidth | 
|   81      * @param {?number=} preferredHeight |   82      * @param {?number=} preferredHeight | 
|   82      * @param {?WebInspector.Popover.Orientation=} arrowDirection |   83      * @param {?WebInspector.Popover.Orientation=} arrowDirection | 
|   83      */ |   84      */ | 
|   84     _innerShow: function(view, contentElement, anchor, preferredWidth, preferred
     Height, arrowDirection) |   85     _innerShow: function(view, contentElement, anchor, preferredWidth, preferred
     Height, arrowDirection) | 
|   85     { |   86     { | 
|   86         if (this._disposed) |   87         if (this._disposed) | 
|   87             return; |   88             return; | 
|   88         this.contentElement = contentElement; |   89         this._contentElement = contentElement; | 
|   89  |   90  | 
|   90         // This should not happen, but we hide previous popup to be on the safe 
     side. |   91         // This should not happen, but we hide previous popup to be on the safe 
     side. | 
|   91         if (WebInspector.Popover._popover) |   92         if (WebInspector.Popover._popover) | 
|   92             WebInspector.Popover._popover.hide(); |   93             WebInspector.Popover._popover.hide(); | 
|   93         WebInspector.Popover._popover = this; |   94         WebInspector.Popover._popover = this; | 
|   94  |   95  | 
|   95         var document = anchor instanceof Element ? anchor.ownerDocument : conten
     tElement.ownerDocument; |   96         var document = anchor instanceof Element ? anchor.ownerDocument : conten
     tElement.ownerDocument; | 
|   96         var window = document.defaultView; |   97         var window = document.defaultView; | 
|   97  |   98  | 
|   98         // Temporarily attach in order to measure preferred dimensions. |   99         // Temporarily attach in order to measure preferred dimensions. | 
|   99         var preferredSize = view ? view.measurePreferredSize() : this.contentEle
     ment.measurePreferredSize(); |  100         var preferredSize = view ? view.measurePreferredSize() : this._contentEl
     ement.measurePreferredSize(); | 
|  100         preferredWidth = preferredWidth || preferredSize.width; |  101         preferredWidth = preferredWidth || preferredSize.width; | 
|  101         preferredHeight = preferredHeight || preferredSize.height; |  102         preferredHeight = preferredHeight || preferredSize.height; | 
|  102  |  103  | 
|  103         window.addEventListener("resize", this._hideBound, false); |  104         window.addEventListener("resize", this._hideBound, false); | 
|  104         document.body.appendChild(this._containerElement); |  105         document.body.appendChild(this._containerElement); | 
|  105         WebInspector.View.prototype.show.call(this, this._containerElement); |  106         WebInspector.View.prototype.show.call(this, this._containerElement); | 
|  106  |  107  | 
|  107         if (view) |  108         if (view) | 
|  108             view.show(this._contentDiv); |  109             view.show(this._contentDiv); | 
|  109         else |  110         else | 
|  110             this._contentDiv.appendChild(this.contentElement); |  111             this._contentDiv.appendChild(this._contentElement); | 
|  111  |  112  | 
|  112         this._positionElement(anchor, preferredWidth, preferredHeight, arrowDire
     ction); |  113         this._positionElement(anchor, preferredWidth, preferredHeight, arrowDire
     ction); | 
|  113  |  114  | 
|  114         if (this._popoverHelper) { |  115         if (this._popoverHelper) { | 
|  115             this._contentDiv.addEventListener("mousemove", this._popoverHelper._
     killHidePopoverTimer.bind(this._popoverHelper), true); |  116             this._contentDiv.addEventListener("mousemove", this._popoverHelper._
     killHidePopoverTimer.bind(this._popoverHelper), true); | 
|  116             this.element.addEventListener("mouseout", this._popoverHelper._popov
     erMouseOut.bind(this._popoverHelper), true); |  117             this.element.addEventListener("mouseout", this._popoverHelper._popov
     erMouseOut.bind(this._popoverHelper), true); | 
|  117         } |  118         } | 
|  118     }, |  119     }, | 
|  119  |  120  | 
|  120     hide: function() |  121     hide: function() | 
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  217             newElementPosition.height += scrollerWidth; |  218             newElementPosition.height += scrollerWidth; | 
|  218             horizontalAlignment = "left"; |  219             horizontalAlignment = "left"; | 
|  219             if (verticalAlignment === WebInspector.Popover.Orientation.Bottom) |  220             if (verticalAlignment === WebInspector.Popover.Orientation.Bottom) | 
|  220                 newElementPosition.y -= scrollerWidth; |  221                 newElementPosition.y -= scrollerWidth; | 
|  221             // Position arrow accurately. |  222             // Position arrow accurately. | 
|  222             this._popupArrowElement.style.left = Math.max(0, anchorBox.x - borde
     rRadius * 2 - arrowOffset) + "px"; |  223             this._popupArrowElement.style.left = Math.max(0, anchorBox.x - borde
     rRadius * 2 - arrowOffset) + "px"; | 
|  223             this._popupArrowElement.style.left += anchorBox.width / 2; |  224             this._popupArrowElement.style.left += anchorBox.width / 2; | 
|  224         } |  225         } | 
|  225  |  226  | 
|  226         this.element.className = WebInspector.Popover._classNamePrefix + " " + v
     erticalAlignment + "-" + horizontalAlignment + "-arrow"; |  227         this.element.className = WebInspector.Popover._classNamePrefix + " " + v
     erticalAlignment + "-" + horizontalAlignment + "-arrow"; | 
 |  228         WebInspector.installComponentRootStyles(this.element); | 
|  227         this.element.positionAt(newElementPosition.x - borderWidth, newElementPo
     sition.y - borderWidth, container); |  229         this.element.positionAt(newElementPosition.x - borderWidth, newElementPo
     sition.y - borderWidth, container); | 
|  228         this.element.style.width = newElementPosition.width + borderWidth * 2 + 
     "px"; |  230         this.element.style.width = newElementPosition.width + borderWidth * 2 + 
     "px"; | 
|  229         this.element.style.height = newElementPosition.height + borderWidth * 2 
     + "px"; |  231         this.element.style.height = newElementPosition.height + borderWidth * 2 
     + "px"; | 
|  230     }, |  232     }, | 
|  231  |  233  | 
|  232     __proto__: WebInspector.View.prototype |  234     __proto__: WebInspector.View.prototype | 
|  233 } |  235 } | 
|  234  |  236  | 
|  235 /** |  237 /** | 
|  236  * @constructor |  238  * @constructor | 
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  400             this._resetHoverTimer(); |  402             this._resetHoverTimer(); | 
|  401         } |  403         } | 
|  402     } |  404     } | 
|  403 } |  405 } | 
|  404  |  406  | 
|  405 /** @enum {string} */ |  407 /** @enum {string} */ | 
|  406 WebInspector.Popover.Orientation = { |  408 WebInspector.Popover.Orientation = { | 
|  407     Top: "top", |  409     Top: "top", | 
|  408     Bottom: "bottom" |  410     Bottom: "bottom" | 
|  409 } |  411 } | 
| OLD | NEW |