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

Side by Side Diff: chrome/browser/resources/options/chromeos/virtual_keyboard.js

Issue 9814030: get rid of old options pages (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more fixes Created 8 years, 9 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
(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
5 cr.define('options', function() {
6 const OptionsPage = options.OptionsPage;
7
8 /////////////////////////////////////////////////////////////////////////////
9 // VirtualKeyboardManager class:
10
11 /**
12 * Virtual keyboard management page.
13 * @constructor
14 */
15 function VirtualKeyboardManager() {
16 this.activeNavTab = null;
17 OptionsPage.call(this,
18 'virtualKeyboards',
19 // The templateData.virtualKeyboardPageTabTitle is added
20 // in OptionsPageUIHandler::RegisterTitle().
21 templateData.virtualKeyboardPageTabTitle,
22 'virtual-keyboard-manager');
23 }
24
25 cr.addSingletonGetter(VirtualKeyboardManager);
26
27 VirtualKeyboardManager.prototype = {
28 __proto__: OptionsPage.prototype,
29
30 /**
31 * The virtual keyboards list.
32 * @type {ItemList}
33 * @private
34 */
35 virtualKeyboardsList_: null,
36
37 /** @inheritDoc */
38 initializePage: function() {
39 OptionsPage.prototype.initializePage.call(this);
40 this.createVirtualKeyboardsList_();
41 },
42
43 /** @inheritDoc */
44 didShowPage: function() {
45 chrome.send('updateVirtualKeyboardList');
46 },
47
48 /**
49 * Creates, decorates and initializes the keyboards list.
50 * @private
51 */
52 createVirtualKeyboardsList_: function() {
53 this.virtualKeyboardsList_ = $('virtual-keyboard-per-layout-list');
54 options.VirtualKeyboardsList.decorate(this.virtualKeyboardsList_);
55 this.virtualKeyboardsList_.autoExpands = true;
56 },
57 };
58
59 /**
60 * Sets the list of virtual keyboards shown in the view. This function is
61 * called by C++ code (e.g. chrome/browser/ui/webui/options/chromeos/).
62 * @param {Object} list A list of layouts with their registered virtual
63 * keyboards.
64 */
65 VirtualKeyboardManager.updateVirtualKeyboardList = function(list) {
66 // See virtual_keyboard_list.js for an example of the format the list should
67 // take.
68 var filteredList = list.filter(function(element, index, array) {
69 // Don't show a layout which is supported by only one virtual keyboard
70 // extension.
71 return element.supportedKeyboards.length > 1;
72 });
73
74 // Sort the drop-down menu items by name.
75 filteredList.forEach(function(e) {
76 e.supportedKeyboards.sort(function(e1, e2) {
77 return e1.name > e2.name;
78 });
79 });
80
81 // Sort the list by layout name.
82 $('virtual-keyboard-per-layout-list').setVirtualKeyboardList(
83 filteredList.sort(function(e1, e2) {
84 return e1.layoutName > e2.layoutName;
85 }));
86 };
87
88 // Export
89 return {
90 VirtualKeyboardManager: VirtualKeyboardManager,
91 };
92 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698