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

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

Issue 664583006: Improve keyboard navigation on 'Manage search engines' options page (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 20 matching lines...) Expand all
31 */ 31 */
32 closeButtonElement_: null, 32 closeButtonElement_: null,
33 33
34 /** 34 /**
35 * Whether or not this item can be deleted. 35 * Whether or not this item can be deleted.
36 * @type {boolean} 36 * @type {boolean}
37 * @private 37 * @private
38 */ 38 */
39 deletable_: true, 39 deletable_: true,
40 40
41 /**
42 * Whether or not the close button can be navigated to using the keyboard.
43 * @type {boolean}
44 * @private
45 */
46 closeButtonFocusable_: false,
47
41 /** @override */ 48 /** @override */
42 decorate: function() { 49 decorate: function() {
43 ListItem.prototype.decorate.call(this); 50 ListItem.prototype.decorate.call(this);
44 51
45 this.classList.add('deletable-item'); 52 this.classList.add('deletable-item');
46 53
47 this.contentElement_ = /** @type {HTMLElement} */( 54 this.contentElement_ = /** @type {HTMLElement} */(
48 this.ownerDocument.createElement('div')); 55 this.ownerDocument.createElement('div'));
49 this.appendChild(this.contentElement_); 56 this.appendChild(this.contentElement_);
50 57
51 this.closeButtonElement_ = /** @type {HTMLElement} */( 58 this.closeButtonElement_ = /** @type {HTMLElement} */(
52 this.ownerDocument.createElement('button')); 59 this.ownerDocument.createElement('button'));
53 this.closeButtonElement_.className = 60 this.closeButtonElement_.className =
54 'raw-button row-delete-button custom-appearance'; 61 'raw-button row-delete-button custom-appearance';
55 this.closeButtonElement_.addEventListener('mousedown', 62 this.closeButtonElement_.addEventListener('mousedown',
56 this.handleMouseDownUpOnClose_); 63 this.handleMouseDownUpOnClose_);
57 this.closeButtonElement_.addEventListener('mouseup', 64 this.closeButtonElement_.addEventListener('mouseup',
58 this.handleMouseDownUpOnClose_); 65 this.handleMouseDownUpOnClose_);
59 this.closeButtonElement_.addEventListener('focus', 66 this.closeButtonElement_.addEventListener('focus',
60 this.handleFocus_.bind(this)); 67 this.handleFocus_.bind(this));
61 this.closeButtonElement_.tabIndex = -1; 68 this.closeButtonFocusable = false;
62 this.closeButtonElement_.title = 69 this.closeButtonElement_.title =
63 loadTimeData.getString('deletableItemDeleteButtonTitle'); 70 loadTimeData.getString('deletableItemDeleteButtonTitle');
64 this.appendChild(this.closeButtonElement_); 71 this.appendChild(this.closeButtonElement_);
65 }, 72 },
66 73
67 /** 74 /**
68 * Returns the element subclasses should add content to. 75 * Returns the element subclasses should add content to.
69 * @return {HTMLElement} The element subclasses should popuplate. 76 * @return {HTMLElement} The element subclasses should popuplate.
70 */ 77 */
71 get contentElement() { 78 get contentElement() {
(...skipping 12 matching lines...) Expand all
84 * show the delete button (although space is still reserved for it). 91 * show the delete button (although space is still reserved for it).
85 */ 92 */
86 get deletable() { 93 get deletable() {
87 return this.deletable_; 94 return this.deletable_;
88 }, 95 },
89 set deletable(value) { 96 set deletable(value) {
90 this.deletable_ = value; 97 this.deletable_ = value;
91 this.closeButtonElement_.disabled = !value; 98 this.closeButtonElement_.disabled = !value;
92 }, 99 },
93 100
101 /* Gets/sets the closeButtonFocusable property. If closeButtonFocusable is
102 * false then the delete button does not participate in the keyboard tab
103 * order.
104 */
105 get closeButtonFocusable() {
106 return this.closeButtonFocusable_;
107 },
108 set closeButtonFocusable(value) {
Dan Beam 2014/10/18 01:35:43 nit: if (focusable != this.closeButtonFocusable
Dan Beam 2014/10/18 01:35:43 nit: value => focusable
109 this.closeButtonElement_.tabIndex = value ? 0 : -1;
110 this.closeButtonFocusable_ = value;
111 },
112
94 /** 113 /**
95 * Called when a focusable child element receives focus. Selects this item 114 * Called when a focusable child element receives focus. Selects this item
96 * in the list selection model. 115 * in the list selection model.
97 * @private 116 * @private
98 */ 117 */
99 handleFocus_: function() { 118 handleFocus_: function() {
100 // This handler is also fired when the child receives focus as a result of 119 // This handler is also fired when the child receives focus as a result of
101 // the item getting selected by the customized mouse/keyboard handling in 120 // the item getting selected by the customized mouse/keyboard handling in
102 // SelectionController. Take care not to destroy a potential multiple 121 // SelectionController. Take care not to destroy a potential multiple
103 // selection in this case. 122 // selection in this case.
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 */ 216 */
198 deleteItemAtIndex: function(index) { 217 deleteItemAtIndex: function(index) {
199 }, 218 },
200 }; 219 };
201 220
202 return { 221 return {
203 DeletableItemList: DeletableItemList, 222 DeletableItemList: DeletableItemList,
204 DeletableItem: DeletableItem, 223 DeletableItem: DeletableItem,
205 }; 224 };
206 }); 225 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698