Chromium Code Reviews| 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 69c6c381f9776d13f0617b96f48539cd69fc7c32..247c475e2a0ac18f511821a84a4d3fc93f28ef9f 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) { |
| @@ -3168,7 +3203,7 @@ FileManager.prototype = { |
| FileManager.prototype.onUnload_ = function(event) { |
| if (this.subscribedOnDirectoryChanges_) { |
| - chrome.fileBrowserPrivate.removeFileWatch(event.previousDirEntry.toURL(), |
| + chrome.fileBrowserPrivate.removeFileWatch(this.currentDirEntry_.toURL(), |
|
Vladislav Kaznacheev
2011/11/21 13:14:50
This change is already committed by jamescook
SeRya
2011/11/21 14:19:41
Merged.
|
| function(result) { |
| if (!result) { |
| console.log('Failed to remove file watch'); |
| @@ -3179,7 +3214,7 @@ FileManager.prototype = { |
| FileManager.prototype.onFileChanged_ = function(event) { |
| // We receive a lot of events even in folders we are not interested in. |
| - if (event.fileUrl == this.currentDirEntry_.toURL()) |
| + if (event.fileUrl == event.previousDirEntry.toURL()) |
|
Vladislav Kaznacheev
2011/11/21 13:14:50
Does this belong to this change?
SeRya
2011/11/21 14:19:41
Removed.
|
| this.rescanDirectoryLater_(); |
| }; |