 Chromium Code Reviews
 Chromium Code Reviews Issue 7256002:
  Multi-Profiles: New Profile Setup UI  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src
    
  
    Issue 7256002:
  Multi-Profiles: New Profile Setup UI  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src| OLD | NEW | 
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 
Evan Stade
2011/07/01 20:33:18
namespace everything in this file
 | |
| 5 // Tracks the currently selected avatar icon. | |
| 6 var gSelectedAvatarIconIndex = 0; | |
| 
Evan Stade
2011/07/01 20:33:18
I don't think this is the right variable naming st
 | |
| 7 | |
| 8 // Initializes everything once the document loads. | |
| 9 function load() { | |
| 10 // Allow platform specific CSS rules. | |
| 11 cr.enablePlatformSpecificCSSRules(); | |
| 12 | |
| 13 // Add handlers to HTML elements. | |
| 14 $('create-button').onclick = function () { onCreate(); }; | |
| 
Evan Stade
2011/07/01 20:33:18
simply onclick = onCreate
 
sail
2011/07/01 23:47:04
Done.
 | |
| 15 $('cancel-button').onclick = function () { onCancel(); }; | |
| 16 $('profile-name-form').onsubmit = function () { | |
| 17 onCreate(); | |
| 18 // Return false to prevent the submit handler from doing a post. | |
| 19 return false; | |
| 20 }; | |
| 21 | |
| 22 chrome.send('requestProfileInfo'); | |
| 23 updateLogo(); | |
| 24 $('profile-name').focus(); | |
| 25 } | |
| 26 | |
| 27 // Sends the profile information to the browser. | |
| 28 function onCreate() { | |
| 29 chrome.send('create', [$('profile-name').value, | |
| 30 String(gSelectedAvatarIconIndex)]); | |
| 31 } | |
| 32 | |
| 33 // Lets the browser know that the user doesn't want to create the profile. | |
| 34 function onCancel() { | |
| 35 chrome.send('cancel'); | |
| 36 } | |
| 37 | |
| 38 // Changes the selected profile. | |
| 39 function onAvatarClicked(index) { | |
| 40 var menu = $('avatar-menu'); | |
| 41 for (var i = 0; i < menu.childNodes.length; i++) { | |
| 42 var button = menu.childNodes[i]; | |
| 43 if (i == index) | |
| 44 button.classList.add("avatar-button-selected"); | |
| 45 else | |
| 46 button.classList.remove("avatar-button-selected"); | |
| 47 } | |
| 48 gSelectedAvatarIconIndex = index; | |
| 49 } | |
| 50 | |
| 51 // Sets the logo image. | |
| 52 function updateLogo() { | |
| 53 var imageId = 'IDR_PRODUCT_LOGO'; | |
| 54 if (document.documentElement.getAttribute('customlogo') == 'true') | |
| 55 imageId = 'IDR_CUSTOM_PRODUCT_LOGO'; | |
| 56 | |
| 57 $('logo-img').src = 'chrome://theme/' + imageId + '?' + Date.now(); | |
| 58 } | |
| 59 | |
| 60 // Callback from the browser to set the profile information on the page. | |
| 61 function setProfileInfo(profileName, profileIconIndex) { | |
| 62 $('profile-name').value = profileName; | |
| 63 onAvatarClicked(profileIconIndex); | |
| 64 } | |
| 65 | |
| 66 // Callback from the browser to fill the avatar menu with default avatar | |
| 67 // images. | |
| 68 function setDefaultAvatarImages(imageUrlList) { | |
| 69 var menu = $('avatar-menu'); | |
| 70 for (var i = 0; i < imageUrlList.length; i++) { | |
| 71 var button = document.createElement("input"); | |
| 72 button.setAttribute("type", "image"); | |
| 73 button.setAttribute("class", "avatar-button"); | |
| 74 button.setAttribute("src", imageUrlList[i]); | |
| 75 button.setAttribute("onclick", "onAvatarClicked(" + i + ")"); | |
| 76 menu.appendChild(button); | |
| 77 } | |
| 78 } | |
| 79 | |
| 80 window.addEventListener('DOMContentLoaded', load); | |
| OLD | NEW |