Chromium Code Reviews| Index: chrome/browser/resources/new_profile.js |
| diff --git a/chrome/browser/resources/new_profile.js b/chrome/browser/resources/new_profile.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..ffbd9a3e7e457595ad7af7317021213a2520b3af |
| --- /dev/null |
| +++ b/chrome/browser/resources/new_profile.js |
| @@ -0,0 +1,79 @@ |
| +// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +var gSelectedAvatarIconIndex = 0; |
| + |
| +/////////////////////////////////////////////////////////////////////////////// |
| +// Helper functions |
| +function $(o) {return document.getElementById(o);} |
| + |
| +function load() { |
| + chrome.send('requestProfileInfo', []); |
| + updateLogo(); |
| +} |
| + |
| +function onCreate() { |
| + chrome.send('create', [$('profile-name').value, |
| + String(gSelectedAvatarIconIndex)]); |
| + return false; |
|
Miranda Callahan
2011/06/27 16:42:08
Not sure why we're returning "false" here, and in
sail
2011/06/27 17:37:24
Done.
Oops, left over code from when I was using t
|
| +} |
| + |
| +function onCancel() { |
| + chrome.send('cancel', []); |
| + return false; |
|
Miranda Callahan
2011/06/27 16:42:08
see comment above.
sail
2011/06/27 17:37:24
Done.
|
| +} |
| + |
| +function onAvatarClicked(index) { |
| + var menu = document.getElementById("avatar-menu"); |
| + for (var i = 0; i < menu.childNodes.length; i++) { |
| + var button = menu.childNodes[i]; |
| + if (i == index) { |
| + button.setAttribute("style", "background-color: blue"); |
| + } else { |
| + button.setAttribute("style", "background-color: transparent"); |
| + } |
| + } |
| + gSelectedAvatarIconIndex = index; |
| +} |
| + |
| +function updateLogo() { |
| + var imageId = 'IDR_PRODUCT_LOGO'; |
| + if (document.documentElement.getAttribute('customlogo') == 'true') |
| + imageId = 'IDR_CUSTOM_PRODUCT_LOGO'; |
| + |
| + $('logo-img').src = 'chrome://theme/' + imageId + '?' + Date.now(); |
| +} |
| + |
| +/////////////////////////////////////////////////////////////////////////////// |
| +// Chrome callbacks: |
| + |
| +function setProfileInfo(profileName, profileIconIndex) { |
| + $('profile-name').value = profileName; |
| + onAvatarClicked(profileIconIndex); |
| +} |
| + |
| +function setDefaultAvatarImages(imageUrlList) { |
| + var menu = document.getElementById("avatar-menu"); |
| + for (var i = 0; i < imageUrlList.length; i++) { |
| + var button = document.createElement("input"); |
| + button.setAttribute("type", "image"); |
| + button.setAttribute("class", "avatar-button"); |
| + button.setAttribute("src", imageUrlList[i]); |
| + button.setAttribute("onclick", "onAvatarClicked(" + i + ")"); |
| + menu.appendChild(button); |
| + } |
| +} |
| + |
| +function themeChanged() { |
|
Miranda Callahan
2011/06/27 16:42:08
Is this for future use?
sail
2011/06/27 17:37:24
Yea, I removed this and add a TODO in the .cc code
|
| + updateLogo(); |
| +} |
| + |
| +// Add handlers to HTML elements. |
| +document.body.onload = load; |
| +$('create-button').onclick = function () { onCreate(''); }; |
| +$('cancel-button').onclick = function () { onCancel(''); }; |
| +$('profile-name-form').onsubmit = function () { |
| + onCreate(''); |
| + return false; |
|
Miranda Callahan
2011/06/27 16:42:08
again, should this be returning false?
sail
2011/06/27 17:37:24
Yea, this has to return false so that the submit h
Miranda Callahan
2011/06/30 22:31:46
Can you add a comment to just clarify that for fut
sail
2011/06/30 22:38:15
Done.
|
| +}; |