Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(481)

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/ui/Dialog.js

Issue 2493373002: DevTools: rename WebInspector into modules. (Closed)
Patch Set: for bots Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 13 matching lines...) Expand all
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 /** 31 /**
32 * @unrestricted 32 * @unrestricted
33 */ 33 */
34 WebInspector.Dialog = class extends WebInspector.Widget { 34 UI.Dialog = class extends UI.Widget {
35 constructor() { 35 constructor() {
36 super(true); 36 super(true);
37 this.markAsRoot(); 37 this.markAsRoot();
38 this.registerRequiredCSS('ui/dialog.css'); 38 this.registerRequiredCSS('ui/dialog.css');
39 39
40 this.contentElement.createChild('content'); 40 this.contentElement.createChild('content');
41 this.contentElement.tabIndex = 0; 41 this.contentElement.tabIndex = 0;
42 this.contentElement.addEventListener('focus', this._onFocus.bind(this), fals e); 42 this.contentElement.addEventListener('focus', this._onFocus.bind(this), fals e);
43 this._keyDownBound = this._onKeyDown.bind(this); 43 this._keyDownBound = this._onKeyDown.bind(this);
44 44
45 this._wrapsContent = false; 45 this._wrapsContent = false;
46 this._dimmed = false; 46 this._dimmed = false;
47 /** @type {!Map<!HTMLElement, number>} */ 47 /** @type {!Map<!HTMLElement, number>} */
48 this._tabIndexMap = new Map(); 48 this._tabIndexMap = new Map();
49 } 49 }
50 50
51 /** 51 /**
52 * @return {boolean} 52 * @return {boolean}
53 */ 53 */
54 static hasInstance() { 54 static hasInstance() {
55 return !!WebInspector.Dialog._instance; 55 return !!UI.Dialog._instance;
56 } 56 }
57 57
58 /** 58 /**
59 * @param {!WebInspector.Widget} view 59 * @param {!UI.Widget} view
60 */ 60 */
61 static setModalHostView(view) { 61 static setModalHostView(view) {
62 WebInspector.Dialog._modalHostView = view; 62 UI.Dialog._modalHostView = view;
63 } 63 }
64 64
65 /** 65 /**
66 * FIXME: make utility method in Dialog, so clients use it instead of this get ter. 66 * FIXME: make utility method in Dialog, so clients use it instead of this get ter.
67 * Method should be like Dialog.showModalElement(position params, reposition c allback). 67 * Method should be like Dialog.showModalElement(position params, reposition c allback).
68 * @return {?WebInspector.Widget} 68 * @return {?UI.Widget}
69 */ 69 */
70 static modalHostView() { 70 static modalHostView() {
71 return WebInspector.Dialog._modalHostView; 71 return UI.Dialog._modalHostView;
72 } 72 }
73 73
74 static modalHostRepositioned() { 74 static modalHostRepositioned() {
75 if (WebInspector.Dialog._instance) 75 if (UI.Dialog._instance)
76 WebInspector.Dialog._instance._position(); 76 UI.Dialog._instance._position();
77 } 77 }
78 78
79 /** 79 /**
80 * @override 80 * @override
81 */ 81 */
82 show() { 82 show() {
83 if (WebInspector.Dialog._instance) 83 if (UI.Dialog._instance)
84 WebInspector.Dialog._instance.detach(); 84 UI.Dialog._instance.detach();
85 WebInspector.Dialog._instance = this; 85 UI.Dialog._instance = this;
86 86
87 var document = /** @type {!Document} */ (WebInspector.Dialog._modalHostView. element.ownerDocument); 87 var document = /** @type {!Document} */ (UI.Dialog._modalHostView.element.ow nerDocument);
88 this._disableTabIndexOnElements(document); 88 this._disableTabIndexOnElements(document);
89 89
90 this._glassPane = new WebInspector.GlassPane(document, this._dimmed); 90 this._glassPane = new UI.GlassPane(document, this._dimmed);
91 this._glassPane.element.addEventListener('click', this._onGlassPaneClick.bin d(this), false); 91 this._glassPane.element.addEventListener('click', this._onGlassPaneClick.bin d(this), false);
92 this.element.ownerDocument.body.addEventListener('keydown', this._keyDownBou nd, false); 92 this.element.ownerDocument.body.addEventListener('keydown', this._keyDownBou nd, false);
93 93
94 super.show(this._glassPane.element); 94 super.show(this._glassPane.element);
95 95
96 this._position(); 96 this._position();
97 this._focusRestorer = new WebInspector.WidgetFocusRestorer(this); 97 this._focusRestorer = new UI.WidgetFocusRestorer(this);
98 } 98 }
99 99
100 /** 100 /**
101 * @override 101 * @override
102 */ 102 */
103 detach() { 103 detach() {
104 this._focusRestorer.restore(); 104 this._focusRestorer.restore();
105 105
106 this.element.ownerDocument.body.removeEventListener('keydown', this._keyDown Bound, false); 106 this.element.ownerDocument.body.removeEventListener('keydown', this._keyDown Bound, false);
107 super.detach(); 107 super.detach();
108 108
109 this._glassPane.dispose(); 109 this._glassPane.dispose();
110 delete this._glassPane; 110 delete this._glassPane;
111 111
112 this._restoreTabIndexOnElements(); 112 this._restoreTabIndexOnElements();
113 113
114 delete WebInspector.Dialog._instance; 114 delete UI.Dialog._instance;
115 } 115 }
116 116
117 addCloseButton() { 117 addCloseButton() {
118 var closeButton = this.contentElement.createChild('div', 'dialog-close-butto n', 'dt-close-button'); 118 var closeButton = this.contentElement.createChild('div', 'dialog-close-butto n', 'dt-close-button');
119 closeButton.gray = true; 119 closeButton.gray = true;
120 closeButton.addEventListener('click', this.detach.bind(this), false); 120 closeButton.addEventListener('click', this.detach.bind(this), false);
121 } 121 }
122 122
123 /** 123 /**
124 * @param {number=} positionX 124 * @param {number=} positionX
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 188
189 /** 189 /**
190 * @param {!Event} event 190 * @param {!Event} event
191 */ 191 */
192 _onGlassPaneClick(event) { 192 _onGlassPaneClick(event) {
193 if (!this.element.isSelfOrAncestor(/** @type {?Node} */ (event.target))) 193 if (!this.element.isSelfOrAncestor(/** @type {?Node} */ (event.target)))
194 this.detach(); 194 this.detach();
195 } 195 }
196 196
197 _position() { 197 _position() {
198 var container = WebInspector.Dialog._modalHostView.element; 198 var container = UI.Dialog._modalHostView.element;
199 199
200 var width = container.offsetWidth - 10; 200 var width = container.offsetWidth - 10;
201 var height = container.offsetHeight - 10; 201 var height = container.offsetHeight - 10;
202 202
203 if (this._wrapsContent) { 203 if (this._wrapsContent) {
204 width = Math.min(width, this.contentElement.offsetWidth); 204 width = Math.min(width, this.contentElement.offsetWidth);
205 height = Math.min(height, this.contentElement.offsetHeight); 205 height = Math.min(height, this.contentElement.offsetHeight);
206 } 206 }
207 207
208 if (this._maxSize) { 208 if (this._maxSize) {
(...skipping 19 matching lines...) Expand all
228 228
229 this.element.style.width = width + 'px'; 229 this.element.style.width = width + 'px';
230 this.element.style.height = height + 'px'; 230 this.element.style.height = height + 'px';
231 this.element.positionAt(positionX, positionY, container); 231 this.element.positionAt(positionX, positionY, container);
232 } 232 }
233 233
234 /** 234 /**
235 * @param {!Event} event 235 * @param {!Event} event
236 */ 236 */
237 _onKeyDown(event) { 237 _onKeyDown(event) {
238 if (event.keyCode === WebInspector.KeyboardShortcut.Keys.Esc.code) { 238 if (event.keyCode === UI.KeyboardShortcut.Keys.Esc.code) {
239 event.consume(true); 239 event.consume(true);
240 this.detach(); 240 this.detach();
241 } 241 }
242 } 242 }
243 }; 243 };
244 244
245 245
246 /** @type {?Element} */ 246 /** @type {?Element} */
247 WebInspector.Dialog._previousFocusedElement = null; 247 UI.Dialog._previousFocusedElement = null;
248 248
249 /** @type {?WebInspector.Widget} */ 249 /** @type {?UI.Widget} */
250 WebInspector.Dialog._modalHostView = null; 250 UI.Dialog._modalHostView = null;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698