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 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
311 units: 'pixels' | 311 units: 'pixels' |
312 }, | 312 }, |
313 ]; | 313 ]; |
314 | 314 |
315 return new GeneralConfig(OVERSCROLL_TITLE, | 315 return new GeneralConfig(OVERSCROLL_TITLE, |
316 OVERSCROLL_PREFIX, | 316 OVERSCROLL_PREFIX, |
317 OVERSCROLL_FIELDS); | 317 OVERSCROLL_FIELDS); |
318 } | 318 } |
319 | 319 |
320 /** | 320 /** |
321 * Returns a GeneralConfig for configuring workspace_cycler.* preferences. | |
322 * @return {object} A GeneralConfig object. | |
323 */ | |
324 function WorkspaceCyclerConfig() { | |
325 var WORKSPACE_CYCLER_TITLE = 'Workspace Cycler Configuration'; | |
326 | |
327 var WORKSPACE_CYCLER_PREFIX = 'workspace_cycler.'; | |
328 | |
329 var WORKSPACE_CYCLER_FIELDS = [ | |
330 { | |
331 key: 'selected_scale', | |
332 label: 'Scale of the selected workspace', | |
333 units: '%' | |
334 }, | |
335 { | |
336 key: 'min_scale', | |
337 label: 'Minimum workspace scale (scale of deepest workspace)', | |
338 units: '%' | |
339 }, | |
340 { | |
341 key: 'max_scale', | |
342 label: 'Maximimum workspace scale (scale of shallowest workspace)', | |
343 units: '%' | |
344 }, | |
345 { | |
346 key: 'min_brightness', | |
347 label: 'Minimum workspace brightness (deepest & shallowest workspace)', | |
348 units: '%' | |
349 }, | |
350 { | |
351 key: 'background_opacity', | |
352 label: 'Desktop background opacity when cycling through workspaces', | |
353 units: '%' | |
354 }, | |
355 { | |
356 key: 'distance_to_initiate_cycling', | |
357 label: 'Vertical distance to scroll to initiate cycling', | |
358 units: 'pixels' | |
359 }, | |
360 { | |
361 key: 'scroll_distance_to_cycle_to_next_workspace', | |
362 label: 'Vertical distance to scroll to cycle to the next workspace', | |
363 units: 'pixels' | |
364 }, | |
365 { key: 'cycler_step_animation_duration_ratio', | |
366 label: 'Cycler step animation duration ratio', | |
367 units: 'ms / pixels vertical scroll' | |
368 }, | |
369 { key: 'start_cycler_animation_duration', | |
370 label: 'Duration of the animations to start cycling', | |
371 units: 'ms' | |
372 }, | |
373 { key: 'stop_cycler_animation_duration', | |
374 label: 'Duration of the animations to stop cycling', | |
375 units: 'ms' | |
376 } | |
377 ]; | |
378 | |
379 return new GeneralConfig(WORKSPACE_CYCLER_TITLE, | |
380 WORKSPACE_CYCLER_PREFIX, | |
381 WORKSPACE_CYCLER_FIELDS); | |
382 } | |
383 | |
384 /** | |
321 * WebUI instance for configuring gesture.* and overscroll.* preference values | 385 * WebUI instance for configuring gesture.* and overscroll.* preference values |
322 * used by Chrome's gesture recognition system. | 386 * used by Chrome's gesture recognition system. |
323 */ | 387 */ |
324 var gesture_config = (function() { | 388 var gesture_config = (function() { |
325 | 389 |
326 /** | 390 /** |
327 * Build and initialize the gesture configuration form. | 391 * Build and initialize the gesture configuration form. |
328 */ | 392 */ |
329 function initialize() { | 393 function initialize() { |
330 var g = GestureConfig(); | 394 var g = GestureConfig(); |
331 g.buildAll(); | 395 g.buildAll(); |
332 | 396 |
333 var o = OverscrollConfig(); | 397 var o = OverscrollConfig(); |
334 o.buildAll(); | 398 o.buildAll(); |
335 | 399 |
400 // Asynchronously check whether the workspace cycler configuration should | |
401 // be added. If it should be, add it in the callback. | |
402 checkShouldAddWorkspaceCyclerConfiguration(); | |
403 | |
sadrul
2013/02/11 16:41:19
This isn't necessary. Just add the config here. Th
| |
336 $('reset-button').onclick = function() { | 404 $('reset-button').onclick = function() { |
337 g.onReset(); | 405 g.onReset(); |
338 o.onReset(); | 406 o.onReset(); |
339 }; | 407 }; |
340 } | 408 } |
341 | 409 |
342 /** | 410 /** |
411 * Asynchronously checks whether the workspace cycler configuration should | |
412 * be added to the form. If it should be, it is added to the form in the | |
413 * callback. | |
414 */ | |
415 function checkShouldAddWorkspaceCyclerConfiguration() { | |
416 chrome.send('checkShouldAddWorkspaceCyclerConfiguration'); | |
417 } | |
418 | |
419 /** | |
343 * Handle callback from call to getPreferenceValue. | 420 * Handle callback from call to getPreferenceValue. |
344 * @param {string} prefName The name of the requested preference value. | 421 * @param {string} prefName The name of the requested preference value. |
345 * @param {value} value The current value associated with prefName. | 422 * @param {value} value The current value associated with prefName. |
346 */ | 423 */ |
347 function getPreferenceValueResult(prefName, value) { | 424 function getPreferenceValueResult(prefName, value) { |
348 prefName = prefName.substring(prefName.indexOf('.') + 1); | 425 prefName = prefName.substring(prefName.indexOf('.') + 1); |
349 $(prefName).value = value; | 426 $(prefName).value = value; |
350 } | 427 } |
351 | 428 |
429 /** | |
430 * Handle callback from call to checkShouldAddWorkspaceCyclerConfiguration. | |
431 * @param {bool} should_add Whether the workspace cycler configuration should | |
432 * be added to the form. | |
433 */ | |
434 function checkShouldAddWorkspaceCyclerConfigurationResult(should_add) { | |
435 if (should_add) { | |
436 var c = WorkspaceCyclerConfig(); | |
437 c.buildAll(); | |
438 } | |
439 } | |
440 | |
352 return { | 441 return { |
353 initialize: initialize, | 442 initialize: initialize, |
354 getPreferenceValueResult: getPreferenceValueResult | 443 checkShouldAddWorkspaceCyclerConfiguration: |
444 checkShouldAddWorkspaceCyclerConfiguration, | |
445 getPreferenceValueResult: getPreferenceValueResult, | |
446 checkShouldAddWorkspaceCyclerConfigurationResult: | |
447 checkShouldAddWorkspaceCyclerConfigurationResult | |
355 }; | 448 }; |
356 })(); | 449 })(); |
357 | 450 |
358 document.addEventListener('DOMContentLoaded', gesture_config.initialize); | 451 document.addEventListener('DOMContentLoaded', gesture_config.initialize); |
OLD | NEW |