Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / resources / options / chromeos / pointer_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   /** @const */ var SettingsDialog = options.SettingsDialog;
7
8   /**
9    * PointerOverlay class
10    * Dialog that allows users to set pointer settings (touchpad/mouse).
11    * @extends {SettingsDialog}
12    */
13   function PointerOverlay() {
14     // The title is updated dynamically in the setTitle method as pointer
15     // devices are discovered or removed.
16     SettingsDialog.call(this, 'pointer-overlay',
17                         '', 'pointer-overlay',
18                         $('pointer-overlay-confirm'),
19                         $('pointer-overlay-cancel'));
20   }
21
22   cr.addSingletonGetter(PointerOverlay);
23
24   PointerOverlay.prototype = {
25     __proto__: SettingsDialog.prototype,
26   };
27
28   /**
29    * Sets the visibility state of the touchpad group.
30    * @param {boolean} show True to show, false to hide.
31    */
32   PointerOverlay.showTouchpadControls = function(show) {
33     $('pointer-section-touchpad').hidden = !show;
34   };
35
36   /**
37    * Sets the visibility state of the mouse group.
38    * @param {boolean} show True to show, false to hide.
39    */
40   PointerOverlay.showMouseControls = function(show) {
41     $('pointer-section-mouse').hidden = !show;
42   };
43
44   /**
45    * Updates the title of the pointer dialog.  The title is set dynamically
46    * based on whether a touchpad, mouse or both are present.  The label on the
47    * button that activates the overlay is also updated to stay in sync. A
48    * message is displayed in the main settings page if no pointer devices are
49    * available.
50    * @param {string} label i18n key for the overlay title.
51    */
52   PointerOverlay.setTitle = function(label) {
53     var button = $('pointer-settings-button');
54     var noPointersLabel = $('no-pointing-devices');
55     if (label.length > 0) {
56       var title = loadTimeData.getString(label);
57       button.textContent = title;
58       button.hidden = false;
59       noPointersLabel.hidden = true;
60     } else {
61       button.hidden = true;
62       noPointersLabel.hidden = false;
63     }
64   };
65
66   // Export
67   return {
68     PointerOverlay: PointerOverlay
69   };
70 });