| 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 13 matching lines...) Expand all Loading... |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 /** | 31 /** |
| 32 * @unrestricted | 32 * @unrestricted |
| 33 */ | 33 */ |
| 34 WebInspector.Popover = class extends WebInspector.Widget { | 34 UI.Popover = class extends UI.Widget { |
| 35 /** | 35 /** |
| 36 * @param {!WebInspector.PopoverHelper=} popoverHelper | 36 * @param {!UI.PopoverHelper=} popoverHelper |
| 37 */ | 37 */ |
| 38 constructor(popoverHelper) { | 38 constructor(popoverHelper) { |
| 39 super(); | 39 super(); |
| 40 this.markAsRoot(); | 40 this.markAsRoot(); |
| 41 this.element.className = WebInspector.Popover._classNamePrefix; // Override | 41 this.element.className = UI.Popover._classNamePrefix; // Override |
| 42 this._containerElement = createElementWithClass('div', 'fill popover-contain
er'); | 42 this._containerElement = createElementWithClass('div', 'fill popover-contain
er'); |
| 43 | 43 |
| 44 this._popupArrowElement = this.element.createChild('div', 'arrow'); | 44 this._popupArrowElement = this.element.createChild('div', 'arrow'); |
| 45 this._contentDiv = this.element.createChild('div', 'content'); | 45 this._contentDiv = this.element.createChild('div', 'content'); |
| 46 | 46 |
| 47 this._popoverHelper = popoverHelper; | 47 this._popoverHelper = popoverHelper; |
| 48 this._hideBound = this.hide.bind(this); | 48 this._hideBound = this.hide.bind(this); |
| 49 } | 49 } |
| 50 | 50 |
| 51 /** | 51 /** |
| 52 * @param {!Element} element | 52 * @param {!Element} element |
| 53 * @param {!Element|!AnchorBox} anchor | 53 * @param {!Element|!AnchorBox} anchor |
| 54 * @param {?number=} preferredWidth | 54 * @param {?number=} preferredWidth |
| 55 * @param {?number=} preferredHeight | 55 * @param {?number=} preferredHeight |
| 56 * @param {?WebInspector.Popover.Orientation=} arrowDirection | 56 * @param {?UI.Popover.Orientation=} arrowDirection |
| 57 */ | 57 */ |
| 58 showForAnchor(element, anchor, preferredWidth, preferredHeight, arrowDirection
) { | 58 showForAnchor(element, anchor, preferredWidth, preferredHeight, arrowDirection
) { |
| 59 this._innerShow(null, element, anchor, preferredWidth, preferredHeight, arro
wDirection); | 59 this._innerShow(null, element, anchor, preferredWidth, preferredHeight, arro
wDirection); |
| 60 } | 60 } |
| 61 | 61 |
| 62 /** | 62 /** |
| 63 * @param {!WebInspector.Widget} view | 63 * @param {!UI.Widget} view |
| 64 * @param {!Element|!AnchorBox} anchor | 64 * @param {!Element|!AnchorBox} anchor |
| 65 * @param {?number=} preferredWidth | 65 * @param {?number=} preferredWidth |
| 66 * @param {?number=} preferredHeight | 66 * @param {?number=} preferredHeight |
| 67 */ | 67 */ |
| 68 showView(view, anchor, preferredWidth, preferredHeight) { | 68 showView(view, anchor, preferredWidth, preferredHeight) { |
| 69 this._innerShow(view, view.element, anchor, preferredWidth, preferredHeight)
; | 69 this._innerShow(view, view.element, anchor, preferredWidth, preferredHeight)
; |
| 70 } | 70 } |
| 71 | 71 |
| 72 /** | 72 /** |
| 73 * @param {?WebInspector.Widget} view | 73 * @param {?UI.Widget} view |
| 74 * @param {!Element} contentElement | 74 * @param {!Element} contentElement |
| 75 * @param {!Element|!AnchorBox} anchor | 75 * @param {!Element|!AnchorBox} anchor |
| 76 * @param {?number=} preferredWidth | 76 * @param {?number=} preferredWidth |
| 77 * @param {?number=} preferredHeight | 77 * @param {?number=} preferredHeight |
| 78 * @param {?WebInspector.Popover.Orientation=} arrowDirection | 78 * @param {?UI.Popover.Orientation=} arrowDirection |
| 79 */ | 79 */ |
| 80 _innerShow(view, contentElement, anchor, preferredWidth, preferredHeight, arro
wDirection) { | 80 _innerShow(view, contentElement, anchor, preferredWidth, preferredHeight, arro
wDirection) { |
| 81 if (this._disposed) | 81 if (this._disposed) |
| 82 return; | 82 return; |
| 83 this._contentElement = contentElement; | 83 this._contentElement = contentElement; |
| 84 | 84 |
| 85 // This should not happen, but we hide previous popup to be on the safe side
. | 85 // This should not happen, but we hide previous popup to be on the safe side
. |
| 86 if (WebInspector.Popover._popover) | 86 if (UI.Popover._popover) |
| 87 WebInspector.Popover._popover.hide(); | 87 UI.Popover._popover.hide(); |
| 88 WebInspector.Popover._popover = this; | 88 UI.Popover._popover = this; |
| 89 | 89 |
| 90 var document = anchor instanceof Element ? anchor.ownerDocument : contentEle
ment.ownerDocument; | 90 var document = anchor instanceof Element ? anchor.ownerDocument : contentEle
ment.ownerDocument; |
| 91 var window = document.defaultView; | 91 var window = document.defaultView; |
| 92 | 92 |
| 93 // Temporarily attach in order to measure preferred dimensions. | 93 // Temporarily attach in order to measure preferred dimensions. |
| 94 var preferredSize = view ? view.measurePreferredSize() : WebInspector.measur
ePreferredSize(this._contentElement); | 94 var preferredSize = view ? view.measurePreferredSize() : UI.measurePreferred
Size(this._contentElement); |
| 95 this._preferredWidth = preferredWidth || preferredSize.width; | 95 this._preferredWidth = preferredWidth || preferredSize.width; |
| 96 this._preferredHeight = preferredHeight || preferredSize.height; | 96 this._preferredHeight = preferredHeight || preferredSize.height; |
| 97 | 97 |
| 98 window.addEventListener('resize', this._hideBound, false); | 98 window.addEventListener('resize', this._hideBound, false); |
| 99 document.body.appendChild(this._containerElement); | 99 document.body.appendChild(this._containerElement); |
| 100 super.show(this._containerElement); | 100 super.show(this._containerElement); |
| 101 | 101 |
| 102 if (view) | 102 if (view) |
| 103 view.show(this._contentDiv); | 103 view.show(this._contentDiv); |
| 104 else | 104 else |
| 105 this._contentDiv.appendChild(this._contentElement); | 105 this._contentDiv.appendChild(this._contentElement); |
| 106 | 106 |
| 107 this.positionElement(anchor, this._preferredWidth, this._preferredHeight, ar
rowDirection); | 107 this.positionElement(anchor, this._preferredWidth, this._preferredHeight, ar
rowDirection); |
| 108 | 108 |
| 109 if (this._popoverHelper) { | 109 if (this._popoverHelper) { |
| 110 this._contentDiv.addEventListener( | 110 this._contentDiv.addEventListener( |
| 111 'mousemove', this._popoverHelper._killHidePopoverTimer.bind(this._popo
verHelper), true); | 111 'mousemove', this._popoverHelper._killHidePopoverTimer.bind(this._popo
verHelper), true); |
| 112 this.element.addEventListener('mouseout', this._popoverHelper._popoverMous
eOut.bind(this._popoverHelper), true); | 112 this.element.addEventListener('mouseout', this._popoverHelper._popoverMous
eOut.bind(this._popoverHelper), true); |
| 113 } | 113 } |
| 114 } | 114 } |
| 115 | 115 |
| 116 hide() { | 116 hide() { |
| 117 this._containerElement.ownerDocument.defaultView.removeEventListener('resize
', this._hideBound, false); | 117 this._containerElement.ownerDocument.defaultView.removeEventListener('resize
', this._hideBound, false); |
| 118 this.detach(); | 118 this.detach(); |
| 119 this._containerElement.remove(); | 119 this._containerElement.remove(); |
| 120 delete WebInspector.Popover._popover; | 120 delete UI.Popover._popover; |
| 121 } | 121 } |
| 122 | 122 |
| 123 get disposed() { | 123 get disposed() { |
| 124 return this._disposed; | 124 return this._disposed; |
| 125 } | 125 } |
| 126 | 126 |
| 127 dispose() { | 127 dispose() { |
| 128 if (this.isShowing()) | 128 if (this.isShowing()) |
| 129 this.hide(); | 129 this.hide(); |
| 130 this._disposed = true; | 130 this._disposed = true; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 143 */ | 143 */ |
| 144 setNoPadding(noPadding) { | 144 setNoPadding(noPadding) { |
| 145 this._hasNoPadding = noPadding; | 145 this._hasNoPadding = noPadding; |
| 146 this._contentDiv.classList.toggle('no-padding', this._hasNoPadding); | 146 this._contentDiv.classList.toggle('no-padding', this._hasNoPadding); |
| 147 } | 147 } |
| 148 | 148 |
| 149 /** | 149 /** |
| 150 * @param {!Element|!AnchorBox} anchorElement | 150 * @param {!Element|!AnchorBox} anchorElement |
| 151 * @param {number=} preferredWidth | 151 * @param {number=} preferredWidth |
| 152 * @param {number=} preferredHeight | 152 * @param {number=} preferredHeight |
| 153 * @param {?WebInspector.Popover.Orientation=} arrowDirection | 153 * @param {?UI.Popover.Orientation=} arrowDirection |
| 154 */ | 154 */ |
| 155 positionElement(anchorElement, preferredWidth, preferredHeight, arrowDirection
) { | 155 positionElement(anchorElement, preferredWidth, preferredHeight, arrowDirection
) { |
| 156 const borderWidth = this._hasNoPadding ? 0 : 8; | 156 const borderWidth = this._hasNoPadding ? 0 : 8; |
| 157 const scrollerWidth = this._hasFixedHeight ? 0 : 14; | 157 const scrollerWidth = this._hasFixedHeight ? 0 : 14; |
| 158 const arrowHeight = this._hasNoPadding ? 8 : 15; | 158 const arrowHeight = this._hasNoPadding ? 8 : 15; |
| 159 const arrowOffset = 10; | 159 const arrowOffset = 10; |
| 160 const borderRadius = 4; | 160 const borderRadius = 4; |
| 161 const arrowRadius = 6; | 161 const arrowRadius = 6; |
| 162 preferredWidth = preferredWidth || this._preferredWidth; | 162 preferredWidth = preferredWidth || this._preferredWidth; |
| 163 preferredHeight = preferredHeight || this._preferredHeight; | 163 preferredHeight = preferredHeight || this._preferredHeight; |
| 164 | 164 |
| 165 // Skinny tooltips are not pretty, their arrow location is not nice. | 165 // Skinny tooltips are not pretty, their arrow location is not nice. |
| 166 preferredWidth = Math.max(preferredWidth, 50); | 166 preferredWidth = Math.max(preferredWidth, 50); |
| 167 // Position relative to main DevTools element. | 167 // Position relative to main DevTools element. |
| 168 const container = WebInspector.Dialog.modalHostView().element; | 168 const container = UI.Dialog.modalHostView().element; |
| 169 const totalWidth = container.offsetWidth; | 169 const totalWidth = container.offsetWidth; |
| 170 const totalHeight = container.offsetHeight; | 170 const totalHeight = container.offsetHeight; |
| 171 | 171 |
| 172 var anchorBox = anchorElement instanceof AnchorBox ? anchorElement : anchorE
lement.boxInWindow(window); | 172 var anchorBox = anchorElement instanceof AnchorBox ? anchorElement : anchorE
lement.boxInWindow(window); |
| 173 anchorBox = anchorBox.relativeToElement(container); | 173 anchorBox = anchorBox.relativeToElement(container); |
| 174 var newElementPosition = {x: 0, y: 0, width: preferredWidth + scrollerWidth,
height: preferredHeight}; | 174 var newElementPosition = {x: 0, y: 0, width: preferredWidth + scrollerWidth,
height: preferredHeight}; |
| 175 | 175 |
| 176 var verticalAlignment; | 176 var verticalAlignment; |
| 177 var roomAbove = anchorBox.y; | 177 var roomAbove = anchorBox.y; |
| 178 var roomBelow = totalHeight - anchorBox.y - anchorBox.height; | 178 var roomBelow = totalHeight - anchorBox.y - anchorBox.height; |
| 179 this._popupArrowElement.hidden = false; | 179 this._popupArrowElement.hidden = false; |
| 180 | 180 |
| 181 if ((roomAbove > roomBelow) || (arrowDirection === WebInspector.Popover.Orie
ntation.Bottom)) { | 181 if ((roomAbove > roomBelow) || (arrowDirection === UI.Popover.Orientation.Bo
ttom)) { |
| 182 // Positioning above the anchor. | 182 // Positioning above the anchor. |
| 183 if ((anchorBox.y > newElementPosition.height + arrowHeight + borderRadius)
|| | 183 if ((anchorBox.y > newElementPosition.height + arrowHeight + borderRadius)
|| |
| 184 (arrowDirection === WebInspector.Popover.Orientation.Bottom)) | 184 (arrowDirection === UI.Popover.Orientation.Bottom)) |
| 185 newElementPosition.y = anchorBox.y - newElementPosition.height - arrowHe
ight; | 185 newElementPosition.y = anchorBox.y - newElementPosition.height - arrowHe
ight; |
| 186 else { | 186 else { |
| 187 this._popupArrowElement.hidden = true; | 187 this._popupArrowElement.hidden = true; |
| 188 newElementPosition.y = borderRadius; | 188 newElementPosition.y = borderRadius; |
| 189 newElementPosition.height = anchorBox.y - borderRadius * 2 - arrowHeight
; | 189 newElementPosition.height = anchorBox.y - borderRadius * 2 - arrowHeight
; |
| 190 if (this._hasFixedHeight && newElementPosition.height < preferredHeight)
{ | 190 if (this._hasFixedHeight && newElementPosition.height < preferredHeight)
{ |
| 191 newElementPosition.y = borderRadius; | 191 newElementPosition.y = borderRadius; |
| 192 newElementPosition.height = preferredHeight; | 192 newElementPosition.height = preferredHeight; |
| 193 } | 193 } |
| 194 } | 194 } |
| 195 verticalAlignment = WebInspector.Popover.Orientation.Bottom; | 195 verticalAlignment = UI.Popover.Orientation.Bottom; |
| 196 } else { | 196 } else { |
| 197 // Positioning below the anchor. | 197 // Positioning below the anchor. |
| 198 newElementPosition.y = anchorBox.y + anchorBox.height + arrowHeight; | 198 newElementPosition.y = anchorBox.y + anchorBox.height + arrowHeight; |
| 199 if ((newElementPosition.y + newElementPosition.height + borderRadius >= to
talHeight) && | 199 if ((newElementPosition.y + newElementPosition.height + borderRadius >= to
talHeight) && |
| 200 (arrowDirection !== WebInspector.Popover.Orientation.Top)) { | 200 (arrowDirection !== UI.Popover.Orientation.Top)) { |
| 201 this._popupArrowElement.hidden = true; | 201 this._popupArrowElement.hidden = true; |
| 202 newElementPosition.height = totalHeight - borderRadius - newElementPosit
ion.y; | 202 newElementPosition.height = totalHeight - borderRadius - newElementPosit
ion.y; |
| 203 if (this._hasFixedHeight && newElementPosition.height < preferredHeight)
{ | 203 if (this._hasFixedHeight && newElementPosition.height < preferredHeight)
{ |
| 204 newElementPosition.y = totalHeight - preferredHeight - borderRadius; | 204 newElementPosition.y = totalHeight - preferredHeight - borderRadius; |
| 205 newElementPosition.height = preferredHeight; | 205 newElementPosition.height = preferredHeight; |
| 206 } | 206 } |
| 207 } | 207 } |
| 208 // Align arrow. | 208 // Align arrow. |
| 209 verticalAlignment = WebInspector.Popover.Orientation.Top; | 209 verticalAlignment = UI.Popover.Orientation.Top; |
| 210 } | 210 } |
| 211 | 211 |
| 212 var horizontalAlignment; | 212 var horizontalAlignment; |
| 213 this._popupArrowElement.removeAttribute('style'); | 213 this._popupArrowElement.removeAttribute('style'); |
| 214 if (anchorBox.x + newElementPosition.width < totalWidth) { | 214 if (anchorBox.x + newElementPosition.width < totalWidth) { |
| 215 newElementPosition.x = Math.max(borderRadius, anchorBox.x - borderRadius -
arrowOffset); | 215 newElementPosition.x = Math.max(borderRadius, anchorBox.x - borderRadius -
arrowOffset); |
| 216 horizontalAlignment = 'left'; | 216 horizontalAlignment = 'left'; |
| 217 this._popupArrowElement.style.left = arrowOffset + 'px'; | 217 this._popupArrowElement.style.left = arrowOffset + 'px'; |
| 218 } else if (newElementPosition.width + borderRadius * 2 < totalWidth) { | 218 } else if (newElementPosition.width + borderRadius * 2 < totalWidth) { |
| 219 newElementPosition.x = totalWidth - newElementPosition.width - borderRadiu
s - 2 * borderWidth; | 219 newElementPosition.x = totalWidth - newElementPosition.width - borderRadiu
s - 2 * borderWidth; |
| 220 horizontalAlignment = 'right'; | 220 horizontalAlignment = 'right'; |
| 221 // Position arrow accurately. | 221 // Position arrow accurately. |
| 222 var arrowRightPosition = Math.max(0, totalWidth - anchorBox.x - anchorBox.
width - borderRadius - arrowOffset); | 222 var arrowRightPosition = Math.max(0, totalWidth - anchorBox.x - anchorBox.
width - borderRadius - arrowOffset); |
| 223 arrowRightPosition += anchorBox.width / 2; | 223 arrowRightPosition += anchorBox.width / 2; |
| 224 arrowRightPosition = Math.min(arrowRightPosition, newElementPosition.width
- borderRadius - arrowOffset); | 224 arrowRightPosition = Math.min(arrowRightPosition, newElementPosition.width
- borderRadius - arrowOffset); |
| 225 this._popupArrowElement.style.right = arrowRightPosition + 'px'; | 225 this._popupArrowElement.style.right = arrowRightPosition + 'px'; |
| 226 } else { | 226 } else { |
| 227 newElementPosition.x = borderRadius; | 227 newElementPosition.x = borderRadius; |
| 228 newElementPosition.width = totalWidth - borderRadius * 2; | 228 newElementPosition.width = totalWidth - borderRadius * 2; |
| 229 newElementPosition.height += scrollerWidth; | 229 newElementPosition.height += scrollerWidth; |
| 230 horizontalAlignment = 'left'; | 230 horizontalAlignment = 'left'; |
| 231 if (verticalAlignment === WebInspector.Popover.Orientation.Bottom) | 231 if (verticalAlignment === UI.Popover.Orientation.Bottom) |
| 232 newElementPosition.y -= scrollerWidth; | 232 newElementPosition.y -= scrollerWidth; |
| 233 // Position arrow accurately. | 233 // Position arrow accurately. |
| 234 this._popupArrowElement.style.left = | 234 this._popupArrowElement.style.left = |
| 235 Math.max(0, anchorBox.x - newElementPosition.x - borderRadius - arrowR
adius + anchorBox.width / 2) + 'px'; | 235 Math.max(0, anchorBox.x - newElementPosition.x - borderRadius - arrowR
adius + anchorBox.width / 2) + 'px'; |
| 236 } | 236 } |
| 237 | 237 |
| 238 this.element.className = | 238 this.element.className = |
| 239 WebInspector.Popover._classNamePrefix + ' ' + verticalAlignment + '-' +
horizontalAlignment + '-arrow'; | 239 UI.Popover._classNamePrefix + ' ' + verticalAlignment + '-' + horizontal
Alignment + '-arrow'; |
| 240 this.element.positionAt(newElementPosition.x, newElementPosition.y - borderW
idth, container); | 240 this.element.positionAt(newElementPosition.x, newElementPosition.y - borderW
idth, container); |
| 241 this.element.style.width = newElementPosition.width + borderWidth * 2 + 'px'
; | 241 this.element.style.width = newElementPosition.width + borderWidth * 2 + 'px'
; |
| 242 this.element.style.height = newElementPosition.height + borderWidth * 2 + 'p
x'; | 242 this.element.style.height = newElementPosition.height + borderWidth * 2 + 'p
x'; |
| 243 } | 243 } |
| 244 }; | 244 }; |
| 245 | 245 |
| 246 WebInspector.Popover._classNamePrefix = 'popover'; | 246 UI.Popover._classNamePrefix = 'popover'; |
| 247 | 247 |
| 248 /** | 248 /** |
| 249 * @unrestricted | 249 * @unrestricted |
| 250 */ | 250 */ |
| 251 WebInspector.PopoverHelper = class { | 251 UI.PopoverHelper = class { |
| 252 /** | 252 /** |
| 253 * @param {!Element} panelElement | 253 * @param {!Element} panelElement |
| 254 * @param {boolean=} disableOnClick | 254 * @param {boolean=} disableOnClick |
| 255 */ | 255 */ |
| 256 constructor(panelElement, disableOnClick) { | 256 constructor(panelElement, disableOnClick) { |
| 257 this._disableOnClick = !!disableOnClick; | 257 this._disableOnClick = !!disableOnClick; |
| 258 panelElement.addEventListener('mousedown', this._mouseDown.bind(this), false
); | 258 panelElement.addEventListener('mousedown', this._mouseDown.bind(this), false
); |
| 259 panelElement.addEventListener('mousemove', this._mouseMove.bind(this), false
); | 259 panelElement.addEventListener('mousemove', this._mouseMove.bind(this), false
); |
| 260 panelElement.addEventListener('mouseout', this._mouseOut.bind(this), false); | 260 panelElement.addEventListener('mouseout', this._mouseOut.bind(this), false); |
| 261 this.setTimeout(1000, 500); | 261 this.setTimeout(1000, 500); |
| 262 } | 262 } |
| 263 | 263 |
| 264 /** | 264 /** |
| 265 * @param {function(!Element, !Event):(!Element|!AnchorBox|undefined)} getAnch
or | 265 * @param {function(!Element, !Event):(!Element|!AnchorBox|undefined)} getAnch
or |
| 266 * @param {function(!Element, !WebInspector.Popover):undefined} showPopover | 266 * @param {function(!Element, !UI.Popover):undefined} showPopover |
| 267 * @param {function()=} onHide | 267 * @param {function()=} onHide |
| 268 */ | 268 */ |
| 269 initializeCallbacks(getAnchor, showPopover, onHide) { | 269 initializeCallbacks(getAnchor, showPopover, onHide) { |
| 270 this._getAnchor = getAnchor; | 270 this._getAnchor = getAnchor; |
| 271 this._showPopover = showPopover; | 271 this._showPopover = showPopover; |
| 272 this._onHide = onHide; | 272 this._onHide = onHide; |
| 273 } | 273 } |
| 274 | 274 |
| 275 /** | 275 /** |
| 276 * @param {number} timeout | 276 * @param {number} timeout |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 if (!this._eventInHoverElement(event)) | 328 if (!this._eventInHoverElement(event)) |
| 329 this._startHidePopoverTimer(); | 329 this._startHidePopoverTimer(); |
| 330 } | 330 } |
| 331 | 331 |
| 332 _startHidePopoverTimer() { | 332 _startHidePopoverTimer() { |
| 333 // User has 500ms (this._hideTimeout) to reach the popup. | 333 // User has 500ms (this._hideTimeout) to reach the popup. |
| 334 if (!this._popover || this._hidePopoverTimer) | 334 if (!this._popover || this._hidePopoverTimer) |
| 335 return; | 335 return; |
| 336 | 336 |
| 337 /** | 337 /** |
| 338 * @this {WebInspector.PopoverHelper} | 338 * @this {UI.PopoverHelper} |
| 339 */ | 339 */ |
| 340 function doHide() { | 340 function doHide() { |
| 341 this._hidePopover(); | 341 this._hidePopover(); |
| 342 delete this._hidePopoverTimer; | 342 delete this._hidePopoverTimer; |
| 343 } | 343 } |
| 344 this._hidePopoverTimer = setTimeout(doHide.bind(this), this._hideTimeout); | 344 this._hidePopoverTimer = setTimeout(doHide.bind(this), this._hideTimeout); |
| 345 } | 345 } |
| 346 | 346 |
| 347 _handleMouseAction(event, isMouseDown) { | 347 _handleMouseAction(event, isMouseDown) { |
| 348 this._resetHoverTimer(); | 348 this._resetHoverTimer(); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 | 383 |
| 384 this._popover.dispose(); | 384 this._popover.dispose(); |
| 385 delete this._popover; | 385 delete this._popover; |
| 386 this._hoverElement = null; | 386 this._hoverElement = null; |
| 387 } | 387 } |
| 388 | 388 |
| 389 _mouseHover(element) { | 389 _mouseHover(element) { |
| 390 delete this._hoverTimer; | 390 delete this._hoverTimer; |
| 391 this._hoverElement = element; | 391 this._hoverElement = element; |
| 392 this._hidePopover(); | 392 this._hidePopover(); |
| 393 this._popover = new WebInspector.Popover(this); | 393 this._popover = new UI.Popover(this); |
| 394 this._showPopover(element, this._popover); | 394 this._showPopover(element, this._popover); |
| 395 } | 395 } |
| 396 | 396 |
| 397 _killHidePopoverTimer() { | 397 _killHidePopoverTimer() { |
| 398 if (this._hidePopoverTimer) { | 398 if (this._hidePopoverTimer) { |
| 399 clearTimeout(this._hidePopoverTimer); | 399 clearTimeout(this._hidePopoverTimer); |
| 400 delete this._hidePopoverTimer; | 400 delete this._hidePopoverTimer; |
| 401 | 401 |
| 402 // We know that we reached the popup, but we might have moved over other e
lements. | 402 // We know that we reached the popup, but we might have moved over other e
lements. |
| 403 // Discard pending command. | 403 // Discard pending command. |
| 404 this._resetHoverTimer(); | 404 this._resetHoverTimer(); |
| 405 } | 405 } |
| 406 } | 406 } |
| 407 }; | 407 }; |
| 408 | 408 |
| 409 /** @enum {string} */ | 409 /** @enum {string} */ |
| 410 WebInspector.Popover.Orientation = { | 410 UI.Popover.Orientation = { |
| 411 Top: 'top', | 411 Top: 'top', |
| 412 Bottom: 'bottom' | 412 Bottom: 'bottom' |
| 413 }; | 413 }; |
| OLD | NEW |