| OLD | NEW | 
|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 | 5 | 
| 6 /** | 6 /** | 
| 7  * @fileoverview Implements an element that is hidden by default, but | 7  * @fileoverview Implements an element that is hidden by default, but | 
| 8  * when shown, dims and (attempts to) disable the main document. | 8  * when shown, dims and (attempts to) disable the main document. | 
| 9  * | 9  * | 
| 10  * You can turn any div into an overlay. Note that while an | 10  * You can turn any div into an overlay. Note that while an | 
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 49       overlay.oldParent_ = overlay.parentNode; | 49       overlay.oldParent_ = overlay.parentNode; | 
| 50       this.contentHost.appendChild(overlay); | 50       this.contentHost.appendChild(overlay); | 
| 51       this.contentHost.appendChild(this.tabCatcher); | 51       this.contentHost.appendChild(this.tabCatcher); | 
| 52 | 52 | 
| 53       // Show the overlay root. | 53       // Show the overlay root. | 
| 54       this.ownerDocument.body.classList.add('disabled-by-overlay'); | 54       this.ownerDocument.body.classList.add('disabled-by-overlay'); | 
| 55       this.visible = true; | 55       this.visible = true; | 
| 56 | 56 | 
| 57       // Bring overlay into focus. | 57       // Bring overlay into focus. | 
| 58       overlay.tabIndex = 0; | 58       overlay.tabIndex = 0; | 
| 59       overlay.focus(); | 59       var focusElement = | 
|  | 60           overlay.querySelector('button, input, list, select, a'); | 
|  | 61       if (!focusElement) { | 
|  | 62         focusElement = overlay; | 
|  | 63       } | 
|  | 64       focusElement.focus(); | 
| 60 | 65 | 
| 61       // Listen to key and focus events to prevent focus from | 66       // Listen to key and focus events to prevent focus from | 
| 62       // leaving the overlay. | 67       // leaving the overlay. | 
| 63       this.ownerDocument.addEventListener('focusin', | 68       this.ownerDocument.addEventListener('focusin', | 
| 64           this.onFocusInBoundToThis_, true); | 69           this.onFocusInBoundToThis_, true); | 
| 65       overlay.addEventListener('keydown', this.onKeydownBoundToThis_); | 70       overlay.addEventListener('keydown', this.onKeydownBoundToThis_); | 
| 66     }, | 71     }, | 
| 67 | 72 | 
| 68     /** | 73     /** | 
| 69      * Clicking outside of the overlay will de-focus the overlay. The | 74      * Clicking outside of the overlay will de-focus the overlay. The | 
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 168    * Shows and hides the overlay. Note that while visible == true, the overlay | 173    * Shows and hides the overlay. Note that while visible == true, the overlay | 
| 169    * element will be tempoarily reparented to another place in the DOM. | 174    * element will be tempoarily reparented to another place in the DOM. | 
| 170    */ | 175    */ | 
| 171   cr.defineProperty(Overlay, 'visible', cr.PropertyKind.BOOL_ATTR, | 176   cr.defineProperty(Overlay, 'visible', cr.PropertyKind.BOOL_ATTR, | 
| 172       Overlay.prototype.onVisibleChanged_); | 177       Overlay.prototype.onVisibleChanged_); | 
| 173 | 178 | 
| 174   return { | 179   return { | 
| 175     Overlay: Overlay | 180     Overlay: Overlay | 
| 176   }; | 181   }; | 
| 177 }); | 182 }); | 
| OLD | NEW | 
|---|