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

Unified Diff: chrome/browser/resources/file_manager/js/file_manager.js

Issue 8788011: Disabling "Select all" chechbox when the dir is empty. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix. Created 9 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/file_manager/js/file_manager.js
diff --git a/chrome/browser/resources/file_manager/js/file_manager.js b/chrome/browser/resources/file_manager/js/file_manager.js
index bbf220269178eef97a40603294ff4fecdeccfa02..af830bb96b3f5c112dbc58c21ea1d07b3ecaec8a 100644
--- a/chrome/browser/resources/file_manager/js/file_manager.js
+++ b/chrome/browser/resources/file_manager/js/file_manager.js
@@ -750,6 +750,9 @@ FileManager.prototype = {
this.selectionModelClass_ = cr.ui.ListSelectionModel;
}
+ this.dataModel_.addEventListener('splice',
+ this.onDataModelSplice_.bind(this));
+
this.initTable_();
this.initGrid_();
@@ -853,6 +856,12 @@ FileManager.prototype = {
setTimeout(function() { successCallback(entry) }, 0);
};
+ FileManager.prototype.onDataModelSplice_ = function(event) {
+ var checkbox = this.document_.querySelector('#select-all-checkbox');
+ if (checkbox)
+ this.updateSelectAllCheckboxState_(checkbox);
+ };
+
/**
* Get the file type of the entry, caching the result.
*
@@ -1560,14 +1569,13 @@ FileManager.prototype = {
input.setAttribute('type', 'checkbox');
input.setAttribute('tabindex', -1);
input.id = 'select-all-checkbox';
- input.checked = this.areAllItemsSelected();
+ this.updateSelectAllCheckboxState_(input);
- var self = this;
input.addEventListener('click', function(event) {
- if (self.areAllItemsSelected())
- table.selectionModel.unselectAll();
- else
+ if (input.checked)
table.selectionModel.selectAll();
+ else
+ table.selectionModel.unselectAll();
event.preventDefault();
event.stopPropagation();
});
@@ -1579,12 +1587,12 @@ FileManager.prototype = {
};
/**
- * Check if all items in the current list are selected.
- * @return {boolean} True if all items are selected.
+ * Update check and disable states of the 'Select all' checkbox.
*/
- FileManager.prototype.areAllItemsSelected = function() {
- return this.selection && this.dataModel_.length > 0 &&
- this.dataModel_.length == this.selection.totalCount;
+ FileManager.prototype.updateSelectAllCheckboxState_ = function(checkbox) {
+ checkbox.checked = this.selection && this.dataModel_.length > 0 &&
+ this.dataModel_.length == this.selection.totalCount;
+ checkbox.disabled = this.dataModel_.length == 0;
};
/**
@@ -2941,7 +2949,7 @@ FileManager.prototype = {
var selectAllCheckbox =
this.document_.getElementById('select-all-checkbox');
if (selectAllCheckbox)
- selectAllCheckbox.checked = this.areAllItemsSelected();
+ this.updateSelectAllCheckboxState_(selectAllCheckbox);
};
FileManager.prototype.updateOkButton_ = function(event) {
« 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