Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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.contentSettings', function() { | 5 cr.define('options.contentSettings', function() { |
| 6 const DeletableItemList = options.DeletableItemList; | 6 const DeletableItemList = options.DeletableItemList; |
| 7 const DeletableItem = options.DeletableItem; | 7 const DeletableItem = options.DeletableItem; |
| 8 const ArrayDataModel = cr.ui.ArrayDataModel; | 8 const ArrayDataModel = cr.ui.ArrayDataModel; |
| 9 | 9 |
| 10 /** | 10 /** |
| (...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 452 var addRowItem = new ExceptionsAddRowListItem(this.contentType, | 452 var addRowItem = new ExceptionsAddRowListItem(this.contentType, |
| 453 this.mode, | 453 this.mode, |
| 454 this.enableAskOption); | 454 this.enableAskOption); |
| 455 addRowItem.deletable = false; | 455 addRowItem.deletable = false; |
| 456 return addRowItem; | 456 return addRowItem; |
| 457 } | 457 } |
| 458 }, | 458 }, |
| 459 | 459 |
| 460 /** | 460 /** |
| 461 * Adds an exception to the js model. | 461 * Adds an exception to the js model. |
| 462 * @param {Object} entry A dictionary of values for the exception. | 462 * @param {Object} entries A list of dictionaries of values, each dictionary |
| 463 * represents an exception. | |
| 463 */ | 464 */ |
| 464 addException: function(entry) { | 465 addExceptions: function(entries) { |
| 466 var insertIndex = this.dataModel.length; | |
| 467 | |
| 465 if (this.isEditable()) { | 468 if (this.isEditable()) { |
| 466 // We have to add it before the Add New Exception row. | 469 // We have to add it before the Add New Exception row. |
| 467 this.dataModel.splice(this.dataModel.length - 1, 0, entry); | 470 insertIndex = insertIndex - 1; |
| 468 } else { | |
| 469 this.dataModel.push(entry); | |
| 470 } | 471 } |
| 472 | |
| 473 var args = [insertIndex, 0]; | |
|
arv (Not doing code reviews)
2011/01/12 00:42:32
more JS magic...
args.push.apply(args, entries);
| |
| 474 for (var i = 0; i < entries.length; i++) { | |
| 475 args.push(entries[i]); | |
| 476 } | |
| 477 | |
| 478 this.dataModel.splice.apply(this.dataModel, args); | |
| 471 }, | 479 }, |
| 472 | 480 |
| 473 /** | 481 /** |
| 474 * The browser has finished checking a pattern for validity. Update the | 482 * The browser has finished checking a pattern for validity. Update the |
| 475 * list item to reflect this. | 483 * list item to reflect this. |
| 476 * @param {string} pattern The pattern. | 484 * @param {string} pattern The pattern. |
| 477 * @param {bool} valid Whether said pattern is valid in the context of | 485 * @param {bool} valid Whether said pattern is valid in the context of |
| 478 * a content exception setting. | 486 * a content exception setting. |
| 479 */ | 487 */ |
| 480 patternValidityCheckComplete: function(pattern, valid) { | 488 patternValidityCheckComplete: function(pattern, valid) { |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 604 } | 612 } |
| 605 }; | 613 }; |
| 606 | 614 |
| 607 return { | 615 return { |
| 608 ExceptionsListItem: ExceptionsListItem, | 616 ExceptionsListItem: ExceptionsListItem, |
| 609 ExceptionsAddRowListItem: ExceptionsAddRowListItem, | 617 ExceptionsAddRowListItem: ExceptionsAddRowListItem, |
| 610 ExceptionsList: ExceptionsList, | 618 ExceptionsList: ExceptionsList, |
| 611 ContentSettingsExceptionsArea: ContentSettingsExceptionsArea, | 619 ContentSettingsExceptionsArea: ContentSettingsExceptionsArea, |
| 612 }; | 620 }; |
| 613 }); | 621 }); |
| OLD | NEW |