OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Setting the src of an img to an empty string can crash the browser, so we | 5 // Setting the src of an img to an empty string can crash the browser, so we |
6 // use an empty 1x1 gif instead. | 6 // use an empty 1x1 gif instead. |
7 const EMPTY_IMAGE_URI = 'data:image/gif;base64,' | 7 const EMPTY_IMAGE_URI = 'data:image/gif;base64,' |
8 + 'R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw%3D%3D'; | 8 + 'R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw%3D%3D'; |
9 | 9 |
10 var g_slideshow_data = null; | 10 var g_slideshow_data = null; |
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
632 | 632 |
633 this.document_.addEventListener('canExecute', | 633 this.document_.addEventListener('canExecute', |
634 this.onCanExecute_.bind(this)); | 634 this.onCanExecute_.bind(this)); |
635 this.document_.addEventListener('command', this.onCommand_.bind(this)); | 635 this.document_.addEventListener('command', this.onCommand_.bind(this)); |
636 } | 636 } |
637 | 637 |
638 /** | 638 /** |
639 * One-time initialization of dialogs. | 639 * One-time initialization of dialogs. |
640 */ | 640 */ |
641 FileManager.prototype.initDialogs_ = function() { | 641 FileManager.prototype.initDialogs_ = function() { |
642 cr.ui.dialogs.BaseDialog.OK_LABEL = str('OK_LABEL'); | 642 var d = cr.ui.dialogs; |
643 cr.ui.dialogs.BaseDialog.CANCEL_LABEL = str('CANCEL_LABEL'); | 643 d.BaseDialog.OK_LABEL = str('OK_LABEL'); |
644 this.alert = new cr.ui.dialogs.AlertDialog(this.dialogDom_); | 644 d.BaseDialog.CANCEL_LABEL = str('CANCEL_LABEL'); |
645 this.confirm = new cr.ui.dialogs.ConfirmDialog(this.dialogDom_); | 645 this.alert = new d.AlertDialog(this.dialogDom_); |
646 this.prompt = new cr.ui.dialogs.PromptDialog(this.dialogDom_); | 646 this.confirm = new d.ConfirmDialog(this.dialogDom_); |
647 this.prompt = new d.PromptDialog(this.dialogDom_); | |
647 }; | 648 }; |
648 | 649 |
649 /** | 650 /** |
650 * One-time initialization of various DOM nodes. | 651 * One-time initialization of various DOM nodes. |
651 */ | 652 */ |
652 FileManager.prototype.initDom_ = function() { | 653 FileManager.prototype.initDom_ = function() { |
653 // Cache nodes we'll be manipulating. | 654 // Cache nodes we'll be manipulating. |
654 this.previewThumbnails_ = | 655 this.previewThumbnails_ = |
655 this.dialogDom_.querySelector('.preview-thumbnails'); | 656 this.dialogDom_.querySelector('.preview-thumbnails'); |
656 this.previewPanel_ = this.dialogDom_.querySelector('.preview-panel'); | 657 this.previewPanel_ = this.dialogDom_.querySelector('.preview-panel'); |
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1150 new cr.ui.table.TableColumn('cachedMtime_', | 1151 new cr.ui.table.TableColumn('cachedMtime_', |
1151 str('DATE_COLUMN_LABEL'), 21) | 1152 str('DATE_COLUMN_LABEL'), 21) |
1152 ]; | 1153 ]; |
1153 | 1154 |
1154 columns[0].renderFunction = this.renderName_.bind(this); | 1155 columns[0].renderFunction = this.renderName_.bind(this); |
1155 columns[1].renderFunction = this.renderSize_.bind(this); | 1156 columns[1].renderFunction = this.renderSize_.bind(this); |
1156 columns[2].renderFunction = this.renderType_.bind(this); | 1157 columns[2].renderFunction = this.renderType_.bind(this); |
1157 columns[3].renderFunction = this.renderDate_.bind(this); | 1158 columns[3].renderFunction = this.renderDate_.bind(this); |
1158 | 1159 |
1159 if (this.showCheckboxes_) { | 1160 if (this.showCheckboxes_) { |
1160 columns.unshift(new cr.ui.table.TableColumn('checkbox_', '', 3)); | 1161 columns.unshift(new cr.ui.table.TableColumn('checkbox_', '', 3.6)); |
1161 columns[0].renderFunction = this.renderCheckbox_.bind(this); | 1162 columns[0].renderFunction = this.renderCheckbox_.bind(this); |
1163 columns[0].headerRenderFunction = | |
1164 this.renderCheckboxColumnHeader_.bind(this); | |
1162 } | 1165 } |
1163 | 1166 |
1164 this.table_ = this.dialogDom_.querySelector('.detail-table'); | 1167 this.table_ = this.dialogDom_.querySelector('.detail-table'); |
1165 cr.ui.Table.decorate(this.table_); | 1168 cr.ui.Table.decorate(this.table_); |
1166 | 1169 |
1167 this.table_.selectionModel = new this.selectionModelClass_(); | 1170 this.table_.selectionModel = new this.selectionModelClass_(); |
1168 this.table_.columnModel = new cr.ui.table.TableColumnModel(columns); | 1171 this.table_.columnModel = new cr.ui.table.TableColumnModel(columns); |
1169 | 1172 |
1170 this.table_.addEventListener( | 1173 this.table_.addEventListener( |
1171 'dblclick', this.onDetailDoubleClick_.bind(this)); | 1174 'dblclick', this.onDetailDoubleClick_.bind(this)); |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1537 if (this.selection && this.selection.entries.indexOf(entry) != -1) { | 1540 if (this.selection && this.selection.entries.indexOf(entry) != -1) { |
1538 // Our DOM nodes get discarded as soon as we're scrolled out of view, | 1541 // Our DOM nodes get discarded as soon as we're scrolled out of view, |
1539 // so we have to make sure the check state is correct when we're brought | 1542 // so we have to make sure the check state is correct when we're brought |
1540 // back to life. | 1543 // back to life. |
1541 input.checked = true; | 1544 input.checked = true; |
1542 } | 1545 } |
1543 | 1546 |
1544 return input; | 1547 return input; |
1545 }; | 1548 }; |
1546 | 1549 |
1550 FileManager.prototype.renderCheckboxColumnHeader_ = function(table) { | |
1551 var input = this.document_.createElement('input'); | |
1552 input.setAttribute('type', 'checkbox'); | |
1553 input.setAttribute('tabindex', -1); | |
1554 input.id = 'select-all-checkbox'; | |
1555 input.checked = this.areAllItemsSelected(); | |
1556 | |
1557 var self = this; | |
1558 input.addEventListener('click', function(event) { | |
1559 if (self.areAllItemsSelected()) | |
1560 table.selectionModel.unselectAll(); | |
1561 else | |
1562 table.selectionModel.selectAll(); | |
1563 event.preventDefault(); | |
1564 }); | |
1565 | |
1566 return input; | |
1567 }; | |
1568 | |
1569 /** | |
1570 * Check if all items in the current list are selected. | |
1571 * @return {boolean} True if all items are selected. | |
1572 */ | |
1573 FileManager.prototype.areAllItemsSelected = function() { | |
1574 return this.selection && | |
1575 this.dataModel_.length == this.selection.totalCount; | |
1576 }; | |
1577 | |
1547 /** | 1578 /** |
1548 * Insert a thumbnail image to fit/fill the container. | 1579 * Insert a thumbnail image to fit/fill the container. |
1549 * | 1580 * |
1550 * Using webkit center packing does not align the image properly, so we need | 1581 * Using webkit center packing does not align the image properly, so we need |
1551 * to wait until the image loads and its proportions are known, then manually | 1582 * to wait until the image loads and its proportions are known, then manually |
1552 * position it at the center. | 1583 * position it at the center. |
1553 * | 1584 * |
1554 * @param {HTMLElement} parent | 1585 * @param {HTMLElement} parent |
1555 * @param {HTMLImageElement} img | 1586 * @param {HTMLImageElement} img |
1556 * @param {string} url | 1587 * @param {string} url |
(...skipping 1255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2812 if (this.selection.totalCount > 0) { | 2843 if (this.selection.totalCount > 0) { |
2813 // If more than one file is selected, make sure all checkboxes are lit | 2844 // If more than one file is selected, make sure all checkboxes are lit |
2814 // up. | 2845 // up. |
2815 for (var i = 0; i < this.selection.entries.length; i++) { | 2846 for (var i = 0; i < this.selection.entries.length; i++) { |
2816 var selectedIndex = this.selection.indexes[i]; | 2847 var selectedIndex = this.selection.indexes[i]; |
2817 var listItem = this.currentList_.getListItemByIndex(selectedIndex); | 2848 var listItem = this.currentList_.getListItemByIndex(selectedIndex); |
2818 if (listItem) | 2849 if (listItem) |
2819 listItem.querySelector('input[type="checkbox"]').checked = true; | 2850 listItem.querySelector('input[type="checkbox"]').checked = true; |
2820 } | 2851 } |
2821 } | 2852 } |
2853 var selectAllCheckbox = | |
2854 this.document_.getElementById('select-all-checkbox'); | |
2855 if (selectAllCheckbox) | |
2856 selectAllCheckbox.checked = this.areAllItemsSelected(); | |
2822 }; | 2857 }; |
2823 | 2858 |
2824 FileManager.prototype.updateOkButton_ = function(event) { | 2859 FileManager.prototype.updateOkButton_ = function(event) { |
2825 var selectable; | 2860 var selectable; |
2826 | 2861 |
2827 if (this.dialogType_ == FileManager.DialogType.SELECT_FOLDER) { | 2862 if (this.dialogType_ == FileManager.DialogType.SELECT_FOLDER) { |
2828 selectable = this.selection.directoryCount == 1 && | 2863 selectable = this.selection.directoryCount == 1 && |
2829 this.selection.fileCount == 0; | 2864 this.selection.fileCount == 0; |
2830 } else if (this.dialogType_ == FileManager.DialogType.SELECT_OPEN_FILE) { | 2865 } else if (this.dialogType_ == FileManager.DialogType.SELECT_OPEN_FILE) { |
2831 selectable = (this.selection.directoryCount == 0 && | 2866 selectable = (this.selection.directoryCount == 0 && |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3161 | 3196 |
3162 var li = this.findListItem_(event); | 3197 var li = this.findListItem_(event); |
3163 if (!li) { | 3198 if (!li) { |
3164 console.log('li not found', event); | 3199 console.log('li not found', event); |
3165 return; | 3200 return; |
3166 } | 3201 } |
3167 }; | 3202 }; |
3168 | 3203 |
3169 FileManager.prototype.onUnload_ = function(event) { | 3204 FileManager.prototype.onUnload_ = function(event) { |
3170 if (this.subscribedOnDirectoryChanges_) { | 3205 if (this.subscribedOnDirectoryChanges_) { |
3171 chrome.fileBrowserPrivate.removeFileWatch(event.previousDirEntry.toURL(), | 3206 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.
| |
3172 function(result) { | 3207 function(result) { |
3173 if (!result) { | 3208 if (!result) { |
3174 console.log('Failed to remove file watch'); | 3209 console.log('Failed to remove file watch'); |
3175 } | 3210 } |
3176 }); | 3211 }); |
3177 } | 3212 } |
3178 }; | 3213 }; |
3179 | 3214 |
3180 FileManager.prototype.onFileChanged_ = function(event) { | 3215 FileManager.prototype.onFileChanged_ = function(event) { |
3181 // We receive a lot of events even in folders we are not interested in. | 3216 // We receive a lot of events even in folders we are not interested in. |
3182 if (event.fileUrl == this.currentDirEntry_.toURL()) | 3217 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.
| |
3183 this.rescanDirectoryLater_(); | 3218 this.rescanDirectoryLater_(); |
3184 }; | 3219 }; |
3185 | 3220 |
3186 /** | 3221 /** |
3187 * Determine whether or not a click should initiate a rename. | 3222 * Determine whether or not a click should initiate a rename. |
3188 * | 3223 * |
3189 * Renames can happen on mouse click if the user clicks on a label twice, | 3224 * Renames can happen on mouse click if the user clicks on a label twice, |
3190 * at least a half second apart. | 3225 * at least a half second apart. |
3191 */ | 3226 */ |
3192 FileManager.prototype.allowRenameClick_ = function(event, row) { | 3227 FileManager.prototype.allowRenameClick_ = function(event, row) { |
(...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3783 }); | 3818 }); |
3784 }, onError); | 3819 }, onError); |
3785 | 3820 |
3786 function onError(err) { | 3821 function onError(err) { |
3787 console.log('Error while checking free space: ' + err); | 3822 console.log('Error while checking free space: ' + err); |
3788 setTimeout(doCheck, 1000 * 60); | 3823 setTimeout(doCheck, 1000 * 60); |
3789 } | 3824 } |
3790 } | 3825 } |
3791 } | 3826 } |
3792 })(); | 3827 })(); |
OLD | NEW |