source: other-projects/nz-flag-design/trunk/render-3d/Flag_files/slider.js@ 29968

Last change on this file since 29968 was 29954, checked in by davidb, 9 years ago

Minor mods: higher wind default, and commented out line that randomly changed the colour of an intersected object with a mousedown event

File size: 1.1 KB
RevLine 
[29693]1jQuery(document).ready(function ($) {
[29719]2
[29954]3 var initialValue = 250;
[29721]4 var tooltip = '<span class="tt"><span class="text">'+getDescript(initialValue)+'</span></span>';
5 var target;
[29719]6
[29693]7 $("#speed").slider({
[29694]8 min: 25,
9 max: 300,
[29719]10 value: initialValue,
[29693]11 animate: true,
12 range: 'min',
[29719]13 create: function(event, ui) {
14 initTooltip(ui);
15 },
[29693]16 slide: function(event, ui) {
[29719]17 setSpeed(ui);
[29693]18 }
19 });
20
[29719]21 function initTooltip(ui){
[29721]22 target = ui.handle || $('.ui-slider-handle');
[29719]23 }
24
25 function setSpeed(ui){
26 windStrength = ui.value;
[29721]27 tooltip = '<span class="tt"><span class="text">'+getDescript(ui.value)+'</span></span>';
28 target = ui.handle || $('.ui-slider-handle');
29 $(target).html(tooltip);
[29719]30 }
31
[29721]32 function getDescript(speed){
33 if(speed < 50) return 'calm';
34 if(speed < 100) return 'light';
35 if(speed < 150) return 'fair';
36 if(speed < 200) return 'heavy';
37 return 'gusty';
38 }
39
[29693]40 $(".ui-slider").mouseenter(function(){
41 controls.enabled = false;
[29721]42 $(target).html(tooltip);
[29693]43 });
44
45 $(".ui-slider").mouseleave(function(){
46 controls.enabled = true;
[29721]47 $(".tt").remove();
[29693]48 });
[29719]49
[29693]50});
Note: See TracBrowser for help on using the repository browser.