-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.js
114 lines (105 loc) · 2.95 KB
/
demo.js
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
$(function(){
$('.roulette').find('img').hover(function(){
console.log($(this).height());
});
var appendLogMsg = function(msg) {
$('#msg')
.append('<p class="muted">' + msg + '</p>')
.scrollTop(100000000);
}
var p = {
startCallback : function() {
appendLogMsg('start');
$('#speed, #duration').slider('disable');
$('#stopImageNumber').spinner('disable');
$('.start').attr('disabled', 'true');
$('.stop').removeAttr('disabled');
},
slowDownCallback : function() {
appendLogMsg('slowdown');
$('.stop').attr('disabled', 'true');
},
stopCallback : function($stopElm) {
appendLogMsg('stop');
$('#speed, #duration').slider('enable');
$('#stopImageNumber').spinner('enable');
$('.start').removeAttr('disabled');
$('.stop').attr('disabled', 'true');
}
}
var rouletter = $('div.roulette');
rouletter.roulette(p);
$('.stop').click(function(){
var stopImageNumber = $('.stopImageNumber').val();
if(stopImageNumber == "") {
stopImageNumber = null;
}
rouletter.roulette('stop');
});
$('.stop').attr('disabled', 'true');
$('.start').click(function(){
rouletter.roulette('start');
});
var updateParamater = function(){
p['speed'] = Number($('.speed_param').eq(0).text());
p['duration'] = Number($('.duration_param').eq(0).text());
p['stopImageNumber'] = Number($('.stop_image_number_param').eq(0).text());
rouletter.roulette('option', p);
}
var updateSpeed = function(speed){
$('.speed_param').text(speed);
}
$('#speed').slider({
min: 1,
max: 30,
value : 15,
slide: function( event, ui ) {
updateSpeed(ui.value);
updateParamater();
}
});
updateSpeed($('#speed').slider('value'));
var updateDuration = function(duration){
$('.duration_param').text(duration);
}
$('#duration').slider({
min: 2,
max: 10,
value : 3,
slide: function( event, ui ) {
updateDuration(ui.value);
updateParamater();
}
});
updateDuration($('#duration').slider('value'));
var updateStopImageNumber = function(stopImageNumber) {
$('.image_sample').children().css('opacity' , 0.2);
$('.image_sample').children().filter('[data-value="' + stopImageNumber + '"]').css('opacity' , 1);
$('.stop_image_number_param').text(stopImageNumber);
updateParamater();
}
$('#stopImageNumber').spinner({
spin: function( event, ui ) {
var imageNumber = ui.value;
if ( ui.value > 4 ) {
$( this ).spinner( "value", -1 );
imageNumber = 0;
updateStopImageNumber(-1);
return false;
} else if ( ui.value < -1 ) {
$( this ).spinner( "value", 4 );
imageNumber = 4;
updateStopImageNumber(4);
return false;
}
updateStopImageNumber(imageNumber);
}
});
$('#stopImageNumber').spinner('value', -1);
updateStopImageNumber($('#stopImageNumber').spinner('value'));
$('.image_sample').children().click(function(){
var stopImageNumber = $(this).attr('data-value');
$('#stopImageNumber').spinner('value', stopImageNumber);
updateStopImageNumber(stopImageNumber);
});
});