diff options
6 files changed, 82 insertions, 9 deletions
diff --git a/chrome/browser/resources/file_manager/css/file_manager.css b/chrome/browser/resources/file_manager/css/file_manager.css index 50044e9..d227436 100644 --- a/chrome/browser/resources/file_manager/css/file_manager.css +++ b/chrome/browser/resources/file_manager/css/file_manager.css @@ -378,9 +378,14 @@ div.img-container > img { z-index: 2; -webkit-margin-end: 0px; margin-top: 6px; + margin-left: 7px; opacity: 0.1; } +#select-all-checkbox { + margin: 0; +} + li.thumbnail-item .file-checkbox { opacity: 0; } diff --git a/chrome/browser/resources/file_manager/js/file_manager.js b/chrome/browser/resources/file_manager/js/file_manager.js index d36a8e2..fc6e6e6 100644 --- a/chrome/browser/resources/file_manager/js/file_manager.js +++ b/chrome/browser/resources/file_manager/js/file_manager.js @@ -637,11 +637,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_); }; /** @@ -1155,8 +1156,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'); @@ -1542,6 +1545,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. * @@ -2816,6 +2847,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) { diff --git a/chrome/browser/resources/shared/js/cr/ui/array_data_model.js b/chrome/browser/resources/shared/js/cr/ui/array_data_model.js index 5a83dd3..3992c46 100644 --- a/chrome/browser/resources/shared/js/cr/ui/array_data_model.js +++ b/chrome/browser/resources/shared/js/cr/ui/array_data_model.js @@ -77,6 +77,15 @@ cr.define('cr.ui', function() { }, /** + * Returns true if the field has a compare function. + * @param {string} field The field to check. + * @return {boolean} True if the field is sortable. + */ + isSortable: function(field) { + return this.compareFunctions_ && field in this.compareFunctions_; + }, + + /** * Returns current sort status. * @return {!Object} Current sort status. */ diff --git a/chrome/browser/resources/shared/js/cr/ui/table/table_column.js b/chrome/browser/resources/shared/js/cr/ui/table/table_column.js index a2202a3..ba54387 100644 --- a/chrome/browser/resources/shared/js/cr/ui/table/table_column.js +++ b/chrome/browser/resources/shared/js/cr/ui/table/table_column.js @@ -31,8 +31,6 @@ cr.define('cr.ui.table', function() { width_: null, - renderFunction_: null, - /** * Clones column. * @return {cr.ui.table.TableColumn} Clone of the given column. @@ -40,6 +38,7 @@ cr.define('cr.ui.table', function() { clone: function() { var tableColumn = new TableColumn(this.id_, this.name_, this.width_); tableColumn.renderFunction = this.renderFunction_; + tableColumn.headerRenderFunction = this.headerRenderFunction_; return tableColumn; }, @@ -55,6 +54,15 @@ cr.define('cr.ui.table', function() { div.textContent = dataItem[columnId]; return div; }, + + /** + * Renders table header. This is the default render function. + * @param {cr.ui.Table} table The table. + * @return {HTMLElement} Rendered element. + */ + headerRenderFunction_: function(table) { + return table.ownerDocument.createTextNode(this.name); + }, }; /** @@ -81,6 +89,12 @@ cr.define('cr.ui.table', function() { */ cr.defineProperty(TableColumn, 'renderFunction'); + /** + * The column header render function. + * @type {Function(cr.ui.Table): HTMLElement} + */ + cr.defineProperty(TableColumn, 'headerRenderFunction'); + return { TableColumn: TableColumn }; diff --git a/chrome/browser/resources/shared/js/cr/ui/table/table_column_model.js b/chrome/browser/resources/shared/js/cr/ui/table/table_column_model.js index 13399dd..346fd7f 100644 --- a/chrome/browser/resources/shared/js/cr/ui/table/table_column_model.js +++ b/chrome/browser/resources/shared/js/cr/ui/table/table_column_model.js @@ -132,6 +132,16 @@ cr.define('cr.ui.table', function() { }, /** + * Render the column header. + * @param {number} index The index of the column. + * @param {cr.ui.Table} Owner table. + */ + renderHeader: function(index, table) { + var c = this.columns_[index]; + return c.headerRenderFunction.call(c, table); + }, + + /** * The total width of the columns. * @type {number} */ diff --git a/chrome/browser/resources/shared/js/cr/ui/table/table_header.js b/chrome/browser/resources/shared/js/cr/ui/table/table_header.js index 88d04a7..5411bba 100644 --- a/chrome/browser/resources/shared/js/cr/ui/table/table_header.js +++ b/chrome/browser/resources/shared/js/cr/ui/table/table_header.js @@ -124,7 +124,7 @@ cr.define('cr.ui.table', function() { labelDiv.className = 'table-header-label'; var span = this.ownerDocument.createElement('span'); - span.textContent = cm.getName(index); + span.appendChild(cm.renderHeader(index, this.table_)); var rtl = this.ownerDocument.defaultView.getComputedStyle(this). direction == 'rtl'; if (rtl) { |