| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 */ | 165 */ |
| 166 cr.defineProperty(Command, 'disabled', cr.PropertyKind.BOOL_ATTR); | 166 cr.defineProperty(Command, 'disabled', cr.PropertyKind.BOOL_ATTR); |
| 167 | 167 |
| 168 /** | 168 /** |
| 169 * Whether the command is hidden or not. | 169 * Whether the command is hidden or not. |
| 170 * @type {boolean} | 170 * @type {boolean} |
| 171 */ | 171 */ |
| 172 cr.defineProperty(Command, 'hidden', cr.PropertyKind.BOOL_ATTR); | 172 cr.defineProperty(Command, 'hidden', cr.PropertyKind.BOOL_ATTR); |
| 173 | 173 |
| 174 /** | 174 /** |
| 175 * Whether the command is checked or not. | |
| 176 * @type {boolean} | |
| 177 */ | |
| 178 cr.defineProperty(Command, 'checked', cr.PropertyKind.BOOL_ATTR); | |
| 179 | |
| 180 /** | |
| 181 * Dispatches a canExecute event on the target. | 175 * Dispatches a canExecute event on the target. |
| 182 * @param {cr.ui.Command} command The command that we are testing for. | 176 * @param {cr.ui.Command} command The command that we are testing for. |
| 183 * @param {Element} target The target element to dispatch the event on. | 177 * @param {Element} target The target element to dispatch the event on. |
| 184 */ | 178 */ |
| 185 function dispatchCanExecuteEvent(command, target) { | 179 function dispatchCanExecuteEvent(command, target) { |
| 186 var e = new CanExecuteEvent(command, true) | 180 var e = new CanExecuteEvent(command, true) |
| 187 target.dispatchEvent(e); | 181 target.dispatchEvent(e); |
| 188 command.disabled = !e.canExecute; | 182 command.disabled = !e.canExecute; |
| 189 } | 183 } |
| 190 | 184 |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 this.stopPropagation(); | 286 this.stopPropagation(); |
| 293 } | 287 } |
| 294 }; | 288 }; |
| 295 | 289 |
| 296 // Export | 290 // Export |
| 297 return { | 291 return { |
| 298 Command: Command, | 292 Command: Command, |
| 299 CanExecuteEvent: CanExecuteEvent | 293 CanExecuteEvent: CanExecuteEvent |
| 300 }; | 294 }; |
| 301 }); | 295 }); |
| OLD | NEW |