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 cr.define('cr.ui', function() { | 5 cr.define('cr.ui', function() { |
6 /** @const */ var Command = cr.ui.Command; | 6 /** @const */ var Command = cr.ui.Command; |
7 | 7 |
8 /** | 8 /** |
9 * Creates a new menu item element. | 9 * Creates a new menu item element. |
10 * @param {Object=} opt_propertyBag Optional properties. | 10 * @param {Object=} opt_propertyBag Optional properties. |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 * Handles mouseup events. This dispatches an activate event; if there is an | 117 * Handles mouseup events. This dispatches an activate event; if there is an |
118 * associated command, that command is executed. | 118 * associated command, that command is executed. |
119 * @param {Event} e The mouseup event object. | 119 * @param {Event} e The mouseup event object. |
120 * @private | 120 * @private |
121 */ | 121 */ |
122 handleMouseUp_: function(e) { | 122 handleMouseUp_: function(e) { |
123 if (!this.disabled && !this.isSeparator() && this.selected) { | 123 if (!this.disabled && !this.isSeparator() && this.selected) { |
124 // Store |contextElement| since it'll be removed by {Menu} on handling | 124 // Store |contextElement| since it'll be removed by {Menu} on handling |
125 // 'activate' event. | 125 // 'activate' event. |
126 var contextElement = this.parentNode.contextElement; | 126 var contextElement = this.parentNode.contextElement; |
| 127 var activationEvent = cr.doc.createEvent('Event'); |
| 128 activationEvent.initEvent('activate', true, true); |
| 129 activationEvent.originalEvent = e; |
127 // Dispatch command event followed by executing the command object. | 130 // Dispatch command event followed by executing the command object. |
128 if (cr.dispatchSimpleEvent(this, 'activate', true, true)) { | 131 if (this.dispatchEvent(activationEvent)) { |
129 var command = this.command; | 132 var command = this.command; |
130 if (command) | 133 if (command) |
131 command.execute(contextElement); | 134 command.execute(contextElement); |
132 } | 135 } |
133 } | 136 } |
134 }, | 137 }, |
135 | 138 |
136 /** | 139 /** |
137 * Updates command according to the node on which this menu was invoked. | 140 * Updates command according to the node on which this menu was invoked. |
138 * @param {Node=} opt_node Node on which menu was opened. | 141 * @param {Node=} opt_node Node on which menu was opened. |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 * Whether the menu item is checked or not. | 190 * Whether the menu item is checked or not. |
188 * @type {boolean} | 191 * @type {boolean} |
189 */ | 192 */ |
190 cr.defineProperty(MenuItem, 'checked', cr.PropertyKind.BOOL_ATTR); | 193 cr.defineProperty(MenuItem, 'checked', cr.PropertyKind.BOOL_ATTR); |
191 | 194 |
192 // Export | 195 // Export |
193 return { | 196 return { |
194 MenuItem: MenuItem | 197 MenuItem: MenuItem |
195 }; | 198 }; |
196 }); | 199 }); |
OLD | NEW |