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

Last change on this file since 29721 was 29721, checked in by bmt11, 9 years ago

Tooltip is now polished and finished

File size: 1.1 KB
Line 
1jQuery(document).ready(function ($) {
2
3 var initialValue = 100;
4 var tooltip = '<span class="tt"><span class="text">'+getDescript(initialValue)+'</span></span>';
5 var target;
6
7 $("#speed").slider({
8 min: 25,
9 max: 300,
10 value: initialValue,
11 animate: true,
12 range: 'min',
13 create: function(event, ui) {
14 initTooltip(ui);
15 },
16 slide: function(event, ui) {
17 setSpeed(ui);
18 }
19 });
20
21 function initTooltip(ui){
22 target = ui.handle || $('.ui-slider-handle');
23 }
24
25 function setSpeed(ui){
26 windStrength = ui.value;
27 tooltip = '<span class="tt"><span class="text">'+getDescript(ui.value)+'</span></span>';
28 target = ui.handle || $('.ui-slider-handle');
29 $(target).html(tooltip);
30 }
31
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
40 $(".ui-slider").mouseenter(function(){
41 controls.enabled = false;
42 $(target).html(tooltip);
43 });
44
45 $(".ui-slider").mouseleave(function(){
46 controls.enabled = true;
47 $(".tt").remove();
48 });
49
50});
Note: See TracBrowser for help on using the repository browser.