| 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 27 matching lines...) Expand all Loading... |
| 38 WebInspector.Widget.call(this); | 38 WebInspector.Widget.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 this._containerElement = createElementWithClass("div", "fill popover-contain
er"); | 41 this._containerElement = createElementWithClass("div", "fill popover-contain
er"); |
| 42 | 42 |
| 43 this._popupArrowElement = this.element.createChild("div", "arrow"); | 43 this._popupArrowElement = this.element.createChild("div", "arrow"); |
| 44 this._contentDiv = this.element.createChild("div", "content"); | 44 this._contentDiv = this.element.createChild("div", "content"); |
| 45 | 45 |
| 46 this._popoverHelper = popoverHelper; | 46 this._popoverHelper = popoverHelper; |
| 47 this._hideBound = this.hide.bind(this); | 47 this._hideBound = this.hide.bind(this); |
| 48 } | 48 }; |
| 49 | 49 |
| 50 WebInspector.Popover._classNamePrefix = "popover"; | 50 WebInspector.Popover._classNamePrefix = "popover"; |
| 51 | 51 |
| 52 WebInspector.Popover.prototype = { | 52 WebInspector.Popover.prototype = { |
| 53 /** | 53 /** |
| 54 * @param {!Element} element | 54 * @param {!Element} element |
| 55 * @param {!Element|!AnchorBox} anchor | 55 * @param {!Element|!AnchorBox} anchor |
| 56 * @param {?number=} preferredWidth | 56 * @param {?number=} preferredWidth |
| 57 * @param {?number=} preferredHeight | 57 * @param {?number=} preferredHeight |
| 58 * @param {?WebInspector.Popover.Orientation=} arrowDirection | 58 * @param {?WebInspector.Popover.Orientation=} arrowDirection |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 this._popupArrowElement.style.left = Math.max(0, anchorBox.x - newEl
ementPosition.x - borderRadius - arrowRadius + anchorBox.width / 2) + "px"; | 242 this._popupArrowElement.style.left = Math.max(0, anchorBox.x - newEl
ementPosition.x - borderRadius - arrowRadius + anchorBox.width / 2) + "px"; |
| 243 } | 243 } |
| 244 | 244 |
| 245 this.element.className = WebInspector.Popover._classNamePrefix + " " + v
erticalAlignment + "-" + horizontalAlignment + "-arrow"; | 245 this.element.className = WebInspector.Popover._classNamePrefix + " " + v
erticalAlignment + "-" + horizontalAlignment + "-arrow"; |
| 246 this.element.positionAt(newElementPosition.x, newElementPosition.y - bor
derWidth, container); | 246 this.element.positionAt(newElementPosition.x, newElementPosition.y - bor
derWidth, container); |
| 247 this.element.style.width = newElementPosition.width + borderWidth * 2 +
"px"; | 247 this.element.style.width = newElementPosition.width + borderWidth * 2 +
"px"; |
| 248 this.element.style.height = newElementPosition.height + borderWidth * 2
+ "px"; | 248 this.element.style.height = newElementPosition.height + borderWidth * 2
+ "px"; |
| 249 }, | 249 }, |
| 250 | 250 |
| 251 __proto__: WebInspector.Widget.prototype | 251 __proto__: WebInspector.Widget.prototype |
| 252 } | 252 }; |
| 253 | 253 |
| 254 /** | 254 /** |
| 255 * @constructor | 255 * @constructor |
| 256 * @param {!Element} panelElement | 256 * @param {!Element} panelElement |
| 257 * @param {function(!Element, !Event):(!Element|!AnchorBox|undefined)} getAnchor | 257 * @param {function(!Element, !Event):(!Element|!AnchorBox|undefined)} getAnchor |
| 258 * @param {function(!Element, !WebInspector.Popover):undefined} showPopover | 258 * @param {function(!Element, !WebInspector.Popover):undefined} showPopover |
| 259 * @param {function()=} onHide | 259 * @param {function()=} onHide |
| 260 * @param {boolean=} disableOnClick | 260 * @param {boolean=} disableOnClick |
| 261 */ | 261 */ |
| 262 WebInspector.PopoverHelper = function(panelElement, getAnchor, showPopover, onHi
de, disableOnClick) | 262 WebInspector.PopoverHelper = function(panelElement, getAnchor, showPopover, onHi
de, disableOnClick) |
| 263 { | 263 { |
| 264 this._getAnchor = getAnchor; | 264 this._getAnchor = getAnchor; |
| 265 this._showPopover = showPopover; | 265 this._showPopover = showPopover; |
| 266 this._onHide = onHide; | 266 this._onHide = onHide; |
| 267 this._disableOnClick = !!disableOnClick; | 267 this._disableOnClick = !!disableOnClick; |
| 268 panelElement.addEventListener("mousedown", this._mouseDown.bind(this), false
); | 268 panelElement.addEventListener("mousedown", this._mouseDown.bind(this), false
); |
| 269 panelElement.addEventListener("mousemove", this._mouseMove.bind(this), false
); | 269 panelElement.addEventListener("mousemove", this._mouseMove.bind(this), false
); |
| 270 panelElement.addEventListener("mouseout", this._mouseOut.bind(this), false); | 270 panelElement.addEventListener("mouseout", this._mouseOut.bind(this), false); |
| 271 this.setTimeout(1000, 500); | 271 this.setTimeout(1000, 500); |
| 272 } | 272 }; |
| 273 | 273 |
| 274 WebInspector.PopoverHelper.prototype = { | 274 WebInspector.PopoverHelper.prototype = { |
| 275 /** | 275 /** |
| 276 * @param {number} timeout | 276 * @param {number} timeout |
| 277 * @param {number=} hideTimeout | 277 * @param {number=} hideTimeout |
| 278 */ | 278 */ |
| 279 setTimeout: function(timeout, hideTimeout) | 279 setTimeout: function(timeout, hideTimeout) |
| 280 { | 280 { |
| 281 this._timeout = timeout; | 281 this._timeout = timeout; |
| 282 if (typeof hideTimeout === "number") | 282 if (typeof hideTimeout === "number") |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 { | 411 { |
| 412 if (this._hidePopoverTimer) { | 412 if (this._hidePopoverTimer) { |
| 413 clearTimeout(this._hidePopoverTimer); | 413 clearTimeout(this._hidePopoverTimer); |
| 414 delete this._hidePopoverTimer; | 414 delete this._hidePopoverTimer; |
| 415 | 415 |
| 416 // We know that we reached the popup, but we might have moved over o
ther elements. | 416 // We know that we reached the popup, but we might have moved over o
ther elements. |
| 417 // Discard pending command. | 417 // Discard pending command. |
| 418 this._resetHoverTimer(); | 418 this._resetHoverTimer(); |
| 419 } | 419 } |
| 420 } | 420 } |
| 421 } | 421 }; |
| 422 | 422 |
| 423 /** @enum {string} */ | 423 /** @enum {string} */ |
| 424 WebInspector.Popover.Orientation = { | 424 WebInspector.Popover.Orientation = { |
| 425 Top: "top", | 425 Top: "top", |
| 426 Bottom: "bottom" | 426 Bottom: "bottom" |
| 427 } | 427 }; |
| OLD | NEW |