Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 var Page = cr.ui.pageManager.Page; | 6 var Page = cr.ui.pageManager.Page; |
| 7 var PageManager = cr.ui.pageManager.PageManager; | 7 var PageManager = cr.ui.pageManager.PageManager; |
| 8 | 8 |
| 9 /** | 9 /** |
| 10 * ImportDataOverlay class | 10 * ImportDataOverlay class |
| 11 * Encapsulated handling of the 'Import Data' overlay page. | 11 * Encapsulated handling of the 'Import Data' overlay page. |
| 12 * @class | 12 * @class |
| 13 */ | 13 */ |
| 14 function ImportDataOverlay() { | 14 function ImportDataOverlay() { |
| 15 Page.call(this, | 15 Page.call(this, |
| 16 'importData', | 16 'importData', |
| 17 loadTimeData.getString('importDataOverlayTabTitle'), | 17 loadTimeData.getString('importDataOverlayTabTitle'), |
| 18 'import-data-overlay'); | 18 'import-data-overlay'); |
| 19 } | 19 } |
| 20 | 20 |
| 21 cr.addSingletonGetter(ImportDataOverlay); | 21 cr.addSingletonGetter(ImportDataOverlay); |
| 22 | 22 |
| 23 /** | |
| 24 * Returns true if import checkbox for a type is visible and checked. | |
|
Dan Beam
2014/10/08 21:36:23
@param {string} type The type of data to import. U
Gaja
2014/10/10 05:19:30
Done.
| |
| 25 */ | |
| 26 function importable(type) { | |
| 27 var id = 'import-' + type; | |
| 28 return $(id + '-with-label').style.display != 'none' && $(id).checked; | |
| 29 } | |
| 30 | |
| 23 ImportDataOverlay.prototype = { | 31 ImportDataOverlay.prototype = { |
| 24 // Inherit from Page. | 32 // Inherit from Page. |
| 25 __proto__: Page.prototype, | 33 __proto__: Page.prototype, |
| 26 | 34 |
| 27 /** @override */ | 35 /** @override */ |
| 28 initializePage: function() { | 36 initializePage: function() { |
| 29 Page.prototype.initializePage.call(this); | 37 Page.prototype.initializePage.call(this); |
| 30 | 38 |
| 31 var self = this; | 39 var self = this; |
| 32 var checkboxes = | 40 var checkboxes = |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 68 // Form controls are disabled until the profile list has been loaded. | 76 // Form controls are disabled until the profile list has been loaded. |
| 69 self.setAllControlsEnabled_(false); | 77 self.setAllControlsEnabled_(false); |
| 70 }, | 78 }, |
| 71 | 79 |
| 72 /** | 80 /** |
| 73 * Sets the enabled and checked state of the commit button. | 81 * Sets the enabled and checked state of the commit button. |
| 74 * @private | 82 * @private |
| 75 */ | 83 */ |
| 76 validateCommitButton_: function() { | 84 validateCommitButton_: function() { |
| 77 var somethingToImport = | 85 var somethingToImport = |
| 78 $('import-history').checked || $('import-favorites').checked || | 86 importable('history') || importable('favorites') || |
| 79 $('import-passwords').checked || $('import-search').checked || | 87 importable('passwords') || importable('search') || |
| 80 $('import-autofill-form-data').checked; | 88 importable('autofill-form-data'); |
| 81 $('import-data-commit').disabled = !somethingToImport; | 89 $('import-data-commit').disabled = !somethingToImport; |
| 82 $('import-choose-file').disabled = !$('import-favorites').checked; | 90 $('import-choose-file').disabled = !$('import-favorites').checked; |
| 83 }, | 91 }, |
| 84 | 92 |
| 85 /** | 93 /** |
| 86 * Sets the enabled state of all the checkboxes and the commit button. | 94 * Sets the enabled state of all the checkboxes and the commit button. |
| 87 * @private | 95 * @private |
| 88 */ | 96 */ |
| 89 setAllControlsEnabled_: function(enabled) { | 97 setAllControlsEnabled_: function(enabled) { |
| 90 var checkboxes = | 98 var checkboxes = |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 270 ImportDataOverlay.getInstance().validateCommitButton_(); | 278 ImportDataOverlay.getInstance().validateCommitButton_(); |
| 271 | 279 |
| 272 PageManager.showPageByName('importData'); | 280 PageManager.showPageByName('importData'); |
| 273 }; | 281 }; |
| 274 | 282 |
| 275 // Export | 283 // Export |
| 276 return { | 284 return { |
| 277 ImportDataOverlay: ImportDataOverlay | 285 ImportDataOverlay: ImportDataOverlay |
| 278 }; | 286 }; |
| 279 }); | 287 }); |
| OLD | NEW |