| 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 28 matching lines...) Expand all Loading... |
| 39 constructor(container, getRequest) { | 39 constructor(container, getRequest) { |
| 40 this._disableOnClick = false; | 40 this._disableOnClick = false; |
| 41 this._hasPadding = false; | 41 this._hasPadding = false; |
| 42 this._getRequest = getRequest; | 42 this._getRequest = getRequest; |
| 43 this._scheduledRequest = null; | 43 this._scheduledRequest = null; |
| 44 /** @type {?function()} */ | 44 /** @type {?function()} */ |
| 45 this._hidePopoverCallback = null; | 45 this._hidePopoverCallback = null; |
| 46 container.addEventListener('mousedown', this._mouseDown.bind(this), false); | 46 container.addEventListener('mousedown', this._mouseDown.bind(this), false); |
| 47 container.addEventListener('mousemove', this._mouseMove.bind(this), false); | 47 container.addEventListener('mousemove', this._mouseMove.bind(this), false); |
| 48 container.addEventListener('mouseout', this._mouseOut.bind(this), false); | 48 container.addEventListener('mouseout', this._mouseOut.bind(this), false); |
| 49 this.setTimeout(1000, 500); | 49 this.setTimeout(1000); |
| 50 } | 50 } |
| 51 | 51 |
| 52 /** | 52 /** |
| 53 * @param {number} timeout | 53 * @param {number} showTimeout |
| 54 * @param {number=} hideTimeout | 54 * @param {number=} hideTimeout |
| 55 * @param {boolean=} hideOnAnchorLeave |
| 55 */ | 56 */ |
| 56 setTimeout(timeout, hideTimeout) { | 57 setTimeout(showTimeout, hideTimeout, hideOnAnchorLeave) { |
| 57 this._timeout = timeout; | 58 this._showTimeout = showTimeout; |
| 58 if (typeof hideTimeout === 'number') | 59 this._hideTimeout = typeof hideTimeout === 'number' ? hideTimeout : showTime
out / 2; |
| 59 this._hideTimeout = hideTimeout; | 60 this._hideOnAnchorLeave = hideOnAnchorLeave; |
| 60 else | |
| 61 this._hideTimeout = timeout / 2; | |
| 62 } | 61 } |
| 63 | 62 |
| 64 /** | 63 /** |
| 65 * @param {boolean} hasPadding | 64 * @param {boolean} hasPadding |
| 66 */ | 65 */ |
| 67 setHasPadding(hasPadding) { | 66 setHasPadding(hasPadding) { |
| 68 this._hasPadding = hasPadding; | 67 this._hasPadding = hasPadding; |
| 69 } | 68 } |
| 70 | 69 |
| 71 /** | 70 /** |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 */ | 103 */ |
| 105 _mouseMove(event) { | 104 _mouseMove(event) { |
| 106 // Pretend that nothing has happened. | 105 // Pretend that nothing has happened. |
| 107 if (this._eventInScheduledContent(event)) | 106 if (this._eventInScheduledContent(event)) |
| 108 return; | 107 return; |
| 109 | 108 |
| 110 this._startHidePopoverTimer(this._hideTimeout); | 109 this._startHidePopoverTimer(this._hideTimeout); |
| 111 this._stopShowPopoverTimer(); | 110 this._stopShowPopoverTimer(); |
| 112 if (event.which && this._disableOnClick) | 111 if (event.which && this._disableOnClick) |
| 113 return; | 112 return; |
| 114 this._startShowPopoverTimer(event, this.isPopoverVisible() ? this._timeout *
0.6 : this._timeout); | 113 this._startShowPopoverTimer(event, this.isPopoverVisible() ? this._showTimeo
ut * 0.6 : this._showTimeout); |
| 115 } | 114 } |
| 116 | 115 |
| 117 /** | 116 /** |
| 118 * @param {!Event} event | 117 * @param {!Event} event |
| 119 */ | 118 */ |
| 120 _popoverMouseMove(event) { | 119 _popoverMouseMove(event) { |
| 121 this._stopHidePopoverTimer(); | 120 this._stopHidePopoverTimer(); |
| 122 } | 121 } |
| 123 | 122 |
| 124 /** | 123 /** |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 this._hidePopoverCallback = () => { | 234 this._hidePopoverCallback = () => { |
| 236 if (request.hide) | 235 if (request.hide) |
| 237 request.hide.call(null); | 236 request.hide.call(null); |
| 238 popover.hide(); | 237 popover.hide(); |
| 239 delete UI.PopoverHelper._popoverHelper; | 238 delete UI.PopoverHelper._popoverHelper; |
| 240 }; | 239 }; |
| 241 }); | 240 }); |
| 242 } | 241 } |
| 243 | 242 |
| 244 _stopHidePopoverTimer() { | 243 _stopHidePopoverTimer() { |
| 245 if (!this._hidePopoverTimer) | 244 if (!this._hidePopoverTimer || this._hideOnAnchorLeave) |
| 246 return; | 245 return; |
| 247 clearTimeout(this._hidePopoverTimer); | 246 clearTimeout(this._hidePopoverTimer); |
| 248 delete this._hidePopoverTimer; | 247 delete this._hidePopoverTimer; |
| 249 | 248 |
| 250 // We know that we reached the popup, but we might have moved over other ele
ments. | 249 // We know that we reached the popup, but we might have moved over other ele
ments. |
| 251 // Discard pending command. | 250 // Discard pending command. |
| 252 this._stopShowPopoverTimer(); | 251 this._stopShowPopoverTimer(); |
| 253 } | 252 } |
| 254 }; | 253 }; |
| 255 | 254 |
| 256 /** @typedef {{box: !AnchorBox, show:(function(!UI.GlassPane):!Promise<boolean>)
, hide:(function()|undefined)}} */ | 255 /** @typedef {{box: !AnchorBox, show:(function(!UI.GlassPane):!Promise<boolean>)
, hide:(function()|undefined)}} */ |
| 257 UI.PopoverRequest; | 256 UI.PopoverRequest; |
| OLD | NEW |