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