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

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

Issue 5935003: DOMUI: Implement new-style password manager. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Whitespace. Created 10 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 List = cr.ui.List; 6 const List = cr.ui.List;
7 const ListItem = cr.ui.ListItem; 7 const ListItem = cr.ui.ListItem;
8 8
9 /** 9 /**
10 * Wraps a list item to make it deletable, adding a button that will trigger a 10 * Wraps a list item to make it deletable, adding a button that will trigger a
(...skipping 13 matching lines...) Expand all
24 */ 24 */
25 DeletableListItem.decorate = function(el) { 25 DeletableListItem.decorate = function(el) {
26 el.__proto__ = DeletableListItem.prototype; 26 el.__proto__ = DeletableListItem.prototype;
27 el.decorate(); 27 el.decorate();
28 }; 28 };
29 29
30 DeletableListItem.prototype = { 30 DeletableListItem.prototype = {
31 __proto__: ListItem.prototype, 31 __proto__: ListItem.prototype,
32 32
33 /** 33 /**
34 * The list item being wrapped to make in deletable. 34 * The list item being wrapped to make it deletable.
35 * @type {!ListItem} 35 * @type {!ListItem}
36 * @private 36 * @private
37 */ 37 */
38 baseItem_: null, 38 baseItem_: null,
39 39
40 /** @inheritDoc */ 40 /** @inheritDoc */
41 decorate: function() { 41 decorate: function() {
42 ListItem.prototype.decorate.call(this); 42 ListItem.prototype.decorate.call(this);
43 43
44 this.className = 'deletable-item'; 44 this.baseItem_.classList.add('deletable-item');
45 var contentEl = this.ownerDocument.createElement('div'); 45 this.appendChild(this.baseItem_);
46 contentEl.appendChild(this.baseItem_); 46
47 //this.className = 'deletable-item';
47 var closeButtonEl = this.ownerDocument.createElement('button'); 48 var closeButtonEl = this.ownerDocument.createElement('button');
48 closeButtonEl.className = 'close-button'; 49 closeButtonEl.className = 'close-button';
49
50 this.appendChild(contentEl);
51 this.appendChild(closeButtonEl); 50 this.appendChild(closeButtonEl);
52 }, 51 },
53 52
53 /** @inheritDoc */
54 selectionChanged: function() {
55 // Forward the selection state to the |baseItem_|.
56 // TODO(jhawkins): This is terrible.
57 this.baseItem_.selected = this.selected;
James Hawkins 2010/12/16 19:28:28 I'm not particularly happy with this API. The fac
58 this.baseItem_.selectionChanged();
59 },
60
54 /** 61 /**
55 * Returns the list item being wrapped to make in deletable. 62 * Returns the list item being wrapped to make it deletable.
56 * @return {!ListItem} The list item being wrapped 63 * @return {!ListItem} The list item being wrapped
57 */ 64 */
58 get contentItem() { 65 get contentItem() {
59 return this.baseItem_; 66 return this.baseItem_;
60 } 67 },
61 }; 68 };
62 69
63 var DeletableItemList = cr.ui.define('list'); 70 var DeletableItemList = cr.ui.define('list');
64 71
65 DeletableItemList.prototype = { 72 DeletableItemList.prototype = {
66 __proto__: List.prototype, 73 __proto__: List.prototype,
67 74
68 /** @inheritDoc */ 75 /** @inheritDoc */
69 decorate: function() { 76 decorate: function() {
70 List.prototype.decorate.call(this); 77 List.prototype.decorate.call(this);
(...skipping 29 matching lines...) Expand all
100 if (target.className == 'close-button') { 107 if (target.className == 'close-button') {
101 var listItem = this.getListItemAncestor(target); 108 var listItem = this.getListItemAncestor(target);
102 if (listItem) 109 if (listItem)
103 this.deleteItemAtIndex(this.getIndexOfListItem(listItem)); 110 this.deleteItemAtIndex(this.getIndexOfListItem(listItem));
104 } 111 }
105 }, 112 },
106 113
107 /** 114 /**
108 * Called when an item should be deleted; subclasses are responsible for 115 * Called when an item should be deleted; subclasses are responsible for
109 * implementing. 116 * implementing.
110 * @param {number} index The indexd of the item that is being deleted. 117 * @param {number} index The index of the item that is being deleted.
111 */ 118 */
112 deleteItemAtIndex: function(index) { 119 deleteItemAtIndex: function(index) {
113 }, 120 },
114 }; 121 };
115 122
116 return { 123 return {
117 DeletableItemList: DeletableItemList 124 DeletableItemList: DeletableItemList
118 }; 125 };
119 }); 126 });
OLDNEW
« no previous file with comments | « chrome/browser/dom_ui/options/password_manager_handler.cc ('k') | chrome/browser/resources/options/options.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698