OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 | 6 |
7 const Menu = cr.ui.Menu; | 7 const Menu = cr.ui.Menu; |
8 | 8 |
9 /** | 9 /** |
10 * Handles context menus. | 10 * Handles context menus. |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
204 | 204 |
205 if (!element.getRectForContextMenu) { | 205 if (!element.getRectForContextMenu) { |
206 /** | 206 /** |
207 * @return {!ClientRect} The rect to use for positioning the context | 207 * @return {!ClientRect} The rect to use for positioning the context |
208 * menu when the context menu is not opened using a mouse position. | 208 * menu when the context menu is not opened using a mouse position. |
209 */ | 209 */ |
210 element.getRectForContextMenu = function() { | 210 element.getRectForContextMenu = function() { |
211 return this.getBoundingClientRect(); | 211 return this.getBoundingClientRect(); |
212 }; | 212 }; |
213 } | 213 } |
214 }, | |
215 | |
216 /** | |
217 * Sets the given contextMenu to the given element. A contextMenu property | |
218 * would be added if necessary. | |
219 * @param {!Element|!Function} element The element or class to set the | |
arv (Not doing code reviews)
2012/01/18 19:19:49
This should probably only be {!Element} even thoug
| |
220 * contextMenu to. | |
221 * @param {!cr.ui.Menu} contextMenu The contextMenu property to be set. | |
222 */ | |
223 setContextMenu: function(element, contextMenu) { | |
224 if (!element.contextMenu) | |
225 this.addContextMenuProperty(element); | |
226 element.contextMenu = contextMenu; | |
214 } | 227 } |
215 }; | 228 }; |
216 | 229 |
217 /** | 230 /** |
218 * The singleton context menu handler. | 231 * The singleton context menu handler. |
219 * @type {!ContextMenuHandler} | 232 * @type {!ContextMenuHandler} |
220 */ | 233 */ |
221 var contextMenuHandler = new ContextMenuHandler; | 234 var contextMenuHandler = new ContextMenuHandler; |
222 | 235 |
223 // Export | 236 // Export |
224 return { | 237 return { |
225 contextMenuHandler: contextMenuHandler | 238 contextMenuHandler: contextMenuHandler |
226 }; | 239 }; |
227 }); | 240 }); |
OLD | NEW |