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

Side by Side Diff: chrome/browser/resources/file_manager/js/default_action_dialog.js

Issue 23483029: [Files.app] Not to capture mouse events when the suggest app dialog is visible. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/resources/file_manager/js/file_manager.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 'use strict'; 5 'use strict';
6 6
7 7
8 /** 8 /**
9 * DefaultActionDialog contains a message, a list box, an ok button, and a 9 * DefaultActionDialog contains a message, a list box, an ok button, and a
10 * cancel button. 10 * cancel button.
11 * This dialog should be used as action picker for file operations. 11 * This dialog should be used as action picker for file operations.
12 */ 12 */
13 cr.define('cr.filebrowser', function() { 13 cr.define('cr.filebrowser', function() {
14 14
15 /** 15 /**
16 * Creates dialog in DOM tree. 16 * Creates dialog in DOM tree.
17 * 17 *
18 * @param {HTMLElement} parentNode Node to be parent for this dialog. 18 * @param {HTMLElement} parentNode Node to be parent for this dialog.
19 * @constructor 19 * @constructor
20 * @extends {cr.ui.dialogs.BaseDialog} 20 * @extends {FileManagerDialogBase}
21 */ 21 */
22 function DefaultActionDialog(parentNode) { 22 function DefaultActionDialog(parentNode) {
23 cr.ui.dialogs.BaseDialog.call(this, parentNode); 23 FileManagerDialogBase.call(this, parentNode);
24 24
25 this.frame_.id = 'default-action-dialog'; 25 this.frame_.id = 'default-action-dialog';
26 26
27 this.list_ = new cr.ui.List(); 27 this.list_ = new cr.ui.List();
28 this.list_.id = 'default-actions-list'; 28 this.list_.id = 'default-actions-list';
29 this.frame_.insertBefore(this.list_, this.text_.nextSibling); 29 this.frame_.insertBefore(this.list_, this.text_.nextSibling);
30 30
31 this.selectionModel_ = this.list_.selectionModel = 31 this.selectionModel_ = this.list_.selectionModel =
32 new cr.ui.ListSingleSelectionModel(); 32 new cr.ui.ListSingleSelectionModel();
33 this.dataModel_ = this.list_.dataModel = new cr.ui.ArrayDataModel([]); 33 this.dataModel_ = this.list_.dataModel = new cr.ui.ArrayDataModel([]);
34 34
35 // List has max-height defined at css, so that list grows automatically, 35 // List has max-height defined at css, so that list grows automatically,
36 // but doesn't exceed predefined size. 36 // but doesn't exceed predefined size.
37 this.list_.autoExpands = true; 37 this.list_.autoExpands = true;
38 this.list_.activateItemAtIndex = this.activateItemAtIndex_.bind(this); 38 this.list_.activateItemAtIndex = this.activateItemAtIndex_.bind(this);
39 39
40 this.initialFocusElement_ = this.list_; 40 this.initialFocusElement_ = this.list_;
41 41
42 var self = this; 42 var self = this;
43 43
44 // Binding stuff doesn't work with constructors, so we have to create 44 // Binding stuff doesn't work with constructors, so we have to create
45 // closure here. 45 // closure here.
46 this.list_.itemConstructor = function(item) { 46 this.list_.itemConstructor = function(item) {
47 return self.renderItem(item); 47 return self.renderItem(item);
48 }; 48 };
49 } 49 }
50 50
51 DefaultActionDialog.prototype = { 51 DefaultActionDialog.prototype = {
52 __proto__: cr.ui.dialogs.BaseDialog.prototype 52 __proto__: FileManagerDialogBase.prototype
53 }; 53 };
54 54
55 /** 55 /**
56 * @override 56 * @override
57 */ 57 */
58 DefaultActionDialog.prototype.onInputFocus = function() { 58 DefaultActionDialog.prototype.onInputFocus = function() {
59 this.list_.select(); 59 this.list_.select();
60 }; 60 };
61 61
62 /** 62 /**
(...skipping 23 matching lines...) Expand all
86 return result; 86 return result;
87 }; 87 };
88 88
89 /** 89 /**
90 * Shows dialog. 90 * Shows dialog.
91 * 91 *
92 * @param {string} title Title in dialog caption. 92 * @param {string} title Title in dialog caption.
93 * @param {string} message Message in dialog caption. 93 * @param {string} message Message in dialog caption.
94 * @param {Array.<Object>} items Items to render in the list. 94 * @param {Array.<Object>} items Items to render in the list.
95 * @param {number} defaultIndex Item to select by default. 95 * @param {number} defaultIndex Item to select by default.
96 * @param {function(Object=)} onOk OK callback with the selected item. 96 * @param {function(Object=)} opt_onOk OK callback with the selected item.
97 * @param {function()=} opt_onCancel Cancel callback. 97 * @param {function()=} opt_onCancel Cancel callback.
98 * @param {function()=} opt_onShow Show callback.
99 */ 98 */
100 DefaultActionDialog.prototype.show = function(title, message, items, 99 DefaultActionDialog.prototype.show = function(title, message, items,
101 defaultIndex, onOk, opt_onCancel, opt_onShow) { 100 defaultIndex, opt_onOk, opt_onCancel) {
102 101
103 cr.ui.dialogs.BaseDialog.prototype.showWithTitle.apply( 102 var show = FileManagerDialogBase.prototype.showOkCancelDialog.call(
104 this, [title, message, onOk, opt_onCancel, opt_onShow]); 103 this, title, message, opt_onOk, opt_onCancel);
104
105 if (!show) {
106 console.error('DefaultActionDialog can\'t be shown.');
107 return;
108 }
105 109
106 if (!message) { 110 if (!message) {
107 this.text_.setAttribute('hidden', 'hidden'); 111 this.text_.setAttribute('hidden', 'hidden');
108 } else { 112 } else {
109 this.text_.removeAttribute('hidden'); 113 this.text_.removeAttribute('hidden');
110 } 114 }
111 115
112 this.list_.startBatchUpdates(); 116 this.list_.startBatchUpdates();
113 this.dataModel_.splice(0, this.dataModel_.length); 117 this.dataModel_.splice(0, this.dataModel_.length);
114 for (var i = 0; i < items.length; i++) { 118 for (var i = 0; i < items.length; i++) {
(...skipping 29 matching lines...) Expand all
144 this.onCancelClick_(event); 148 this.onCancelClick_(event);
145 event.preventDefault(); 149 event.preventDefault();
146 } else if (event.keyCode == 32 || event.keyCode == 13) { 150 } else if (event.keyCode == 32 || event.keyCode == 13) {
147 this.onOkClick_(); 151 this.onOkClick_();
148 event.preventDefault(); 152 event.preventDefault();
149 } 153 }
150 }; 154 };
151 155
152 return {DefaultActionDialog: DefaultActionDialog}; 156 return {DefaultActionDialog: DefaultActionDialog};
153 }); 157 });
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/file_manager/js/file_manager.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698