summaryrefslogtreecommitdiffstats
path: root/chrome/browser/resources/options.html
blob: 8bdec6431995f70a2f4094d7cdbcf9242e92bb61 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
<!DOCTYPE HTML>
<html i18n-values="dir:textdirection;" id="t">
<head>
<meta charset="utf-8">
<title i18n-content="title"></title>
<link rel="icon" href="../../app/theme/history_favicon.png">
<script src="shared/js/local_strings.js"></script>
<script>
///////////////////////////////////////////////////////////////////////////////
// Globals:

function $(o) {return document.getElementById(o);}

// Extracts preference value out of reponse callback of fetchPrefs call.
function getPref(dict, name) {
  return eval('dict.'+name);
}

// Sets new value for preference.
function setBooleanPref(name, value) {
  chrome.send('setBooleanPref', [name, String(value)]);
}

function setIntegerPref(name, value) {
  chrome.send('setIntegerPref', [name, String(value)]);
}

function setStringPref(name, value) {
  chrome.send('setStringPref', [name, value]);
}
///////////////////////////////////////////////////////////////////////////////
// Document Functions:
/**
 * Window onload handler, sets up the page.
 */
function load() {
  localStrings = new LocalStrings();
  loadSystemPrefs();
    
  selectPage('system');
  // TODO(zelidrag): preserve first that needs to be shown.
}

function selectPage(name) {
  var page = $(name+'Page');
  var nav = $(name+'PageNav');
  page.style.visibility = 'visible';
  nav.class = 'navbar_item navbar_item_selected';
}

///////////////////////////////////////////////////////////////////////////////
// System (ChromeOS) Functions:

var kTimeZone = 'settings.datetime.timezone';
var kTapToClickEnabled = 'settings.touchpad.enable_tap_to_click';
var kVertEdgeScrollEnabled = 'settings.touchpad.enable_vert_edge_scroll';
var kTouchpadSpeedFactor = 'settings.touchpad.speed_factor';
var kTouchpadSensitivity = 'settings.touchpad.sensitivity';
var kAccessibilityEnabled = 'settings.accessibility';
       
/**
 * Loads ChromeOS System preferences.
 */
function loadSystemPrefs() {
  chrome.send("fetchPrefs", ['systemPrefsFetched', '',
                             kTimeZone,
                             kTapToClickEnabled,
                             kVertEdgeScrollEnabled,
                             kTouchpadSpeedFactor,
                             kTouchpadSensitivity,
                             kAccessibilityEnabled]);
}

function setupTimezones(selectedValue) {
  timezoneSel = $('timezoneSel');
  for (key in templateData.timezoneMap) {
    var selected = key == selectedValue;
    timezoneSel.options[timezoneSel.options.length] =
        new Option(templateData.timezoneMap[key], key, false, selected);
  }
}

function systemPrefsFetched(context, dict) {
  $('tapToClickChk').checked = getPref(dict, kTapToClickEnabled);
  $('vertScrollChk').checked = getPref(dict, kVertEdgeScrollEnabled);
  $('sensitivityRng').value = getPref(dict, kTouchpadSensitivity);
  $('speedRng').value = getPref(dict, kTouchpadSpeedFactor);
  $('accesibilityChk').checked = getPref(dict, kAccessibilityEnabled);
  setupTimezones(getPref(dict, kTimeZone));
}

function selectChanged(control) {
  if (control.id == 'timezoneSel') {
    setStringPref(kTimeZone, control.options[control.selectedIndex].value);
  }
}

function checkboxChanged(control) {
  if (control.id == 'tapToClickChk') {
    setBooleanPref(kTapToClickEnabled, control.checked);
  } else if (control.id == 'vertScrollChk') {
    setBooleanPref(kVertEdgeScrollEnabled, control.checked);
  } else if (control.id == 'vertScrollChk') {
    setBooleanPref(kTapToClickEnabled, control.checked);
  } else if (control.id == 'accesibilityChk') {
    setBooleanPref(kAccessibilityEnabled, control.checked);
  } 
}

function rangeChanged(control) {
  if (control.id == 'sensitivityRng') {
    setIntegerPref(kTouchpadSensitivity, control.value);
  } else if (control.id == 'speedRng') {
    setIntegerPref(kTouchpadSpeedFactor, control.value);
  }
}

function buttonClicked(control) {
  if (conrol.id == 'languageBtn') {
    // TODO: Open ChromeOS language settings page.
  }
}


</script>
<link rel="stylesheet" href="dom_ui.css">
<!-- TODO(zelidrag) just a temp style placeholder until redesign -->
<style>
.navbar_container {
  border: 1px solid black;
  background-color: #dfdfdf;  
  cursor:pointer;
  font-weight: bold; 
  float:left;
  height: 400px;
  padding: 10px;
  position:relative;
  width: 200px;
}
.navbar_item, .navbar_item2 {
  margin: 5px;
  padding: 5px;
}
.navbar_item_selected {
  background-color: #000000;  
}
.navbar_item_normal {
  background-color: #dfdfdf;  
}
#mainview {
  border: 1px solid black;
  float:left;
  height: 400px;
  width: 600px;
  padding: 10px;
  position:relative;
}
.section {
  margin-top: 10px;
}
.option {
  margin-top: 5px;
}
.section_title {
  font-weight: bold; 
}
.option_control_table {
  padding-left:10px;
}
.navbar2 {
  visibility: hidden;
}
.page {
  visibility: hidden;
}
</style>
</head>
<body onload="load();" i18n-values=".style.fontFamily:fontfamily;.style.fontSize:fontsize">
<div class="header">
</div>
<div class="main">
  <div class="navbar_container">
     <ul class="navbar">
       <li class="navbar_item navbar_item_normal" id="systemPageNav" i18n-values=".innerText:systemPage"></li>
       <li class="navbar_item navbar_item_normal" id="internetPageNav" i18n-values=".innerText:internetPage"></li>
       <li class="navbar_item navbar_item_normal" id="basicsPageNav" i18n-values=".innerText:basicsPage"></li>
       <li class="navbar_item navbar_item_normal" id="personalStuffPageNav" i18n-values=".innerText:personalStuffPage"></li>
       <li class="navbar_item navbar_item_normal" id="underHoodPageNav" i18n-values=".innerText:underHoodPage"></li>
     </ul>
     <hr/>
     <ul class="navbar2">
     </ul>
  </div>
  <div id="mainview">
     <div class="page" id="systemPage">
       <div class="section">
          <div class="section_title" i18n-values=".innerText:datetime_title"></div>
          <div class="option">
             <table class="option_control_table">
             <tr>
               <td class="option_name" i18n-values=".innerText:timezone"></td>
               <td class="option_value">
                 <select id="timezoneSel" class="control timezone_dropdown" onchange="selectChanged(this)"></select>
               </td>
             </tr>
             </table>
          </div>
       </div>
       <div class="section">
          <div class="section_title" i18n-values=".innerText:touchpad"></div>
          <div class="option">
             <table class="option_control_table">
             <tr>
               <td class="option_name" i18n-values=".innerText:sensitivity"></td>
               <td class="option_value">
                 <input id="sensitivityRng" type="range" min="1" max="10" class="touchSlider" style="-webkit-appearance:slider-horizontal;" onchange="rangeChanged(this)">
               </td>
             </tr>
             <tr>
               <td class="option_name" i18n-values=".innerText:speed_factor"></td>
               <td class="option_value">
                 <input id="speedRng" type="range" min="1" max="10" class="touchSlider" style="-webkit-appearance:slider-horizontal;" onchange="rangeChanged(this)">
               </td>
             </tr>
             <tr>
               <td class="option_name" colspan="2"><input id="tapToClickChk" type="checkbox" onchange="checkboxChanged(this)"/><span  i18n-values=".innerText:enable_tap_to_click"></span></td>
             </tr>
             <tr>
               <td class="option_name" colspan="2"><input id="vertScrollChk" type="checkbox" onchange="checkboxChanged(this)"/><span  i18n-values=".innerText:enable_vert_edge_scroll"></span></td>
             </tr>
             </table>
          </div>
       </div>
       <div class="section">
          <div class="section_title" i18n-values=".innerText:language"></div>
          <div class="option">
             <table class="option_control_table">
             <tr>
               <td class="option_name"><button id="languageBtn" onclick="buttonClicked" i18n-values=".innerText:language_customize"></button></td>
             </tr>
             </table>
          </div>
       </div>
       <div class="section">
          <div class="section_title" i18n-values=".innerText:accessibility_title"></div>
          <div class="option">
             <table class="option_control_table">
             <tr>
               <td class="option_name"><input id="accesibilityChk" onchange="checkboxChanged(this)" type="checkbox"/><span  i18n-values=".innerText:accessibility"></span></td>
             </tr>
             </table>
          </div>
       </div>
     </div>
  </div>
</div>
</body>
</html>