| 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, | 15 OptionsPage.call(this, |
| 16 'importDataOverlay', | 16 'importDataOverlay', |
| 17 templateData.import_data_title, | 17 templateData.import_data_title, |
| 18 'import-data-overlay'); | 18 'import-data-overlay'); |
| 19 } | 19 } |
| 20 | 20 |
| 21 ImportDataOverlay.throbIntervalId = 0; | |
| 22 | |
| 23 cr.addSingletonGetter(ImportDataOverlay); | 21 cr.addSingletonGetter(ImportDataOverlay); |
| 24 | 22 |
| 25 ImportDataOverlay.prototype = { | 23 ImportDataOverlay.prototype = { |
| 26 // Inherit from OptionsPage. | 24 // Inherit from OptionsPage. |
| 27 __proto__: OptionsPage.prototype, | 25 __proto__: OptionsPage.prototype, |
| 28 | 26 |
| 29 /** | 27 /** |
| 30 * Initialize the page. | 28 * Initialize the page. |
| 31 */ | 29 */ |
| 32 initializePage: function() { | 30 initializePage: function() { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 53 String($('import-history').checked), | 51 String($('import-history').checked), |
| 54 String($('import-favorites').checked), | 52 String($('import-favorites').checked), |
| 55 String($('import-passwords').checked), | 53 String($('import-passwords').checked), |
| 56 String($('import-search').checked)]); | 54 String($('import-search').checked)]); |
| 57 }; | 55 }; |
| 58 | 56 |
| 59 $('import-data-cancel').onclick = function() { | 57 $('import-data-cancel').onclick = function() { |
| 60 ImportDataOverlay.dismiss(); | 58 ImportDataOverlay.dismiss(); |
| 61 }; | 59 }; |
| 62 | 60 |
| 61 cr.ui.Throbber.decorate($('import-throbber')); |
| 62 |
| 63 // Form controls are disabled until the profile list has been loaded. | 63 // Form controls are disabled until the profile list has been loaded. |
| 64 self.setControlsSensitive_(false); | 64 self.setControlsSensitive_(false); |
| 65 }, | 65 }, |
| 66 | 66 |
| 67 /** | 67 /** |
| 68 * Set enabled and checked state of the commit button. | 68 * Set enabled and checked state of the commit button. |
| 69 * @private | 69 * @private |
| 70 */ | 70 */ |
| 71 validateCommitButton_: function() { | 71 validateCommitButton_: function() { |
| 72 var somethingToImport = | 72 var somethingToImport = |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 var checkboxes = | 160 var checkboxes = |
| 161 document.querySelectorAll('#import-checkboxes input[type=checkbox]'); | 161 document.querySelectorAll('#import-checkboxes input[type=checkbox]'); |
| 162 for (var i = 0; i < checkboxes.length; i++) { | 162 for (var i = 0; i < checkboxes.length; i++) { |
| 163 checkboxes[i].disabled = true; | 163 checkboxes[i].disabled = true; |
| 164 } | 164 } |
| 165 } else { | 165 } else { |
| 166 ImportDataOverlay.getInstance().updateCheckboxes_(); | 166 ImportDataOverlay.getInstance().updateCheckboxes_(); |
| 167 } | 167 } |
| 168 $('import-browsers').disabled = state; | 168 $('import-browsers').disabled = state; |
| 169 $('import-data-commit').disabled = state; | 169 $('import-data-commit').disabled = state; |
| 170 $('import-throbber').style.visibility = state ? "visible" : "hidden"; | 170 $('import-throbber').visible = state; |
| 171 | |
| 172 function advanceThrobber() { | |
| 173 var throbber = $('import-throbber'); | |
| 174 throbber.style.backgroundPositionX = | |
| 175 ((parseInt(getComputedStyle(throbber).backgroundPositionX, 10) - 16) | |
| 176 % 576) + 'px'; | |
| 177 } | |
| 178 if (state) { | |
| 179 ImportDataOverlay.throbIntervalId = setInterval(advanceThrobber, 30); | |
| 180 } else { | |
| 181 clearInterval(ImportDataOverlay.throbIntervalId); | |
| 182 } | |
| 183 }; | 171 }; |
| 184 | 172 |
| 185 /** | 173 /** |
| 186 * Remove the import overlay from display. | 174 * Remove the import overlay from display. |
| 187 */ | 175 */ |
| 188 ImportDataOverlay.dismiss = function() { | 176 ImportDataOverlay.dismiss = function() { |
| 189 ImportDataOverlay.setImportingState(false); | 177 ImportDataOverlay.setImportingState(false); |
| 190 OptionsPage.clearOverlays(); | 178 OptionsPage.clearOverlays(); |
| 191 } | 179 } |
| 192 | 180 |
| 193 // Export | 181 // Export |
| 194 return { | 182 return { |
| 195 ImportDataOverlay: ImportDataOverlay | 183 ImportDataOverlay: ImportDataOverlay |
| 196 }; | 184 }; |
| 197 | 185 |
| 198 }); | 186 }); |
| OLD | NEW |