| 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 23 matching lines...) Expand all Loading... |
| 34 */ | 34 */ |
| 35 WebInspector.Dialog = function() | 35 WebInspector.Dialog = function() |
| 36 { | 36 { |
| 37 WebInspector.Widget.call(this, true); | 37 WebInspector.Widget.call(this, true); |
| 38 this.markAsRoot(); | 38 this.markAsRoot(); |
| 39 this.registerRequiredCSS("ui/dialog.css"); | 39 this.registerRequiredCSS("ui/dialog.css"); |
| 40 | 40 |
| 41 this.contentElement.createChild("content"); | 41 this.contentElement.createChild("content"); |
| 42 this.contentElement.tabIndex = 0; | 42 this.contentElement.tabIndex = 0; |
| 43 this.contentElement.addEventListener("focus", this._onFocus.bind(this), fals
e); | 43 this.contentElement.addEventListener("focus", this._onFocus.bind(this), fals
e); |
| 44 this.contentElement.addEventListener("keydown", this._onKeyDown.bind(this),
false); | 44 this._keyDownBound = this._onKeyDown.bind(this); |
| 45 | 45 |
| 46 this._wrapsContent = false; | 46 this._wrapsContent = false; |
| 47 this._dimmed = false; | 47 this._dimmed = false; |
| 48 /** @type {!Map<!HTMLElement, number>} */ | 48 /** @type {!Map<!HTMLElement, number>} */ |
| 49 this._tabIndexMap = new Map(); | 49 this._tabIndexMap = new Map(); |
| 50 } | 50 } |
| 51 | 51 |
| 52 /** | 52 /** |
| 53 * TODO(dgozman): remove this method (it's only used for shortcuts handling). | |
| 54 * @return {boolean} | 53 * @return {boolean} |
| 55 */ | 54 */ |
| 56 WebInspector.Dialog.hasInstance = function() | 55 WebInspector.Dialog.hasInstance = function() |
| 57 { | 56 { |
| 58 return !!WebInspector.Dialog._instance; | 57 return !!WebInspector.Dialog._instance; |
| 59 } | 58 } |
| 60 | 59 |
| 61 WebInspector.Dialog.prototype = { | 60 WebInspector.Dialog.prototype = { |
| 62 /** | 61 /** |
| 63 * @override | 62 * @override |
| 64 */ | 63 */ |
| 65 show: function() | 64 show: function() |
| 66 { | 65 { |
| 67 if (WebInspector.Dialog._instance) | 66 if (WebInspector.Dialog._instance) |
| 68 WebInspector.Dialog._instance.detach(); | 67 WebInspector.Dialog._instance.detach(); |
| 69 WebInspector.Dialog._instance = this; | 68 WebInspector.Dialog._instance = this; |
| 70 | 69 |
| 71 var document = /** @type {!Document} */ (WebInspector.Dialog._modalHostV
iew.element.ownerDocument); | 70 var document = /** @type {!Document} */ (WebInspector.Dialog._modalHostV
iew.element.ownerDocument); |
| 72 this._disableTabIndexOnElements(document); | 71 this._disableTabIndexOnElements(document); |
| 73 | 72 |
| 74 this._glassPane = new WebInspector.GlassPane(document, this._dimmed); | 73 this._glassPane = new WebInspector.GlassPane(document, this._dimmed); |
| 75 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); |
| 76 | 76 |
| 77 // When a dialog closes, focus should be restored to the previous focuse
d element when | 77 // When a dialog closes, focus should be restored to the previous focuse
d element when |
| 78 // possible, otherwise the default inspector view element. | 78 // possible, otherwise the default inspector view element. |
| 79 WebInspector.Dialog._previousFocusedElement = WebInspector.currentFocusE
lement() || WebInspector.Dialog._modalHostView.defaultFocusedElement(); | 79 WebInspector.Dialog._previousFocusedElement = WebInspector.currentFocusE
lement() || WebInspector.Dialog._modalHostView.defaultFocusedElement(); |
| 80 | 80 |
| 81 WebInspector.Widget.prototype.show.call(this, this._glassPane.element); | 81 WebInspector.Widget.prototype.show.call(this, this._glassPane.element); |
| 82 | 82 |
| 83 this._position(); | 83 this._position(); |
| 84 this.focus(); | 84 this.focus(); |
| 85 }, | 85 }, |
| 86 | 86 |
| 87 /** | 87 /** |
| 88 * @override | 88 * @override |
| 89 */ | 89 */ |
| 90 detach: function() | 90 detach: function() |
| 91 { | 91 { |
| 92 this.element.ownerDocument.body.removeEventListener("keydown", this._key
DownBound, false); |
| 92 WebInspector.Widget.prototype.detach.call(this); | 93 WebInspector.Widget.prototype.detach.call(this); |
| 93 | 94 |
| 94 this._glassPane.dispose(); | 95 this._glassPane.dispose(); |
| 95 delete this._glassPane; | 96 delete this._glassPane; |
| 96 | 97 |
| 97 if (WebInspector.Dialog._previousFocusedElement) | 98 if (WebInspector.Dialog._previousFocusedElement) |
| 98 WebInspector.Dialog._previousFocusedElement.focus(); | 99 WebInspector.Dialog._previousFocusedElement.focus(); |
| 99 delete WebInspector.Dialog._previousFocusedElement; | 100 delete WebInspector.Dialog._previousFocusedElement; |
| 100 | 101 |
| 101 this._restoreTabIndexOnElements(); | 102 this._restoreTabIndexOnElements(); |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 { | 281 { |
| 281 return WebInspector.Dialog._modalHostView; | 282 return WebInspector.Dialog._modalHostView; |
| 282 }; | 283 }; |
| 283 | 284 |
| 284 WebInspector.Dialog.modalHostRepositioned = function() | 285 WebInspector.Dialog.modalHostRepositioned = function() |
| 285 { | 286 { |
| 286 if (WebInspector.Dialog._instance) | 287 if (WebInspector.Dialog._instance) |
| 287 WebInspector.Dialog._instance._position(); | 288 WebInspector.Dialog._instance._position(); |
| 288 }; | 289 }; |
| 289 | 290 |
| OLD | NEW |