Commit ac1df3e3 authored by serya@chromium.org's avatar serya@chromium.org

Disabling "Select all" chechbox when the dir is empty.

BUG=chromium-os:20156
TEST=None


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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@112980 0039d316-1c4b-4281-b951-d872f2087c98
parent ff5e9422
......@@ -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) {
......
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