| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 The Chromium Authors. All rights reserved. | 2 * Copyright 2014 The Chromium Authors. All rights reserved. |
| 3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
| 4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
| 5 */ | 5 */ |
| 6 /** | 6 /** |
| 7 * @implements {WebInspector.ListWidget.Delegate} | 7 * @implements {UI.ListWidget.Delegate} |
| 8 * @unrestricted | 8 * @unrestricted |
| 9 */ | 9 */ |
| 10 WebInspector.FrameworkBlackboxSettingsTab = class extends WebInspector.VBox { | 10 Settings.FrameworkBlackboxSettingsTab = class extends UI.VBox { |
| 11 constructor() { | 11 constructor() { |
| 12 super(true); | 12 super(true); |
| 13 this.registerRequiredCSS('settings/frameworkBlackboxSettingsTab.css'); | 13 this.registerRequiredCSS('settings/frameworkBlackboxSettingsTab.css'); |
| 14 | 14 |
| 15 this.contentElement.createChild('div', 'header').textContent = WebInspector.
UIString('Framework Blackbox Patterns'); | 15 this.contentElement.createChild('div', 'header').textContent = Common.UIStri
ng('Framework Blackbox Patterns'); |
| 16 this.contentElement.createChild('div', 'blackbox-content-scripts') | 16 this.contentElement.createChild('div', 'blackbox-content-scripts') |
| 17 .appendChild(WebInspector.SettingsUI.createSettingCheckbox( | 17 .appendChild(UI.SettingsUI.createSettingCheckbox( |
| 18 WebInspector.UIString('Blackbox content scripts'), WebInspector.modu
leSetting('skipContentScripts'), true)); | 18 Common.UIString('Blackbox content scripts'), Common.moduleSetting('s
kipContentScripts'), true)); |
| 19 | 19 |
| 20 this._blackboxLabel = WebInspector.UIString('Blackbox'); | 20 this._blackboxLabel = Common.UIString('Blackbox'); |
| 21 this._disabledLabel = WebInspector.UIString('Disabled'); | 21 this._disabledLabel = Common.UIString('Disabled'); |
| 22 | 22 |
| 23 this._list = new WebInspector.ListWidget(this); | 23 this._list = new UI.ListWidget(this); |
| 24 this._list.element.classList.add('blackbox-list'); | 24 this._list.element.classList.add('blackbox-list'); |
| 25 this._list.registerRequiredCSS('settings/frameworkBlackboxSettingsTab.css'); | 25 this._list.registerRequiredCSS('settings/frameworkBlackboxSettingsTab.css'); |
| 26 | 26 |
| 27 var placeholder = createElementWithClass('div', 'blackbox-list-empty'); | 27 var placeholder = createElementWithClass('div', 'blackbox-list-empty'); |
| 28 placeholder.textContent = WebInspector.UIString('No blackboxed patterns'); | 28 placeholder.textContent = Common.UIString('No blackboxed patterns'); |
| 29 this._list.setEmptyPlaceholder(placeholder); | 29 this._list.setEmptyPlaceholder(placeholder); |
| 30 this._list.show(this.contentElement); | 30 this._list.show(this.contentElement); |
| 31 var addPatternButton = | 31 var addPatternButton = |
| 32 createTextButton(WebInspector.UIString('Add pattern...'), this._addButto
nClicked.bind(this), 'add-button'); | 32 createTextButton(Common.UIString('Add pattern...'), this._addButtonClick
ed.bind(this), 'add-button'); |
| 33 this.contentElement.appendChild(addPatternButton); | 33 this.contentElement.appendChild(addPatternButton); |
| 34 | 34 |
| 35 this._setting = WebInspector.moduleSetting('skipStackFramesPattern'); | 35 this._setting = Common.moduleSetting('skipStackFramesPattern'); |
| 36 this._setting.addChangeListener(this._settingUpdated, this); | 36 this._setting.addChangeListener(this._settingUpdated, this); |
| 37 | 37 |
| 38 this.setDefaultFocusedElement(addPatternButton); | 38 this.setDefaultFocusedElement(addPatternButton); |
| 39 this.contentElement.tabIndex = 0; | 39 this.contentElement.tabIndex = 0; |
| 40 } | 40 } |
| 41 | 41 |
| 42 /** | 42 /** |
| 43 * @override | 43 * @override |
| 44 */ | 44 */ |
| 45 wasShown() { | 45 wasShown() { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 */ | 84 */ |
| 85 removeItemRequested(item, index) { | 85 removeItemRequested(item, index) { |
| 86 var patterns = this._setting.getAsArray(); | 86 var patterns = this._setting.getAsArray(); |
| 87 patterns.splice(index, 1); | 87 patterns.splice(index, 1); |
| 88 this._setting.setAsArray(patterns); | 88 this._setting.setAsArray(patterns); |
| 89 } | 89 } |
| 90 | 90 |
| 91 /** | 91 /** |
| 92 * @override | 92 * @override |
| 93 * @param {*} item | 93 * @param {*} item |
| 94 * @param {!WebInspector.ListWidget.Editor} editor | 94 * @param {!UI.ListWidget.Editor} editor |
| 95 * @param {boolean} isNew | 95 * @param {boolean} isNew |
| 96 */ | 96 */ |
| 97 commitEdit(item, editor, isNew) { | 97 commitEdit(item, editor, isNew) { |
| 98 item.pattern = editor.control('pattern').value.trim(); | 98 item.pattern = editor.control('pattern').value.trim(); |
| 99 item.disabled = editor.control('behavior').value === this._disabledLabel; | 99 item.disabled = editor.control('behavior').value === this._disabledLabel; |
| 100 | 100 |
| 101 var list = this._setting.getAsArray(); | 101 var list = this._setting.getAsArray(); |
| 102 if (isNew) | 102 if (isNew) |
| 103 list.push(item); | 103 list.push(item); |
| 104 this._setting.setAsArray(list); | 104 this._setting.setAsArray(list); |
| 105 } | 105 } |
| 106 | 106 |
| 107 /** | 107 /** |
| 108 * @override | 108 * @override |
| 109 * @param {*} item | 109 * @param {*} item |
| 110 * @return {!WebInspector.ListWidget.Editor} | 110 * @return {!UI.ListWidget.Editor} |
| 111 */ | 111 */ |
| 112 beginEdit(item) { | 112 beginEdit(item) { |
| 113 var editor = this._createEditor(); | 113 var editor = this._createEditor(); |
| 114 editor.control('pattern').value = item.pattern; | 114 editor.control('pattern').value = item.pattern; |
| 115 editor.control('behavior').value = item.disabled ? this._disabledLabel : thi
s._blackboxLabel; | 115 editor.control('behavior').value = item.disabled ? this._disabledLabel : thi
s._blackboxLabel; |
| 116 return editor; | 116 return editor; |
| 117 } | 117 } |
| 118 | 118 |
| 119 /** | 119 /** |
| 120 * @return {!WebInspector.ListWidget.Editor} | 120 * @return {!UI.ListWidget.Editor} |
| 121 */ | 121 */ |
| 122 _createEditor() { | 122 _createEditor() { |
| 123 if (this._editor) | 123 if (this._editor) |
| 124 return this._editor; | 124 return this._editor; |
| 125 | 125 |
| 126 var editor = new WebInspector.ListWidget.Editor(); | 126 var editor = new UI.ListWidget.Editor(); |
| 127 this._editor = editor; | 127 this._editor = editor; |
| 128 var content = editor.contentElement(); | 128 var content = editor.contentElement(); |
| 129 | 129 |
| 130 var titles = content.createChild('div', 'blackbox-edit-row'); | 130 var titles = content.createChild('div', 'blackbox-edit-row'); |
| 131 titles.createChild('div', 'blackbox-pattern').textContent = WebInspector.UIS
tring('Pattern'); | 131 titles.createChild('div', 'blackbox-pattern').textContent = Common.UIString(
'Pattern'); |
| 132 titles.createChild('div', 'blackbox-separator blackbox-separator-invisible')
; | 132 titles.createChild('div', 'blackbox-separator blackbox-separator-invisible')
; |
| 133 titles.createChild('div', 'blackbox-behavior').textContent = WebInspector.UI
String('Behavior'); | 133 titles.createChild('div', 'blackbox-behavior').textContent = Common.UIString
('Behavior'); |
| 134 | 134 |
| 135 var fields = content.createChild('div', 'blackbox-edit-row'); | 135 var fields = content.createChild('div', 'blackbox-edit-row'); |
| 136 fields.createChild('div', 'blackbox-pattern') | 136 fields.createChild('div', 'blackbox-pattern') |
| 137 .appendChild(editor.createInput('pattern', 'text', '/framework\\.js$', p
atternValidator.bind(this))); | 137 .appendChild(editor.createInput('pattern', 'text', '/framework\\.js$', p
atternValidator.bind(this))); |
| 138 fields.createChild('div', 'blackbox-separator blackbox-separator-invisible')
; | 138 fields.createChild('div', 'blackbox-separator blackbox-separator-invisible')
; |
| 139 fields.createChild('div', 'blackbox-behavior') | 139 fields.createChild('div', 'blackbox-behavior') |
| 140 .appendChild(editor.createSelect('behavior', [this._blackboxLabel, this.
_disabledLabel], behaviorValidator)); | 140 .appendChild(editor.createSelect('behavior', [this._blackboxLabel, this.
_disabledLabel], behaviorValidator)); |
| 141 | 141 |
| 142 return editor; | 142 return editor; |
| 143 | 143 |
| 144 /** | 144 /** |
| 145 * @param {*} item | 145 * @param {*} item |
| 146 * @param {number} index | 146 * @param {number} index |
| 147 * @param {!HTMLInputElement|!HTMLSelectElement} input | 147 * @param {!HTMLInputElement|!HTMLSelectElement} input |
| 148 * @this {WebInspector.FrameworkBlackboxSettingsTab} | 148 * @this {Settings.FrameworkBlackboxSettingsTab} |
| 149 * @return {boolean} | 149 * @return {boolean} |
| 150 */ | 150 */ |
| 151 function patternValidator(item, index, input) { | 151 function patternValidator(item, index, input) { |
| 152 var pattern = input.value.trim(); | 152 var pattern = input.value.trim(); |
| 153 var patterns = this._setting.getAsArray(); | 153 var patterns = this._setting.getAsArray(); |
| 154 for (var i = 0; i < patterns.length; ++i) { | 154 for (var i = 0; i < patterns.length; ++i) { |
| 155 if (i !== index && patterns[i].pattern === pattern) | 155 if (i !== index && patterns[i].pattern === pattern) |
| 156 return false; | 156 return false; |
| 157 } | 157 } |
| 158 | 158 |
| 159 var regex; | 159 var regex; |
| 160 try { | 160 try { |
| 161 regex = new RegExp(pattern); | 161 regex = new RegExp(pattern); |
| 162 } catch (e) { | 162 } catch (e) { |
| 163 } | 163 } |
| 164 return !!(pattern && regex); | 164 return !!(pattern && regex); |
| 165 } | 165 } |
| 166 | 166 |
| 167 /** | 167 /** |
| 168 * @param {*} item | 168 * @param {*} item |
| 169 * @param {number} index | 169 * @param {number} index |
| 170 * @param {!HTMLInputElement|!HTMLSelectElement} input | 170 * @param {!HTMLInputElement|!HTMLSelectElement} input |
| 171 * @return {boolean} | 171 * @return {boolean} |
| 172 */ | 172 */ |
| 173 function behaviorValidator(item, index, input) { | 173 function behaviorValidator(item, index, input) { |
| 174 return true; | 174 return true; |
| 175 } | 175 } |
| 176 } | 176 } |
| 177 }; | 177 }; |
| OLD | NEW |