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_METADATA = true; | 7 const ENABLE_METADATA = true; |
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_METADATA; | 10 const ENABLE_THUMBNAIL_VIEW = ENABLE_METADATA; |
(...skipping 1529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1540 event.preventDefault(); | 1540 event.preventDefault(); |
1541 } | 1541 } |
1542 }; | 1542 }; |
1543 | 1543 |
1544 /** | 1544 /** |
1545 * Update the UI when the selection model changes. | 1545 * Update the UI when the selection model changes. |
1546 * | 1546 * |
1547 * @param {cr.Event} event The change event. | 1547 * @param {cr.Event} event The change event. |
1548 */ | 1548 */ |
1549 FileManager.prototype.onSelectionChanged_ = function(event) { | 1549 FileManager.prototype.onSelectionChanged_ = function(event) { |
1550 var selectable; | 1550 this.summarizeSelection_(); |
rginda
2011/06/07 23:35:35
This was moved to updateOkButton_, where it should
| |
1551 this.updatePreview_(); | |
1551 | 1552 |
1552 this.summarizeSelection_(); | 1553 if (this.dialogType_ == FileManager.DialogType.SELECT_SAVEAS_FILE) { |
rginda
2011/06/07 23:35:35
This snippet came from updateOkButton_. It was ac
| |
1554 // If this is a save-as dialog, copy the selected file into the filename | |
1555 // input text box. | |
1556 if (this.selection.leadEntry && this.selection.leadEntry.isFile) | |
1557 this.filenameInput_.value = this.selection.leadEntry.name; | |
1558 } | |
1559 | |
1553 this.updateOkButton_(); | 1560 this.updateOkButton_(); |
1554 this.updatePreview_(); | |
1555 | 1561 |
1556 var self = this; | 1562 var self = this; |
1557 setTimeout(function() { self.onSelectionChangeComplete_(event) }, 0); | 1563 setTimeout(function() { self.onSelectionChangeComplete_(event) }, 0); |
1558 }; | 1564 }; |
1559 | 1565 |
1566 /** | |
1567 * Handle selection change related tasks that won't run properly during | |
1568 * the actual selection change event. | |
1569 */ | |
1560 FileManager.prototype.onSelectionChangeComplete_ = function(event) { | 1570 FileManager.prototype.onSelectionChangeComplete_ = function(event) { |
1561 if (!this.showCheckboxes_) | 1571 if (!this.showCheckboxes_) |
1562 return; | 1572 return; |
1563 | 1573 |
1564 for (var i = 0; i < event.changes.length; i++) { | 1574 for (var i = 0; i < event.changes.length; i++) { |
1565 // Turn off any checkboxes for items that are no longer selected. | 1575 // Turn off any checkboxes for items that are no longer selected. |
1566 var selectedIndex = event.changes[i].index; | 1576 var selectedIndex = event.changes[i].index; |
1567 var listItem = this.currentList_.getListItemByIndex(selectedIndex); | 1577 var listItem = this.currentList_.getListItemByIndex(selectedIndex); |
1568 if (!listItem) { | 1578 if (!listItem) { |
1569 // When changing directories, we get notified about list items | 1579 // When changing directories, we get notified about list items |
(...skipping 16 matching lines...) Expand all Loading... | |
1586 | 1596 |
1587 var selectedIndex = this.selection.indexes[i]; | 1597 var selectedIndex = this.selection.indexes[i]; |
1588 var listItem = this.currentList_.getListItemByIndex(selectedIndex); | 1598 var listItem = this.currentList_.getListItemByIndex(selectedIndex); |
1589 if (listItem) | 1599 if (listItem) |
1590 listItem.querySelector('input[type="checkbox"]').checked = true; | 1600 listItem.querySelector('input[type="checkbox"]').checked = true; |
1591 } | 1601 } |
1592 } | 1602 } |
1593 }; | 1603 }; |
1594 | 1604 |
1595 FileManager.prototype.updateOkButton_ = function(event) { | 1605 FileManager.prototype.updateOkButton_ = function(event) { |
1606 var selectable; | |
1607 | |
1596 if (this.dialogType_ == FileManager.DialogType.SELECT_FOLDER) { | 1608 if (this.dialogType_ == FileManager.DialogType.SELECT_FOLDER) { |
1597 selectable = this.selection.directoryCount == 1 && | 1609 selectable = this.selection.directoryCount == 1 && |
1598 this.selection.fileCount == 0; | 1610 this.selection.fileCount == 0; |
1599 } else if (this.dialogType_ == FileManager.DialogType.SELECT_OPEN_FILE) { | 1611 } else if (this.dialogType_ == FileManager.DialogType.SELECT_OPEN_FILE) { |
1600 selectable = (this.selection.directoryCount == 0 && | 1612 selectable = (this.selection.directoryCount == 0 && |
1601 this.selection.fileCount == 1); | 1613 this.selection.fileCount == 1); |
1602 } else if (this.dialogType_ == | 1614 } else if (this.dialogType_ == |
1603 FileManager.DialogType.SELECT_OPEN_MULTI_FILE) { | 1615 FileManager.DialogType.SELECT_OPEN_MULTI_FILE) { |
1604 selectable = (this.selection.directoryCount == 0 && | 1616 selectable = (this.selection.directoryCount == 0 && |
1605 this.selection.fileCount >= 1); | 1617 this.selection.fileCount >= 1); |
1606 } else if (this.dialogType_ == FileManager.DialogType.SELECT_SAVEAS_FILE) { | 1618 } else if (this.dialogType_ == FileManager.DialogType.SELECT_SAVEAS_FILE) { |
1607 if (this.selection.leadEntry && this.selection.leadEntry.isFile) | |
1608 this.filenameInput_.value = this.selection.leadEntry.name; | |
1609 | |
1610 if (this.currentDirEntry_.fullPath == '/' || | 1619 if (this.currentDirEntry_.fullPath == '/' || |
1611 this.currentDirEntry_.fullPath == MEDIA_DIRECTORY) { | 1620 this.currentDirEntry_.fullPath == MEDIA_DIRECTORY) { |
1612 // Nothing can be saved in to the root or media/ directories. | 1621 // Nothing can be saved in to the root or media/ directories. |
1613 selectable = false; | 1622 selectable = false; |
1614 } else { | 1623 } else { |
1615 selectable = !!this.filenameInput_.value; | 1624 selectable = !!this.filenameInput_.value; |
1616 } | 1625 } |
1617 } else if (this.dialogType_ == FileManager.DialogType.FULL_PAGE) { | 1626 } else if (this.dialogType_ == FileManager.DialogType.FULL_PAGE) { |
1618 // No "select" buttons on the full page UI. | 1627 // No "select" buttons on the full page UI. |
1619 selectable = true; | 1628 selectable = true; |
1620 } else { | 1629 } else { |
1621 throw new Error('Unknown dialog type'); | 1630 throw new Error('Unknown dialog type'); |
1622 } | 1631 } |
1623 | 1632 |
1624 this.okButton_.disabled = !selectable; | 1633 this.okButton_.disabled = !selectable; |
1634 return selectable; | |
1625 }; | 1635 }; |
1626 | 1636 |
1627 /** | 1637 /** |
1628 * Handle a double-click event on an entry in the detail list. | 1638 * Handle a double-click event on an entry in the detail list. |
1629 * | 1639 * |
1630 * @param {Event} event The click event. | 1640 * @param {Event} event The click event. |
1631 */ | 1641 */ |
1632 FileManager.prototype.onDetailDoubleClick_ = function(event) { | 1642 FileManager.prototype.onDetailDoubleClick_ = function(event) { |
1633 if (this.renameInput_.currentEntry) { | 1643 if (this.renameInput_.currentEntry) { |
1634 // Don't pay attention to double clicks during a rename. | 1644 // Don't pay attention to double clicks during a rename. |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1915 | 1925 |
1916 FileManager.prototype.cancelRename_ = function(event) { | 1926 FileManager.prototype.cancelRename_ = function(event) { |
1917 this.renameInput_.currentEntry = null; | 1927 this.renameInput_.currentEntry = null; |
1918 this.lastLabelClick_ = null; | 1928 this.lastLabelClick_ = null; |
1919 | 1929 |
1920 if (this.renameInput_.parentNode) | 1930 if (this.renameInput_.parentNode) |
1921 this.renameInput_.parentNode.removeChild(this.renameInput_); | 1931 this.renameInput_.parentNode.removeChild(this.renameInput_); |
1922 }; | 1932 }; |
1923 | 1933 |
1924 FileManager.prototype.onFilenameInputKeyUp_ = function(event) { | 1934 FileManager.prototype.onFilenameInputKeyUp_ = function(event) { |
1925 this.okButton_.disabled = this.filenameInput_.value.length == 0; | 1935 var enabled = this.updateOkButton_(); |
1926 | 1936 if (enabled && event.keyCode == 13 /* Enter */) |
1927 if (event.keyCode == 13 /* Enter */ && !this.okButton_.disabled) | |
1928 this.onOk_(); | 1937 this.onOk_(); |
1929 }; | 1938 }; |
1930 | 1939 |
1931 FileManager.prototype.onFilenameInputFocus_ = function(event) { | 1940 FileManager.prototype.onFilenameInputFocus_ = function(event) { |
1932 var input = this.filenameInput_; | 1941 var input = this.filenameInput_; |
1933 | 1942 |
1934 // On focus we want to select everything but the extension, but | 1943 // On focus we want to select everything but the extension, but |
1935 // Chrome will select-all after the focus event completes. We | 1944 // Chrome will select-all after the focus event completes. We |
1936 // schedule a timeout to alter the focus after that happens. | 1945 // schedule a timeout to alter the focus after that happens. |
1937 setTimeout(function() { | 1946 setTimeout(function() { |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2124 } else if (this.dialogType_ == FileManager.DialogType.SELECT_OPEN_FILE) { | 2133 } else if (this.dialogType_ == FileManager.DialogType.SELECT_OPEN_FILE) { |
2125 if (!this.selection.leadEntry.isFile) | 2134 if (!this.selection.leadEntry.isFile) |
2126 throw new Error('Selected entry is not a file!'); | 2135 throw new Error('Selected entry is not a file!'); |
2127 } | 2136 } |
2128 | 2137 |
2129 chrome.fileBrowserPrivate.selectFile(ary[0], 0); | 2138 chrome.fileBrowserPrivate.selectFile(ary[0], 0); |
2130 window.close(); | 2139 window.close(); |
2131 }; | 2140 }; |
2132 | 2141 |
2133 })(); | 2142 })(); |
OLD | NEW |