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

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

Issue 3143012: Reland r55881: Disable the 'Clear browsing Data' button when no checkboxes are checked. (Closed) Base URL: git://git.chromium.org/chromium.git
Patch Set: address stuart concern Created 10 years, 4 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
OLDNEW
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 * ClearBrowserData class 10 * ClearBrowserData class
(...skipping 16 matching lines...) Expand all
27 27
28 /** 28 /**
29 * Initialize the page. 29 * Initialize the page.
30 */ 30 */
31 initializePage: function() { 31 initializePage: function() {
32 // Call base class implementation to starts preference initialization. 32 // Call base class implementation to starts preference initialization.
33 OptionsPage.prototype.initializePage.call(this); 33 OptionsPage.prototype.initializePage.call(this);
34 34
35 // Setup option values for the time period select control. 35 // Setup option values for the time period select control.
36 $('clearBrowsingDataTimePeriod').initializeValues( 36 $('clearBrowsingDataTimePeriod').initializeValues(
37 templateData.clearBrowsingDataTimeList) 37 templateData.clearBrowsingDataTimeList);
38
39 var f = cr.bind(this.updateButtonState_, this);
40 var types = ['browser.clear_data.browsing_history',
41 'browser.clear_data.download_history',
42 'browser.clear_data.cache',
43 'browser.clear_data.cookies',
44 'browser.clear_data.passwords',
45 'browser.clear_data.form_data'];
46 types.forEach(function(type) {
47 Preferences.getInstance().addEventListener(type, f);
48 });
49
50 var checkboxes = document.querySelectorAll(
51 '#checkboxListData input[type=checkbox]');
52 for (var i = 0; i < checkboxes.length; i++) {
53 checkboxes[i].onclick = f;
54 }
55 this.updateButtonState_();
38 56
39 // Setup click handler for the clear(Ok) button. 57 // Setup click handler for the clear(Ok) button.
40 $('clearBrowsingDataCommit').onclick = function(event) { 58 $('clearBrowsingDataCommit').onclick = function(event) {
41 chrome.send('performClearBrowserData'); 59 chrome.send('performClearBrowserData');
42 }; 60 };
43 } 61 },
62
63 updateButtonState_: function() {
64 var checkboxes = document.querySelectorAll(
65 '#checkboxListData input[type=checkbox]');
66 var isChecked = false;
67 for (var i = 0; i < checkboxes.length; i++) {
68 if (checkboxes[i].checked) {
69 isChecked = true;
70 break;
71 }
72 }
73 $('clearBrowsingDataCommit').disabled = !isChecked;
74 },
44 }; 75 };
45 76
46 // 77 //
47 // Chrome callbacks 78 // Chrome callbacks
48 // 79 //
49 ClearBrowserDataOverlay.setClearingState = function(state) { 80 ClearBrowserDataOverlay.setClearingState = function(state) {
50 $('deleteBrowsingHistoryCheckbox').disabled = state; 81 $('deleteBrowsingHistoryCheckbox').disabled = state;
51 $('deleteDownloadHistoryCheckbox').disabled = state; 82 $('deleteDownloadHistoryCheckbox').disabled = state;
52 $('deleteCacheCheckbox').disabled = state; 83 $('deleteCacheCheckbox').disabled = state;
53 $('deleteCookiesCheckbox').disabled = state; 84 $('deleteCookiesCheckbox').disabled = state;
(...skipping 24 matching lines...) Expand all
78 this.setClearingState(false); 109 this.setClearingState(false);
79 } 110 }
80 111
81 // Export 112 // Export
82 return { 113 return {
83 ClearBrowserDataOverlay: ClearBrowserDataOverlay 114 ClearBrowserDataOverlay: ClearBrowserDataOverlay
84 }; 115 };
85 116
86 }); 117 });
87 118
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698