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

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

Issue 7134004: file manager: clean up rename click detection (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 6 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 // 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 1707 matching lines...) Expand 10 before | Expand all | Expand 10 after
1718 }); 1718 });
1719 } 1719 }
1720 1720
1721 spliceArgs.unshift(0, 0); // index, deleteCount 1721 spliceArgs.unshift(0, 0); // index, deleteCount
1722 self.dataModel_.splice.apply(self.dataModel_, spliceArgs); 1722 self.dataModel_.splice.apply(self.dataModel_, spliceArgs);
1723 1723
1724 // Keep reading until entries.length is 0. 1724 // Keep reading until entries.length is 0.
1725 reader.readEntries(onReadSome); 1725 reader.readEntries(onReadSome);
1726 }; 1726 };
1727 1727
1728 // Updated when a user clicks on the label of a file, used to detect
1729 // when a click is eligible to trigger a rename. Can be null, or
1730 // an object with 'path' and 'date' properties.
1728 this.lastLabelClick_ = null; 1731 this.lastLabelClick_ = null;
1729 1732
1730 // Clear the table first. 1733 // Clear the table first.
1731 this.dataModel_.splice(0, this.dataModel_.length); 1734 this.dataModel_.splice(0, this.dataModel_.length);
1732 1735
1733 this.updateBreadcrumbs_(); 1736 this.updateBreadcrumbs_();
1734 1737
1735 if (this.currentDirEntry_.fullPath != '/') { 1738 if (this.currentDirEntry_.fullPath != '/') {
1736 // If not the root directory, just read the contents. 1739 // If not the root directory, just read the contents.
1737 reader = this.currentDirEntry_.createReader(); 1740 reader = this.currentDirEntry_.createReader();
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
1818 if (event.srcElement.className != 'filename-label') 1821 if (event.srcElement.className != 'filename-label')
1819 return false; 1822 return false;
1820 1823
1821 // Wrong button or using a keyboard modifier. 1824 // Wrong button or using a keyboard modifier.
1822 if (event.button != 0 || event.shiftKey || event.metaKey || event.altKey) { 1825 if (event.button != 0 || event.shiftKey || event.metaKey || event.altKey) {
1823 this.lastLabelClick_ = null; 1826 this.lastLabelClick_ = null;
1824 return false; 1827 return false;
1825 } 1828 }
1826 1829
1827 var now = new Date(); 1830 var now = new Date();
1831 var path = event.srcElement.entry.fullPath;
1828 1832
1829 this.lastLabelClick_ = this.lastLabelClick_ || now; 1833 if (this.lastLabelClick_ && this.lastLabelClick_.path == path) {
1830 var delay = now - this.lastLabelClick_; 1834 var delay = now - this.lastLabelClick_.date;
1831 if (!row.selected || delay < 500) 1835 if (delay > 500 && delay < 2000)
1832 return false; 1836 return true;
1837 }
1833 1838
1834 this.lastLabelClick_ = now; 1839 this.lastLabelClick_ = {path: path, date: now};
1835 return true; 1840 return false;
1836 }; 1841 };
1837 1842
1838 FileManager.prototype.initiateRename_= function(label) { 1843 FileManager.prototype.initiateRename_= function(label) {
1839 var input = this.renameInput_; 1844 var input = this.renameInput_;
1840 1845
1841 window.label = label;
rginda 2011/06/07 22:58:14 This is some debugging code that slipped in in a p
1842
1843 input.value = label.textContent; 1846 input.value = label.textContent;
1844 input.style.top = label.offsetTop + 'px'; 1847 input.style.top = label.offsetTop + 'px';
1845 input.style.left = label.offsetLeft + 'px'; 1848 input.style.left = label.offsetLeft + 'px';
1846 input.style.width = label.clientWidth + 'px'; 1849 input.style.width = label.clientWidth + 'px';
1847 label.parentNode.appendChild(input); 1850 label.parentNode.appendChild(input);
1848 input.focus(); 1851 input.focus();
1849 var selectionEnd = input.value.lastIndexOf('.'); 1852 var selectionEnd = input.value.lastIndexOf('.');
1850 if (selectionEnd == -1) { 1853 if (selectionEnd == -1) {
1851 input.select(); 1854 input.select();
1852 } else { 1855 } else {
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
2124 } else if (this.dialogType_ == FileManager.DialogType.SELECT_OPEN_FILE) { 2127 } else if (this.dialogType_ == FileManager.DialogType.SELECT_OPEN_FILE) {
2125 if (!this.selection.leadEntry.isFile) 2128 if (!this.selection.leadEntry.isFile)
2126 throw new Error('Selected entry is not a file!'); 2129 throw new Error('Selected entry is not a file!');
2127 } 2130 }
2128 2131
2129 chrome.fileBrowserPrivate.selectFile(ary[0], 0); 2132 chrome.fileBrowserPrivate.selectFile(ary[0], 0);
2130 window.close(); 2133 window.close();
2131 }; 2134 };
2132 2135
2133 })(); 2136 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698