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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 (function() { | 160 (function() { |
161 | 161 |
162 // Private variables and helper functions. | 162 // Private variables and helper functions. |
163 | 163 |
164 /** | 164 /** |
165 * Unicode codepoint for 'BLACK RIGHT-POINTING SMALL TRIANGLE'. | 165 * Unicode codepoint for 'BLACK RIGHT-POINTING SMALL TRIANGLE'. |
166 */ | 166 */ |
167 const RIGHT_TRIANGLE = '\u25b8'; | 167 const RIGHT_TRIANGLE = '\u25b8'; |
168 | 168 |
169 /** | 169 /** |
170 * The DirectoryEntry.fullPath value of the Downloads directory. | |
171 */ | |
172 const DOWNLOADS_DIRECTORY = '/Downloads'; | |
173 | |
174 /** | |
175 * The DirectoryEntry.fullPath value of the directory containing externally | 170 * The DirectoryEntry.fullPath value of the directory containing externally |
176 * mounted removable storage volumes. | 171 * mounted removable storage volumes. |
177 */ | 172 */ |
178 const REMOVABLE_DIRECTORY = '/removable'; | 173 const REMOVABLE_DIRECTORY = '/removable'; |
179 | 174 |
180 /** | 175 /** |
181 * The DirectoryEntry.fullPath value of the directory containing externally | 176 * The DirectoryEntry.fullPath value of the directory containing externally |
182 * mounted archive file volumes. | 177 * mounted archive file volumes. |
183 */ | 178 */ |
184 const ARCHIVE_DIRECTORY = '/archive'; | 179 const ARCHIVE_DIRECTORY = '/archive'; |
185 | 180 |
186 /** | 181 /** |
| 182 * The DirectoryEntry.fullPath value of the downloads directory. |
| 183 */ |
| 184 const DOWNLOADS_DIRECTORY = '/Downloads'; |
| 185 |
| 186 /** |
| 187 * Height of the downloads folder warning, in px. |
| 188 */ |
| 189 const DOWNLOADS_WARNING_HEIGHT = '57px'; |
| 190 |
| 191 /** |
| 192 * Location of the FAQ about the downloads directory. |
| 193 */ |
| 194 const DOWNLOADS_FAQ_URL = 'http://www.google.com/support/chromeos/bin/' + |
| 195 'answer.py?hl=en&answer=1061547'; |
| 196 |
| 197 /** |
187 * Mnemonics for the second parameter of the changeDirectory method. | 198 * Mnemonics for the second parameter of the changeDirectory method. |
188 */ | 199 */ |
189 const CD_WITH_HISTORY = true; | 200 const CD_WITH_HISTORY = true; |
190 const CD_NO_HISTORY = false; | 201 const CD_NO_HISTORY = false; |
191 | 202 |
192 /** | 203 /** |
193 * Mnemonics for the recurse parameter of the copyFiles method. | 204 * Mnemonics for the recurse parameter of the copyFiles method. |
194 */ | 205 */ |
195 const CP_RECURSE = true; | 206 const CP_RECURSE = true; |
196 const CP_NO_RECURSE = false; | 207 const CP_NO_RECURSE = false; |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
559 this.previewSummary_ = this.dialogDom_.querySelector('.preview-summary'); | 570 this.previewSummary_ = this.dialogDom_.querySelector('.preview-summary'); |
560 this.previewMetadata_ = this.dialogDom_.querySelector('.preview-metadata'); | 571 this.previewMetadata_ = this.dialogDom_.querySelector('.preview-metadata'); |
561 this.filenameInput_ = this.dialogDom_.querySelector('.filename-input'); | 572 this.filenameInput_ = this.dialogDom_.querySelector('.filename-input'); |
562 this.taskButtons_ = this.dialogDom_.querySelector('.task-buttons'); | 573 this.taskButtons_ = this.dialogDom_.querySelector('.task-buttons'); |
563 this.okButton_ = this.dialogDom_.querySelector('.ok'); | 574 this.okButton_ = this.dialogDom_.querySelector('.ok'); |
564 this.cancelButton_ = this.dialogDom_.querySelector('.cancel'); | 575 this.cancelButton_ = this.dialogDom_.querySelector('.cancel'); |
565 this.newFolderButton_ = this.dialogDom_.querySelector('.new-folder'); | 576 this.newFolderButton_ = this.dialogDom_.querySelector('.new-folder'); |
566 this.copyButton_ = this.dialogDom_.querySelector('.clipboard-copy'); | 577 this.copyButton_ = this.dialogDom_.querySelector('.clipboard-copy'); |
567 this.pasteButton_ = this.dialogDom_.querySelector('.clipboard-paste'); | 578 this.pasteButton_ = this.dialogDom_.querySelector('.clipboard-paste'); |
568 | 579 |
| 580 this.downloadsWarning_ = |
| 581 this.dialogDom_.querySelector('.downloads-warning'); |
| 582 var html = util.htmlUnescape(strf('DOWNLOADS_DIRECTORY_WARNING', |
| 583 DOWNLOADS_FAQ_URL)); |
| 584 // TODO(rginda): Fix this string in the grd file to include the target |
| 585 // attribute, post R14. |
| 586 html = html.replace('<a href=', '<a target=new_ href='); |
| 587 this.downloadsWarning_.lastElementChild.innerHTML = html; |
| 588 |
569 this.document_.addEventListener('keydown', this.onKeyDown_.bind(this)); | 589 this.document_.addEventListener('keydown', this.onKeyDown_.bind(this)); |
570 | 590 |
571 this.descriptionTable_ = | 591 this.descriptionTable_ = |
572 this.dialogDom_.querySelector('.preview-metadata-table'); | 592 this.dialogDom_.querySelector('.preview-metadata-table'); |
573 | 593 |
574 this.renameInput_ = this.document_.createElement('input'); | 594 this.renameInput_ = this.document_.createElement('input'); |
575 this.renameInput_.className = 'rename'; | 595 this.renameInput_.className = 'rename'; |
576 | 596 |
577 this.renameInput_.addEventListener( | 597 this.renameInput_.addEventListener( |
578 'keydown', this.onRenameInputKeyDown_.bind(this)); | 598 'keydown', this.onRenameInputKeyDown_.bind(this)); |
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
999 } | 1019 } |
1000 }; | 1020 }; |
1001 | 1021 |
1002 /** | 1022 /** |
1003 * Respond to the back button. | 1023 * Respond to the back button. |
1004 */ | 1024 */ |
1005 FileManager.prototype.onPopState_ = function(event) { | 1025 FileManager.prototype.onPopState_ = function(event) { |
1006 this.changeDirectory(event.state, CD_NO_HISTORY); | 1026 this.changeDirectory(event.state, CD_NO_HISTORY); |
1007 }; | 1027 }; |
1008 | 1028 |
| 1029 FileManager.prototype.requestResize_ = function(timeout) { |
| 1030 var self = this; |
| 1031 setTimeout(function() { self.onResize_() }, timeout || 0); |
| 1032 }; |
| 1033 |
1009 /** | 1034 /** |
1010 * Resize details and thumb views to fit the new window size. | 1035 * Resize details and thumb views to fit the new window size. |
1011 */ | 1036 */ |
1012 FileManager.prototype.onResize_ = function() { | 1037 FileManager.prototype.onResize_ = function() { |
1013 this.table_.style.height = this.grid_.style.height = | 1038 this.table_.style.height = this.grid_.style.height = |
1014 this.grid_.parentNode.clientHeight + 'px'; | 1039 this.grid_.parentNode.clientHeight + 'px'; |
1015 this.table_.style.width = this.grid_.style.width = | 1040 this.table_.style.width = this.grid_.style.width = |
1016 this.grid_.parentNode.clientWidth + 'px'; | 1041 this.grid_.parentNode.clientWidth + 'px'; |
1017 | 1042 |
1018 this.table_.list_.style.width = this.table_.parentNode.clientWidth + 'px'; | 1043 this.table_.list_.style.width = this.table_.parentNode.clientWidth + 'px'; |
(...skipping 1321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2340 * | 2365 * |
2341 * @param {cr.Event} event The directory-changed event. | 2366 * @param {cr.Event} event The directory-changed event. |
2342 */ | 2367 */ |
2343 FileManager.prototype.onDirectoryChanged_ = function(event) { | 2368 FileManager.prototype.onDirectoryChanged_ = function(event) { |
2344 if (event.saveHistory) { | 2369 if (event.saveHistory) { |
2345 history.pushState(this.currentDirEntry_.fullPath, | 2370 history.pushState(this.currentDirEntry_.fullPath, |
2346 this.currentDirEntry_.fullPath, | 2371 this.currentDirEntry_.fullPath, |
2347 location.href); | 2372 location.href); |
2348 } | 2373 } |
2349 | 2374 |
| 2375 if (this.currentDirEntry_.fullPath.substr(0, DOWNLOADS_DIRECTORY.length) == |
| 2376 DOWNLOADS_DIRECTORY) { |
| 2377 if (this.downloadsWarning_.style.height != DOWNLOADS_WARNING_HEIGHT) { |
| 2378 // Current path starts with DOWNLOADS_DIRECTORY, show the warning. |
| 2379 this.downloadsWarning_.style.height = DOWNLOADS_WARNING_HEIGHT; |
| 2380 this.requestResize_(100); |
| 2381 } |
| 2382 } else { |
| 2383 if (this.downloadsWarning_.style.height != '0') { |
| 2384 this.downloadsWarning_.style.height = '0'; |
| 2385 this.requestResize_(100); |
| 2386 } |
| 2387 } |
| 2388 |
2350 this.updateCommands_(); | 2389 this.updateCommands_(); |
2351 this.updateOkButton_(); | 2390 this.updateOkButton_(); |
2352 | 2391 |
2353 // New folder should never be enabled in the root or media/ directories. | 2392 // New folder should never be enabled in the root or media/ directories. |
2354 this.newFolderButton_.disabled = isSystemDirEntry(this.currentDirEntry_); | 2393 this.newFolderButton_.disabled = isSystemDirEntry(this.currentDirEntry_); |
2355 | 2394 |
2356 this.document_.title = this.currentDirEntry_.fullPath; | 2395 this.document_.title = this.currentDirEntry_.fullPath; |
2357 | 2396 |
2358 var self = this; | 2397 var self = this; |
2359 this.rescanDirectory_(function() { | 2398 this.rescanDirectory_(function() { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2401 | 2440 |
2402 // Splice takes the to-be-spliced-in array as individual parameters, | 2441 // Splice takes the to-be-spliced-in array as individual parameters, |
2403 // rather than as an array, so we need to perform some acrobatics... | 2442 // rather than as an array, so we need to perform some acrobatics... |
2404 var spliceArgs = [].slice.call(entries); | 2443 var spliceArgs = [].slice.call(entries); |
2405 | 2444 |
2406 // Hide files that start with a dot ('.'). | 2445 // Hide files that start with a dot ('.'). |
2407 // TODO(rginda): User should be able to override this. Support for other | 2446 // TODO(rginda): User should be able to override this. Support for other |
2408 // commonly hidden patterns might be nice too. | 2447 // commonly hidden patterns might be nice too. |
2409 if (self.filterFiles_) { | 2448 if (self.filterFiles_) { |
2410 spliceArgs = spliceArgs.filter(function(e) { | 2449 spliceArgs = spliceArgs.filter(function(e) { |
2411 return e.name.substr(0, 1) != '.'; | 2450 return e.name.substr(0, 1) != '.'; |
2412 }); | 2451 }); |
2413 } | 2452 } |
2414 | 2453 |
2415 spliceArgs.unshift(0, 0); // index, deleteCount | 2454 spliceArgs.unshift(0, 0); // index, deleteCount |
2416 self.dataModel_.splice.apply(self.dataModel_, spliceArgs); | 2455 self.dataModel_.splice.apply(self.dataModel_, spliceArgs); |
2417 | 2456 |
2418 // Keep reading until entries.length is 0. | 2457 // Keep reading until entries.length is 0. |
2419 reader.readEntries(onReadSome); | 2458 reader.readEntries(onReadSome); |
2420 }; | 2459 }; |
2421 | 2460 |
2422 // Updated when a user clicks on the label of a file, used to detect | 2461 // Updated when a user clicks on the label of a file, used to detect |
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3006 | 3045 |
3007 if (msg) { | 3046 if (msg) { |
3008 console.log('no no no'); | 3047 console.log('no no no'); |
3009 this.alert.show(msg, onAccept); | 3048 this.alert.show(msg, onAccept); |
3010 return false; | 3049 return false; |
3011 } | 3050 } |
3012 | 3051 |
3013 return true; | 3052 return true; |
3014 }; | 3053 }; |
3015 })(); | 3054 })(); |
OLD | NEW |