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

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

Issue 8548012: Added "select all/none" checkbox. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge Created 9 years, 1 month 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
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 c41b1c393f84514275b57ee777e85086be71912f..057f9ba48009ecf825f6401640d13d5375e1ab89 100644
--- a/chrome/browser/resources/file_manager/js/file_manager.js
+++ b/chrome/browser/resources/file_manager/js/file_manager.js
@@ -639,11 +639,12 @@ FileManager.prototype = {
* One-time initialization of dialogs.
*/
FileManager.prototype.initDialogs_ = function() {
- cr.ui.dialogs.BaseDialog.OK_LABEL = str('OK_LABEL');
- cr.ui.dialogs.BaseDialog.CANCEL_LABEL = str('CANCEL_LABEL');
- this.alert = new cr.ui.dialogs.AlertDialog(this.dialogDom_);
- this.confirm = new cr.ui.dialogs.ConfirmDialog(this.dialogDom_);
- this.prompt = new cr.ui.dialogs.PromptDialog(this.dialogDom_);
+ var d = cr.ui.dialogs;
+ d.BaseDialog.OK_LABEL = str('OK_LABEL');
+ d.BaseDialog.CANCEL_LABEL = str('CANCEL_LABEL');
+ this.alert = new d.AlertDialog(this.dialogDom_);
+ this.confirm = new d.ConfirmDialog(this.dialogDom_);
+ this.prompt = new d.PromptDialog(this.dialogDom_);
};
/**
@@ -1157,8 +1158,10 @@ FileManager.prototype = {
columns[3].renderFunction = this.renderDate_.bind(this);
if (this.showCheckboxes_) {
- columns.unshift(new cr.ui.table.TableColumn('checkbox_', '', 3));
+ columns.unshift(new cr.ui.table.TableColumn('checkbox_', '', 3.6));
columns[0].renderFunction = this.renderCheckbox_.bind(this);
+ columns[0].headerRenderFunction =
+ this.renderCheckboxColumnHeader_.bind(this);
}
this.table_ = this.dialogDom_.querySelector('.detail-table');
@@ -1544,6 +1547,34 @@ FileManager.prototype = {
return input;
};
+ FileManager.prototype.renderCheckboxColumnHeader_ = function(table) {
+ var input = this.document_.createElement('input');
+ input.setAttribute('type', 'checkbox');
+ input.setAttribute('tabindex', -1);
+ input.id = 'select-all-checkbox';
+ input.checked = this.areAllItemsSelected();
+
+ var self = this;
+ input.addEventListener('click', function(event) {
+ if (self.areAllItemsSelected())
+ table.selectionModel.unselectAll();
+ else
+ table.selectionModel.selectAll();
+ event.preventDefault();
+ });
+
+ return input;
+ };
+
+ /**
+ * Check if all items in the current list are selected.
+ * @return {boolean} True if all items are selected.
+ */
+ FileManager.prototype.areAllItemsSelected = function() {
+ return this.selection &&
+ this.dataModel_.length == this.selection.totalCount;
+ };
+
/**
* Insert a thumbnail image to fit/fill the container.
*
@@ -2819,6 +2850,10 @@ FileManager.prototype = {
listItem.querySelector('input[type="checkbox"]').checked = true;
}
}
+ var selectAllCheckbox =
+ this.document_.getElementById('select-all-checkbox');
+ if (selectAllCheckbox)
+ selectAllCheckbox.checked = this.areAllItemsSelected();
};
FileManager.prototype.updateOkButton_ = function(event) {

Powered by Google App Engine
This is Rietveld 408576698