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

Side by Side Diff: chrome/browser/resources/options/autofill_options_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: 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.autofillOptions', function() { 5 cr.define('options.autofillOptions', function() {
6 const DeletableItem = options.DeletableItem; 6 const DeletableItem = options.DeletableItem;
7 const DeletableItemList = options.DeletableItemList; 7 const DeletableItemList = options.DeletableItemList;
8 const InlineEditableItem = options.InlineEditableItem; 8 const InlineEditableItem = options.InlineEditableItem;
9 const InlineEditableItemList = options.InlineEditableItemList; 9 const InlineEditableItemList = options.InlineEditableItemList;
10 10
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 /** 284 /**
285 * Create a new value list. 285 * Create a new value list.
286 * @constructor 286 * @constructor
287 * @extends {options.InlineEditableItemList} 287 * @extends {options.InlineEditableItemList}
288 */ 288 */
289 var AutofillValuesList = cr.ui.define('list'); 289 var AutofillValuesList = cr.ui.define('list');
290 290
291 AutofillValuesList.prototype = { 291 AutofillValuesList.prototype = {
292 __proto__: InlineEditableItemList.prototype, 292 __proto__: InlineEditableItemList.prototype,
293 293
294 decorate: function() {
295 InlineEditableItemList.prototype.decorate.call(this);
296
297 var self = this;
298 function handleBlur(e) {
299 // When the blur event happens we do not know who is getting focus so we
300 // delay this a bit until we know if the new focus node is outside the
301 // list.
302 var doc = e.target.ownerDocument;
303 window.setTimeout(function() {
304 var activeElement = doc.activeElement;
305 if (!self.contains(activeElement))
306 self.selectionModel.unselectAll();
307 }, 50);
308 }
309
310 this.addEventListener('blur', handleBlur, true);
311 },
Ilya Sherman 2011/09/15 04:10:39 This functionality is now in |handleListFocusChang
312
313 /** @inheritDoc */ 294 /** @inheritDoc */
314 createItem: function(entry) { 295 createItem: function(entry) {
315 if (entry != null) 296 if (entry != null)
316 return new ValuesListItem(this, entry); 297 return new ValuesListItem(this, entry);
317 else 298 else
318 return new ValuesAddRowListItem(this); 299 return new ValuesAddRowListItem(this);
319 }, 300 },
320 301
321 /** @inheritDoc */ 302 /** @inheritDoc */
322 deleteItemAtIndex: function(index) { 303 deleteItemAtIndex: function(index) {
323 this.dataModel.splice(index, 1); 304 this.dataModel.splice(index, 1);
324 }, 305 },
325 306
326 /** @inheritDoc */ 307 /** @inheritDoc */
327 shouldFocusPlaceholder: function() { 308 shouldFocusPlaceholder: function() {
328 return false; 309 return false;
329 }, 310 },
330 311
331 /** 312 /**
313 * Called when the list hierarchy as a whole loses or gains focus.
314 * If the list was focused in response to a mouse click, call into the
315 * superclass's implementation. If the list was focused in response to a
316 * keyboard navigation, focus the first item.
317 * If the list loses focus, unselect all the elements.
318 * @param {Event} e The change event.
319 * @private
320 */
321 handleListFocusChange_: function(e) {
322 // We check to see whether there is a selected item as a proxy for
323 // distinguishing between mouse- and keyboard-originated focus events.
324 var selectedItem = this.selectedItem;
325 if (selectedItem)
James Hawkins 2011/09/15 19:28:02 Is there nothing in |e| that gives us better data
Ilya Sherman 2011/09/15 20:39:01 Not that I could find. If you know of something,
326 InlineEditableItemList.prototype.handleListFocusChange_.call(this, e);
327
328 if (!e.newValue) {
329 // When the list loses focus, unselect all the elements.
330 this.selectionModel.unselectAll();
James Hawkins 2011/09/15 19:28:02 Hmm. Why unselect? Blur doesn't unselect on other
Ilya Sherman 2011/09/15 20:39:01 I personally think blur should unselect *all* list
331 } else {
332 // When the list gains focus, select the first item if nothing else is
333 // selected.
334 var firstItem = this.getListItemByIndex(0);
335 if (!selectedItem && firstItem && e.newValue)
336 firstItem.handleFocus_();
337 }
338 },
339
340 /**
332 * Called when a new list item should be validated; subclasses are 341 * Called when a new list item should be validated; subclasses are
333 * responsible for implementing if validation is required. 342 * responsible for implementing if validation is required.
334 * @param {number} index The index of the item that was inserted or changed. 343 * @param {number} index The index of the item that was inserted or changed.
335 * @param {number} remove The number items to remove. 344 * @param {number} remove The number items to remove.
336 * @param {string} value The value of the item to insert. 345 * @param {string} value The value of the item to insert.
337 */ 346 */
338 validateAndSave: function(index, remove, value) { 347 validateAndSave: function(index, remove, value) {
339 this.dataModel.splice(index, remove, value); 348 this.dataModel.splice(index, remove, value);
340 }, 349 },
341 }; 350 };
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 CreditCardListItem: CreditCardListItem, 406 CreditCardListItem: CreditCardListItem,
398 ValuesListItem: ValuesListItem, 407 ValuesListItem: ValuesListItem,
399 ValuesAddRowListItem: ValuesAddRowListItem, 408 ValuesAddRowListItem: ValuesAddRowListItem,
400 AutofillAddressList: AutofillAddressList, 409 AutofillAddressList: AutofillAddressList,
401 AutofillCreditCardList: AutofillCreditCardList, 410 AutofillCreditCardList: AutofillCreditCardList,
402 AutofillValuesList: AutofillValuesList, 411 AutofillValuesList: AutofillValuesList,
403 AutofillPhoneValuesList: AutofillPhoneValuesList, 412 AutofillPhoneValuesList: AutofillPhoneValuesList,
404 AutofillFaxValuesList: AutofillFaxValuesList, 413 AutofillFaxValuesList: AutofillFaxValuesList,
405 }; 414 };
406 }); 415 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698