OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 /** | 5 /** |
6 * FileManager constructor. | 6 * FileManager constructor. |
7 * | 7 * |
8 * FileManager objects encapsulate the functionality of the file selector | 8 * FileManager objects encapsulate the functionality of the file selector |
9 * dialogs, as well as the full screen file manager application (though the | 9 * dialogs, as well as the full screen file manager application (though the |
10 * latter is not yet implemented). | 10 * latter is not yet implemented). |
(...skipping 1041 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1052 */ | 1052 */ |
1053 FileManager.prototype.initGrid_ = function() { | 1053 FileManager.prototype.initGrid_ = function() { |
1054 var self = this; | 1054 var self = this; |
1055 this.grid_.itemConstructor = | 1055 this.grid_.itemConstructor = |
1056 GridItem.bind(null, this, this.showCheckboxes_); | 1056 GridItem.bind(null, this, this.showCheckboxes_); |
1057 // TODO(bshe): should override cr.ui.List's activateItemAtIndex function | 1057 // TODO(bshe): should override cr.ui.List's activateItemAtIndex function |
1058 // rather than listen explicitly for double click or tap events. | 1058 // rather than listen explicitly for double click or tap events. |
1059 this.grid_.addEventListener( | 1059 this.grid_.addEventListener( |
1060 'dblclick', this.onDetailDoubleClickOrTap_.bind(this)); | 1060 'dblclick', this.onDetailDoubleClickOrTap_.bind(this)); |
1061 this.grid_.addEventListener( | 1061 this.grid_.addEventListener( |
1062 'click', this.onDetailClick_.bind(this)); | |
1063 this.grid_.addEventListener( | |
1062 cr.ui.TouchHandler.EventType.TAP, | 1064 cr.ui.TouchHandler.EventType.TAP, |
1063 this.onDetailDoubleClickOrTap_.bind(this)); | 1065 this.onDetailDoubleClickOrTap_.bind(this)); |
1064 cr.ui.contextMenuHandler.setContextMenu(this.grid_, this.fileContextMenu_); | 1066 cr.ui.contextMenuHandler.setContextMenu(this.grid_, this.fileContextMenu_); |
1065 }; | 1067 }; |
1066 | 1068 |
1067 /** | 1069 /** |
1068 * Initialize the file list table. | 1070 * Initialize the file list table. |
1069 */ | 1071 */ |
1070 FileManager.prototype.initTable_ = function() { | 1072 FileManager.prototype.initTable_ = function() { |
1071 var renderFunction = this.table_.getRenderFunction(); | 1073 var renderFunction = this.table_.getRenderFunction(); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1114 } else { | 1116 } else { |
1115 this.gdataColumnModel_ = null; | 1117 this.gdataColumnModel_ = null; |
1116 } | 1118 } |
1117 | 1119 |
1118 // TODO(bshe): should override cr.ui.List's activateItemAtIndex function | 1120 // TODO(bshe): should override cr.ui.List's activateItemAtIndex function |
1119 // rather than listen explicitly for double click or tap events. | 1121 // rather than listen explicitly for double click or tap events. |
1120 // Don't pay attention to double clicks on the table header. | 1122 // Don't pay attention to double clicks on the table header. |
1121 this.table_.list.addEventListener( | 1123 this.table_.list.addEventListener( |
1122 'dblclick', this.onDetailDoubleClickOrTap_.bind(this)); | 1124 'dblclick', this.onDetailDoubleClickOrTap_.bind(this)); |
1123 this.table_.list.addEventListener( | 1125 this.table_.list.addEventListener( |
1126 'click', this.onDetailClick_.bind(this)); | |
1127 this.table_.list.addEventListener( | |
1124 cr.ui.TouchHandler.EventType.TAP, | 1128 cr.ui.TouchHandler.EventType.TAP, |
1125 this.onDetailDoubleClickOrTap_.bind(this)); | 1129 this.onDetailDoubleClickOrTap_.bind(this)); |
1126 | 1130 |
1127 cr.ui.contextMenuHandler.setContextMenu(this.table_.querySelector('.list'), | 1131 cr.ui.contextMenuHandler.setContextMenu(this.table_.querySelector('.list'), |
1128 this.fileContextMenu_); | 1132 this.fileContextMenu_); |
1129 }; | 1133 }; |
1130 | 1134 |
1131 FileManager.prototype.onCopyProgress_ = function(event) { | 1135 FileManager.prototype.onCopyProgress_ = function(event) { |
1132 if (event.reason === 'ERROR' && | 1136 if (event.reason === 'ERROR' && |
1133 event.error.reason === 'FILESYSTEM_ERROR' && | 1137 event.error.reason === 'FILESYSTEM_ERROR' && |
(...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1819 }; | 1823 }; |
1820 | 1824 |
1821 /** | 1825 /** |
1822 * Render filename label for grid and list view. | 1826 * Render filename label for grid and list view. |
1823 * @param {Entry} entry The Entry object to render. | 1827 * @param {Entry} entry The Entry object to render. |
1824 * @return {HTMLDivElement} The label. | 1828 * @return {HTMLDivElement} The label. |
1825 */ | 1829 */ |
1826 FileManager.prototype.renderFileNameLabel_ = function(entry) { | 1830 FileManager.prototype.renderFileNameLabel_ = function(entry) { |
1827 // Filename need to be in a '.filename-label' container for correct | 1831 // Filename need to be in a '.filename-label' container for correct |
1828 // work of inplace renaming. | 1832 // work of inplace renaming. |
1829 var fileName = this.document_.createElement('div'); | 1833 var box = this.document_.createElement('div'); |
1830 fileName.className = 'filename-label'; | 1834 box.className = 'filename-label'; |
1835 var fileName = this.document_.createElement('span'); | |
1831 fileName.textContent = entry.name; | 1836 fileName.textContent = entry.name; |
1837 box.appendChild(fileName); | |
1832 | 1838 |
1833 return fileName; | 1839 return box; |
1834 }; | 1840 }; |
1835 | 1841 |
1836 /** | 1842 /** |
1837 * Render the Size column of the detail table. | 1843 * Render the Size column of the detail table. |
1838 * | 1844 * |
1839 * @param {Entry} entry The Entry object to render. | 1845 * @param {Entry} entry The Entry object to render. |
1840 * @param {string} columnId The id of the column to be rendered. | 1846 * @param {string} columnId The id of the column to be rendered. |
1841 * @param {cr.ui.Table} table The table doing the rendering. | 1847 * @param {cr.ui.Table} table The table doing the rendering. |
1842 */ | 1848 */ |
1843 FileManager.prototype.renderSize_ = function(entry, columnId, table) { | 1849 FileManager.prototype.renderSize_ = function(entry, columnId, table) { |
(...skipping 1002 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2846 } | 2852 } |
2847 var entry = this.selection.entries[0]; | 2853 var entry = this.selection.entries[0]; |
2848 | 2854 |
2849 if (entry.isDirectory) { | 2855 if (entry.isDirectory) { |
2850 return this.onDirectoryAction(entry); | 2856 return this.onDirectoryAction(entry); |
2851 } | 2857 } |
2852 | 2858 |
2853 this.dispatchSelectionAction_(); | 2859 this.dispatchSelectionAction_(); |
2854 }; | 2860 }; |
2855 | 2861 |
2862 /** | |
2863 * Handles mouse click or tap. Simulates double click if click happens | |
2864 * on the file name or the icon. | |
2865 * @param {Event} event The click event. | |
2866 */ | |
2867 FileManager.prototype.onDetailClick_ = function(event) { | |
2868 if (this.isRenamingInProgress()) { | |
2869 // Don't pay attention to clicks during a rename. | |
2870 return; | |
2871 } | |
2872 | |
2873 if (event.target.parentElement.classList.contains('filename-label') || | |
Dmitry Zvorygin
2012/08/03 18:03:40
I don't like this hacky code with a lot of 'or-ed'
| |
2874 event.target.classList.contains('detail-icon') || | |
2875 event.target.classList.contains('img-container')) { | |
2876 this.onDetailDoubleClickOrTap_(event); | |
2877 event.stopPropagation(); | |
2878 event.preventDefault(); | |
2879 } | |
2880 }; | |
2881 | |
2856 FileManager.prototype.dispatchSelectionAction_ = function() { | 2882 FileManager.prototype.dispatchSelectionAction_ = function() { |
2857 if (this.dialogType_ == FileManager.DialogType.FULL_PAGE) { | 2883 if (this.dialogType_ == FileManager.DialogType.FULL_PAGE) { |
2858 if (this.selection.tasks) | 2884 if (this.selection.tasks) |
2859 this.selection.tasks.executeDefault(); | 2885 this.selection.tasks.executeDefault(); |
2860 return true; | 2886 return true; |
2861 } | 2887 } |
2862 if (!this.okButton_.disabled) { | 2888 if (!this.okButton_.disabled) { |
2863 this.onOk_(); | 2889 this.onOk_(); |
2864 return true; | 2890 return true; |
2865 } | 2891 } |
(...skipping 1186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4052 } | 4078 } |
4053 | 4079 |
4054 var defaultActionSeparator = | 4080 var defaultActionSeparator = |
4055 this.dialogDom_.querySelector('#default-action-separator'); | 4081 this.dialogDom_.querySelector('#default-action-separator'); |
4056 | 4082 |
4057 this.defaultActionMenuItem_.hidden = !taskItem; | 4083 this.defaultActionMenuItem_.hidden = !taskItem; |
4058 defaultActionSeparator.hidden = !taskItem; | 4084 defaultActionSeparator.hidden = !taskItem; |
4059 } | 4085 } |
4060 })(); | 4086 })(); |
4061 | 4087 |
OLD | NEW |