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

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

Issue 7607027: Options: Two fixes for Autofill lists. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 4 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
« no previous file with comments | « no previous file | chrome/browser/resources/options/inline_editable_list.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 162
163 /** 163 /**
164 * Called when committing an edit. Committing a non-empty value adds it 164 * Called when committing an edit. Committing a non-empty value adds it
165 * to the end of the values list, leaving this "AddRow" in place. 165 * to the end of the values list, leaving this "AddRow" in place.
166 * @param {Event} e The end event. 166 * @param {Event} e The end event.
167 * @extends {options.ValuesListItem} 167 * @extends {options.ValuesListItem}
168 * @private 168 * @private
169 */ 169 */
170 onEditCommitted_: function(e) { 170 onEditCommitted_: function(e) {
171 var i = this.list.items.indexOf(this); 171 var i = this.list.items.indexOf(this);
172 if (i < 0 || i >= this.list.dataModel.length) 172 if (i < 0 || i >= this.list.dataModel.length || !this.input.value.length)
173 return; 173 return;
174 174
175 if (this.input.value && 175 if (this.input.value &&
176 this.list.dataModel.indexOf(this.input.value) == -1) { 176 this.list.dataModel.indexOf(this.input.value) == -1) {
177 // It is important that updateIndex is done before validateAndSave. 177 // It is important that updateIndex is done before validateAndSave.
178 // Otherwise we can not be sure about AddRow index. 178 // Otherwise we can not be sure about AddRow index.
179 this.list.dataModel.updateIndex(i); 179 this.list.dataModel.updateIndex(i);
180 this.list.validateAndSave(i, 0, this.input.value); 180 this.list.validateAndSave(i, 0, this.input.value);
181 } else { 181 } else {
182 this.input.value = ''; 182 this.input.value = '';
183 this.list.dataModel.updateIndex(i);
184 } 183 }
185 }, 184 },
186 }; 185 };
187 186
188 /** 187 /**
189 * Create a new address list. 188 * Create a new address list.
190 * @constructor 189 * @constructor
191 * @extends {options.DeletableItemList} 190 * @extends {options.DeletableItemList}
192 */ 191 */
193 var AutofillAddressList = cr.ui.define('list'); 192 var AutofillAddressList = cr.ui.define('list');
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 return new ValuesListItem(this, entry); 299 return new ValuesListItem(this, entry);
301 else 300 else
302 return new ValuesAddRowListItem(this); 301 return new ValuesAddRowListItem(this);
303 }, 302 },
304 303
305 /** @inheritDoc */ 304 /** @inheritDoc */
306 deleteItemAtIndex: function(index) { 305 deleteItemAtIndex: function(index) {
307 this.dataModel.splice(index, 1); 306 this.dataModel.splice(index, 1);
308 }, 307 },
309 308
309 /** @inheritDoc */
310 shouldFocusPlaceholder: function() {
csilv 2011/08/10 17:55:25 odd that we consider "placeholder" a word? not su
311 return false;
312 },
313
310 /** 314 /**
311 * Called when a new list item should be validated; subclasses are 315 * Called when a new list item should be validated; subclasses are
312 * responsible for implementing if validation is required. 316 * responsible for implementing if validation is required.
313 * @param {number} index The index of the item that was inserted or changed. 317 * @param {number} index The index of the item that was inserted or changed.
314 * @param {number} remove The number items to remove. 318 * @param {number} remove The number items to remove.
315 * @param {string} value The value of the item to insert. 319 * @param {string} value The value of the item to insert.
316 */ 320 */
317 validateAndSave: function(index, remove, value) { 321 validateAndSave: function(index, remove, value) {
318 this.dataModel.splice(index, remove, value); 322 this.dataModel.splice(index, remove, value);
319 }, 323 },
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 CreditCardListItem: CreditCardListItem, 380 CreditCardListItem: CreditCardListItem,
377 ValuesListItem: ValuesListItem, 381 ValuesListItem: ValuesListItem,
378 ValuesAddRowListItem: ValuesAddRowListItem, 382 ValuesAddRowListItem: ValuesAddRowListItem,
379 AutofillAddressList: AutofillAddressList, 383 AutofillAddressList: AutofillAddressList,
380 AutofillCreditCardList: AutofillCreditCardList, 384 AutofillCreditCardList: AutofillCreditCardList,
381 AutofillValuesList: AutofillValuesList, 385 AutofillValuesList: AutofillValuesList,
382 AutofillPhoneValuesList: AutofillPhoneValuesList, 386 AutofillPhoneValuesList: AutofillPhoneValuesList,
383 AutofillFaxValuesList: AutofillFaxValuesList, 387 AutofillFaxValuesList: AutofillFaxValuesList,
384 }; 388 };
385 }); 389 });
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/options/inline_editable_list.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698