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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/ui/Infobar.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 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 * @unrestricted 5 * @unrestricted
6 */ 6 */
7 WebInspector.Infobar = class { 7 UI.Infobar = class {
8 /** 8 /**
9 * @param {!WebInspector.Infobar.Type} type 9 * @param {!UI.Infobar.Type} type
10 * @param {string} text 10 * @param {string} text
11 * @param {!WebInspector.Setting=} disableSetting 11 * @param {!Common.Setting=} disableSetting
12 */ 12 */
13 constructor(type, text, disableSetting) { 13 constructor(type, text, disableSetting) {
14 this.element = createElementWithClass('div', 'flex-none'); 14 this.element = createElementWithClass('div', 'flex-none');
15 this._shadowRoot = WebInspector.createShadowRootWithCoreStyles(this.element, 'ui/infobar.css'); 15 this._shadowRoot = UI.createShadowRootWithCoreStyles(this.element, 'ui/infob ar.css');
16 this._contentElement = this._shadowRoot.createChild('div', 'infobar infobar- ' + type); 16 this._contentElement = this._shadowRoot.createChild('div', 'infobar infobar- ' + type);
17 17
18 this._mainRow = this._contentElement.createChild('div', 'infobar-main-row'); 18 this._mainRow = this._contentElement.createChild('div', 'infobar-main-row');
19 this._mainRow.createChild('div', type + '-icon icon'); 19 this._mainRow.createChild('div', type + '-icon icon');
20 this._mainRowText = this._mainRow.createChild('div', 'infobar-main-title'); 20 this._mainRowText = this._mainRow.createChild('div', 'infobar-main-title');
21 this._mainRowText.textContent = text; 21 this._mainRowText.textContent = text;
22 this._detailsRows = this._contentElement.createChild('div', 'infobar-details -rows hidden'); 22 this._detailsRows = this._contentElement.createChild('div', 'infobar-details -rows hidden');
23 23
24 this._toggleElement = this._mainRow.createChild('div', 'infobar-toggle hidde n'); 24 this._toggleElement = this._mainRow.createChild('div', 'infobar-toggle hidde n');
25 this._toggleElement.addEventListener('click', this._onToggleDetails.bind(thi s), false); 25 this._toggleElement.addEventListener('click', this._onToggleDetails.bind(thi s), false);
26 this._toggleElement.textContent = WebInspector.UIString('more'); 26 this._toggleElement.textContent = Common.UIString('more');
27 27
28 /** @type {?WebInspector.Setting} */ 28 /** @type {?Common.Setting} */
29 this._disableSetting = disableSetting || null; 29 this._disableSetting = disableSetting || null;
30 if (disableSetting) { 30 if (disableSetting) {
31 var disableButton = this._mainRow.createChild('div', 'infobar-toggle'); 31 var disableButton = this._mainRow.createChild('div', 'infobar-toggle');
32 disableButton.textContent = WebInspector.UIString('never show'); 32 disableButton.textContent = Common.UIString('never show');
33 disableButton.addEventListener('click', this._onDisable.bind(this), false) ; 33 disableButton.addEventListener('click', this._onDisable.bind(this), false) ;
34 } 34 }
35 35
36 this._closeButton = this._contentElement.createChild('div', 'close-button', 'dt-close-button'); 36 this._closeButton = this._contentElement.createChild('div', 'close-button', 'dt-close-button');
37 this._closeButton.addEventListener('click', this.dispose.bind(this), false); 37 this._closeButton.addEventListener('click', this.dispose.bind(this), false);
38 38
39 /** @type {?function()} */ 39 /** @type {?function()} */
40 this._closeCallback = null; 40 this._closeCallback = null;
41 } 41 }
42 42
43 /** 43 /**
44 * @param {!WebInspector.Infobar.Type} type 44 * @param {!UI.Infobar.Type} type
45 * @param {string} text 45 * @param {string} text
46 * @param {!WebInspector.Setting=} disableSetting 46 * @param {!Common.Setting=} disableSetting
47 * @return {?WebInspector.Infobar} 47 * @return {?UI.Infobar}
48 */ 48 */
49 static create(type, text, disableSetting) { 49 static create(type, text, disableSetting) {
50 if (disableSetting && disableSetting.get()) 50 if (disableSetting && disableSetting.get())
51 return null; 51 return null;
52 return new WebInspector.Infobar(type, text, disableSetting); 52 return new UI.Infobar(type, text, disableSetting);
53 } 53 }
54 54
55 dispose() { 55 dispose() {
56 this.element.remove(); 56 this.element.remove();
57 this._onResize(); 57 this._onResize();
58 if (this._closeCallback) 58 if (this._closeCallback)
59 this._closeCallback.call(null); 59 this._closeCallback.call(null);
60 } 60 }
61 61
62 /** 62 /**
63 * @param {string} text 63 * @param {string} text
64 */ 64 */
65 setText(text) { 65 setText(text) {
66 this._mainRowText.textContent = text; 66 this._mainRowText.textContent = text;
67 this._onResize(); 67 this._onResize();
68 } 68 }
69 69
70 /** 70 /**
71 * @param {?function()} callback 71 * @param {?function()} callback
72 */ 72 */
73 setCloseCallback(callback) { 73 setCloseCallback(callback) {
74 this._closeCallback = callback; 74 this._closeCallback = callback;
75 } 75 }
76 76
77 /** 77 /**
78 * @param {!WebInspector.Widget} parentView 78 * @param {!UI.Widget} parentView
79 */ 79 */
80 setParentView(parentView) { 80 setParentView(parentView) {
81 this._parentView = parentView; 81 this._parentView = parentView;
82 } 82 }
83 83
84 _onResize() { 84 _onResize() {
85 if (this._parentView) 85 if (this._parentView)
86 this._parentView.doResize(); 86 this._parentView.doResize();
87 } 87 }
88 88
(...skipping 16 matching lines...) Expand all
105 this._toggleElement.classList.remove('hidden'); 105 this._toggleElement.classList.remove('hidden');
106 var infobarDetailsRow = this._detailsRows.createChild('div', 'infobar-detail s-row'); 106 var infobarDetailsRow = this._detailsRows.createChild('div', 'infobar-detail s-row');
107 var detailsRowMessage = infobarDetailsRow.createChild('span', 'infobar-row-m essage'); 107 var detailsRowMessage = infobarDetailsRow.createChild('span', 'infobar-row-m essage');
108 detailsRowMessage.textContent = message || ''; 108 detailsRowMessage.textContent = message || '';
109 return detailsRowMessage; 109 return detailsRowMessage;
110 } 110 }
111 }; 111 };
112 112
113 113
114 /** @enum {string} */ 114 /** @enum {string} */
115 WebInspector.Infobar.Type = { 115 UI.Infobar.Type = {
116 Warning: 'warning', 116 Warning: 'warning',
117 Info: 'info' 117 Info: 'info'
118 }; 118 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698