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 /** |
175 * Dispatches a canExecute event on the target. | 181 * Dispatches a canExecute event on the target. |
176 * @param {cr.ui.Command} command The command that we are testing for. | 182 * @param {cr.ui.Command} command The command that we are testing for. |
177 * @param {Element} target The target element to dispatch the event on. | 183 * @param {Element} target The target element to dispatch the event on. |
178 */ | 184 */ |
179 function dispatchCanExecuteEvent(command, target) { | 185 function dispatchCanExecuteEvent(command, target) { |
180 var e = new CanExecuteEvent(command, true) | 186 var e = new CanExecuteEvent(command, true) |
181 target.dispatchEvent(e); | 187 target.dispatchEvent(e); |
182 command.disabled = !e.canExecute; | 188 command.disabled = !e.canExecute; |
183 } | 189 } |
184 | 190 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 this.stopPropagation(); | 292 this.stopPropagation(); |
287 } | 293 } |
288 }; | 294 }; |
289 | 295 |
290 // Export | 296 // Export |
291 return { | 297 return { |
292 Command: Command, | 298 Command: Command, |
293 CanExecuteEvent: CanExecuteEvent | 299 CanExecuteEvent: CanExecuteEvent |
294 }; | 300 }; |
295 }); | 301 }); |
OLD | NEW |