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 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
229 commandManagers[uid] = new CommandManager(doc); | 229 commandManagers[uid] = new CommandManager(doc); |
230 } | 230 } |
231 }; | 231 }; |
232 | 232 |
233 CommandManager.prototype = { | 233 CommandManager.prototype = { |
234 | 234 |
235 /** | 235 /** |
236 * Handles focus changes on the document. | 236 * Handles focus changes on the document. |
237 * @param {Event} e The focus event object. | 237 * @param {Event} e The focus event object. |
238 * @private | 238 * @private |
239 * @suppress {checkTypes} | |
240 * TODO(vitalyp): remove the suppression. | |
Dan Beam
2014/09/30 16:47:15
this is fine by me
| |
239 */ | 241 */ |
240 handleFocus_: function(e) { | 242 handleFocus_: function(e) { |
241 var target = e.target; | 243 var target = e.target; |
242 | 244 |
243 // Ignore focus on a menu button or command item | 245 // Ignore focus on a menu button or command item. |
244 if (target.menu || target.command) | 246 if (target.menu || target.command) |
245 return; | 247 return; |
246 | 248 |
247 var commands = Array.prototype.slice.call( | 249 var commands = Array.prototype.slice.call( |
248 target.ownerDocument.querySelectorAll('command')); | 250 target.ownerDocument.querySelectorAll('command')); |
249 | 251 |
250 commands.forEach(function(command) { | 252 commands.forEach(function(command) { |
251 dispatchCanExecuteEvent(command, target); | 253 dispatchCanExecuteEvent(command, target); |
252 }); | 254 }); |
253 }, | 255 }, |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
317 this.stopPropagation(); | 319 this.stopPropagation(); |
318 } | 320 } |
319 }; | 321 }; |
320 | 322 |
321 // Export | 323 // Export |
322 return { | 324 return { |
323 Command: Command, | 325 Command: Command, |
324 CanExecuteEvent: CanExecuteEvent | 326 CanExecuteEvent: CanExecuteEvent |
325 }; | 327 }; |
326 }); | 328 }); |
OLD | NEW |