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

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: Merged with master. 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 719a4eea128aa196ac63ad830085e122d0d208c6..502b1bbf4f93349ffc1e3052e2defd8401fb9ace 100644
--- a/chrome/browser/resources/file_manager/js/file_manager.js
+++ b/chrome/browser/resources/file_manager/js/file_manager.js
@@ -2499,6 +2499,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 };
+ }
+
+ /**
* 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.
@@ -2508,7 +2517,8 @@ FileManager.prototype = {
this.taskItems_.clear();
var defaultTask = null;
- var tasksCount = 0;
+ var dropDownItems = [];
+
for (var i = 0; i < tasksList.length; i++) {
var task = tasksList[i];
@@ -2567,15 +2577,27 @@ FileManager.prototype = {
task.title = str('INSTALL_CRX');
}
}
- this.taskItems_.addItem(this.renderTaskItem_(task));
- tasksCount++;
- if (defaultTask == null) defaultTask = task;
+
+ if (defaultTask == null) {
+ defaultTask = task;
+ this.taskItems_.defaultItem = this.createComboboxItem_(task);
+ task.title = task.title + ' ' + str('DEFAULT_ACTION_LABEL');
+ dropDownItems.push(this.createComboboxItem_(task));
+ } else {
+ dropDownItems.push(this.createComboboxItem_(task));
+ }
}
- this.taskItems_.hidden = tasksCount == 0;
- if (tasksCount > 1) {
- // Duplicate default task in drop-down list.
- this.taskItems_.addItem(this.renderTaskItem_(defaultTask));
+ this.taskItems_.hidden = dropDownItems.length == 0;
+
+ if (dropDownItems.length > 1) {
+ dropDownItems.sort(function(a, b) {
+ return a.label.localeCompare(b.label);
+ });
+
+ for (var j = 0; j < dropDownItems.length; j++) {
+ this.taskItems_.addDropDownItem(dropDownItems[j]);
+ }
}
selection.tasksList = tasksList;
@@ -2586,22 +2608,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