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

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

Issue 7903001: Improve Tab-key navigation for editing Autofill addresses and credit cards. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: De-nitting Created 9 years, 3 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 * 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 this.contentElement_ = this.ownerDocument.createElement('div'); 45 this.contentElement_ = this.ownerDocument.createElement('div');
46 this.appendChild(this.contentElement_); 46 this.appendChild(this.contentElement_);
47 47
48 this.closeButtonElement_ = this.ownerDocument.createElement('button'); 48 this.closeButtonElement_ = this.ownerDocument.createElement('button');
49 this.closeButtonElement_.classList.add('raw-button'); 49 this.closeButtonElement_.classList.add('raw-button');
50 this.closeButtonElement_.classList.add('close-button'); 50 this.closeButtonElement_.classList.add('close-button');
51 this.closeButtonElement_.addEventListener('mousedown', 51 this.closeButtonElement_.addEventListener('mousedown',
52 this.handleMouseDownUpOnClose_); 52 this.handleMouseDownUpOnClose_);
53 this.closeButtonElement_.addEventListener('mouseup', 53 this.closeButtonElement_.addEventListener('mouseup',
54 this.handleMouseDownUpOnClose_); 54 this.handleMouseDownUpOnClose_);
55 this.closeButtonElement_.addEventListener('focus',
56 this.handleFocus_.bind(this));
55 this.appendChild(this.closeButtonElement_); 57 this.appendChild(this.closeButtonElement_);
56 }, 58 },
57 59
58 /** 60 /**
59 * Returns the element subclasses should add content to. 61 * Returns the element subclasses should add content to.
60 * @return {HTMLElement} The element subclasses should popuplate. 62 * @return {HTMLElement} The element subclasses should popuplate.
61 */ 63 */
62 get contentElement() { 64 get contentElement() {
63 return this.contentElement_; 65 return this.contentElement_;
64 }, 66 },
65 67
66 /* Gets/sets the deletable property. An item that is not deletable doesn't 68 /* Gets/sets the deletable property. An item that is not deletable doesn't
67 * show the delete button (although space is still reserved for it). 69 * show the delete button (although space is still reserved for it).
68 */ 70 */
69 get deletable() { 71 get deletable() {
70 return this.deletable_; 72 return this.deletable_;
71 }, 73 },
72 set deletable(value) { 74 set deletable(value) {
73 this.deletable_ = value; 75 this.deletable_ = value;
74 this.closeButtonElement_.disabled = !value; 76 this.closeButtonElement_.disabled = !value;
75 }, 77 },
76 78
77 /** 79 /**
80 * Called when a focusable child element receives focus. Selects this item
81 * in the list selection model.
82 * @private
83 */
84 handleFocus_: function() {
85 var list = this.parentNode;
86 var index = list.getIndexOfListItem(this);
87 list.selectionModel.selectedIndex = index;
88 list.selectionModel.anchorIndex = index;
89 },
90
91 /**
78 * Don't let the list have a crack at the event. We don't want clicking the 92 * Don't let the list have a crack at the event. We don't want clicking the
79 * close button to change the selection of the list. 93 * close button to change the selection of the list.
80 * @param {Event} e The mouse down/up event object. 94 * @param {Event} e The mouse down/up event object.
81 * @private 95 * @private
82 */ 96 */
83 handleMouseDownUpOnClose_: function(e) { 97 handleMouseDownUpOnClose_: function(e) {
84 if (!e.target.disabled) 98 if (!e.target.disabled)
85 e.stopPropagation(); 99 e.stopPropagation();
86 }, 100 },
87 }; 101 };
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 */ 176 */
163 deleteItemAtIndex: function(index) { 177 deleteItemAtIndex: function(index) {
164 }, 178 },
165 }; 179 };
166 180
167 return { 181 return {
168 DeletableItemList: DeletableItemList, 182 DeletableItemList: DeletableItemList,
169 DeletableItem: DeletableItem, 183 DeletableItem: DeletableItem,
170 }; 184 };
171 }); 185 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698