OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Redefine '$' here rather than including 'cr.js', since this is | 5 // Redefine '$' here rather than including 'cr.js', since this is |
6 // the only function needed. This allows this file to be loaded | 6 // the only function needed. This allows this file to be loaded |
7 // in a browser directly for layout and some testing purposes. | 7 // in a browser directly for layout and some testing purposes. |
8 var $ = function(id) { return document.getElementById(id); }; | 8 var $ = function(id) { return document.getElementById(id); }; |
9 | 9 |
10 /** | 10 /** |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 chrome.send('resetPreferenceValue', [this.prefix + prefName]); | 132 chrome.send('resetPreferenceValue', [this.prefix + prefName]); |
133 } | 133 } |
134 }; | 134 }; |
135 | 135 |
136 /** | 136 /** |
137 * Returns a GeneralConfig for configuring gestures.* preferences. | 137 * Returns a GeneralConfig for configuring gestures.* preferences. |
138 * @return {object} A GeneralConfig object. | 138 * @return {object} A GeneralConfig object. |
139 */ | 139 */ |
140 function GestureConfig() { | 140 function GestureConfig() { |
141 /** The title of the section for the gesture preferences. **/ | 141 /** The title of the section for the gesture preferences. **/ |
142 /** @const */ var GESTURE_TITLE = 'Gesture Properties'; | 142 /** @const */ var GESTURE_TITLE = 'Gesture Configuration'; |
143 | 143 |
144 /** Common prefix of gesture preferences. **/ | 144 /** Common prefix of gesture preferences. **/ |
145 /** @const */ var GESTURE_PREFIX = 'gesture.'; | 145 /** @const */ var GESTURE_PREFIX = 'gesture.'; |
146 | 146 |
147 /** List of fields used to dynamically build form. **/ | 147 /** List of fields used to dynamically build form. **/ |
148 var GESTURE_FIELDS = [ | 148 var GESTURE_FIELDS = [ |
149 { | 149 { |
150 key: 'fling_max_cancel_to_down_time_in_ms', | 150 key: 'fling_max_cancel_to_down_time_in_ms', |
151 label: 'Maximum Cancel to Down Time for Tap Suppression', | 151 label: 'Maximum Cancel to Down Time for Tap Suppression', |
152 units: 'milliseconds', | 152 units: 'milliseconds', |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 ]; | 278 ]; |
279 | 279 |
280 return new GeneralConfig(GESTURE_TITLE, GESTURE_PREFIX, GESTURE_FIELDS); | 280 return new GeneralConfig(GESTURE_TITLE, GESTURE_PREFIX, GESTURE_FIELDS); |
281 } | 281 } |
282 | 282 |
283 /** | 283 /** |
284 * Returns a GeneralConfig for configuring overscroll.* preferences. | 284 * Returns a GeneralConfig for configuring overscroll.* preferences. |
285 * @return {object} A GeneralConfig object. | 285 * @return {object} A GeneralConfig object. |
286 */ | 286 */ |
287 function OverscrollConfig() { | 287 function OverscrollConfig() { |
288 /** @const */ var OVERSCROLL_TITLE = 'Overscroll Properties'; | 288 /** @const */ var OVERSCROLL_TITLE = 'Overscroll Configuration'; |
289 | 289 |
290 /** @const */ var OVERSCROLL_PREFIX = 'overscroll.'; | 290 /** @const */ var OVERSCROLL_PREFIX = 'overscroll.'; |
291 | 291 |
292 var OVERSCROLL_FIELDS = [ | 292 var OVERSCROLL_FIELDS = [ |
293 { | 293 { |
294 key: 'horizontal_threshold_complete', | 294 key: 'horizontal_threshold_complete', |
295 label: 'Complete when overscrolled (horizontal)', | 295 label: 'Complete when overscrolled (horizontal)', |
296 units: '%' | 296 units: '%' |
297 }, | 297 }, |
298 { | 298 { |
(...skipping 17 matching lines...) Expand all Loading... |
316 units: 'pixels' | 316 units: 'pixels' |
317 }, | 317 }, |
318 ]; | 318 ]; |
319 | 319 |
320 return new GeneralConfig(OVERSCROLL_TITLE, | 320 return new GeneralConfig(OVERSCROLL_TITLE, |
321 OVERSCROLL_PREFIX, | 321 OVERSCROLL_PREFIX, |
322 OVERSCROLL_FIELDS); | 322 OVERSCROLL_FIELDS); |
323 } | 323 } |
324 | 324 |
325 /** | 325 /** |
| 326 * Returns a GeneralConfig for configuring workspace_cycler.* preferences. |
| 327 * @return {object} A GeneralConfig object. |
| 328 */ |
| 329 function WorkspaceCyclerConfig() { |
| 330 /** @const */ var WORKSPACE_CYCLER_TITLE = 'Workspace Cycler Configuration'; |
| 331 |
| 332 /** @const */ var WORKSPACE_CYCLER_PREFIX = 'workspace_cycler.'; |
| 333 |
| 334 var WORKSPACE_CYCLER_FIELDS = [ |
| 335 { |
| 336 key: 'selected_scale', |
| 337 label: 'Scale of the selected workspace', |
| 338 units: '%' |
| 339 }, |
| 340 { |
| 341 key: 'min_scale', |
| 342 label: 'Minimum workspace scale (scale of deepest workspace)', |
| 343 units: '%' |
| 344 }, |
| 345 { |
| 346 key: 'max_scale', |
| 347 label: 'Maximimum workspace scale (scale of shallowest workspace)', |
| 348 units: '%' |
| 349 }, |
| 350 { |
| 351 key: 'min_brightness', |
| 352 label: 'Minimum workspace brightness (deepest & shallowest workspace)', |
| 353 units: '%' |
| 354 }, |
| 355 { |
| 356 key: 'background_opacity', |
| 357 label: 'Desktop background opacity when cycling through workspaces', |
| 358 units: '%' |
| 359 }, |
| 360 { |
| 361 key: 'distance_to_initiate_cycling', |
| 362 label: 'Vertical distance to scroll to initiate cycling', |
| 363 units: 'pixels' |
| 364 }, |
| 365 { |
| 366 key: 'scroll_distance_to_cycle_to_next_workspace', |
| 367 label: 'Vertical distance to scroll to cycle to the next workspace', |
| 368 units: 'pixels' |
| 369 }, |
| 370 { key: 'cycler_step_animation_duration_ratio', |
| 371 label: 'Cycler step animation duration ratio', |
| 372 units: 'ms / pixels vertical scroll' |
| 373 }, |
| 374 { key: 'start_cycler_animation_duration', |
| 375 label: 'Duration of the animations to start cycling', |
| 376 units: 'ms' |
| 377 }, |
| 378 { key: 'stop_cycler_animation_duration', |
| 379 label: 'Duration of the animations to stop cycling', |
| 380 units: 'ms' |
| 381 } |
| 382 ]; |
| 383 |
| 384 return new GeneralConfig(WORKSPACE_CYCLER_TITLE, |
| 385 WORKSPACE_CYCLER_PREFIX, |
| 386 WORKSPACE_CYCLER_FIELDS); |
| 387 } |
| 388 |
| 389 /** |
326 * Returns a GeneralConfig for configuring flingcurve.* preferences. | 390 * Returns a GeneralConfig for configuring flingcurve.* preferences. |
327 * @return {object} A GeneralConfig object. | 391 * @return {object} A GeneralConfig object. |
328 */ | 392 */ |
329 function FlingConfig() { | 393 function FlingConfig() { |
330 var FLING_PREFIX = 'flingcurve.'; | 394 /** @const */ var FLING_TITLE = 'Fling Configuration'; |
| 395 |
| 396 /** @const */ var FLING_PREFIX = 'flingcurve.'; |
331 | 397 |
332 var FLING_FIELDS = [ | 398 var FLING_FIELDS = [ |
333 { | 399 { |
334 key: 'touchscreen_alpha', | 400 key: 'touchscreen_alpha', |
335 label: 'Touchscreen fling deacceleration coefficients', | 401 label: 'Touchscreen fling deacceleration coefficients', |
336 units: 'alpha' | 402 units: 'alpha' |
337 }, | 403 }, |
338 { | 404 { |
339 key: 'touchscreen_beta', | 405 key: 'touchscreen_beta', |
340 label: '', | 406 label: '', |
(...skipping 14 matching lines...) Expand all Loading... |
355 label: '', | 421 label: '', |
356 units: 'beta' | 422 units: 'beta' |
357 }, | 423 }, |
358 { | 424 { |
359 key: 'touchpad_gamma', | 425 key: 'touchpad_gamma', |
360 label: '', | 426 label: '', |
361 units: 'gamma' | 427 units: 'gamma' |
362 }, | 428 }, |
363 ]; | 429 ]; |
364 | 430 |
365 return new GeneralConfig(FLING_PREFIX, FLING_FIELDS); | 431 return new GeneralConfig(FLING_TITLE, FLING_PREFIX, FLING_FIELDS); |
366 } | 432 } |
367 | 433 |
368 | 434 |
369 /** | 435 /** |
370 * WebUI instance for configuring gesture.* and overscroll.* preference values | 436 * WebUI instance for configuring gesture.* and overscroll.* preference values |
371 * used by Chrome's gesture recognition system. | 437 * used by Chrome's gesture recognition system. |
372 */ | 438 */ |
373 var gesture_config = (function() { | 439 var gesture_config = (function() { |
374 | 440 |
375 /** | 441 /** |
376 * Build and initialize the gesture configuration form. | 442 * Build and initialize the gesture configuration form. |
377 */ | 443 */ |
378 function initialize() { | 444 function initialize() { |
379 var g = GestureConfig(); | 445 var g = GestureConfig(); |
380 g.buildAll(); | 446 g.buildAll(); |
381 | 447 |
382 var o = OverscrollConfig(); | 448 var o = OverscrollConfig(); |
383 o.buildAll(); | 449 o.buildAll(); |
384 | 450 |
385 var f = FlingConfig(); | 451 var f = FlingConfig(); |
386 f.buildAll(); | 452 f.buildAll(); |
387 | 453 |
| 454 var c = WorkspaceCyclerConfig(); |
| 455 c.buildAll(); |
| 456 |
388 $('reset-button').onclick = function() { | 457 $('reset-button').onclick = function() { |
389 g.onReset(); | 458 g.onReset(); |
390 o.onReset(); | 459 o.onReset(); |
391 f.onReset(); | 460 f.onReset(); |
| 461 c.onReset(); |
392 }; | 462 }; |
393 } | 463 } |
394 | 464 |
395 /** | 465 /** |
396 * Handle callback from call to getPreferenceValue. | 466 * Handle callback from call to getPreferenceValue. |
397 * @param {string} prefName The name of the requested preference value. | 467 * @param {string} prefName The name of the requested preference value. |
398 * @param {value} value The current value associated with prefName. | 468 * @param {value} value The current value associated with prefName. |
399 */ | 469 */ |
400 function getPreferenceValueResult(prefName, value) { | 470 function getPreferenceValueResult(prefName, value) { |
401 prefName = prefName.substring(prefName.indexOf('.') + 1); | 471 prefName = prefName.substring(prefName.indexOf('.') + 1); |
402 $(prefName).value = value; | 472 $(prefName).value = value; |
403 } | 473 } |
404 | 474 |
405 return { | 475 return { |
406 initialize: initialize, | 476 initialize: initialize, |
407 getPreferenceValueResult: getPreferenceValueResult | 477 getPreferenceValueResult: getPreferenceValueResult |
408 }; | 478 }; |
409 })(); | 479 })(); |
410 | 480 |
411 document.addEventListener('DOMContentLoaded', gesture_config.initialize); | 481 document.addEventListener('DOMContentLoaded', gesture_config.initialize); |
OLD | NEW |