| OLD | NEW |
| 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 UI.ListWidget = class extends UI.VBox { | 7 UI.ListWidget = class extends UI.VBox { |
| 8 /** | 8 /** |
| 9 * @param {!UI.ListWidget.Delegate} delegate | 9 * @param {!UI.ListWidget.Delegate} delegate |
| 10 */ | 10 */ |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 */ | 257 */ |
| 258 UI.ListWidget.Editor = class { | 258 UI.ListWidget.Editor = class { |
| 259 constructor() { | 259 constructor() { |
| 260 this.element = createElementWithClass('div', 'editor-container'); | 260 this.element = createElementWithClass('div', 'editor-container'); |
| 261 this.element.addEventListener('keydown', onKeyDown.bind(null, isEscKey, this
._cancelClicked.bind(this)), false); | 261 this.element.addEventListener('keydown', onKeyDown.bind(null, isEscKey, this
._cancelClicked.bind(this)), false); |
| 262 this.element.addEventListener('keydown', onKeyDown.bind(null, isEnterKey, th
is._commitClicked.bind(this)), false); | 262 this.element.addEventListener('keydown', onKeyDown.bind(null, isEnterKey, th
is._commitClicked.bind(this)), false); |
| 263 | 263 |
| 264 this._contentElement = this.element.createChild('div', 'editor-content'); | 264 this._contentElement = this.element.createChild('div', 'editor-content'); |
| 265 | 265 |
| 266 var buttonsRow = this.element.createChild('div', 'editor-buttons'); | 266 var buttonsRow = this.element.createChild('div', 'editor-buttons'); |
| 267 this._commitButton = UI.createTextButton('', this._commitClicked.bind(this))
; | 267 this._commitButton = UI.createTextButton('', this._commitClicked.bind(this),
'', true /* primary */); |
| 268 buttonsRow.appendChild(this._commitButton); | 268 buttonsRow.appendChild(this._commitButton); |
| 269 this._cancelButton = UI.createTextButton(Common.UIString('Cancel'), this._ca
ncelClicked.bind(this)); | 269 this._cancelButton = UI.createTextButton(Common.UIString('Cancel'), this._ca
ncelClicked.bind(this)); |
| 270 this._cancelButton.addEventListener( | 270 this._cancelButton.addEventListener( |
| 271 'keydown', onKeyDown.bind(null, isEnterKey, this._cancelClicked.bind(thi
s)), false); | 271 'keydown', onKeyDown.bind(null, isEnterKey, this._cancelClicked.bind(thi
s)), false); |
| 272 buttonsRow.appendChild(this._cancelButton); | 272 buttonsRow.appendChild(this._cancelButton); |
| 273 | 273 |
| 274 /** | 274 /** |
| 275 * @param {function(!Event):boolean} predicate | 275 * @param {function(!Event):boolean} predicate |
| 276 * @param {function()} callback | 276 * @param {function()} callback |
| 277 * @param {!Event} event | 277 * @param {!Event} event |
| (...skipping 23 matching lines...) Expand all Loading... |
| 301 } | 301 } |
| 302 | 302 |
| 303 /** | 303 /** |
| 304 * @return {!Element} | 304 * @return {!Element} |
| 305 */ | 305 */ |
| 306 contentElement() { | 306 contentElement() { |
| 307 return this._contentElement; | 307 return this._contentElement; |
| 308 } | 308 } |
| 309 | 309 |
| 310 /** | 310 /** |
| 311 * @param {boolean} material | |
| 312 */ | |
| 313 setMaterial(material) { | |
| 314 this._commitButton.classList.toggle('material-button', material); | |
| 315 this._commitButton.classList.toggle('default', material); | |
| 316 this._cancelButton.classList.toggle('material-button', material); | |
| 317 this.element.classList.toggle('material', material); | |
| 318 } | |
| 319 | |
| 320 /** | |
| 321 * @param {string} name | 311 * @param {string} name |
| 322 * @param {string} type | 312 * @param {string} type |
| 323 * @param {string} title | 313 * @param {string} title |
| 324 * @param {function(*, number, (!HTMLInputElement|!HTMLSelectElement)):boolean
} validator | 314 * @param {function(*, number, (!HTMLInputElement|!HTMLSelectElement)):boolean
} validator |
| 325 * @return {!HTMLInputElement} | 315 * @return {!HTMLInputElement} |
| 326 */ | 316 */ |
| 327 createInput(name, type, title, validator) { | 317 createInput(name, type, title, validator) { |
| 328 var input = /** @type {!HTMLInputElement} */ (createElement('input')); | 318 var input = /** @type {!HTMLInputElement} */ (createElement('input')); |
| 329 input.type = type; | 319 input.type = type; |
| 330 input.placeholder = title; | 320 input.placeholder = title; |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 | 403 |
| 414 _cancelClicked() { | 404 _cancelClicked() { |
| 415 var cancel = this._cancel; | 405 var cancel = this._cancel; |
| 416 this._commit = null; | 406 this._commit = null; |
| 417 this._cancel = null; | 407 this._cancel = null; |
| 418 this._item = null; | 408 this._item = null; |
| 419 this._index = -1; | 409 this._index = -1; |
| 420 cancel(); | 410 cancel(); |
| 421 } | 411 } |
| 422 }; | 412 }; |
| OLD | NEW |