Commit 4cd824a5 authored by yoshiki@chromium.org's avatar yoshiki@chromium.org

[Files.app] Remove OK and Cancel buttons in task picker dialog

BUG=223574
TEST=manually tested

Review URL: https://codereview.chromium.org/108163005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@243526 0039d316-1c4b-4281-b951-d872f2087c98
parent f8864cb2
...@@ -36,6 +36,8 @@ cr.define('cr.filebrowser', function() { ...@@ -36,6 +36,8 @@ cr.define('cr.filebrowser', function() {
// but doesn't exceed predefined size. // but doesn't exceed predefined size.
this.list_.autoExpands = true; this.list_.autoExpands = true;
this.list_.activateItemAtIndex = this.activateItemAtIndex_.bind(this); this.list_.activateItemAtIndex = this.activateItemAtIndex_.bind(this);
// Use 'click' instead of 'change' for keyboard users.
this.list_.addEventListener('click', this.onSelected_.bind(this));
this.initialFocusElement_ = this.list_; this.initialFocusElement_ = this.list_;
...@@ -93,14 +95,16 @@ cr.define('cr.filebrowser', function() { ...@@ -93,14 +95,16 @@ cr.define('cr.filebrowser', function() {
* @param {string} message Message in dialog caption. * @param {string} message Message in dialog caption.
* @param {Array.<Object>} items Items to render in the list. * @param {Array.<Object>} items Items to render in the list.
* @param {number} defaultIndex Item to select by default. * @param {number} defaultIndex Item to select by default.
* @param {function(Object=)} opt_onOk OK callback with the selected item. * @param {function(Object)} onSelectedItem Callback which is called when an
* @param {function()=} opt_onCancel Cancel callback. * item is selected.
*/ */
DefaultActionDialog.prototype.show = function(title, message, items, DefaultActionDialog.prototype.show = function(title, message, items,
defaultIndex, opt_onOk, opt_onCancel) { defaultIndex, onSelectedItem) {
var show = FileManagerDialogBase.prototype.showOkCancelDialog.call( this.onSelectedItemCallback_ = onSelectedItem;
this, title, message, opt_onOk, opt_onCancel);
var show = FileManagerDialogBase.prototype.showTitleAndTextDialog.call(
this, title, message);
if (!show) { if (!show) {
console.error('DefaultActionDialog can\'t be shown.'); console.error('DefaultActionDialog can\'t be shown.');
...@@ -128,15 +132,15 @@ cr.define('cr.filebrowser', function() { ...@@ -128,15 +132,15 @@ cr.define('cr.filebrowser', function() {
*/ */
DefaultActionDialog.prototype.activateItemAtIndex_ = function(index) { DefaultActionDialog.prototype.activateItemAtIndex_ = function(index) {
this.hide(); this.hide();
this.onOk_(this.dataModel_.item(index)); this.onSelectedItemCallback_(this.dataModel_.item(index));
}; };
/** /**
* Closes dialog and invokes callback with currently-selected item. * Closes dialog and invokes callback with currently-selected item.
* @override
*/ */
DefaultActionDialog.prototype.onOkClick_ = function() { DefaultActionDialog.prototype.onSelected_ = function() {
this.activateItemAtIndex_(this.selectionModel_.selectedIndex); if (this.selectionModel_.selectedIndex !== -1)
this.activateItemAtIndex_(this.selectionModel_.selectedIndex);
}; };
/** /**
...@@ -145,10 +149,10 @@ cr.define('cr.filebrowser', function() { ...@@ -145,10 +149,10 @@ cr.define('cr.filebrowser', function() {
DefaultActionDialog.prototype.onContainerKeyDown_ = function(event) { DefaultActionDialog.prototype.onContainerKeyDown_ = function(event) {
// Handle Escape. // Handle Escape.
if (event.keyCode == 27) { if (event.keyCode == 27) {
this.onCancelClick_(event); this.hide();
event.preventDefault(); event.preventDefault();
} else if (event.keyCode == 32 || event.keyCode == 13) { } else if (event.keyCode == 32 || event.keyCode == 13) {
this.onOkClick_(); this.onSelected_();
event.preventDefault(); event.preventDefault();
} }
}; };
......
...@@ -568,7 +568,7 @@ CommandHandler.COMMANDS_['open-with'] = { ...@@ -568,7 +568,7 @@ CommandHandler.COMMANDS_['open-with'] = {
if (tasks) { if (tasks) {
tasks.showTaskPicker(fileManager.defaultTaskPicker, tasks.showTaskPicker(fileManager.defaultTaskPicker,
str('OPEN_WITH_BUTTON_LABEL'), str('OPEN_WITH_BUTTON_LABEL'),
null, '',
function(task) { function(task) {
tasks.execute(task.taskId); tasks.execute(task.taskId);
}); });
......
...@@ -103,6 +103,7 @@ FileManagerDialogBase.prototype.showTitleOnlyDialog = function(title) { ...@@ -103,6 +103,7 @@ FileManagerDialogBase.prototype.showTitleOnlyDialog = function(title) {
* dialog failed to show due to an existing dialog. * dialog failed to show due to an existing dialog.
*/ */
FileManagerDialogBase.prototype.showTitleAndTextDialog = function(title, text) { FileManagerDialogBase.prototype.showTitleAndTextDialog = function(title, text) {
this.buttons.style.display = 'none';
return this.showImpl_(title, text, null, null, null); return this.showImpl_(title, text, null, null, null);
}; };
......
...@@ -66,22 +66,22 @@ cr.define('cr.ui.dialogs', function() { ...@@ -66,22 +66,22 @@ cr.define('cr.ui.dialogs', function() {
this.text_.className = 'cr-dialog-text'; this.text_.className = 'cr-dialog-text';
this.frame_.appendChild(this.text_); this.frame_.appendChild(this.text_);
var buttons = doc.createElement('div'); this.buttons = doc.createElement('div');
buttons.className = 'cr-dialog-buttons'; this.buttons.className = 'cr-dialog-buttons';
this.frame_.appendChild(buttons); this.frame_.appendChild(this.buttons);
this.okButton_ = doc.createElement('button'); this.okButton_ = doc.createElement('button');
this.okButton_.className = 'cr-dialog-ok'; this.okButton_.className = 'cr-dialog-ok';
this.okButton_.textContent = BaseDialog.OK_LABEL; this.okButton_.textContent = BaseDialog.OK_LABEL;
this.okButton_.addEventListener('click', this.onOkClick_.bind(this)); this.okButton_.addEventListener('click', this.onOkClick_.bind(this));
buttons.appendChild(this.okButton_); this.buttons.appendChild(this.okButton_);
this.cancelButton_ = doc.createElement('button'); this.cancelButton_ = doc.createElement('button');
this.cancelButton_.className = 'cr-dialog-cancel'; this.cancelButton_.className = 'cr-dialog-cancel';
this.cancelButton_.textContent = BaseDialog.CANCEL_LABEL; this.cancelButton_.textContent = BaseDialog.CANCEL_LABEL;
this.cancelButton_.addEventListener('click', this.cancelButton_.addEventListener('click',
this.onCancelClick_.bind(this)); this.onCancelClick_.bind(this));
buttons.appendChild(this.cancelButton_); this.buttons.appendChild(this.cancelButton_);
this.initialFocusElement_ = this.okButton_; this.initialFocusElement_ = this.okButton_;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment