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

Side by Side Diff: chrome/browser/resources/chromeos/login/network_dropdown.js

Issue 14827004: cros: Arrow key traversal in views. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 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) 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 /** 5 /**
6 * @fileoverview Network drop-down implementation. 6 * @fileoverview Network drop-down implementation.
7 */ 7 */
8 8
9 cr.define('cr.ui', function() { 9 cr.define('cr.ui', function() {
10 /** 10 /**
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 }); 287 });
288 288
289 el.addEventListener('keydown', function f(e) { 289 el.addEventListener('keydown', function f(e) {
290 if (this.inFocus && !this.controller.isShown && 290 if (this.inFocus && !this.controller.isShown &&
291 (e.keyCode == DropDown.KEYCODE_ENTER || 291 (e.keyCode == DropDown.KEYCODE_ENTER ||
292 e.keyCode == DropDown.KEYCODE_SPACE || 292 e.keyCode == DropDown.KEYCODE_SPACE ||
293 e.keyCode == DropDown.KEYCODE_UP || 293 e.keyCode == DropDown.KEYCODE_UP ||
294 e.keyCode == DropDown.KEYCODE_DOWN)) { 294 e.keyCode == DropDown.KEYCODE_DOWN)) {
295 this.opening = true; 295 this.opening = true;
296 this.controller.isShown = true; 296 this.controller.isShown = true;
297 e.stopPropagation();
298 e.preventDefault();
297 } 299 }
298 }); 300 });
299 return el; 301 return el;
300 }, 302 },
301 303
302 /** 304 /**
303 * Handles keydown event from the keyboard. 305 * Handles keydown event from the keyboard.
304 * @private 306 * @private
305 * @param {!Event} e Keydown event. 307 * @param {!Event} e Keydown event.
306 */ 308 */
307 keyDownHandler_: function(e) { 309 keyDownHandler_: function(e) {
308 if (!this.isShown) 310 if (!this.isShown)
309 return; 311 return;
310 var selected = this.container.selectedItem; 312 var selected = this.container.selectedItem;
313 var handled = false;
311 switch (e.keyCode) { 314 switch (e.keyCode) {
312 case DropDown.KEYCODE_UP: { 315 case DropDown.KEYCODE_UP: {
313 do { 316 do {
314 selected = selected.previousSibling; 317 selected = selected.previousSibling;
315 if (!selected) 318 if (!selected)
316 selected = this.container.lastElementChild; 319 selected = this.container.lastElementChild;
317 } while (selected.iid < 0); 320 } while (selected.iid < 0);
318 this.container.selectItem(selected, false); 321 this.container.selectItem(selected, false);
322 handled = true;
319 break; 323 break;
320 } 324 }
321 case DropDown.KEYCODE_DOWN: { 325 case DropDown.KEYCODE_DOWN: {
322 do { 326 do {
323 selected = selected.nextSibling; 327 selected = selected.nextSibling;
324 if (!selected) 328 if (!selected)
325 selected = this.container.firstItem; 329 selected = this.container.firstItem;
326 } while (selected.iid < 0); 330 } while (selected.iid < 0);
327 this.container.selectItem(selected, false); 331 this.container.selectItem(selected, false);
332 handled = true;
328 break; 333 break;
329 } 334 }
330 case DropDown.KEYCODE_ESC: { 335 case DropDown.KEYCODE_ESC: {
331 this.isShown = false; 336 this.isShown = false;
337 handled = true;
332 break; 338 break;
333 } 339 }
334 case DropDown.KEYCODE_TAB: { 340 case DropDown.KEYCODE_TAB: {
335 this.isShown = false; 341 this.isShown = false;
342 handled = true;
336 break; 343 break;
337 } 344 }
338 case DropDown.KEYCODE_ENTER: { 345 case DropDown.KEYCODE_ENTER: {
339 if (!this.title_.opening) { 346 if (!this.title_.opening) {
340 this.title_.focus(); 347 this.title_.focus();
341 this.isShown = false; 348 this.isShown = false;
342 var item = 349 var item =
343 this.title_.controller.container.selectedItem.lastElementChild; 350 this.title_.controller.container.selectedItem.lastElementChild;
344 if (item.iid >= 0 && !item.classList.contains('disabled-item')) 351 if (item.iid >= 0 && !item.classList.contains('disabled-item'))
345 chrome.send('networkItemChosen', [item.iid]); 352 chrome.send('networkItemChosen', [item.iid]);
346 } 353 }
354 handled = true;
347 break; 355 break;
348 } 356 }
349 } 357 }
358 if (handled) {
359 e.stopPropagation();
360 e.preventDefault();
361 }
350 this.title_.opening = false; 362 this.title_.opening = false;
351 } 363 }
352 }; 364 };
353 365
354 /** 366 /**
355 * Updates networks list with the new data. 367 * Updates networks list with the new data.
356 * @param {!Object} data Networks list. 368 * @param {!Object} data Networks list.
357 */ 369 */
358 DropDown.updateNetworks = function(data) { 370 DropDown.updateNetworks = function(data) {
359 if (DropDown.activeElementId_) 371 if (DropDown.activeElementId_)
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 * Refreshes network drop-down. Should be called on language change. 415 * Refreshes network drop-down. Should be called on language change.
404 */ 416 */
405 DropDown.refresh = function() { 417 DropDown.refresh = function() {
406 chrome.send('networkDropdownRefresh'); 418 chrome.send('networkDropdownRefresh');
407 }; 419 };
408 420
409 return { 421 return {
410 DropDown: DropDown 422 DropDown: DropDown
411 }; 423 };
412 }); 424 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698