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 1809 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1820 * | 1820 * |
1821 * Invoked by cr.ui.Table when a file needs to be rendered. | 1821 * Invoked by cr.ui.Table when a file needs to be rendered. |
1822 * | 1822 * |
1823 * @param {Entry} entry The Entry object to render. | 1823 * @param {Entry} entry The Entry object to render. |
1824 * @param {string} columnId The id of the column to be rendered. | 1824 * @param {string} columnId The id of the column to be rendered. |
1825 * @param {cr.ui.Table} table The table doing the rendering. | 1825 * @param {cr.ui.Table} table The table doing the rendering. |
1826 */ | 1826 */ |
1827 FileManager.prototype.renderIconType_ = function(entry, columnId, table) { | 1827 FileManager.prototype.renderIconType_ = function(entry, columnId, table) { |
1828 var icon = this.document_.createElement('div'); | 1828 var icon = this.document_.createElement('div'); |
1829 icon.className = 'detail-icon'; | 1829 icon.className = 'detail-icon'; |
1830 icon.setAttribute('iconType', FileType.getIcon(entry)); | 1830 icon.setAttribute('file-type-icon', FileType.getIcon(entry)); |
1831 return icon; | 1831 return icon; |
1832 }; | 1832 }; |
1833 | 1833 |
1834 /** | 1834 /** |
1835 * Return the localized name for the root. | 1835 * Return the localized name for the root. |
1836 * @param {string} path The full path of the root (starting with slash). | 1836 * @param {string} path The full path of the root (starting with slash). |
1837 * @return {string} The localized name. | 1837 * @return {string} The localized name. |
1838 */ | 1838 */ |
1839 FileManager.prototype.getRootLabel_ = function(path) { | 1839 FileManager.prototype.getRootLabel_ = function(path) { |
1840 if (path === RootDirectory.DOWNLOADS) | 1840 if (path === RootDirectory.DOWNLOADS) |
(...skipping 25 matching lines...) Expand all Loading... |
1866 } | 1866 } |
1867 }; | 1867 }; |
1868 li.addEventListener('mousedown', handleClick); | 1868 li.addEventListener('mousedown', handleClick); |
1869 li.addEventListener(cr.ui.TouchHandler.EventType.TOUCH_START, handleClick); | 1869 li.addEventListener(cr.ui.TouchHandler.EventType.TOUCH_START, handleClick); |
1870 | 1870 |
1871 var rootType = PathUtil.getRootType(path); | 1871 var rootType = PathUtil.getRootType(path); |
1872 | 1872 |
1873 var div = this.document_.createElement('div'); | 1873 var div = this.document_.createElement('div'); |
1874 div.className = 'root-label'; | 1874 div.className = 'root-label'; |
1875 | 1875 |
1876 div.setAttribute('type', rootType); | 1876 div.setAttribute('volume-type-icon', rootType); |
1877 if (rootType === RootType.REMOVABLE) | 1877 if (rootType === RootType.REMOVABLE) |
1878 div.setAttribute('subType', this.volumeManager_.getDeviceType(path)); | 1878 div.setAttribute('volume-subtype', |
| 1879 this.volumeManager_.getDeviceType(path)); |
1879 | 1880 |
1880 div.textContent = this.getRootLabel_(path); | 1881 div.textContent = this.getRootLabel_(path); |
1881 li.appendChild(div); | 1882 li.appendChild(div); |
1882 | 1883 |
1883 if (rootType === RootType.ARCHIVE || rootType === RootType.REMOVABLE) { | 1884 if (rootType === RootType.ARCHIVE || rootType === RootType.REMOVABLE) { |
1884 var eject = this.document_.createElement('div'); | 1885 var eject = this.document_.createElement('div'); |
1885 eject.className = 'root-eject'; | 1886 eject.className = 'root-eject'; |
1886 eject.addEventListener('click', function(event) { | 1887 eject.addEventListener('click', function(event) { |
1887 event.stopPropagation(); | 1888 event.stopPropagation(); |
1888 this.unmountVolume_(path); | 1889 this.unmountVolume_(path); |
1889 }.bind(this)); | 1890 }.bind(this)); |
1890 // Block other mouse handlers. | 1891 // Block other mouse handlers. |
1891 eject.addEventListener('mouseup', function(e) { e.stopPropagation() }); | 1892 eject.addEventListener('mouseup', function(e) { e.stopPropagation() }); |
1892 eject.addEventListener('mousedown', function(e) { e.stopPropagation() }); | 1893 eject.addEventListener('mousedown', function(e) { e.stopPropagation() }); |
1893 li.appendChild(eject); | 1894 li.appendChild(eject); |
1894 | 1895 |
1895 cr.ui.contextMenuHandler.setContextMenu(li, this.rootsContextMenu_); | 1896 cr.ui.contextMenuHandler.setContextMenu(li, this.rootsContextMenu_); |
1896 } | 1897 } |
1897 | 1898 |
1898 cr.defineProperty(li, 'lead', cr.PropertyKind.BOOL_ATTR); | 1899 cr.defineProperty(li, 'lead', cr.PropertyKind.BOOL_ATTR); |
1899 cr.defineProperty(li, 'selected', cr.PropertyKind.BOOL_ATTR); | 1900 cr.defineProperty(li, 'selected', cr.PropertyKind.BOOL_ATTR); |
1900 | 1901 |
1901 var icon = rootType; | |
1902 if (this.volumeManager_.isUnreadable(path)) { | |
1903 icon = 'unreadable'; | |
1904 } | |
1905 div.setAttribute('icon', icon); | |
1906 | |
1907 return li; | 1902 return li; |
1908 }; | 1903 }; |
1909 | 1904 |
1910 /** | 1905 /** |
1911 * Unmounts device. | 1906 * Unmounts device. |
1912 * @param {string} path Path to a volume to unmount. | 1907 * @param {string} path Path to a volume to unmount. |
1913 */ | 1908 */ |
1914 FileManager.prototype.unmountVolume_ = function(path) { | 1909 FileManager.prototype.unmountVolume_ = function(path) { |
1915 listItem = this.rootsList_.getItemByIndex( | 1910 listItem = this.rootsList_.getItemByIndex( |
1916 this.directoryModel_.findRootsListIndex(path)); | 1911 this.directoryModel_.findRootsListIndex(path)); |
(...skipping 1246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3163 * Show or hide the "Low disk space" warning. | 3158 * Show or hide the "Low disk space" warning. |
3164 * @param {boolean} show True if the box need to be shown. | 3159 * @param {boolean} show True if the box need to be shown. |
3165 */ | 3160 */ |
3166 FileManager.prototype.showLowDiskSpaceWarning_ = function(show) { | 3161 FileManager.prototype.showLowDiskSpaceWarning_ = function(show) { |
3167 var box = this.dialogDom_.querySelector('.downloads-warning'); | 3162 var box = this.dialogDom_.querySelector('.downloads-warning'); |
3168 | 3163 |
3169 if (box.hidden == !show) return; | 3164 if (box.hidden == !show) return; |
3170 | 3165 |
3171 if (show) { | 3166 if (show) { |
3172 var html = util.htmlUnescape(str('DOWNLOADS_DIRECTORY_WARNING')); | 3167 var html = util.htmlUnescape(str('DOWNLOADS_DIRECTORY_WARNING')); |
3173 box.lastElementChild.innerHTML = html; | 3168 box.innerHTML = html; |
3174 var link = box.querySelector('a'); | 3169 var link = box.querySelector('a'); |
3175 link.addEventListener('click', | 3170 link.addEventListener('click', |
3176 this.onExternalLinkClick_.bind(this, DOWNLOADS_FAQ_URL)); | 3171 this.onExternalLinkClick_.bind(this, DOWNLOADS_FAQ_URL)); |
3177 } else { | 3172 } else { |
3178 box.lastElementChild.innerHTML = ''; | 3173 box.innerHTML = ''; |
3179 } | 3174 } |
3180 | 3175 |
3181 box.hidden = !show; | 3176 box.hidden = !show; |
3182 this.requestResize_(100); | 3177 this.requestResize_(100); |
3183 }; | 3178 }; |
3184 | 3179 |
3185 /** | 3180 /** |
3186 * Update the location in the address bar. | 3181 * Update the location in the address bar. |
3187 * | 3182 * |
3188 * @param {boolean} replace True if the history state should be replaced, | 3183 * @param {boolean} replace True if the history state should be replaced, |
(...skipping 1092 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4281 this.defaultActionMenuItem_.taskId = taskItem.taskId; | 4276 this.defaultActionMenuItem_.taskId = taskItem.taskId; |
4282 } | 4277 } |
4283 | 4278 |
4284 var defaultActionSeparator = | 4279 var defaultActionSeparator = |
4285 this.dialogDom_.querySelector('#default-action-separator'); | 4280 this.dialogDom_.querySelector('#default-action-separator'); |
4286 | 4281 |
4287 this.defaultActionMenuItem_.hidden = !taskItem; | 4282 this.defaultActionMenuItem_.hidden = !taskItem; |
4288 defaultActionSeparator.hidden = !taskItem; | 4283 defaultActionSeparator.hidden = !taskItem; |
4289 } | 4284 } |
4290 })(); | 4285 })(); |
OLD | NEW |