Upstream version 8.37.180.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / resources / options / chromeos / keyboard_overlay.js
1 // Copyright (c) 2012 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
7   /**
8    * Encapsulated handling of the keyboard overlay.
9    * @constructor
10    */
11   function KeyboardOverlay() {
12     options.SettingsDialog.call(this, 'keyboard-overlay',
13         loadTimeData.getString('keyboardOverlayTitle'),
14         'keyboard-overlay',
15         $('keyboard-confirm'), $('keyboard-cancel'));
16   }
17
18   cr.addSingletonGetter(KeyboardOverlay);
19
20   KeyboardOverlay.prototype = {
21     __proto__: options.SettingsDialog.prototype,
22
23     /**
24      * Initializes the page. This method is called in initialize.
25      */
26     initializePage: function() {
27       options.SettingsDialog.prototype.initializePage.call(this);
28
29       $('languages-and-input-settings').onclick = function(e) {
30         OptionsPage.navigateToPage('languages');
31         chrome.send('coreOptionsUserMetricsAction',
32                     ['Options_KeyboardShowLanguageSettings']);
33       };
34
35       $('keyboard-shortcuts').onclick = function(e) {
36         chrome.send('showKeyboardShortcuts');
37         chrome.send('coreOptionsUserMetricsAction',
38                     ['Options_KeyboardShowKeyboardShortcuts']);
39       };
40     },
41
42     /**
43      * Show/hide the caps lock remapping section.
44      * @private
45      */
46     showCapsLockOptions_: function(show) {
47       $('caps-lock-remapping-section').hidden = !show;
48     },
49
50     /**
51      * Show/hide the diamond key remapping section.
52      * @private
53      */
54     showDiamondKeyOptions_: function(show) {
55       $('diamond-key-remapping-section').hidden = !show;
56     },
57   };
58
59   // Forward public APIs to private implementations.
60   [
61     'showCapsLockOptions',
62     'showDiamondKeyOptions',
63   ].forEach(function(name) {
64     KeyboardOverlay[name] = function() {
65       var instance = KeyboardOverlay.getInstance();
66       return instance[name + '_'].apply(instance, arguments);
67     };
68   });
69
70   // Export
71   return {
72     KeyboardOverlay: KeyboardOverlay
73   };
74 });