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

Side by Side Diff: ui/webui/resources/js/cr/ui/menu.js

Issue 1058873009: Bookmark manager: Pass in explicit targets to the delete and rename commands. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Created 5 years, 8 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
OLDNEW
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 6
7 /** @const */ var MenuItem = cr.ui.MenuItem; 7 /** @const */ var MenuItem = cr.ui.MenuItem;
8 8
9 /** 9 /**
10 * Creates a new menu element. Menu dispatches all commands on the element it 10 * Creates a new menu element. Menu dispatches all commands on the element it
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 selectNextAvailable(1); 214 selectNextAvailable(1);
215 this.focusSelectedItem(); 215 this.focusSelectedItem();
216 return true; 216 return true;
217 case 'Up': 217 case 'Up':
218 selectNextAvailable(-1); 218 selectNextAvailable(-1);
219 this.focusSelectedItem(); 219 this.focusSelectedItem();
220 return true; 220 return true;
221 case 'Enter': 221 case 'Enter':
222 case 'U+0020': // Space 222 case 'U+0020': // Space
223 if (item) { 223 if (item) {
224 // Store |contextElement| since it'll be removed when handling the
225 // 'activate' event.
226 var contextElement = this.contextElement;
224 var activationEvent = cr.doc.createEvent('Event'); 227 var activationEvent = cr.doc.createEvent('Event');
225 activationEvent.initEvent('activate', true, true); 228 activationEvent.initEvent('activate', true, true);
226 activationEvent.originalEvent = e; 229 activationEvent.originalEvent = e;
227 if (item.dispatchEvent(activationEvent)) { 230 if (item.dispatchEvent(activationEvent)) {
228 if (item.command) 231 if (item.command)
229 item.command.execute(); 232 item.command.execute(contextElement);
230 } 233 }
231 } 234 }
232 return true; 235 return true;
233 } 236 }
234 237
235 return false; 238 return false;
236 }, 239 },
237 240
238 /** 241 /**
239 * Updates menu items command according to context. 242 * Updates menu items command according to context.
(...skipping 30 matching lines...) Expand all
270 /** 273 /**
271 * Selector for children which are menu items. 274 * Selector for children which are menu items.
272 */ 275 */
273 cr.defineProperty(Menu, 'menuItemSelector', cr.PropertyKind.ATTR); 276 cr.defineProperty(Menu, 'menuItemSelector', cr.PropertyKind.ATTR);
274 277
275 // Export 278 // Export
276 return { 279 return {
277 Menu: Menu 280 Menu: Menu
278 }; 281 };
279 }); 282 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698