| Index: chrome/browser/resources/user_chooser/user_chooser.js
|
| diff --git a/chrome/browser/resources/user_chooser/user_chooser.js b/chrome/browser/resources/user_chooser/user_chooser.js
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..33b8090ef4515124d170321a0549313cb454bb97
|
| --- /dev/null
|
| +++ b/chrome/browser/resources/user_chooser/user_chooser.js
|
| @@ -0,0 +1,59 @@
|
| +// Copyright (c) 2012 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.
|
| +<include src="user_chooser_common.js"></include>
|
| +
|
| +cr.define('UserChooser', function() {
|
| + 'use strict';
|
| +
|
| + /**
|
| + * Setups given "select" element using the list and adds callback.
|
| + * @param {!Element} select Select object to be updated.
|
| + * @param {!Object} list List of the options to be added.
|
| + * @param {string} callback Callback name which should be send to Chrome or
|
| + * an empty string if the event listener shouldn't be added.
|
| + */
|
| + function setupSelect(select, list, callback) {
|
| + select.options.length = 0;
|
| + for (var i = 0; i < list.length; ++i) {
|
| + var item = list[i];
|
| + var option =
|
| + new Option(item.title, item.value, item.selected, item.selected);
|
| + select.appendChild(option);
|
| + }
|
| + if (callback) {
|
| + var sendCallback = function() {
|
| + chrome.send(callback, [select.options[select.selectedIndex].value]);
|
| + };
|
| + select.addEventListener('blur', sendCallback);
|
| + select.addEventListener('click', sendCallback);
|
| + select.addEventListener('keyup', function(event) {
|
| + var keycodeInterested = [
|
| + 9, // Tab
|
| + 13, // Enter
|
| + 27, // Escape
|
| + ];
|
| + if (keycodeInterested.indexOf(event.keyCode) >= 0)
|
| + sendCallback();
|
| + });
|
| + }
|
| + }
|
| +
|
| + function initialize() {
|
| + login.AccountPickerScreen.register();
|
| + login.GaiaSigninScreen.register();
|
| +
|
| + cr.ui.Bubble.decorate($('bubble'));
|
| + login.HeaderBar.decorate($('login-header-bar'));
|
| +
|
| + chrome.send('userChooserInitialize');
|
| + }
|
| +
|
| + // Return an object with all of the exports.
|
| + return {
|
| + initialize: initialize,
|
| + setupSelect: setupSelect
|
| + };
|
| +});
|
| +
|
| +document.addEventListener('DOMContentLoaded', UserChooser.initialize);
|
|
|