| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 WebInspector.Dialog._instance.detach(); | 67 WebInspector.Dialog._instance.detach(); |
| 68 WebInspector.Dialog._instance = this; | 68 WebInspector.Dialog._instance = this; |
| 69 | 69 |
| 70 var document = /** @type {!Document} */ (WebInspector.Dialog._modalHostV
iew.element.ownerDocument); | 70 var document = /** @type {!Document} */ (WebInspector.Dialog._modalHostV
iew.element.ownerDocument); |
| 71 this._disableTabIndexOnElements(document); | 71 this._disableTabIndexOnElements(document); |
| 72 | 72 |
| 73 this._glassPane = new WebInspector.GlassPane(document, this._dimmed); | 73 this._glassPane = new WebInspector.GlassPane(document, this._dimmed); |
| 74 this._glassPane.element.addEventListener("click", this._onGlassPaneClick
.bind(this), false); | 74 this._glassPane.element.addEventListener("click", this._onGlassPaneClick
.bind(this), false); |
| 75 this.element.ownerDocument.body.addEventListener("keydown", this._keyDow
nBound, false); | 75 this.element.ownerDocument.body.addEventListener("keydown", this._keyDow
nBound, false); |
| 76 | 76 |
| 77 // When a dialog closes, focus should be restored to the previous focuse
d element when | |
| 78 // possible, otherwise the default inspector view element. | |
| 79 WebInspector.Dialog._previousFocusedElement = WebInspector.currentFocusE
lement(); | |
| 80 | |
| 81 WebInspector.Widget.prototype.show.call(this, this._glassPane.element); | 77 WebInspector.Widget.prototype.show.call(this, this._glassPane.element); |
| 82 | 78 |
| 83 this._position(); | 79 this._position(); |
| 84 this.focus(); | 80 this._focusRestorer = new WebInspector.WidgetFocusRestorer(this); |
| 85 }, | 81 }, |
| 86 | 82 |
| 87 /** | 83 /** |
| 88 * @override | 84 * @override |
| 89 */ | 85 */ |
| 90 detach: function() | 86 detach: function() |
| 91 { | 87 { |
| 88 this._focusRestorer.restore(); |
| 89 |
| 92 this.element.ownerDocument.body.removeEventListener("keydown", this._key
DownBound, false); | 90 this.element.ownerDocument.body.removeEventListener("keydown", this._key
DownBound, false); |
| 93 WebInspector.Widget.prototype.detach.call(this); | 91 WebInspector.Widget.prototype.detach.call(this); |
| 94 | 92 |
| 95 this._glassPane.dispose(); | 93 this._glassPane.dispose(); |
| 96 delete this._glassPane; | 94 delete this._glassPane; |
| 97 | 95 |
| 98 if (WebInspector.Dialog._previousFocusedElement) | |
| 99 WebInspector.Dialog._previousFocusedElement.focus(); | |
| 100 delete WebInspector.Dialog._previousFocusedElement; | |
| 101 | |
| 102 this._restoreTabIndexOnElements(); | 96 this._restoreTabIndexOnElements(); |
| 103 | 97 |
| 104 delete WebInspector.Dialog._instance; | 98 delete WebInspector.Dialog._instance; |
| 105 }, | 99 }, |
| 106 | 100 |
| 107 addCloseButton: function() | 101 addCloseButton: function() |
| 108 { | 102 { |
| 109 var closeButton = this.contentElement.createChild("div", "dialog-close-b
utton", "dt-close-button"); | 103 var closeButton = this.contentElement.createChild("div", "dialog-close-b
utton", "dt-close-button"); |
| 110 closeButton.gray = true; | 104 closeButton.gray = true; |
| 111 closeButton.addEventListener("click", this.detach.bind(this), false); | 105 closeButton.addEventListener("click", this.detach.bind(this), false); |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 { | 263 { |
| 270 return WebInspector.Dialog._modalHostView; | 264 return WebInspector.Dialog._modalHostView; |
| 271 }; | 265 }; |
| 272 | 266 |
| 273 WebInspector.Dialog.modalHostRepositioned = function() | 267 WebInspector.Dialog.modalHostRepositioned = function() |
| 274 { | 268 { |
| 275 if (WebInspector.Dialog._instance) | 269 if (WebInspector.Dialog._instance) |
| 276 WebInspector.Dialog._instance._position(); | 270 WebInspector.Dialog._instance._position(); |
| 277 }; | 271 }; |
| 278 | 272 |
| OLD | NEW |