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

Side by Side Diff: chrome/browser/resources/options2/chromeos/network_list.js

Issue 10174013: Fix scrolling of network menus. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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('options.network', function() { 5 cr.define('options.network', function() {
6 6
7 var ArrayDataModel = cr.ui.ArrayDataModel; 7 var ArrayDataModel = cr.ui.ArrayDataModel;
8 var List = cr.ui.List; 8 var List = cr.ui.List;
9 var ListItem = cr.ui.ListItem; 9 var ListItem = cr.ui.ListItem;
10 var Menu = cr.ui.Menu; 10 var Menu = cr.ui.Menu;
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 Menu.decorate(menu); 285 Menu.decorate(menu);
286 for (var i = 0; i < this.data.menu.length; i++) { 286 for (var i = 0; i < this.data.menu.length; i++) {
287 var entry = this.data.menu[i]; 287 var entry = this.data.menu[i];
288 var button = this.ownerDocument.createElement('div'); 288 var button = this.ownerDocument.createElement('div');
289 button.className = 'network-menu-item'; 289 button.className = 'network-menu-item';
290 var buttonLabel = this.ownerDocument.createElement('div'); 290 var buttonLabel = this.ownerDocument.createElement('div');
291 buttonLabel.className = 'network-menu-item-label'; 291 buttonLabel.className = 'network-menu-item-label';
292 buttonLabel.textContent = entry.label; 292 buttonLabel.textContent = entry.label;
293 button.appendChild(buttonLabel); 293 button.appendChild(buttonLabel);
294 button.addEventListener('click', entry.command); 294 button.addEventListener('click', entry.command);
295 button.addEventListener('mousedown', function(e) {
296 // Prevent blurring of list, which would close the menu.
297 e.preventDefault();
298 });
299 MenuItem.decorate(button); 295 MenuItem.decorate(button);
300 menu.appendChild(button); 296 menu.appendChild(button);
301 } 297 }
302 return menu; 298 return menu;
303 } 299 }
304 return null; 300 return null;
305 }, 301 },
306 302
307 /** 303 /**
308 * Displays a popup menu. 304 * Displays a popup menu.
309 */ 305 */
310 showMenu: function() { 306 showMenu: function() {
311 var rebuild = false; 307 var rebuild = false;
312 if (!this.menu_) { 308 if (!this.menu_) {
313 rebuild = true; 309 rebuild = true;
314 var existing = $(this.getMenuName_()); 310 var existing = $(this.getMenuName_());
315 if (existing) 311 if (existing)
316 closeMenu_(); 312 closeMenu_();
317 this.menu_ = this.createMenu(); 313 this.menu_ = this.createMenu();
314 this.menu_.addEventListener('mousedown', function(e) {
315 // Prevent blurring of list, which would close the menu.
316 e.preventDefault();
317 }, true);
318 var parent = $('network-menus'); 318 var parent = $('network-menus');
319 if (existing) 319 if (existing)
320 parent.replaceChild(this.menu_, existing); 320 parent.replaceChild(this.menu_, existing);
321 else 321 else
322 parent.appendChild(this.menu_); 322 parent.appendChild(this.menu_);
323 } 323 }
324 var top = this.offsetTop + this.clientHeight; 324 var top = this.offsetTop + this.clientHeight;
325 var menuId = this.getMenuName_(); 325 var menuId = this.getMenuName_();
326 if (menuId != activeMenu_ || rebuild) { 326 if (menuId != activeMenu_ || rebuild) {
327 closeMenu_(); 327 closeMenu_();
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 chrome.send('buttonClickCallback', 563 chrome.send('buttonClickCallback',
564 [type, path, command]); 564 [type, path, command]);
565 closeMenu_(); 565 closeMenu_();
566 }; 566 };
567 } else if (command != null) { 567 } else if (command != null) {
568 callback = function() { 568 callback = function() {
569 command(data); 569 command(data);
570 closeMenu_(); 570 closeMenu_();
571 }; 571 };
572 } 572 }
573 if (callback != null) { 573 if (callback != null)
574 button.addEventListener('click', callback); 574 button.addEventListener('click', callback);
575 button.addEventListener('mousedown', function(e) { 575 else
576 // Prevent blurring of list, which would close the menu.
577 e.preventDefault();
578 });
579 } else {
580 buttonLabel.classList.add('network-disabled-control'); 576 buttonLabel.classList.add('network-disabled-control');
581 }
582 MenuItem.decorate(button); 577 MenuItem.decorate(button);
583 menu.appendChild(button); 578 menu.appendChild(button);
584 return button; 579 return button;
585 }, 580 },
586 581
587 /** 582 /**
588 * Adds a menu item for connecting to a network. 583 * Adds a menu item for connecting to a network.
589 * @param {!Element} menu Parent menu. 584 * @param {!Element} menu Parent menu.
590 * @param {Object} data Description of the network. 585 * @param {Object} data Description of the network.
591 * @param {string=} opt_connect Optional connection method. 586 * @param {string=} opt_connect Optional connection method.
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
1000 * Whether the Network list is disabled. Only used for display purpose. 995 * Whether the Network list is disabled. Only used for display purpose.
1001 * @type {boolean} 996 * @type {boolean}
1002 */ 997 */
1003 cr.defineProperty(NetworkList, 'disabled', cr.PropertyKind.BOOL_ATTR); 998 cr.defineProperty(NetworkList, 'disabled', cr.PropertyKind.BOOL_ATTR);
1004 999
1005 // Export 1000 // Export
1006 return { 1001 return {
1007 NetworkList: NetworkList 1002 NetworkList: NetworkList
1008 }; 1003 };
1009 }); 1004 });
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698