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

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

Issue 6930052: Revert 84320 - Autofill DOMUI Prefs should work with i18n phone numbers (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 7 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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 * @private 118 * @private
119 */ 119 */
120 onEditCommitted_: function(e) { 120 onEditCommitted_: function(e) {
121 var i = this.list.items.indexOf(this); 121 var i = this.list.items.indexOf(this);
122 if (this.input.value == this.list.dataModel.item(i)) 122 if (this.input.value == this.list.dataModel.item(i))
123 return; 123 return;
124 124
125 if (this.input.value && 125 if (this.input.value &&
126 this.list.dataModel.indexOf(this.input.value) == -1) { 126 this.list.dataModel.indexOf(this.input.value) == -1) {
127 // Update with new value. 127 // Update with new value.
128 this.list.validateAndSave(i, 1, this.input.value); 128 this.list.dataModel.splice(i, 1, this.input.value);
129 } else { 129 } else {
130 // Reject empty values and duplicates. 130 // Reject empty values and duplicates.
131 this.list.dataModel.splice(i, 1); 131 this.list.dataModel.splice(i, 1);
132 } 132 }
133 }, 133 },
134 }; 134 };
135 135
136 /** 136 /**
137 * Creates a new list item for the Add New Item row, which doesn't represent 137 * Creates a new list item for the Add New Item row, which doesn't represent
138 * an actual entry in the values list but allows the user to add new 138 * an actual entry in the values list but allows the user to add new
(...skipping 28 matching lines...) Expand all
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)
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 this.list.validateAndSave(i, 0, this.input.value); 177 this.list.dataModel.splice(i, 0, this.input.value);
178 } else { 178 } else {
179 this.input.value = ''; 179 this.input.value = '';
180 this.list.dataModel.updateIndex(i); 180 this.list.dataModel.updateIndex(i);
181 } 181 }
182 }, 182 },
183 }; 183 };
184 184
185 /** 185 /**
186 * Create a new address list. 186 * Create a new address list.
187 * @constructor 187 * @constructor
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 if (entry != null) 296 if (entry != null)
297 return new ValuesListItem(this, entry); 297 return new ValuesListItem(this, entry);
298 else 298 else
299 return new ValuesAddRowListItem(this); 299 return new ValuesAddRowListItem(this);
300 }, 300 },
301 301
302 /** @inheritDoc */ 302 /** @inheritDoc */
303 deleteItemAtIndex: function(index) { 303 deleteItemAtIndex: function(index) {
304 this.dataModel.splice(index, 1); 304 this.dataModel.splice(index, 1);
305 }, 305 },
306
307 /**
308 * Called when a new list item should be validated; subclasses are
309 * responsible for implementing if validation is required.
310 * @param {number} index The index of the item that was inserted or changed.
311 * @param {number} remove The number items to remove.
312 * @param {string} value The value of the item to insert.
313 */
314 validateAndSave: function(index, remove, value) {
315 this.dataModel.splice(index, remove, value);
316 },
317 };
318
319 /**
320 * Create a new value list for phone number validation.
321 * @constructor
322 * @extends {options.AutofillValuesList}
323 */
324 var AutofillPhoneValuesList = cr.ui.define('list');
325
326 AutofillPhoneValuesList.prototype = {
327 __proto__: AutofillValuesList.prototype,
328
329 decorate: function() {
330 AutofillValuesList.prototype.decorate.call(this);
331 },
332
333 /** @inheritDoc */
334 validateAndSave: function(index, remove, value) {
335 var numbers = this.dataModel.slice(0, this.dataModel.length - 1);
336 numbers.splice(index, remove, value);
337 var info = new Array();
338 info[0] = index;
339 info[1] = numbers;
340 info[2] = $('country').value;
341 chrome.send('validatePhoneNumbers', info);
342 },
343 };
344
345 /**
346 * Create a new value list for fax number validation.
347 * @constructor
348 * @extends {options.AutofillValuesList}
349 */
350 var AutofillFaxValuesList = cr.ui.define('list');
351
352 AutofillFaxValuesList.prototype = {
353 __proto__: AutofillValuesList.prototype,
354
355 decorate: function() {
356 AutofillValuesList.prototype.decorate.call(this);
357 },
358
359 /** @inheritDoc */
360 validateAndSave: function(index, remove, value) {
361 var numbers = this.dataModel.slice(0, this.dataModel.length - 1);
362 numbers.splice(index, remove, value);
363 var info = new Array();
364 info[0] = index;
365 info[1] = numbers;
366 info[2] = $('country').value;
367 chrome.send('validateFaxNumbers', info);
368 },
369 }; 306 };
370 307
371 return { 308 return {
372 AddressListItem: AddressListItem, 309 AddressListItem: AddressListItem,
373 CreditCardListItem: CreditCardListItem, 310 CreditCardListItem: CreditCardListItem,
374 ValuesListItem: ValuesListItem, 311 ValuesListItem: ValuesListItem,
375 ValuesAddRowListItem: ValuesAddRowListItem, 312 ValuesAddRowListItem: ValuesAddRowListItem,
376 AutofillAddressList: AutofillAddressList, 313 AutofillAddressList: AutofillAddressList,
377 AutofillCreditCardList: AutofillCreditCardList, 314 AutofillCreditCardList: AutofillCreditCardList,
378 AutofillValuesList: AutofillValuesList, 315 AutofillValuesList: AutofillValuesList,
379 AutofillPhoneValuesList: AutofillPhoneValuesList,
380 AutofillFaxValuesList: AutofillFaxValuesList,
381 }; 316 };
382 }); 317 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698