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

Unified Diff: chrome/browser/resources/file_manager/js/file_manager.js

Issue 10391184: [FileBrowser] Migrated ComboButton to menu as dropdown. (Closed) Base URL: improved-actions-menu-126927
Patch Set: Fixed comments. Created 8 years, 7 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 0f428269b42d068ca454bb8be6b803fe5894a81f..5749e40c71575b7624d25118db96f7d7754585dd 100644
--- a/chrome/browser/resources/file_manager/js/file_manager.js
+++ b/chrome/browser/resources/file_manager/js/file_manager.js
@@ -2413,6 +2413,15 @@ FileManager.prototype = {
};
/**
+ * Creates combobox item based on task.
+ * @param {Object} task Task to convert.
+ * @return {Object} Item appendable to combobox drop-down list.
+ */
+ FileManager.prototype.createComboboxItem_ = function(task) {
+ return { label: task.title, iconUrl: task.iconUrl, task: task};
dgozman 2012/05/21 12:40:38 space before }
Dmitry Zvorygin 2012/05/21 13:20:14 Done.
+ }
+
+ /**
* Callback called when tasks for selected files are determined.
* @param {Object} selection Selection is passed here, since this.selection
* can change before tasks were found, and we should be accurate.
@@ -2423,6 +2432,7 @@ FileManager.prototype = {
var defaultTask = null;
var tasksCount = 0;
+
for (var i = 0; i < tasksList.length; i++) {
var task = tasksList[i];
@@ -2481,16 +2491,20 @@ FileManager.prototype = {
task.title = str('INSTALL_CRX');
}
}
- this.taskItems_.addItem(this.renderTaskItem_(task));
tasksCount++;
if (defaultTask == null) defaultTask = task;
+
+ // If we have at least two items, then we have to use drop-down list.
+ if (tasksCount == 2)
+ this.taskItems_.addDropDownItem(this.createComboboxItem_(defaultTask));
+
+ if (tasksCount >= 2)
+ this.taskItems_.addDropDownItem(this.createComboboxItem_(task));
}
this.taskItems_.hidden = tasksCount == 0;
- if (tasksCount > 1) {
- // Duplicate default task in drop-down list.
- this.taskItems_.addItem(this.renderTaskItem_(defaultTask));
- }
+ if (defaultTask != null)
+ this.taskItems_.defaultItem = createComboboxItem_(defaultTask);
selection.tasksList = tasksList;
if (selection.dispatchDefault) {
@@ -2500,22 +2514,6 @@ FileManager.prototype = {
}
};
- FileManager.prototype.renderTaskItem_ = function(task) {
- var item = this.document_.createElement('div');
- item.className = 'task-item';
- item.task = task;
-
- var img = this.document_.createElement('img');
- img.src = task.iconUrl;
- item.appendChild(img);
-
- var label = this.document_.createElement('div');
- label.appendChild(this.document_.createTextNode(task.title));
- item.appendChild(label);
-
- return item;
- };
-
FileManager.prototype.getExtensionId_ = function() {
return chrome.extension.getURL('').split('/')[2];
};
« no previous file with comments | « chrome/browser/resources/file_manager/js/combobutton.js ('k') | chrome/browser/resources/file_manager/main.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698