OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 cr.define('options', function() { | 5 cr.define('options', function() { |
6 /** @const */ var List = cr.ui.List; | 6 /** @const */ var List = cr.ui.List; |
7 /** @const */ var ListItem = cr.ui.ListItem; | 7 /** @const */ var ListItem = cr.ui.ListItem; |
8 | 8 |
9 /** | 9 /** |
10 * Creates a deletable list item, which has a button that will trigger a call | 10 * Creates a deletable list item, which has a button that will trigger a call |
11 * to deleteItemAtIndex(index) in the list. | 11 * to deleteItemAtIndex(index) in the list. |
| 12 * @constructor |
| 13 * @extends {cr.ui.ListItem} |
12 */ | 14 */ |
13 var DeletableItem = cr.ui.define('li'); | 15 var DeletableItem = cr.ui.define('li'); |
14 | 16 |
15 DeletableItem.prototype = { | 17 DeletableItem.prototype = { |
16 __proto__: ListItem.prototype, | 18 __proto__: ListItem.prototype, |
17 | 19 |
18 /** | 20 /** |
19 * The element subclasses should populate with content. | 21 * The element subclasses should populate with content. |
20 * @type {HTMLElement} | 22 * @type {HTMLElement} |
21 * @private | 23 * @private |
(...skipping 13 matching lines...) Expand all Loading... |
35 * @private | 37 * @private |
36 */ | 38 */ |
37 deletable_: true, | 39 deletable_: true, |
38 | 40 |
39 /** @override */ | 41 /** @override */ |
40 decorate: function() { | 42 decorate: function() { |
41 ListItem.prototype.decorate.call(this); | 43 ListItem.prototype.decorate.call(this); |
42 | 44 |
43 this.classList.add('deletable-item'); | 45 this.classList.add('deletable-item'); |
44 | 46 |
45 this.contentElement_ = this.ownerDocument.createElement('div'); | 47 this.contentElement_ = /** @type {HTMLElement} */( |
| 48 this.ownerDocument.createElement('div')); |
46 this.appendChild(this.contentElement_); | 49 this.appendChild(this.contentElement_); |
47 | 50 |
48 this.closeButtonElement_ = this.ownerDocument.createElement('button'); | 51 this.closeButtonElement_ = /** @type {HTMLElement} */( |
| 52 this.ownerDocument.createElement('button')); |
49 this.closeButtonElement_.className = | 53 this.closeButtonElement_.className = |
50 'raw-button row-delete-button custom-appearance'; | 54 'raw-button row-delete-button custom-appearance'; |
51 this.closeButtonElement_.addEventListener('mousedown', | 55 this.closeButtonElement_.addEventListener('mousedown', |
52 this.handleMouseDownUpOnClose_); | 56 this.handleMouseDownUpOnClose_); |
53 this.closeButtonElement_.addEventListener('mouseup', | 57 this.closeButtonElement_.addEventListener('mouseup', |
54 this.handleMouseDownUpOnClose_); | 58 this.handleMouseDownUpOnClose_); |
55 this.closeButtonElement_.addEventListener('focus', | 59 this.closeButtonElement_.addEventListener('focus', |
56 this.handleFocus_.bind(this)); | 60 this.handleFocus_.bind(this)); |
57 this.closeButtonElement_.tabIndex = -1; | 61 this.closeButtonElement_.tabIndex = -1; |
58 this.closeButtonElement_.title = | 62 this.closeButtonElement_.title = |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 * @private | 118 * @private |
115 */ | 119 */ |
116 handleMouseDownUpOnClose_: function(e) { | 120 handleMouseDownUpOnClose_: function(e) { |
117 if (e.target.disabled) | 121 if (e.target.disabled) |
118 return; | 122 return; |
119 e.stopPropagation(); | 123 e.stopPropagation(); |
120 e.preventDefault(); | 124 e.preventDefault(); |
121 }, | 125 }, |
122 }; | 126 }; |
123 | 127 |
| 128 /** |
| 129 * @constructor |
| 130 * @extends {cr.ui.List} |
| 131 */ |
124 var DeletableItemList = cr.ui.define('list'); | 132 var DeletableItemList = cr.ui.define('list'); |
125 | 133 |
126 DeletableItemList.prototype = { | 134 DeletableItemList.prototype = { |
127 __proto__: List.prototype, | 135 __proto__: List.prototype, |
128 | 136 |
129 /** @override */ | 137 /** @override */ |
130 decorate: function() { | 138 decorate: function() { |
131 List.prototype.decorate.call(this); | 139 List.prototype.decorate.call(this); |
132 this.addEventListener('click', this.handleClick_); | 140 this.addEventListener('click', this.handleClick_); |
133 this.addEventListener('keydown', this.handleKeyDown_); | 141 this.addEventListener('keydown', this.handleKeyDown_); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 */ | 196 */ |
189 deleteItemAtIndex: function(index) { | 197 deleteItemAtIndex: function(index) { |
190 }, | 198 }, |
191 }; | 199 }; |
192 | 200 |
193 return { | 201 return { |
194 DeletableItemList: DeletableItemList, | 202 DeletableItemList: DeletableItemList, |
195 DeletableItem: DeletableItem, | 203 DeletableItem: DeletableItem, |
196 }; | 204 }; |
197 }); | 205 }); |
OLD | NEW |