| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 Locally managed user creation flow screen. | 6 * @fileoverview Locally managed user creation flow screen. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 login.createScreen('LocallyManagedUserCreationScreen', | 9 login.createScreen('LocallyManagedUserCreationScreen', |
| 10 'managed-user-creation', function() { | 10 'managed-user-creation', function() { |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 * for importing existing users. | 249 * for importing existing users. |
| 250 * @type {Object} | 250 * @type {Object} |
| 251 */ | 251 */ |
| 252 ImportPod.prototype = { | 252 ImportPod.prototype = { |
| 253 __proto__: HTMLDivElement.prototype, | 253 __proto__: HTMLDivElement.prototype, |
| 254 | 254 |
| 255 /** @override */ | 255 /** @override */ |
| 256 decorate: function() { | 256 decorate: function() { |
| 257 // Mousedown has to be used instead of click to be able to prevent 'focus' | 257 // Mousedown has to be used instead of click to be able to prevent 'focus' |
| 258 // event later. | 258 // event later. |
| 259 this.addEventListener('mousedown', | 259 this.addEventListener('mousedown', this.handleMouseDown_.bind(this)); |
| 260 this.handleMouseDown_.bind(this)); | 260 var screen = $('managed-user-creation'); |
| 261 var importList = screen.importList_; |
| 261 }, | 262 }, |
| 262 | 263 |
| 263 /** | 264 /** |
| 264 * Updates UI elements from user data. | 265 * Updates UI elements from user data. |
| 265 */ | 266 */ |
| 266 update: function() { | 267 update: function() { |
| 267 this.imageElement.src = this.user.avatarurl; | 268 this.imageElement.src = this.user.avatarurl; |
| 268 this.nameElement.textContent = this.user.name; | 269 this.nameElement.textContent = this.user.name; |
| 269 if (this.user.exists) { | 270 if (this.user.exists) { |
| 270 if (this.user.conflict == 'imported') { | 271 if (this.user.conflict == 'imported') { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 * UI element for selecting existing supervised user for import. | 324 * UI element for selecting existing supervised user for import. |
| 324 * @type {Object} | 325 * @type {Object} |
| 325 */ | 326 */ |
| 326 ImportPodList.prototype = { | 327 ImportPodList.prototype = { |
| 327 __proto__: HTMLDivElement.prototype, | 328 __proto__: HTMLDivElement.prototype, |
| 328 | 329 |
| 329 selectedPod_: null, | 330 selectedPod_: null, |
| 330 | 331 |
| 331 /** @override */ | 332 /** @override */ |
| 332 decorate: function() { | 333 decorate: function() { |
| 334 this.setAttribute('tabIndex', 0); |
| 335 this.classList.add('nofocus'); |
| 336 var importList = this; |
| 337 var screen = $('managed-user-creation'); |
| 338 |
| 339 this.addEventListener('focus', function(e) { |
| 340 if (importList.selectedPod_ == null) { |
| 341 if (importList.pods.length > 0) |
| 342 importList.selectPod(importList.pods[0]); |
| 343 } |
| 344 }); |
| 345 |
| 346 this.addEventListener('keydown', function(e) { |
| 347 switch (e.keyIdentifier) { |
| 348 case 'Up': |
| 349 importList.selectNextPod(-1); |
| 350 e.stopPropagation(); |
| 351 break; |
| 352 case 'Enter': |
| 353 if (importList.selectedPod_ != null) |
| 354 screen.importSupervisedUser_(); |
| 355 e.stopPropagation(); |
| 356 break; |
| 357 case 'Down': |
| 358 importList.selectNextPod(+1); |
| 359 e.stopPropagation(); |
| 360 break; |
| 361 } |
| 362 }); |
| 333 }, | 363 }, |
| 334 | 364 |
| 335 /** | 365 /** |
| 336 * Returns all the pods in this pod list. | 366 * Returns all the pods in this pod list. |
| 337 * @type {NodeList} | 367 * @type {NodeList} |
| 338 */ | 368 */ |
| 339 get pods() { | 369 get pods() { |
| 340 return this.children; | 370 return this.children; |
| 341 }, | 371 }, |
| 342 | 372 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 } | 432 } |
| 403 this.selectedPod_ = podToSelect; | 433 this.selectedPod_ = podToSelect; |
| 404 for (var i = 0; i < this.pods.length; i++) { | 434 for (var i = 0; i < this.pods.length; i++) { |
| 405 var pod = this.pods[i]; | 435 var pod = this.pods[i]; |
| 406 if (pod != podToSelect) | 436 if (pod != podToSelect) |
| 407 pod.classList.remove('focused'); | 437 pod.classList.remove('focused'); |
| 408 } | 438 } |
| 409 if (!podToSelect) | 439 if (!podToSelect) |
| 410 return; | 440 return; |
| 411 podToSelect.classList.add('focused'); | 441 podToSelect.classList.add('focused'); |
| 442 podToSelect.focus(); |
| 412 var screen = $('managed-user-creation'); | 443 var screen = $('managed-user-creation'); |
| 413 if (!this.selectedPod_) { | 444 if (!this.selectedPod_) { |
| 414 screen.getScreenButton('import').disabled = true; | 445 screen.getScreenButton('import').disabled = true; |
| 415 } else { | 446 } else { |
| 416 screen.getScreenButton('import').disabled = | 447 screen.getScreenButton('import').disabled = |
| 417 this.selectedPod_.user.exists; | 448 this.selectedPod_.user.exists; |
| 418 if (!this.selectedPod_.user.exists) { | 449 if (!this.selectedPod_.user.exists) { |
| 419 chrome.send('userSelectedForImportInManagedUserCreationFlow', | 450 chrome.send('userSelectedForImportInManagedUserCreationFlow', |
| 420 [podToSelect.user.id]); | 451 [podToSelect.user.id]); |
| 421 } | 452 } |
| 422 } | 453 } |
| 423 }, | 454 }, |
| 424 | 455 |
| 456 selectNextPod: function(direction) { |
| 457 if (!this.selectedPod_) |
| 458 return false; |
| 459 var index = -1; |
| 460 for (var i = 0, pod; pod = this.pods[i]; ++i) { |
| 461 if (pod == this.selectedPod_) { |
| 462 index = i; |
| 463 break; |
| 464 } |
| 465 } |
| 466 if (-1 == index) |
| 467 return false; |
| 468 index = index + direction; |
| 469 if (index < 0 || index >= this.pods.length) |
| 470 return false; |
| 471 this.selectPod(this.pods[index]); |
| 472 return true; |
| 473 }, |
| 474 |
| 425 selectUser: function(user_id) { | 475 selectUser: function(user_id) { |
| 426 for (var i = 0, pod; pod = this.pods[i]; ++i) { | 476 for (var i = 0, pod; pod = this.pods[i]; ++i) { |
| 427 if (pod.user.id == user_id) { | 477 if (pod.user.id == user_id) { |
| 428 this.selectPod(pod); | 478 this.selectPod(pod); |
| 429 this.scrollIntoView(pod); | 479 this.scrollIntoView(pod); |
| 430 break; | 480 break; |
| 431 } | 481 } |
| 432 } | 482 } |
| 433 }, | 483 }, |
| 434 }; | 484 }; |
| (...skipping 1073 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1508 | 1558 |
| 1509 if (userList.length == 1) | 1559 if (userList.length == 1) |
| 1510 this.importList_.selectPod(this.managerList_.pods[0]); | 1560 this.importList_.selectPod(this.managerList_.pods[0]); |
| 1511 | 1561 |
| 1512 if (userList.length > 0 && this.currentPage_ == 'username') | 1562 if (userList.length > 0 && this.currentPage_ == 'username') |
| 1513 this.getScreenElement('import-link').hidden = false; | 1563 this.getScreenElement('import-link').hidden = false; |
| 1514 }, | 1564 }, |
| 1515 }; | 1565 }; |
| 1516 }); | 1566 }); |
| 1517 | 1567 |
| OLD | NEW |