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

Side by Side Diff: chrome/browser/resources/options/deletable_item_list.js

Issue 2939273002: DO NOT SUBMIT: what chrome/browser/resources/ could eventually look like with clang-format (Closed)
Patch Set: Created 3 years, 6 months 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 (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
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 * @protected 45 * @protected
46 */ 46 */
47 closeButtonFocusAllowed: false, 47 closeButtonFocusAllowed: false,
48 48
49 /** @override */ 49 /** @override */
50 decorate: function() { 50 decorate: function() {
51 ListItem.prototype.decorate.call(this); 51 ListItem.prototype.decorate.call(this);
52 52
53 this.classList.add('deletable-item'); 53 this.classList.add('deletable-item');
54 54
55 this.contentElement_ = /** @type {HTMLElement} */( 55 this.contentElement_ =
56 this.ownerDocument.createElement('div')); 56 /** @type {HTMLElement} */ (this.ownerDocument.createElement('div'));
57 this.appendChild(this.contentElement_); 57 this.appendChild(this.contentElement_);
58 58
59 this.closeButtonElement_ = /** @type {HTMLElement} */( 59 this.closeButtonElement_ = /** @type {HTMLElement} */ (
60 this.ownerDocument.createElement('button')); 60 this.ownerDocument.createElement('button'));
61 this.closeButtonElement_.className = 61 this.closeButtonElement_.className =
62 'raw-button row-delete-button custom-appearance'; 62 'raw-button row-delete-button custom-appearance';
63 this.closeButtonElement_.addEventListener('mousedown', 63 this.closeButtonElement_.addEventListener(
64 this.handleMouseDownUpOnClose_); 64 'mousedown', this.handleMouseDownUpOnClose_);
65 this.closeButtonElement_.addEventListener('mouseup', 65 this.closeButtonElement_.addEventListener(
66 this.handleMouseDownUpOnClose_); 66 'mouseup', this.handleMouseDownUpOnClose_);
67 this.closeButtonElement_.addEventListener('focus', 67 this.closeButtonElement_.addEventListener(
68 this.handleFocus.bind(this)); 68 'focus', this.handleFocus.bind(this));
69 this.closeButtonElement_.tabIndex = -1; 69 this.closeButtonElement_.tabIndex = -1;
70 this.closeButtonElement_.title = 70 this.closeButtonElement_.title =
71 loadTimeData.getString('deletableItemDeleteButtonTitle'); 71 loadTimeData.getString('deletableItemDeleteButtonTitle');
72 this.appendChild(this.closeButtonElement_); 72 this.appendChild(this.closeButtonElement_);
73 }, 73 },
74 74
75 /** 75 /**
76 * Returns the element subclasses should add content to. 76 * Returns the element subclasses should add content to.
77 * @return {HTMLElement} The element subclasses should popuplate. 77 * @return {HTMLElement} The element subclasses should popuplate.
78 */ 78 */
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 * @param {Event} e The click event object. 154 * @param {Event} e The click event object.
155 * @protected 155 * @protected
156 */ 156 */
157 handleClick: function(e) { 157 handleClick: function(e) {
158 if (this.disabled) 158 if (this.disabled)
159 return; 159 return;
160 160
161 var target = e.target; 161 var target = e.target;
162 if (target.classList.contains('row-delete-button')) { 162 if (target.classList.contains('row-delete-button')) {
163 var listItem = this.getListItemAncestor( 163 var listItem = this.getListItemAncestor(
164 /** @type {HTMLElement} */(target)); 164 /** @type {HTMLElement} */ (target));
165 var idx = this.getIndexOfListItem(listItem); 165 var idx = this.getIndexOfListItem(listItem);
166 this.deleteItemAtIndex(idx); 166 this.deleteItemAtIndex(idx);
167 } 167 }
168 }, 168 },
169 169
170 /** 170 /**
171 * Callback for keydown events. 171 * Callback for keydown events.
172 * @param {Event} e The keydown event object. 172 * @param {Event} e The keydown event object.
173 * @private 173 * @private
174 */ 174 */
(...skipping 21 matching lines...) Expand all
196 if (this.getListItemByIndex(index).deletable) 196 if (this.getListItemByIndex(index).deletable)
197 this.deleteItemAtIndex(index); 197 this.deleteItemAtIndex(index);
198 } 198 }
199 }, 199 },
200 200
201 /** 201 /**
202 * Called when an item should be deleted; subclasses are responsible for 202 * Called when an item should be deleted; subclasses are responsible for
203 * implementing. 203 * implementing.
204 * @param {number} index The index of the item that is being deleted. 204 * @param {number} index The index of the item that is being deleted.
205 */ 205 */
206 deleteItemAtIndex: function(index) { 206 deleteItemAtIndex: function(index) {},
207 },
208 }; 207 };
209 208
210 return { 209 return {
211 DeletableItemList: DeletableItemList, 210 DeletableItemList: DeletableItemList,
212 DeletableItem: DeletableItem, 211 DeletableItem: DeletableItem,
213 }; 212 };
214 }); 213 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698