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 e05580d061f12540dba7bf0f098af53e51b1f8e9..c5a432ba078bb3f5a9072c6e0ac5d1ee6685fb76 100644 |
--- a/chrome/browser/resources/file_manager/js/file_manager.js |
+++ b/chrome/browser/resources/file_manager/js/file_manager.js |
@@ -1059,6 +1059,8 @@ FileManager.prototype = { |
this.grid_.addEventListener( |
'dblclick', this.onDetailDoubleClickOrTap_.bind(this)); |
this.grid_.addEventListener( |
+ 'click', this.onDetailClick_.bind(this)); |
+ this.grid_.addEventListener( |
cr.ui.TouchHandler.EventType.TAP, |
this.onDetailDoubleClickOrTap_.bind(this)); |
cr.ui.contextMenuHandler.setContextMenu(this.grid_, this.fileContextMenu_); |
@@ -1121,6 +1123,8 @@ FileManager.prototype = { |
this.table_.list.addEventListener( |
'dblclick', this.onDetailDoubleClickOrTap_.bind(this)); |
this.table_.list.addEventListener( |
+ 'click', this.onDetailClick_.bind(this)); |
+ this.table_.list.addEventListener( |
cr.ui.TouchHandler.EventType.TAP, |
this.onDetailDoubleClickOrTap_.bind(this)); |
@@ -1826,11 +1830,13 @@ FileManager.prototype = { |
FileManager.prototype.renderFileNameLabel_ = function(entry) { |
// Filename need to be in a '.filename-label' container for correct |
// work of inplace renaming. |
- var fileName = this.document_.createElement('div'); |
- fileName.className = 'filename-label'; |
+ var box = this.document_.createElement('div'); |
+ box.className = 'filename-label'; |
+ var fileName = this.document_.createElement('span'); |
fileName.textContent = entry.name; |
+ box.appendChild(fileName); |
- return fileName; |
+ return box; |
}; |
/** |
@@ -2853,6 +2859,26 @@ FileManager.prototype = { |
this.dispatchSelectionAction_(); |
}; |
+ /** |
+ * Handles mouse click or tap. Simulates double click if click happens |
+ * on the file name or the icon. |
+ * @param {Event} event The click event. |
+ */ |
+ FileManager.prototype.onDetailClick_ = function(event) { |
+ if (this.isRenamingInProgress()) { |
+ // Don't pay attention to clicks during a rename. |
+ return; |
+ } |
+ |
+ if (event.target.parentElement.classList.contains('filename-label') || |
Dmitry Zvorygin
2012/08/03 18:03:40
I don't like this hacky code with a lot of 'or-ed'
|
+ event.target.classList.contains('detail-icon') || |
+ event.target.classList.contains('img-container')) { |
+ this.onDetailDoubleClickOrTap_(event); |
+ event.stopPropagation(); |
+ event.preventDefault(); |
+ } |
+ }; |
+ |
FileManager.prototype.dispatchSelectionAction_ = function() { |
if (this.dialogType_ == FileManager.DialogType.FULL_PAGE) { |
if (this.selection.tasks) |