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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/file_manager/js/file_manager.js
diff --git a/chrome/browser/resources/file_manager/js/file_manager.js b/chrome/browser/resources/file_manager/js/file_manager.js
index 835f5f0ccd353ba6ce1585c2e1a11818547d882e..552cb4191aac2935a43cbbb05eeab0834d722ac5 100644
--- a/chrome/browser/resources/file_manager/js/file_manager.js
+++ b/chrome/browser/resources/file_manager/js/file_manager.js
@@ -1725,6 +1725,9 @@ FileManager.prototype = {
reader.readEntries(onReadSome);
};
+ // Updated when a user clicks on the label of a file, used to detect
+ // when a click is eligible to trigger a rename. Can be null, or
+ // an object with 'path' and 'date' properties.
this.lastLabelClick_ = null;
// Clear the table first.
@@ -1825,21 +1828,21 @@ FileManager.prototype = {
}
var now = new Date();
+ var path = event.srcElement.entry.fullPath;
- this.lastLabelClick_ = this.lastLabelClick_ || now;
- var delay = now - this.lastLabelClick_;
- if (!row.selected || delay < 500)
- return false;
+ if (this.lastLabelClick_ && this.lastLabelClick_.path == path) {
+ var delay = now - this.lastLabelClick_.date;
+ if (delay > 500 && delay < 2000)
+ return true;
+ }
- this.lastLabelClick_ = now;
- return true;
+ this.lastLabelClick_ = {path: path, date: now};
+ return false;
};
FileManager.prototype.initiateRename_= function(label) {
var input = this.renameInput_;
- window.label = label;
rginda 2011/06/07 22:58:14 This is some debugging code that slipped in in a p
-
input.value = label.textContent;
input.style.top = label.offsetTop + 'px';
input.style.left = label.offsetLeft + 'px';

Powered by Google App Engine
This is Rietveld 408576698