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

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

Issue 2851213005: DevTools: brush up audits 2 launcher UI, allow multiple audit runs, introduce landing page. (Closed)
Patch Set: for landing Created 3 years, 7 months 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 18 matching lines...) Expand all
29 */ 29 */
30 30
31 UI.Dialog = class extends UI.GlassPane { 31 UI.Dialog = class extends UI.GlassPane {
32 constructor() { 32 constructor() {
33 super(); 33 super();
34 this.registerRequiredCSS('ui/dialog.css'); 34 this.registerRequiredCSS('ui/dialog.css');
35 this.contentElement.tabIndex = 0; 35 this.contentElement.tabIndex = 0;
36 this.contentElement.addEventListener('focus', () => this.widget().focus(), f alse); 36 this.contentElement.addEventListener('focus', () => this.widget().focus(), f alse);
37 this.contentElement.addEventListener('keydown', this._onKeyDown.bind(this), false); 37 this.contentElement.addEventListener('keydown', this._onKeyDown.bind(this), false);
38 this.setPointerEventsBehavior(UI.GlassPane.PointerEventsBehavior.BlockedByGl assPane); 38 this.setPointerEventsBehavior(UI.GlassPane.PointerEventsBehavior.BlockedByGl assPane);
39 this.setSetOutsideClickCallback(event => { 39 this.setOutsideClickCallback(event => {
40 this.hide(); 40 this.hide();
41 event.consume(true); 41 event.consume(true);
42 }); 42 });
43 /** @type {!Map<!HTMLElement, number>} */ 43 /** @type {!Map<!HTMLElement, number>} */
44 this._tabIndexMap = new Map(); 44 this._tabIndexMap = new Map();
45 /** @type {?UI.WidgetFocusRestorer} */ 45 /** @type {?UI.WidgetFocusRestorer} */
46 this._focusRestorer = null; 46 this._focusRestorer = null;
47 this._closeOnEscape = true;
47 } 48 }
48 49
49 /** 50 /**
50 * @return {boolean} 51 * @return {boolean}
51 */ 52 */
52 static hasInstance() { 53 static hasInstance() {
53 return !!UI.Dialog._instance; 54 return !!UI.Dialog._instance;
54 } 55 }
55 56
56 /** 57 /**
(...skipping 14 matching lines...) Expand all
71 /** 72 /**
72 * @override 73 * @override
73 */ 74 */
74 hide() { 75 hide() {
75 this._focusRestorer.restore(); 76 this._focusRestorer.restore();
76 super.hide(); 77 super.hide();
77 this._restoreTabIndexOnElements(); 78 this._restoreTabIndexOnElements();
78 delete UI.Dialog._instance; 79 delete UI.Dialog._instance;
79 } 80 }
80 81
82 /**
83 * @param {boolean} close
84 */
85 setCloseOnEscape(close) {
86 this._closeOnEscape = close;
87 }
88
81 addCloseButton() { 89 addCloseButton() {
82 var closeButton = this.contentElement.createChild('div', 'dialog-close-butto n', 'dt-close-button'); 90 var closeButton = this.contentElement.createChild('div', 'dialog-close-butto n', 'dt-close-button');
83 closeButton.gray = true; 91 closeButton.gray = true;
84 closeButton.addEventListener('click', () => this.hide(), false); 92 closeButton.addEventListener('click', () => this.hide(), false);
85 } 93 }
86 94
87 /** 95 /**
88 * @param {!Document} document 96 * @param {!Document} document
89 */ 97 */
90 _disableTabIndexOnElements(document) { 98 _disableTabIndexOnElements(document) {
(...skipping 13 matching lines...) Expand all
104 _restoreTabIndexOnElements() { 112 _restoreTabIndexOnElements() {
105 for (var element of this._tabIndexMap.keys()) 113 for (var element of this._tabIndexMap.keys())
106 element.tabIndex = /** @type {number} */ (this._tabIndexMap.get(element)); 114 element.tabIndex = /** @type {number} */ (this._tabIndexMap.get(element));
107 this._tabIndexMap.clear(); 115 this._tabIndexMap.clear();
108 } 116 }
109 117
110 /** 118 /**
111 * @param {!Event} event 119 * @param {!Event} event
112 */ 120 */
113 _onKeyDown(event) { 121 _onKeyDown(event) {
114 if (event.keyCode === UI.KeyboardShortcut.Keys.Esc.code) { 122 if (this._closeOnEscape && event.keyCode === UI.KeyboardShortcut.Keys.Esc.co de) {
115 event.consume(true); 123 event.consume(true);
116 this.hide(); 124 this.hide();
117 } 125 }
118 } 126 }
119 }; 127 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698