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 1802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1813 * | 1813 * |
1814 * Invoked by cr.ui.Table when a file needs to be rendered. | 1814 * Invoked by cr.ui.Table when a file needs to be rendered. |
1815 * | 1815 * |
1816 * @param {Entry} entry The Entry object to render. | 1816 * @param {Entry} entry The Entry object to render. |
1817 * @param {string} columnId The id of the column to be rendered. | 1817 * @param {string} columnId The id of the column to be rendered. |
1818 * @param {cr.ui.Table} table The table doing the rendering. | 1818 * @param {cr.ui.Table} table The table doing the rendering. |
1819 */ | 1819 */ |
1820 FileManager.prototype.renderIconType_ = function(entry, columnId, table) { | 1820 FileManager.prototype.renderIconType_ = function(entry, columnId, table) { |
1821 var icon = this.document_.createElement('div'); | 1821 var icon = this.document_.createElement('div'); |
1822 icon.className = 'detail-icon'; | 1822 icon.className = 'detail-icon'; |
1823 icon.setAttribute('iconType', FileType.getIcon(entry)); | 1823 icon.setAttribute('file-type-icon', FileType.getIcon(entry)); |
1824 return icon; | 1824 return icon; |
1825 }; | 1825 }; |
1826 | 1826 |
1827 /** | 1827 /** |
1828 * Return the localized name for the root. | 1828 * Return the localized name for the root. |
1829 * @param {string} path The full path of the root (starting with slash). | 1829 * @param {string} path The full path of the root (starting with slash). |
1830 * @return {string} The localized name. | 1830 * @return {string} The localized name. |
1831 */ | 1831 */ |
1832 FileManager.prototype.getRootLabel_ = function(path) { | 1832 FileManager.prototype.getRootLabel_ = function(path) { |
1833 if (path === RootDirectory.DOWNLOADS) | 1833 if (path === RootDirectory.DOWNLOADS) |
(...skipping 25 matching lines...) Expand all Loading... |
1859 } | 1859 } |
1860 }; | 1860 }; |
1861 li.addEventListener('mousedown', handleClick); | 1861 li.addEventListener('mousedown', handleClick); |
1862 li.addEventListener(cr.ui.TouchHandler.EventType.TOUCH_START, handleClick); | 1862 li.addEventListener(cr.ui.TouchHandler.EventType.TOUCH_START, handleClick); |
1863 | 1863 |
1864 var rootType = PathUtil.getRootType(path); | 1864 var rootType = PathUtil.getRootType(path); |
1865 | 1865 |
1866 var div = this.document_.createElement('div'); | 1866 var div = this.document_.createElement('div'); |
1867 div.className = 'root-label'; | 1867 div.className = 'root-label'; |
1868 | 1868 |
1869 div.setAttribute('type', rootType); | 1869 div.setAttribute('volume-type-icon', rootType); |
1870 if (rootType === RootType.REMOVABLE) | 1870 if (rootType === RootType.REMOVABLE) |
1871 div.setAttribute('subType', this.volumeManager_.getDeviceType(path)); | 1871 div.setAttribute('volume-subtype', |
| 1872 this.volumeManager_.getDeviceType(path)); |
1872 | 1873 |
1873 div.textContent = this.getRootLabel_(path); | 1874 div.textContent = this.getRootLabel_(path); |
1874 li.appendChild(div); | 1875 li.appendChild(div); |
1875 | 1876 |
1876 if (rootType === RootType.ARCHIVE || rootType === RootType.REMOVABLE) { | 1877 if (rootType === RootType.ARCHIVE || rootType === RootType.REMOVABLE) { |
1877 var eject = this.document_.createElement('div'); | 1878 var eject = this.document_.createElement('div'); |
1878 eject.className = 'root-eject'; | 1879 eject.className = 'root-eject'; |
1879 eject.addEventListener('click', function(event) { | 1880 eject.addEventListener('click', function(event) { |
1880 event.stopPropagation(); | 1881 event.stopPropagation(); |
1881 this.unmountVolume_(path); | 1882 this.unmountVolume_(path); |
1882 }.bind(this)); | 1883 }.bind(this)); |
1883 // Block other mouse handlers. | 1884 // Block other mouse handlers. |
1884 eject.addEventListener('mouseup', function(e) { e.stopPropagation() }); | 1885 eject.addEventListener('mouseup', function(e) { e.stopPropagation() }); |
1885 eject.addEventListener('mousedown', function(e) { e.stopPropagation() }); | 1886 eject.addEventListener('mousedown', function(e) { e.stopPropagation() }); |
1886 li.appendChild(eject); | 1887 li.appendChild(eject); |
1887 | 1888 |
1888 cr.ui.contextMenuHandler.setContextMenu(li, this.rootsContextMenu_); | 1889 cr.ui.contextMenuHandler.setContextMenu(li, this.rootsContextMenu_); |
1889 } | 1890 } |
1890 | 1891 |
1891 cr.defineProperty(li, 'lead', cr.PropertyKind.BOOL_ATTR); | 1892 cr.defineProperty(li, 'lead', cr.PropertyKind.BOOL_ATTR); |
1892 cr.defineProperty(li, 'selected', cr.PropertyKind.BOOL_ATTR); | 1893 cr.defineProperty(li, 'selected', cr.PropertyKind.BOOL_ATTR); |
1893 | 1894 |
1894 var icon = rootType; | |
1895 if (this.volumeManager_.isUnreadable(path)) { | |
1896 icon = 'unreadable'; | |
1897 } | |
1898 div.setAttribute('icon', icon); | |
1899 | |
1900 return li; | 1895 return li; |
1901 }; | 1896 }; |
1902 | 1897 |
1903 /** | 1898 /** |
1904 * Unmounts device. | 1899 * Unmounts device. |
1905 * @param {string} path Path to a volume to unmount. | 1900 * @param {string} path Path to a volume to unmount. |
1906 */ | 1901 */ |
1907 FileManager.prototype.unmountVolume_ = function(path) { | 1902 FileManager.prototype.unmountVolume_ = function(path) { |
1908 listItem = this.rootsList_.getItemByIndex( | 1903 listItem = this.rootsList_.getItemByIndex( |
1909 this.directoryModel_.findRootsListIndex(path)); | 1904 this.directoryModel_.findRootsListIndex(path)); |
(...skipping 1241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3151 * Show or hide the "Low disk space" warning. | 3146 * Show or hide the "Low disk space" warning. |
3152 * @param {boolean} show True if the box need to be shown. | 3147 * @param {boolean} show True if the box need to be shown. |
3153 */ | 3148 */ |
3154 FileManager.prototype.showLowDiskSpaceWarning_ = function(show) { | 3149 FileManager.prototype.showLowDiskSpaceWarning_ = function(show) { |
3155 var box = this.dialogDom_.querySelector('.downloads-warning'); | 3150 var box = this.dialogDom_.querySelector('.downloads-warning'); |
3156 | 3151 |
3157 if (box.hidden == !show) return; | 3152 if (box.hidden == !show) return; |
3158 | 3153 |
3159 if (show) { | 3154 if (show) { |
3160 var html = util.htmlUnescape(str('DOWNLOADS_DIRECTORY_WARNING')); | 3155 var html = util.htmlUnescape(str('DOWNLOADS_DIRECTORY_WARNING')); |
3161 box.lastElementChild.innerHTML = html; | 3156 box.innerHTML = html; |
3162 var link = box.querySelector('a'); | 3157 var link = box.querySelector('a'); |
3163 link.addEventListener('click', | 3158 link.addEventListener('click', |
3164 this.onExternalLinkClick_.bind(this, DOWNLOADS_FAQ_URL)); | 3159 this.onExternalLinkClick_.bind(this, DOWNLOADS_FAQ_URL)); |
3165 } else { | 3160 } else { |
3166 box.lastElementChild.innerHTML = ''; | 3161 box.innerHTML = ''; |
3167 } | 3162 } |
3168 | 3163 |
3169 box.hidden = !show; | 3164 box.hidden = !show; |
3170 this.requestResize_(100); | 3165 this.requestResize_(100); |
3171 }; | 3166 }; |
3172 | 3167 |
3173 /** | 3168 /** |
3174 * Update the location in the address bar. | 3169 * Update the location in the address bar. |
3175 * | 3170 * |
3176 * @param {boolean} replace True if the history state should be replaced, | 3171 * @param {boolean} replace True if the history state should be replaced, |
(...skipping 1073 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4250 this.gdataSpaceInfoBar_.style.width = | 4245 this.gdataSpaceInfoBar_.style.width = |
4251 (100 * usedSpace / result.totalSizeKB) + '%'; | 4246 (100 * usedSpace / result.totalSizeKB) + '%'; |
4252 } else { | 4247 } else { |
4253 this.gdataSpaceInfoBar_.style.display = 'none'; | 4248 this.gdataSpaceInfoBar_.style.display = 'none'; |
4254 this.gdataSpaceInfoLabel_.textContent = | 4249 this.gdataSpaceInfoLabel_.textContent = |
4255 str('GDATA_FAILED_SPACE_INFO'); | 4250 str('GDATA_FAILED_SPACE_INFO'); |
4256 } | 4251 } |
4257 }.bind(this)); | 4252 }.bind(this)); |
4258 } | 4253 } |
4259 })(); | 4254 })(); |
OLD | NEW |