| 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', function() { | 5 cr.define('options', function() { |
| 6 | 6 |
| 7 var OptionsPage = options.OptionsPage; | 7 var OptionsPage = options.OptionsPage; |
| 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 OptionsPage.call(this, 'importDataOverlay', | 15 OptionsPage.call(this, 'importDataOverlay', |
| 16 templateData.import_data_title, | 16 templateData.import_data_title, |
| 17 'importDataOverlay'); | 17 'importDataOverlay'); |
| 18 } | 18 } |
| 19 | 19 |
| 20 ImportDataOverlay.throbIntervalId = 0 | 20 ImportDataOverlay.throbIntervalId = 0 |
| 21 ImportDataOverlay.checkboxMask = ""; | 21 ImportDataOverlay.checkboxMask = ''; |
| 22 | 22 |
| 23 cr.addSingletonGetter(ImportDataOverlay); | 23 cr.addSingletonGetter(ImportDataOverlay); |
| 24 | 24 |
| 25 ImportDataOverlay.prototype = { | 25 ImportDataOverlay.prototype = { |
| 26 // Inherit ImportDataOverlay from OptionsPage. | 26 // Inherit ImportDataOverlay from OptionsPage. |
| 27 __proto__: OptionsPage.prototype, | 27 __proto__: OptionsPage.prototype, |
| 28 | 28 |
| 29 /** | 29 /** |
| 30 * Initialize the page. | 30 * Initialize the page. |
| 31 */ | 31 */ |
| 32 initializePage: function() { | 32 initializePage: function() { |
| 33 // Call base class implementation to starts preference initialization. | 33 // Call base class implementation to starts preference initialization. |
| 34 OptionsPage.prototype.initializePage.call(this); | 34 OptionsPage.prototype.initializePage.call(this); |
| 35 | 35 |
| 36 var self = this; | 36 var self = this; |
| 37 var checkboxList = $('checkboxList').getElementsByTagName('input'); | 37 var checkboxList = |
| 38 for (var i = 0; i < checkboxList.length; ++i) { | 38 document.querySelectorAll('#checkboxList input[type=checkbox]'); |
| 39 for (var i = 0; i < checkboxList.length; i++) { |
| 39 if(checkboxList[i].type == 'checkbox') | 40 if(checkboxList[i].type == 'checkbox') |
| 40 checkboxList[i].onchange = function(e) { | 41 checkboxList[i].onchange = function(e) { |
| 41 self.countCheckboxes_(); | 42 self.countCheckboxes_(); |
| 42 }; | 43 }; |
| 43 } | 44 } |
| 44 | 45 |
| 45 $('import-data-commit').onclick = function(e) { | 46 $('import-data-commit').onclick = function(e) { |
| 46 /** The first digit in paramList indicates browser selected | 47 /** The first digit in paramList indicates browser selected |
| 47 * The rest indicate the checkboxes (1 is checked, 0 is not) | 48 * The rest indicate the checkboxes (1 is checked, 0 is not) |
| 48 */ | 49 */ |
| 49 var selectedBrowser = $('supported-browsers').selectedIndex; | 50 var selectedBrowser = $('supported-browsers').selectedIndex; |
| 50 var paramList = | 51 var paramList = |
| 51 String(selectedBrowser) + ImportDataOverlay.checkboxMask; | 52 String(selectedBrowser) + ImportDataOverlay.checkboxMask; |
| 52 | 53 |
| 53 chrome.send('importData', [paramList]); | 54 chrome.send('importData', [paramList]); |
| 54 } | 55 } |
| 55 }, | 56 }, |
| 56 | 57 |
| 57 countCheckboxes_: function() { | 58 countCheckboxes_: function() { |
| 58 ImportDataOverlay.checkboxMask = ""; | 59 ImportDataOverlay.checkboxMask = ""; |
| 59 var checkboxList = $('checkboxList').getElementsByTagName('input'); | 60 var checkboxList = |
| 60 for (var i = 0; i < checkboxList.length; ++i) { | 61 document.querySelectorAll('#checkboxList input[type=checkbox]'); |
| 62 for (var i = 0; i < checkboxList.length; i++) { |
| 61 if (checkboxList[i].type == 'checkbox') { | 63 if (checkboxList[i].type == 'checkbox') { |
| 62 if(checkboxList[i].checked) | 64 if(checkboxList[i].checked) |
| 63 ImportDataOverlay.checkboxMask += "1"; | 65 ImportDataOverlay.checkboxMask += "1"; |
| 64 else | 66 else |
| 65 ImportDataOverlay.checkboxMask += "0"; | 67 ImportDataOverlay.checkboxMask += "0"; |
| 66 } | 68 } |
| 67 } | 69 } |
| 68 if (ImportDataOverlay.checkboxMask.indexOf("1") == -1) | 70 if (ImportDataOverlay.checkboxMask.indexOf("1") == -1) |
| 69 $('import-data-commit').disabled = true; | 71 $('import-data-commit').disabled = true; |
| 70 else | 72 else |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 OptionsPage.clearOverlays(); | 144 OptionsPage.clearOverlays(); |
| 143 ImportDataOverlay.setImportingState(false); | 145 ImportDataOverlay.setImportingState(false); |
| 144 } | 146 } |
| 145 | 147 |
| 146 // Export | 148 // Export |
| 147 return { | 149 return { |
| 148 ImportDataOverlay: ImportDataOverlay | 150 ImportDataOverlay: ImportDataOverlay |
| 149 }; | 151 }; |
| 150 | 152 |
| 151 }); | 153 }); |
| OLD | NEW |