| 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 * @param {?number=} preferredWidth | 76 * @param {?number=} preferredWidth |
| 77 * @param {?number=} preferredHeight | 77 * @param {?number=} preferredHeight |
| 78 * @param {?UI.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 var restoreFocus; | 86 if (UI.Popover._popover) |
| 87 if (UI.Popover._popover) { | |
| 88 restoreFocus = UI.Popover._popover.hasFocus(); | |
| 89 UI.Popover._popover.hide(); | 87 UI.Popover._popover.hide(); |
| 90 } | |
| 91 UI.Popover._popover = this; | 88 UI.Popover._popover = this; |
| 92 | 89 |
| 93 var document = anchor instanceof Element ? anchor.ownerDocument : contentEle
ment.ownerDocument; | 90 var document = anchor instanceof Element ? anchor.ownerDocument : contentEle
ment.ownerDocument; |
| 94 var window = document.defaultView; | 91 var window = document.defaultView; |
| 95 | 92 |
| 96 // Temporarily attach in order to measure preferred dimensions. | 93 // Temporarily attach in order to measure preferred dimensions. |
| 97 var preferredSize = view ? view.measurePreferredSize() : UI.measurePreferred
Size(this._contentElement); | 94 var preferredSize = view ? view.measurePreferredSize() : UI.measurePreferred
Size(this._contentElement); |
| 98 this._preferredWidth = preferredWidth || preferredSize.width; | 95 this._preferredWidth = preferredWidth || preferredSize.width; |
| 99 this._preferredHeight = preferredHeight || preferredSize.height; | 96 this._preferredHeight = preferredHeight || preferredSize.height; |
| 100 | 97 |
| 101 window.addEventListener('resize', this._hideBound, false); | 98 window.addEventListener('resize', this._hideBound, false); |
| 102 document.body.appendChild(this._containerElement); | 99 document.body.appendChild(this._containerElement); |
| 103 super.show(this._containerElement); | 100 super.show(this._containerElement); |
| 104 | 101 |
| 105 if (view) { | 102 if (view) |
| 106 view.show(this._contentDiv); | 103 view.show(this._contentDiv); |
| 107 if (restoreFocus) | 104 else |
| 108 view.focus(); | |
| 109 } else { | |
| 110 this._contentDiv.appendChild(this._contentElement); | 105 this._contentDiv.appendChild(this._contentElement); |
| 111 if (restoreFocus) | |
| 112 this._contentElement.focus(); | |
| 113 } | |
| 114 | 106 |
| 115 this.positionElement(anchor, this._preferredWidth, this._preferredHeight, ar
rowDirection); | 107 this.positionElement(anchor, this._preferredWidth, this._preferredHeight, ar
rowDirection); |
| 116 | 108 |
| 117 if (this._popoverHelper) { | 109 if (this._popoverHelper) { |
| 118 this._contentDiv.addEventListener( | 110 this._contentDiv.addEventListener( |
| 119 'mousemove', this._popoverHelper._killHidePopoverTimer.bind(this._popo
verHelper), true); | 111 'mousemove', this._popoverHelper._killHidePopoverTimer.bind(this._popo
verHelper), true); |
| 120 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); |
| 121 } | 113 } |
| 122 } | 114 } |
| 123 | 115 |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 this._resetHoverTimer(); | 404 this._resetHoverTimer(); |
| 413 } | 405 } |
| 414 } | 406 } |
| 415 }; | 407 }; |
| 416 | 408 |
| 417 /** @enum {string} */ | 409 /** @enum {string} */ |
| 418 UI.Popover.Orientation = { | 410 UI.Popover.Orientation = { |
| 419 Top: 'top', | 411 Top: 'top', |
| 420 Bottom: 'bottom' | 412 Bottom: 'bottom' |
| 421 }; | 413 }; |
| OLD | NEW |