Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(301)

Side by Side Diff: chrome/browser/resources/shared/js/cr/ui/context_menu_handler.js

Issue 7215035: ntp4: add app context menu (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: response to review comments Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 cr.define('cr.ui', function() { 5 cr.define('cr.ui', function() {
6 6
7 const positionPopupAtPoint = cr.ui.positionPopupAtPoint;
8 const Menu = cr.ui.Menu; 7 const Menu = cr.ui.Menu;
9 8
10 /** 9 /**
11 * Handles context menus. 10 * Handles context menus.
12 * @constructor 11 * @constructor
13 */ 12 */
14 function ContextMenuHandler() {} 13 function ContextMenuHandler() {}
15 14
16 ContextMenuHandler.prototype = { 15 ContextMenuHandler.prototype = {
17 16
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 element.getRectForContextMenu() : 87 element.getRectForContextMenu() :
89 element.getBoundingClientRect(); 88 element.getBoundingClientRect();
90 var offset = Math.min(rect.width, rect.height) / 2; 89 var offset = Math.min(rect.width, rect.height) / 2;
91 x = rect.left + offset; 90 x = rect.left + offset;
92 y = rect.top + offset; 91 y = rect.top + offset;
93 } else { 92 } else {
94 x = e.clientX; 93 x = e.clientX;
95 y = e.clientY; 94 y = e.clientY;
96 } 95 }
97 96
98 positionPopupAtPoint(x, y, menu); 97 cr.ui.positionPopupAtPoint(x, y, menu);
99 }, 98 },
100 99
101 /** 100 /**
102 * Handles event callbacks. 101 * Handles event callbacks.
103 * @param {!Event} e The event object. 102 * @param {!Event} e The event object.
104 */ 103 */
105 handleEvent: function(e) { 104 handleEvent: function(e) {
106 // Keep track of keydown state so that we can use that to determine the 105 // Keep track of keydown state so that we can use that to determine the
107 // reason for the contextmenu event. 106 // reason for the contextmenu event.
108 switch (e.type) { 107 switch (e.type) {
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 * The singleton context menu handler. 216 * The singleton context menu handler.
218 * @type {!ContextMenuHandler} 217 * @type {!ContextMenuHandler}
219 */ 218 */
220 var contextMenuHandler = new ContextMenuHandler; 219 var contextMenuHandler = new ContextMenuHandler;
221 220
222 // Export 221 // Export
223 return { 222 return {
224 contextMenuHandler: contextMenuHandler 223 contextMenuHandler: contextMenuHandler
225 }; 224 };
226 }); 225 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698