Chromium Code Reviews| 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.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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 718 this.grid_.parentNode.clientWidth + 'px'; | 716 this.grid_.parentNode.clientWidth + 'px'; |
| 719 | 717 |
| 720 this.table_.list_.style.width = this.table_.parentNode.clientWidth + 'px'; | 718 this.table_.list_.style.width = this.table_.parentNode.clientWidth + 'px'; |
| 721 this.table_.list_.style.height = (this.table_.clientHeight - 1 - | 719 this.table_.list_.style.height = (this.table_.clientHeight - 1 - |
| 722 this.table_.header_.clientHeight) + 'px'; | 720 this.table_.header_.clientHeight) + 'px'; |
| 723 | 721 |
| 724 if (this.listType_ == FileManager.ListType.THUMBNAIL) { | 722 if (this.listType_ == FileManager.ListType.THUMBNAIL) { |
| 725 var self = this; | 723 var self = this; |
| 726 setTimeout(function () { | 724 setTimeout(function () { |
| 727 self.grid_.columns = 0; | 725 self.grid_.columns = 0; |
| 728 self.grid_.redraw(); | 726 self.grid_.redraw(); |
|
rginda
2011/05/17 23:56:43
I think this will need to become invalidateAndRedr
vsevik
2011/05/18 11:32:17
This seems unrelated to this change which is compl
rginda
2011/05/18 23:45:19
Where did invalidateAndRedraw come from? I though
| |
| 729 }, 0); | 727 }, 0); |
| 730 } else { | 728 } else { |
| 731 this.currentList_.redraw(); | 729 this.currentList_.invalidateAndRedraw(); |
| 732 } | 730 } |
| 733 }; | 731 }; |
| 734 | 732 |
| 735 /** | 733 /** |
| 736 * Tweak the UI to become a particular kind of dialog, as determined by the | 734 * Tweak the UI to become a particular kind of dialog, as determined by the |
| 737 * dialog type parameter passed to the constructor. | 735 * dialog type parameter passed to the constructor. |
| 738 */ | 736 */ |
| 739 FileManager.prototype.initDialogType_ = function() { | 737 FileManager.prototype.initDialogType_ = function() { |
| 740 var defaultTitle; | 738 var defaultTitle; |
| 741 var okLabel = str('OPEN_LABEL'); | 739 var okLabel = str('OPEN_LABEL'); |
| (...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 Loading... | |
| 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 Loading... | |
| 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 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1990 } else if (this.dialogType_ == FileManager.DialogType.SELECT_OPEN_FILE) { | 1974 } else if (this.dialogType_ == FileManager.DialogType.SELECT_OPEN_FILE) { |
| 1991 if (!this.selection.leadEntry.isFile) | 1975 if (!this.selection.leadEntry.isFile) |
| 1992 throw new Error('Selected entry is not a file!'); | 1976 throw new Error('Selected entry is not a file!'); |
| 1993 } | 1977 } |
| 1994 | 1978 |
| 1995 chrome.fileBrowserPrivate.selectFile(ary[0], 0); | 1979 chrome.fileBrowserPrivate.selectFile(ary[0], 0); |
| 1996 // Window closed by above call. | 1980 // Window closed by above call. |
| 1997 }; | 1981 }; |
| 1998 | 1982 |
| 1999 })(); | 1983 })(); |
| OLD | NEW |