Commit dad86a83 authored by tfarina@chromium.org's avatar tfarina@chromium.org

Reland r55881: Disable the 'Clear browsing Data' button when no checkboxes are checked.

BUG=49037
TEST=out/Debug/chrome --enable-tabbed-options. Go to 'Under the Hood' tab, open the
dialog, check some checkbox, the button should become enabled, uncheck all the
checkboxes, the button should become disabled.

Review URL: http://codereview.chromium.org/3143012

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57322 0039d316-1c4b-4281-b951-d872f2087c98
parent ceaacead
...@@ -6,3 +6,7 @@ ...@@ -6,3 +6,7 @@
display: inline-block; display: inline-block;
visibility: hidden; visibility: hidden;
} }
#checkboxListData > label {
display: block;
}
<div class="page hidden" id="clearBrowserDataOverlay"> <div class="page hidden" id="clearBrowserDataOverlay">
<h1 i18n-content="clearBrowsingDataTitle"></h1> <h1 i18n-content="clearBrowsingDataTitle"></h1>
<h3 i18n-content="clearBrowsingDataLabel"></h3> <h3 i18n-content="clearBrowsingDataLabel"></h3>
<table class="option-control-table"> <div id="checkboxListData">
<tr> <label>
<td class="option-name"><label><input id="deleteBrowsingHistoryCheckbox" <input id="deleteBrowsingHistoryCheckbox"
pref="browser.clear_data.browsing_history" type="checkbox"><span pref="browser.clear_data.browsing_history" type="checkbox">
i18n-content="deleteBrowsingHistoryCheckbox"></span></label></td> <span i18n-content="deleteBrowsingHistoryCheckbox"></span>
</tr> </label>
<tr> <label>
<td class="option-name"><label><input id="deleteDownloadHistoryCheckbox" <input id="deleteDownloadHistoryCheckbox"
pref="browser.clear_data.download_history" type="checkbox"><span pref="browser.clear_data.download_history" type="checkbox">
i18n-content="deleteDownloadHistoryCheckbox"></span></label></td> <span i18n-content="deleteDownloadHistoryCheckbox"></span>
</tr> </label>
<tr> <label>
<td class="option-name"><label><input id="deleteCacheCheckbox" <input id="deleteCacheCheckbox"
pref="browser.clear_data.cache" type="checkbox"><span pref="browser.clear_data.cache" type="checkbox">
i18n-content="deleteCacheCheckbox"></span></label> <span i18n-content="deleteCacheCheckbox"></span>
</td> </label>
</tr> <label>
<tr> <input id="deleteCookiesCheckbox"
<td class="option-name"><label><input id="deleteCookiesCheckbox" pref="browser.clear_data.cookies" type="checkbox">
pref="browser.clear_data.cookies" type="checkbox"><span <span i18n-content="deleteCookiesCheckbox"></span>
i18n-content="deleteCookiesCheckbox"></span></label></td> </label>
</tr> <label>
<tr> <input id="deletePasswordsCheckbox"
<td class="option-name"><label><input id="deletePasswordsCheckbox" pref="browser.clear_data.passwords" type="checkbox">
pref="browser.clear_data.passwords" type="checkbox"><span <span i18n-content="deletePasswordsCheckbox"></span>
i18n-content="deletePasswordsCheckbox"></span></label></td> </label>
</tr> <label>
<tr> <input id="deleteFormDataCheckbox"
<td class="option-name"><label><input id="deleteFormDataCheckbox" pref="browser.clear_data.form_data" type="checkbox">
pref="browser.clear_data.form_data" type="checkbox"><span <span i18n-content="deleteFormDataCheckbox"></span>
i18n-content="deleteFormDataCheckbox"></span></label></td> </label>
</tr> </div>
<tr> <div>
<td> <div>
<label><span i18n-content="clearBrowsingDataTimeLabel"></span> <label>
<span i18n-content="clearBrowsingDataTimeLabel"></span>
<select id="clearBrowsingDataTimePeriod" <select id="clearBrowsingDataTimePeriod"
pref="browser.clear_data.time_period"></select></label> pref="browser.clear_data.time_period"></select>
</td> </label>
</tr> </div>
<tr>
<td>
<span id="cbdThrobber"></span> <span id="cbdThrobber"></span>
<if expr="os == 'win32'">
<button id="clearBrowsingDataCommit" <button id="clearBrowsingDataCommit"
i18n-content="clearBrowsingDataCommit"></button> i18n-content="clearBrowsingDataCommit"></button>
</if>
<button id="clearBrowsingDataDismiss" i18n-content="cancel" <button id="clearBrowsingDataDismiss" i18n-content="cancel"
onclick="ClearBrowserDataOverlay.dismiss();"> onclick="ClearBrowserDataOverlay.dismiss();">
</button> </button>
</td> <if expr="os != 'win32'">
</tr> <button id="clearBrowsingDataCommit"
</table> i18n-content="clearBrowsingDataCommit"></button>
</if>
</div>
<hr> <hr>
<a target="_blank" i18n-content="flash_storage_settings" <a target="_blank" i18n-content="flash_storage_settings"
i18n-values="href:flash_storage_url"></a> i18n-values="href:flash_storage_url"></a>
......
...@@ -34,13 +34,44 @@ cr.define('options', function() { ...@@ -34,13 +34,44 @@ cr.define('options', function() {
// Setup option values for the time period select control. // Setup option values for the time period select control.
$('clearBrowsingDataTimePeriod').initializeValues( $('clearBrowsingDataTimePeriod').initializeValues(
templateData.clearBrowsingDataTimeList) templateData.clearBrowsingDataTimeList);
var f = cr.bind(this.updateButtonState_, this);
var types = ['browser.clear_data.browsing_history',
'browser.clear_data.download_history',
'browser.clear_data.cache',
'browser.clear_data.cookies',
'browser.clear_data.passwords',
'browser.clear_data.form_data'];
types.forEach(function(type) {
Preferences.getInstance().addEventListener(type, f);
});
var checkboxes = document.querySelectorAll(
'#checkboxListData input[type=checkbox]');
for (var i = 0; i < checkboxes.length; i++) {
checkboxes[i].onclick = f;
}
this.updateButtonState_();
// Setup click handler for the clear(Ok) button. // Setup click handler for the clear(Ok) button.
$('clearBrowsingDataCommit').onclick = function(event) { $('clearBrowsingDataCommit').onclick = function(event) {
chrome.send('performClearBrowserData'); chrome.send('performClearBrowserData');
}; };
},
updateButtonState_: function() {
var checkboxes = document.querySelectorAll(
'#checkboxListData input[type=checkbox]');
var isChecked = false;
for (var i = 0; i < checkboxes.length; i++) {
if (checkboxes[i].checked) {
isChecked = true;
break;
}
} }
$('clearBrowsingDataCommit').disabled = !isChecked;
},
}; };
// //
......
...@@ -23,8 +23,13 @@ ...@@ -23,8 +23,13 @@
<span i18n-content="import_history"> <span i18n-content="import_history">
</label><br> </label><br>
</div> </div>
<if expr="os == 'win32'">
<button id="import-data-commit" i18n-content="import_commit"></button>
</if>
<button id="import-data-cancel" i18n-content="cancel" <button id="import-data-cancel" i18n-content="cancel"
onclick="ImportDataOverlay.dismiss();"></button> onclick="ImportDataOverlay.dismiss();"></button>
<if expr="os != 'win32'">
<button id="import-data-commit" i18n-content="import_commit"></button> <button id="import-data-commit" i18n-content="import_commit"></button>
</if>
<span id="import-throbber"></span> <span id="import-throbber"></span>
</div> </div>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment