Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(97)

Side by Side Diff: chrome/browser/resources/file_manager/js/file_manager.js

Issue 6899003: FileManager: assorted fixes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 // TODO(rginda): Remove this and related code after zel's file scheme fix lands. 5 // TODO(rginda): Remove this and related code after zel's file scheme fix lands.
6 const ENABLE_EXIF_READER = false; 6 const ENABLE_EXIF_READER = false;
7 7
8 // TODO(rginda): Remove this when the thumbnail view is less janky. 8 // TODO(rginda): Remove this when the thumbnail view is less janky.
9 const ENABLE_THUMBNAIL_VIEW = false; 9 const ENABLE_THUMBNAIL_VIEW = false;
10 10
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 452
453 this.dataModel_ = new cr.ui.table.TableDataModel([]); 453 this.dataModel_ = new cr.ui.table.TableDataModel([]);
454 this.dataModel_.sort('name'); 454 this.dataModel_.sort('name');
455 this.dataModel_.addEventListener('sorted', 455 this.dataModel_.addEventListener('sorted',
456 this.onDataModelSorted_.bind(this)); 456 this.onDataModelSorted_.bind(this));
457 this.dataModel_.prepareSort = this.prepareSort_.bind(this); 457 this.dataModel_.prepareSort = this.prepareSort_.bind(this);
458 458
459 if (this.dialogType_ == FileManager.DialogType.SELECT_OPEN_FILE || 459 if (this.dialogType_ == FileManager.DialogType.SELECT_OPEN_FILE ||
460 this.dialogType_ == FileManager.DialogType.SELECT_OPEN_FOLDER || 460 this.dialogType_ == FileManager.DialogType.SELECT_OPEN_FOLDER ||
461 this.dialogType_ == FileManager.DialogType.SELECT_SAVEAS_FILE) { 461 this.dialogType_ == FileManager.DialogType.SELECT_SAVEAS_FILE) {
462 this.selectionModel_ = new cr.ui.table.TableSingleSelectionModel(); 462 this.selectionModelClass_ = cr.ui.table.TableSingleSelectionModel;
463 } else { 463 } else {
464 this.selectionModel_ = new cr.ui.table.TableSelectionModel(); 464 this.selectionModelClass_ = cr.ui.table.TableSelectionModel;
465 } 465 }
466 466
467 this.initTable_(); 467 this.initTable_();
468 this.initGrid_(); 468 this.initGrid_();
469 469
470 this.setListType(FileManager.ListType.DETAIL); 470 this.setListType(FileManager.ListType.DETAIL);
471 471
472 this.onResize_(); 472 this.onResize_();
473 this.dialogDom_.style.opacity = '1'; 473 this.dialogDom_.style.opacity = '1';
474 }; 474 };
(...skipping 24 matching lines...) Expand all
499 this.currentList_.redraw(); 499 this.currentList_.redraw();
500 }; 500 };
501 501
502 /** 502 /**
503 * Initialize the file thumbnail grid. 503 * Initialize the file thumbnail grid.
504 */ 504 */
505 FileManager.prototype.initGrid_ = function() { 505 FileManager.prototype.initGrid_ = function() {
506 this.grid_ = this.dialogDom_.querySelector('.thumbnail-grid'); 506 this.grid_ = this.dialogDom_.querySelector('.thumbnail-grid');
507 cr.ui.Grid.decorate(this.grid_); 507 cr.ui.Grid.decorate(this.grid_);
508 this.grid_.dataModel = this.dataModel_; 508 this.grid_.dataModel = this.dataModel_;
509 this.grid_.selectionModel = this.selectionModel_; 509 this.grid_.selectionModel = new this.selectionModelClass_();
510 510
511 var self = this; 511 var self = this;
512 this.grid_.itemConstructor = function(entry) { 512 this.grid_.itemConstructor = function(entry) {
513 return self.renderThumbnail_(entry); 513 return self.renderThumbnail_(entry);
514 }; 514 };
515 515
516 this.grid_.addEventListener( 516 this.grid_.addEventListener(
517 'dblclick', this.onDetailDoubleClick_.bind(this)); 517 'dblclick', this.onDetailDoubleClick_.bind(this));
518 this.grid_.selectionModel.addEventListener( 518 this.grid_.selectionModel.addEventListener(
519 'change', this.onDetailSelectionChanged_.bind(this)); 519 'change', this.onDetailSelectionChanged_.bind(this));
(...skipping 14 matching lines...) Expand all
534 534
535 columns[0].renderFunction = this.renderIconType_.bind(this); 535 columns[0].renderFunction = this.renderIconType_.bind(this);
536 columns[1].renderFunction = this.renderName_.bind(this); 536 columns[1].renderFunction = this.renderName_.bind(this);
537 columns[2].renderFunction = this.renderSize_.bind(this); 537 columns[2].renderFunction = this.renderSize_.bind(this);
538 columns[3].renderFunction = this.renderDate_.bind(this); 538 columns[3].renderFunction = this.renderDate_.bind(this);
539 539
540 this.table_ = this.dialogDom_.querySelector('.detail-table'); 540 this.table_ = this.dialogDom_.querySelector('.detail-table');
541 cr.ui.Table.decorate(this.table_); 541 cr.ui.Table.decorate(this.table_);
542 542
543 this.table_.dataModel = this.dataModel_; 543 this.table_.dataModel = this.dataModel_;
544 this.table_.selectionModel = this.selectionModel_; 544 this.table_.selectionModel = new this.selectionModelClass_();
545 this.table_.columnModel = new cr.ui.table.TableColumnModel(columns); 545 this.table_.columnModel = new cr.ui.table.TableColumnModel(columns);
546 546
547 this.table_.addEventListener( 547 this.table_.addEventListener(
548 'dblclick', this.onDetailDoubleClick_.bind(this)); 548 'dblclick', this.onDetailDoubleClick_.bind(this));
549 this.table_.selectionModel.addEventListener( 549 this.table_.selectionModel.addEventListener(
550 'change', this.onDetailSelectionChanged_.bind(this)); 550 'change', this.onDetailSelectionChanged_.bind(this));
551 }; 551 };
552 552
553 FileManager.prototype.onResize_ = function() { 553 FileManager.prototype.onResize_ = function() {
554 this.table_.style.height = this.grid_.style.height = 554 this.table_.style.height = this.grid_.style.height =
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 632
633 default: 633 default:
634 throw new Error('Unknown dialog type: ' + this.dialogType_); 634 throw new Error('Unknown dialog type: ' + this.dialogType_);
635 } 635 }
636 636
637 this.okButton_.textContent = okLabel; 637 this.okButton_.textContent = okLabel;
638 638
639 dialogTitle = this.params_.title || defaultTitle; 639 dialogTitle = this.params_.title || defaultTitle;
640 this.dialogDom_.querySelector('.dialog-title').textContent = dialogTitle; 640 this.dialogDom_.querySelector('.dialog-title').textContent = dialogTitle;
641 641
642 ary = defaultFolder.match(/^\/home\/[^\/]+\/Downloads(\/.*)?$/); 642 ary = defaultFolder.match(/^\/home\/[^\/]+\/user\/Downloads(\/.*)?$/);
643 if (ary) { 643 if (ary) {
644 // Chrome will probably suggest the full path to Downloads, but 644 // Chrome will probably suggest the full path to Downloads, but
645 // we're working with 'virtual paths', so we have to translate. 645 // we're working with 'virtual paths', so we have to translate.
646 // TODO(rginda): Maybe chrome should have suggested the correct place 646 // TODO(rginda): Maybe chrome should have suggested the correct place
647 // to begin with, but that would mean it would have to treat the 647 // to begin with, but that would mean it would have to treat the
648 // file manager dialogs differently than the native ones. 648 // file manager dialogs differently than the native ones.
649 defaultFolder = '/Downloads' + (ary[1] || ''); 649 defaultFolder = '/Downloads' + (ary[1] || '');
650 } 650 }
651 651
652 this.changeDirectory(defaultFolder); 652 this.changeDirectory(defaultFolder);
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
1110 } 1110 }
1111 1111
1112 if (ENABLE_EXIF_READER) { 1112 if (ENABLE_EXIF_READER) {
1113 if (entry.name.match(/\.jpe?g$/i)) { 1113 if (entry.name.match(/\.jpe?g$/i)) {
1114 // File is a jpg image, fetch the exif thumbnail. 1114 // File is a jpg image, fetch the exif thumbnail.
1115 this.cacheExifMetadata_(entry, function(metadata) { 1115 this.cacheExifMetadata_(entry, function(metadata) {
1116 callback(iconType, metadata.thumbnailURL || entry.toURL()); 1116 callback(iconType, metadata.thumbnailURL || entry.toURL());
1117 }); 1117 });
1118 return; 1118 return;
1119 } 1119 }
1120
1121 // File is some other kind of image, just return the url to the whole
1122 // thing.
1123 setTimeout(function() { callback(iconType, entry.toURL()) });
1124 return;
1125 } 1120 }
1126 1121
1127 // If the exif reader worker isn't enabled, read the entire file as a 1122 // File is some other kind of image, just return the url to the whole
1128 // data url instead. 1123 // thing.
1129 batchAsyncCall(entry, 'file', function(file) { 1124 setTimeout(function() { callback(iconType, entry.toURL()) });
1130 var reader = new FileReader();
1131
1132 reader.onerror = util.ferr('Error reading preview: ' + entry.fullPath);
1133 reader.onloadend = function(e) { callback(iconType, reader.result) };
1134 reader.readAsDataURL(file);
1135 });
1136 }; 1125 };
1137 1126
1138 /** 1127 /**
1139 * Change the current directory. 1128 * Change the current directory.
1140 * 1129 *
1141 * Dispatches the 'directory-changed' event when the directory is successfully 1130 * Dispatches the 'directory-changed' event when the directory is successfully
1142 * changed. 1131 * changed.
1143 * 1132 *
1144 * @param {string} path The absolute path to the new directory. 1133 * @param {string} path The absolute path to the new directory.
1145 */ 1134 */
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
1529 } else if (this.dialogType_ == FileManager.DialogType.SELECT_OPEN_FILE) { 1518 } else if (this.dialogType_ == FileManager.DialogType.SELECT_OPEN_FILE) {
1530 if (!this.selection.leadEntry.isFile) 1519 if (!this.selection.leadEntry.isFile)
1531 throw new Error('Selected entry is not a file!'); 1520 throw new Error('Selected entry is not a file!');
1532 } 1521 }
1533 1522
1534 chrome.fileBrowserPrivate.selectFile(ary[0], 0); 1523 chrome.fileBrowserPrivate.selectFile(ary[0], 0);
1535 window.close(); 1524 window.close();
1536 }; 1525 };
1537 1526
1538 })(); 1527 })();
OLDNEW
« no previous file with comments | « chrome/browser/resources/file_manager/js/exif_reader.js ('k') | chrome/browser/resources/file_manager/js/harness.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698