| 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 // 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 Loading... |
| 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.ArrayDataModel([]); | 521 this.emptyDataModel_ = new cr.ui.table.TableDataModel([]); |
| 522 | 522 |
| 523 this.dataModel_ = new cr.ui.ArrayDataModel([]); | 523 this.dataModel_ = new cr.ui.table.TableDataModel([]); |
| 524 this.dataModel_.sort('name'); | 524 this.dataModel_.sort('name'); |
| 525 this.dataModel_.addEventListener('sorted', |
| 526 this.onDataModelSorted_.bind(this)); |
| 525 this.dataModel_.prepareSort = this.prepareSort_.bind(this); | 527 this.dataModel_.prepareSort = this.prepareSort_.bind(this); |
| 526 | 528 |
| 527 if (this.dialogType_ == FileManager.DialogType.SELECT_OPEN_FILE || | 529 if (this.dialogType_ == FileManager.DialogType.SELECT_OPEN_FILE || |
| 528 this.dialogType_ == FileManager.DialogType.SELECT_OPEN_FOLDER || | 530 this.dialogType_ == FileManager.DialogType.SELECT_OPEN_FOLDER || |
| 529 this.dialogType_ == FileManager.DialogType.SELECT_SAVEAS_FILE) { | 531 this.dialogType_ == FileManager.DialogType.SELECT_SAVEAS_FILE) { |
| 530 this.selectionModelClass_ = cr.ui.ListSingleSelectionModel; | 532 this.selectionModelClass_ = cr.ui.table.TableSingleSelectionModel; |
| 531 } else { | 533 } else { |
| 532 this.selectionModelClass_ = cr.ui.ListSelectionModel; | 534 this.selectionModelClass_ = cr.ui.table.TableSelectionModel; |
| 533 } | 535 } |
| 534 | 536 |
| 535 this.initTable_(); | 537 this.initTable_(); |
| 536 this.initGrid_(); | 538 this.initGrid_(); |
| 537 | 539 |
| 538 this.setListType(FileManager.ListType.DETAIL); | 540 this.setListType(FileManager.ListType.DETAIL); |
| 539 | 541 |
| 540 this.onResize_(); | 542 this.onResize_(); |
| 541 this.dialogDom_.style.opacity = '1'; | 543 this.dialogDom_.style.opacity = '1'; |
| 542 }; | 544 }; |
| (...skipping 874 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1417 util.flog('Error deleting file: ' + entry.fullPath, onDelete)); | 1419 util.flog('Error deleting file: ' + entry.fullPath, onDelete)); |
| 1418 } else { | 1420 } else { |
| 1419 entry.removeRecursively( | 1421 entry.removeRecursively( |
| 1420 onDelete, | 1422 onDelete, |
| 1421 util.flog('Error deleting folder: ' + entry.fullPath, onDelete)); | 1423 util.flog('Error deleting folder: ' + entry.fullPath, onDelete)); |
| 1422 } | 1424 } |
| 1423 } | 1425 } |
| 1424 }; | 1426 }; |
| 1425 | 1427 |
| 1426 /** | 1428 /** |
| 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 /** |
| 1427 * Update the selection summary UI when the selection summarization completes. | 1439 * Update the selection summary UI when the selection summarization completes. |
| 1428 */ | 1440 */ |
| 1429 FileManager.prototype.onSelectionSummarized_ = function() { | 1441 FileManager.prototype.onSelectionSummarized_ = function() { |
| 1430 if (this.selection.totalCount == 0) { | 1442 if (this.selection.totalCount == 0) { |
| 1431 this.previewSummary_.textContent = str('NOTHING_SELECTED'); | 1443 this.previewSummary_.textContent = str('NOTHING_SELECTED'); |
| 1432 | 1444 |
| 1433 } else if (this.selection.totalCount == 1) { | 1445 } else if (this.selection.totalCount == 1) { |
| 1434 this.previewSummary_.textContent = | 1446 this.previewSummary_.textContent = |
| 1435 strf('ONE_FILE_SELECTED', cr.locale.bytesToSi(this.selection.bytes)); | 1447 strf('ONE_FILE_SELECTED', cr.locale.bytesToSi(this.selection.bytes)); |
| 1436 | 1448 |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1549 * | 1561 * |
| 1550 * @param {function()} opt_callback Optional function to invoke when the | 1562 * @param {function()} opt_callback Optional function to invoke when the |
| 1551 * rescan is complete. | 1563 * rescan is complete. |
| 1552 */ | 1564 */ |
| 1553 FileManager.prototype.rescanDirectory_ = function(opt_callback) { | 1565 FileManager.prototype.rescanDirectory_ = function(opt_callback) { |
| 1554 var self = this; | 1566 var self = this; |
| 1555 var reader; | 1567 var reader; |
| 1556 | 1568 |
| 1557 function onReadSome(entries) { | 1569 function onReadSome(entries) { |
| 1558 if (entries.length == 0) { | 1570 if (entries.length == 0) { |
| 1571 if (self.dataModel_.sortStatus.field != 'name') |
| 1572 self.dataModel_.updateIndex(0); |
| 1573 |
| 1559 if (opt_callback) | 1574 if (opt_callback) |
| 1560 opt_callback(); | 1575 opt_callback(); |
| 1561 return; | 1576 return; |
| 1562 } | 1577 } |
| 1563 | 1578 |
| 1564 // Splice takes the to-be-spliced-in array as individual parameters, | 1579 // Splice takes the to-be-spliced-in array as individual parameters, |
| 1565 // rather than as an array, so we need to perform some acrobatics... | 1580 // rather than as an array, so we need to perform some acrobatics... |
| 1566 var spliceArgs = [].slice.call(entries); | 1581 var spliceArgs = [].slice.call(entries); |
| 1567 | 1582 |
| 1568 // Hide files that start with a dot ('.'). | 1583 // Hide files that start with a dot ('.'). |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1594 reader.readEntries(onReadSome); | 1609 reader.readEntries(onReadSome); |
| 1595 return; | 1610 return; |
| 1596 } | 1611 } |
| 1597 | 1612 |
| 1598 // Otherwise, use the provided list of root subdirectories, since the | 1613 // Otherwise, use the provided list of root subdirectories, since the |
| 1599 // real local filesystem root directory (the one we use outside the | 1614 // real local filesystem root directory (the one we use outside the |
| 1600 // harness) can't be enumerated yet. | 1615 // harness) can't be enumerated yet. |
| 1601 var spliceArgs = [].slice.call(this.rootEntries_); | 1616 var spliceArgs = [].slice.call(this.rootEntries_); |
| 1602 spliceArgs.unshift(0, 0); // index, deleteCount | 1617 spliceArgs.unshift(0, 0); // index, deleteCount |
| 1603 self.dataModel_.splice.apply(self.dataModel_, spliceArgs); | 1618 self.dataModel_.splice.apply(self.dataModel_, spliceArgs); |
| 1619 self.dataModel_.updateIndex(0); |
| 1604 | 1620 |
| 1605 if (opt_callback) | 1621 if (opt_callback) |
| 1606 opt_callback(); | 1622 opt_callback(); |
| 1607 }; | 1623 }; |
| 1608 | 1624 |
| 1609 FileManager.prototype.findListItem_ = function(event) { | 1625 FileManager.prototype.findListItem_ = function(event) { |
| 1610 var node = event.srcElement; | 1626 var node = event.srcElement; |
| 1611 while (node) { | 1627 while (node) { |
| 1612 if (node.tagName == 'LI') | 1628 if (node.tagName == 'LI') |
| 1613 break; | 1629 break; |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1980 } else if (this.dialogType_ == FileManager.DialogType.SELECT_OPEN_FILE) { | 1996 } else if (this.dialogType_ == FileManager.DialogType.SELECT_OPEN_FILE) { |
| 1981 if (!this.selection.leadEntry.isFile) | 1997 if (!this.selection.leadEntry.isFile) |
| 1982 throw new Error('Selected entry is not a file!'); | 1998 throw new Error('Selected entry is not a file!'); |
| 1983 } | 1999 } |
| 1984 | 2000 |
| 1985 chrome.fileBrowserPrivate.selectFile(ary[0], 0); | 2001 chrome.fileBrowserPrivate.selectFile(ary[0], 0); |
| 1986 window.close(); | 2002 window.close(); |
| 1987 }; | 2003 }; |
| 1988 | 2004 |
| 1989 })(); | 2005 })(); |
| OLD | NEW |