| 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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 } | 108 } |
| 109 | 109 |
| 110 /** | 110 /** |
| 111 * @param {*} item | 111 * @param {*} item |
| 112 * @param {!Element} element | 112 * @param {!Element} element |
| 113 * @return {!Element} | 113 * @return {!Element} |
| 114 */ | 114 */ |
| 115 _createControls(item, element) { | 115 _createControls(item, element) { |
| 116 var controls = createElementWithClass('div', 'controls-container fill'); | 116 var controls = createElementWithClass('div', 'controls-container fill'); |
| 117 controls.createChild('div', 'controls-gradient'); | 117 controls.createChild('div', 'controls-gradient'); |
| 118 |
| 118 var buttons = controls.createChild('div', 'controls-buttons'); | 119 var buttons = controls.createChild('div', 'controls-buttons'); |
| 119 | 120 |
| 120 var editButton = UI.Icon.create('largeicon-edit', 'edit-button'); | 121 var toolbar = new UI.Toolbar('', buttons); |
| 121 buttons.appendChild(editButton); | |
| 122 editButton.title = Common.UIString('Edit'); | |
| 123 editButton.addEventListener('click', onEditClicked.bind(this), false); | |
| 124 | 122 |
| 125 var removeButton = UI.Icon.create('largeicon-trash-bin', 'remove-button'); | 123 var editButton = new UI.ToolbarButton(Common.UIString('Edit'), 'largeicon-ed
it'); |
| 126 buttons.appendChild(removeButton); | 124 editButton.addEventListener(UI.ToolbarButton.Events.Click, onEditClicked.bin
d(this)); |
| 127 removeButton.title = Common.UIString('Remove'); | 125 toolbar.appendToolbarItem(editButton); |
| 128 removeButton.addEventListener('click', onRemoveClicked.bind(this), false); | 126 |
| 127 var removeButton = new UI.ToolbarButton(Common.UIString('Remove'), 'largeico
n-trash-bin'); |
| 128 removeButton.addEventListener(UI.ToolbarButton.Events.Click, onRemoveClicked
.bind(this)); |
| 129 toolbar.appendToolbarItem(removeButton); |
| 129 | 130 |
| 130 return controls; | 131 return controls; |
| 131 | 132 |
| 132 /** | 133 /** |
| 133 * @param {!Event} event | |
| 134 * @this {UI.ListWidget} | 134 * @this {UI.ListWidget} |
| 135 */ | 135 */ |
| 136 function onEditClicked(event) { | 136 function onEditClicked() { |
| 137 event.consume(); | |
| 138 var index = this._elements.indexOf(element); | 137 var index = this._elements.indexOf(element); |
| 139 var insertionPoint = this._elements[index + 1] || null; | 138 var insertionPoint = this._elements[index + 1] || null; |
| 140 this._startEditing(item, element, insertionPoint); | 139 this._startEditing(item, element, insertionPoint); |
| 141 } | 140 } |
| 142 | 141 |
| 143 /** | 142 /** |
| 144 * @param {!Event} event | |
| 145 * @this {UI.ListWidget} | 143 * @this {UI.ListWidget} |
| 146 */ | 144 */ |
| 147 function onRemoveClicked(event) { | 145 function onRemoveClicked() { |
| 148 event.consume(); | |
| 149 var index = this._elements.indexOf(element); | 146 var index = this._elements.indexOf(element); |
| 150 this._delegate.removeItemRequested(this._items[index], index); | 147 this._delegate.removeItemRequested(this._items[index], index); |
| 151 } | 148 } |
| 152 } | 149 } |
| 153 | 150 |
| 154 /** | 151 /** |
| 155 * @override | 152 * @override |
| 156 */ | 153 */ |
| 157 wasShown() { | 154 wasShown() { |
| 158 super.wasShown(); | 155 super.wasShown(); |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 | 398 |
| 402 _cancelClicked() { | 399 _cancelClicked() { |
| 403 var cancel = this._cancel; | 400 var cancel = this._cancel; |
| 404 this._commit = null; | 401 this._commit = null; |
| 405 this._cancel = null; | 402 this._cancel = null; |
| 406 this._item = null; | 403 this._item = null; |
| 407 this._index = -1; | 404 this._index = -1; |
| 408 cancel(); | 405 cancel(); |
| 409 } | 406 } |
| 410 }; | 407 }; |
| OLD | NEW |