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

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

Issue 636933002: [MAC] Disable 'Import' button when visible checkboxes are unchecked. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing reviewer's comments. Created 6 years, 2 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 * @param {string} type The type of data to import. Used in the element's ID.
25 */
26 function importable(type) {
27 var el = 'import-' + type;
28 return $(el).checked &&
29 getComputedStyle($(el + '-with-label')).display != 'none';
Dan Beam 2014/10/15 03:41:35 fine, but use hidden instead var id = 'import-'
Gaja 2014/10/15 05:10:51 Done.
30 }
31
23 ImportDataOverlay.prototype = { 32 ImportDataOverlay.prototype = {
24 // Inherit from Page. 33 // Inherit from Page.
25 __proto__: Page.prototype, 34 __proto__: Page.prototype,
26 35
27 /** @override */ 36 /** @override */
28 initializePage: function() { 37 initializePage: function() {
29 Page.prototype.initializePage.call(this); 38 Page.prototype.initializePage.call(this);
30 39
31 var self = this; 40 var self = this;
32 var checkboxes = 41 var checkboxes =
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 // Form controls are disabled until the profile list has been loaded. 77 // Form controls are disabled until the profile list has been loaded.
69 self.setAllControlsEnabled_(false); 78 self.setAllControlsEnabled_(false);
70 }, 79 },
71 80
72 /** 81 /**
73 * Sets the enabled and checked state of the commit button. 82 * Sets the enabled and checked state of the commit button.
74 * @private 83 * @private
75 */ 84 */
76 validateCommitButton_: function() { 85 validateCommitButton_: function() {
77 var somethingToImport = 86 var somethingToImport =
78 $('import-history').checked || $('import-favorites').checked || 87 importable('history') || importable('favorites') ||
79 $('import-passwords').checked || $('import-search').checked || 88 importable('passwords') || importable('search') ||
80 $('import-autofill-form-data').checked; 89 importable('autofill-form-data');
81 $('import-data-commit').disabled = !somethingToImport; 90 $('import-data-commit').disabled = !somethingToImport;
82 $('import-choose-file').disabled = !$('import-favorites').checked; 91 $('import-choose-file').disabled = !$('import-favorites').checked;
83 }, 92 },
84 93
85 /** 94 /**
86 * Sets the enabled state of all the checkboxes and the commit button. 95 * Sets the enabled state of all the checkboxes and the commit button.
87 * @private 96 * @private
88 */ 97 */
89 setAllControlsEnabled_: function(enabled) { 98 setAllControlsEnabled_: function(enabled) {
90 var checkboxes = 99 var checkboxes =
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 var importOptions = ['history', 134 var importOptions = ['history',
126 'favorites', 135 'favorites',
127 'passwords', 136 'passwords',
128 'search', 137 'search',
129 'autofill-form-data']; 138 'autofill-form-data'];
130 for (var i = 0; i < importOptions.length; i++) { 139 for (var i = 0; i < importOptions.length; i++) {
131 var checkbox = $('import-' + importOptions[i]); 140 var checkbox = $('import-' + importOptions[i]);
132 var enable = browserProfile && browserProfile[importOptions[i]]; 141 var enable = browserProfile && browserProfile[importOptions[i]];
133 this.setUpCheckboxState_(checkbox, enable); 142 this.setUpCheckboxState_(checkbox, enable);
134 var checkboxWithLabel = $('import-' + importOptions[i] + '-with-label'); 143 var checkboxWithLabel = $('import-' + importOptions[i] + '-with-label');
135 checkboxWithLabel.style.display = enable ? '' : 'none'; 144 checkboxWithLabel.style.display = enable ? '' : 'none';
Dan Beam 2014/10/15 03:41:35 use .hidden instead of display = 'none'. i think
Gaja 2014/10/15 05:10:51 Done. This is much better. Thanks.
136 } 145 }
137 }, 146 },
138 147
139 /** 148 /**
140 * Show or hide gray message at the bottom. 149 * Show or hide gray message at the bottom.
141 * @private 150 * @private
142 */ 151 */
143 updateBottomBar_: function() { 152 updateBottomBar_: function() {
144 var index = $('import-browsers').selectedIndex; 153 var index = $('import-browsers').selectedIndex;
145 var browserProfile; 154 var browserProfile;
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 ImportDataOverlay.getInstance().validateCommitButton_(); 279 ImportDataOverlay.getInstance().validateCommitButton_();
271 280
272 PageManager.showPageByName('importData'); 281 PageManager.showPageByName('importData');
273 }; 282 };
274 283
275 // Export 284 // Export
276 return { 285 return {
277 ImportDataOverlay: ImportDataOverlay 286 ImportDataOverlay: ImportDataOverlay
278 }; 287 };
279 }); 288 });
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698