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

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

Issue 7038024: Move sorting logic from table to list. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed autofill phones. Created 9 years, 7 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
« no previous file with comments | « no previous file | chrome/browser/resources/file_manager/main.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // WK Bug 55728 is fixed on the chrome 12 branch but not on the trunk. 5 // WK Bug 55728 is fixed on the chrome 12 branch but not on the trunk.
6 // TODO(rginda): Enable this everywhere once we have a trunk-worthy fix. 6 // TODO(rginda): Enable this everywhere once we have a trunk-worthy fix.
7 const ENABLE_EXIF_READER = navigator.userAgent.match(/chrome\/12\.0/i); 7 const ENABLE_EXIF_READER = navigator.userAgent.match(/chrome\/12\.0/i);
8 8
9 // Thumbnail view is painful without the exif reader. 9 // Thumbnail view is painful without the exif reader.
10 const ENABLE_THUMBNAIL_VIEW = ENABLE_EXIF_READER; 10 const ENABLE_THUMBNAIL_VIEW = ENABLE_EXIF_READER;
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 if (!eval(expr)) 511 if (!eval(expr))
512 ary[i].style.display = 'none'; 512 ary[i].style.display = 'none';
513 } 513 }
514 514
515 // Populate the static localized strings. 515 // Populate the static localized strings.
516 i18nTemplate.process(this.document_, localStrings.templateData); 516 i18nTemplate.process(this.document_, localStrings.templateData);
517 517
518 // Always sharing the data model between the detail/thumb views confuses 518 // Always sharing the data model between the detail/thumb views confuses
519 // them. Instead we maintain this bogus data model, and hook it up to the 519 // them. Instead we maintain this bogus data model, and hook it up to the
520 // view that is not in use. 520 // view that is not in use.
521 this.emptyDataModel_ = new cr.ui.table.TableDataModel([]); 521 this.emptyDataModel_ = new cr.ui.ArrayDataModel([]);
522 522
523 this.dataModel_ = new cr.ui.table.TableDataModel([]); 523 this.dataModel_ = new cr.ui.ArrayDataModel([]);
524 this.dataModel_.sort('name'); 524 this.dataModel_.sort('name');
525 this.dataModel_.addEventListener('sorted',
526 this.onDataModelSorted_.bind(this));
527 this.dataModel_.prepareSort = this.prepareSort_.bind(this); 525 this.dataModel_.prepareSort = this.prepareSort_.bind(this);
528 526
529 if (this.dialogType_ == FileManager.DialogType.SELECT_OPEN_FILE || 527 if (this.dialogType_ == FileManager.DialogType.SELECT_OPEN_FILE ||
530 this.dialogType_ == FileManager.DialogType.SELECT_OPEN_FOLDER || 528 this.dialogType_ == FileManager.DialogType.SELECT_OPEN_FOLDER ||
531 this.dialogType_ == FileManager.DialogType.SELECT_SAVEAS_FILE) { 529 this.dialogType_ == FileManager.DialogType.SELECT_SAVEAS_FILE) {
532 this.selectionModelClass_ = cr.ui.table.TableSingleSelectionModel; 530 this.selectionModelClass_ = cr.ui.ListSingleSelectionModel;
533 } else { 531 } else {
534 this.selectionModelClass_ = cr.ui.table.TableSelectionModel; 532 this.selectionModelClass_ = cr.ui.ListSelectionModel;
535 } 533 }
536 534
537 this.initTable_(); 535 this.initTable_();
538 this.initGrid_(); 536 this.initGrid_();
539 537
540 this.setListType(FileManager.ListType.DETAIL); 538 this.setListType(FileManager.ListType.DETAIL);
541 539
542 this.onResize_(); 540 this.onResize_();
543 this.dialogDom_.style.opacity = '1'; 541 this.dialogDom_.style.opacity = '1';
544 }; 542 };
(...skipping 874 matching lines...) Expand 10 before | Expand all | Expand 10 after
1419 util.flog('Error deleting file: ' + entry.fullPath, onDelete)); 1417 util.flog('Error deleting file: ' + entry.fullPath, onDelete));
1420 } else { 1418 } else {
1421 entry.removeRecursively( 1419 entry.removeRecursively(
1422 onDelete, 1420 onDelete,
1423 util.flog('Error deleting folder: ' + entry.fullPath, onDelete)); 1421 util.flog('Error deleting folder: ' + entry.fullPath, onDelete));
1424 } 1422 }
1425 } 1423 }
1426 }; 1424 };
1427 1425
1428 /** 1426 /**
1429 * Invoked by the table dataModel after a sort completes.
1430 *
1431 * We use this hook to make sure selected files stay visible after a sort.
1432 */
1433 FileManager.prototype.onDataModelSorted_ = function() {
1434 var i = this.currentList_.selectionModel.leadIndex;
1435 this.currentList_.scrollIntoView(i);
1436 }
1437
1438 /**
1439 * Update the selection summary UI when the selection summarization completes. 1427 * Update the selection summary UI when the selection summarization completes.
1440 */ 1428 */
1441 FileManager.prototype.onSelectionSummarized_ = function() { 1429 FileManager.prototype.onSelectionSummarized_ = function() {
1442 if (this.selection.totalCount == 0) { 1430 if (this.selection.totalCount == 0) {
1443 this.previewSummary_.textContent = str('NOTHING_SELECTED'); 1431 this.previewSummary_.textContent = str('NOTHING_SELECTED');
1444 1432
1445 } else if (this.selection.totalCount == 1) { 1433 } else if (this.selection.totalCount == 1) {
1446 this.previewSummary_.textContent = 1434 this.previewSummary_.textContent =
1447 strf('ONE_FILE_SELECTED', cr.locale.bytesToSi(this.selection.bytes)); 1435 strf('ONE_FILE_SELECTED', cr.locale.bytesToSi(this.selection.bytes));
1448 1436
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
1561 * 1549 *
1562 * @param {function()} opt_callback Optional function to invoke when the 1550 * @param {function()} opt_callback Optional function to invoke when the
1563 * rescan is complete. 1551 * rescan is complete.
1564 */ 1552 */
1565 FileManager.prototype.rescanDirectory_ = function(opt_callback) { 1553 FileManager.prototype.rescanDirectory_ = function(opt_callback) {
1566 var self = this; 1554 var self = this;
1567 var reader; 1555 var reader;
1568 1556
1569 function onReadSome(entries) { 1557 function onReadSome(entries) {
1570 if (entries.length == 0) { 1558 if (entries.length == 0) {
1571 if (self.dataModel_.sortStatus.field != 'name')
1572 self.dataModel_.updateIndex(0);
1573
1574 if (opt_callback) 1559 if (opt_callback)
1575 opt_callback(); 1560 opt_callback();
1576 return; 1561 return;
1577 } 1562 }
1578 1563
1579 // Splice takes the to-be-spliced-in array as individual parameters, 1564 // Splice takes the to-be-spliced-in array as individual parameters,
1580 // rather than as an array, so we need to perform some acrobatics... 1565 // rather than as an array, so we need to perform some acrobatics...
1581 var spliceArgs = [].slice.call(entries); 1566 var spliceArgs = [].slice.call(entries);
1582 1567
1583 // Hide files that start with a dot ('.'). 1568 // Hide files that start with a dot ('.').
(...skipping 25 matching lines...) Expand all
1609 reader.readEntries(onReadSome); 1594 reader.readEntries(onReadSome);
1610 return; 1595 return;
1611 } 1596 }
1612 1597
1613 // Otherwise, use the provided list of root subdirectories, since the 1598 // Otherwise, use the provided list of root subdirectories, since the
1614 // real local filesystem root directory (the one we use outside the 1599 // real local filesystem root directory (the one we use outside the
1615 // harness) can't be enumerated yet. 1600 // harness) can't be enumerated yet.
1616 var spliceArgs = [].slice.call(this.rootEntries_); 1601 var spliceArgs = [].slice.call(this.rootEntries_);
1617 spliceArgs.unshift(0, 0); // index, deleteCount 1602 spliceArgs.unshift(0, 0); // index, deleteCount
1618 self.dataModel_.splice.apply(self.dataModel_, spliceArgs); 1603 self.dataModel_.splice.apply(self.dataModel_, spliceArgs);
1619 self.dataModel_.updateIndex(0);
1620 1604
1621 if (opt_callback) 1605 if (opt_callback)
1622 opt_callback(); 1606 opt_callback();
1623 }; 1607 };
1624 1608
1625 FileManager.prototype.findListItem_ = function(event) { 1609 FileManager.prototype.findListItem_ = function(event) {
1626 var node = event.srcElement; 1610 var node = event.srcElement;
1627 while (node) { 1611 while (node) {
1628 if (node.tagName == 'LI') 1612 if (node.tagName == 'LI')
1629 break; 1613 break;
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
1996 } else if (this.dialogType_ == FileManager.DialogType.SELECT_OPEN_FILE) { 1980 } else if (this.dialogType_ == FileManager.DialogType.SELECT_OPEN_FILE) {
1997 if (!this.selection.leadEntry.isFile) 1981 if (!this.selection.leadEntry.isFile)
1998 throw new Error('Selected entry is not a file!'); 1982 throw new Error('Selected entry is not a file!');
1999 } 1983 }
2000 1984
2001 chrome.fileBrowserPrivate.selectFile(ary[0], 0); 1985 chrome.fileBrowserPrivate.selectFile(ary[0], 0);
2002 window.close(); 1986 window.close();
2003 }; 1987 };
2004 1988
2005 })(); 1989 })();
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/file_manager/main.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698