OLD | NEW |
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 /** | 5 /** |
6 * @fileoverview A command is an abstraction of an action a user can do in the | 6 * @fileoverview A command is an abstraction of an action a user can do in the |
7 * UI. | 7 * UI. |
8 * | 8 * |
9 * When the focus changes in the document for each command a canExecute event | 9 * When the focus changes in the document for each command a canExecute event |
10 * is dispatched on the active element. By listening to this event you can | 10 * is dispatched on the active element. By listening to this event you can |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 * Whether the event object matches the shortcut for this command. | 150 * Whether the event object matches the shortcut for this command. |
151 * @param {!Event} e The key event object. | 151 * @param {!Event} e The key event object. |
152 * @return {boolean} Whether it matched or not. | 152 * @return {boolean} Whether it matched or not. |
153 */ | 153 */ |
154 matchesEvent: function(e) { | 154 matchesEvent: function(e) { |
155 if (!this.keyboardShortcuts_) | 155 if (!this.keyboardShortcuts_) |
156 return false; | 156 return false; |
157 | 157 |
158 return this.keyboardShortcuts_.some(function(keyboardShortcut) { | 158 return this.keyboardShortcuts_.some(function(keyboardShortcut) { |
159 return keyboardShortcut.matchesEvent(e); | 159 return keyboardShortcut.matchesEvent(e); |
160 }); | 160 }); |
161 } | 161 }, |
162 }; | 162 }; |
163 | 163 |
164 /** | 164 /** |
165 * The label of the command. | 165 * The label of the command. |
166 */ | 166 */ |
167 cr.defineProperty(Command, 'label', cr.PropertyKind.ATTR); | 167 cr.defineProperty(Command, 'label', cr.PropertyKind.ATTR); |
168 | 168 |
169 /** | 169 /** |
170 * Whether the command is disabled or not. | 170 * Whether the command is disabled or not. |
171 */ | 171 */ |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 this.preventDefault(); | 321 this.preventDefault(); |
322 } | 322 } |
323 }; | 323 }; |
324 | 324 |
325 // Export | 325 // Export |
326 return { | 326 return { |
327 Command: Command, | 327 Command: Command, |
328 CanExecuteEvent: CanExecuteEvent | 328 CanExecuteEvent: CanExecuteEvent |
329 }; | 329 }; |
330 }); | 330 }); |
OLD | NEW |