| 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} element The element or class to set the contextMenu to. |
| 220 * @param {!cr.ui.Menu} contextMenu The contextMenu property to be set. |
| 221 */ |
| 222 setContextMenu: function(element, contextMenu) { |
| 223 if (!element.contextMenu) |
| 224 this.addContextMenuProperty(element); |
| 225 element.contextMenu = contextMenu; |
| 214 } | 226 } |
| 215 }; | 227 }; |
| 216 | 228 |
| 217 /** | 229 /** |
| 218 * The singleton context menu handler. | 230 * The singleton context menu handler. |
| 219 * @type {!ContextMenuHandler} | 231 * @type {!ContextMenuHandler} |
| 220 */ | 232 */ |
| 221 var contextMenuHandler = new ContextMenuHandler; | 233 var contextMenuHandler = new ContextMenuHandler; |
| 222 | 234 |
| 223 // Export | 235 // Export |
| 224 return { | 236 return { |
| 225 contextMenuHandler: contextMenuHandler | 237 contextMenuHandler: contextMenuHandler |
| 226 }; | 238 }; |
| 227 }); | 239 }); |
| OLD | NEW |