author | Lennard de Rijk <ljvderijk@gmail.com> |
Sat, 04 Jul 2009 14:19:39 +0200 | |
changeset 2528 | 9de8348890d8 |
parent 2415 | 69e9d5cc643f |
permissions | -rw-r--r-- |
2415
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
1 |
/** |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
2 |
* jQuery Spin 1.1.1 |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
3 |
* |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
4 |
* Copyright (c) 2009 Naohiko MORI |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
5 |
* Dual licensed under the MIT and GPL licenses. |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
6 |
* |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
7 |
**/ |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
8 |
(function($){ |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
9 |
var calcFloat = { |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
10 |
get: function(num){ |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
11 |
var num = num.toString(); |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
12 |
if(num.indexOf('.')==-1) return[0, eval(num)]; |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
13 |
var nn = num.split('.'); |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
14 |
var po = nn[1].length; |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
15 |
var st = nn.join(''); |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
16 |
var sign = ''; |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
17 |
if(st.charAt(0)=='-'){ |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
18 |
st = st.substr(1); |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
19 |
sign = '-'; |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
20 |
} |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
21 |
for(var i=0; i<st.length; ++i) if(st.charAt(0)=='0') st=st.substr(1, st.length); |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
22 |
st = sign + st; |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
23 |
return [po, eval(st)]; |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
24 |
}, |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
25 |
getInt: function(num, figure){ |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
26 |
var d = Math.pow(10, figure); |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
27 |
var n = this.get(num); |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
28 |
var v1 = eval('num * d'); |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
29 |
var v2 = eval('n[1] * d'); |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
30 |
if(this.get(v1)[1]==v2) return v1; |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
31 |
return(n[0]==0 ? v1 : eval(v2 + '/Math.pow(10, n[0])')); |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
32 |
}, |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
33 |
sum: function(v1, v2){ |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
34 |
var n1 = this.get(v1); |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
35 |
var n2 = this.get(v2); |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
36 |
var figure = (n1[0] > n2[0] ? n1[0] : n2[0]); |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
37 |
v1 = this.getInt(v1, figure); |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
38 |
v2 = this.getInt(v2, figure); |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
39 |
return eval('v1 + v2')/Math.pow(10, figure); |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
40 |
} |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
41 |
}; |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
42 |
$.extend({ |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
43 |
spin: { |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
44 |
imageBasePath: '/soc/content/images/', |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
45 |
spinBtnImage: 'spin-button.png', |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
46 |
spinUpImage: 'spin-up.png', |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
47 |
spinDownImage: 'spin-down.png', |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
48 |
interval: 1, |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
49 |
max: null, |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
50 |
min: null, |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
51 |
timeInterval: 500, |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
52 |
timeBlink: 200, |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
53 |
btnClass: null, |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
54 |
btnCss: {cursor: 'pointer', padding: 0, margin: 0, verticalAlign: 'middle'}, |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
55 |
txtCss: {marginRight: 0, paddingRight: 0}, |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
56 |
lock: false, |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
57 |
decimal: null, |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
58 |
beforeChange: null, |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
59 |
changed: null, |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
60 |
buttonUp: null, |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
61 |
buttonDown: null |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
62 |
} |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
63 |
}); |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
64 |
$.fn.extend({ |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
65 |
spin: function(o){ |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
66 |
return this.each(function(){ |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
67 |
o = o || {}; |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
68 |
var opt = {}; |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
69 |
$.each($.spin, function(k,v){ |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
70 |
opt[k] = (typeof o[k]!='undefined' ? o[k] : v); |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
71 |
}); |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
72 |
|
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
73 |
var txt = $(this); |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
74 |
|
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
75 |
var spinBtnImage = opt.imageBasePath+opt.spinBtnImage; |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
76 |
var btnSpin = new Image(); |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
77 |
btnSpin.src = spinBtnImage; |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
78 |
var spinUpImage = opt.imageBasePath+opt.spinUpImage; |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
79 |
var btnSpinUp = new Image(); |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
80 |
btnSpinUp.src = spinUpImage; |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
81 |
var spinDownImage = opt.imageBasePath+opt.spinDownImage; |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
82 |
var btnSpinDown = new Image(); |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
83 |
btnSpinDown.src = spinDownImage; |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
84 |
|
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
85 |
var btn = $(document.createElement('img')); |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
86 |
btn.attr('src', spinBtnImage); |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
87 |
if(opt.btnClass) btn.addClass(opt.btnClass); |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
88 |
if(opt.btnCss) btn.css(opt.btnCss); |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
89 |
if(opt.txtCss) txt.css(opt.txtCss); |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
90 |
txt.after(btn); |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
91 |
if(opt.lock){ |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
92 |
txt.focus(function(){txt.blur();}); |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
93 |
} |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
94 |
|
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
95 |
function spin(vector){ |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
96 |
var val = txt.val(); |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
97 |
var org_val = val; |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
98 |
if(opt.decimal) val=val.replace(opt.decimal, '.'); |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
99 |
if(!isNaN(val)){ |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
100 |
val = calcFloat.sum(val, vector * opt.interval); |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
101 |
if(opt.min!==null && val<opt.min) val=opt.min; |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
102 |
if(opt.max!==null && val>opt.max) val=opt.max; |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
103 |
if(val != txt.val()){ |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
104 |
if(opt.decimal) val=val.toString().replace('.', opt.decimal); |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
105 |
var ret = ($.isFunction(opt.beforeChange) ? opt.beforeChange.apply(txt, [val, org_val]) : true); |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
106 |
if(ret!==false){ |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
107 |
txt.val(val); |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
108 |
if($.isFunction(opt.changed)) opt.changed.apply(txt, [val]); |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
109 |
txt.change(); |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
110 |
src = (vector > 0 ? spinUpImage : spinDownImage); |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
111 |
btn.attr('src', src); |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
112 |
if(opt.timeBlink<opt.timeInterval) |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
113 |
setTimeout(function(){btn.attr('src', spinBtnImage);}, opt.timeBlink); |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
114 |
} |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
115 |
} |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
116 |
} |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
117 |
if(vector > 0){ |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
118 |
if($.isFunction(opt.buttonUp)) opt.buttonUp.apply(txt, [val]); |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
119 |
}else{ |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
120 |
if($.isFunction(opt.buttonDown)) opt.buttonDown.apply(txt, [val]); |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
121 |
} |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
122 |
} |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
123 |
|
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
124 |
btn.mousedown(function(e){ |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
125 |
var pos = e.pageY - btn.offset().top; |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
126 |
var vector = (btn.height()/2 > pos ? 1 : -1); |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
127 |
(function(){ |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
128 |
spin(vector); |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
129 |
var tk = setTimeout(arguments.callee, opt.timeInterval); |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
130 |
$(document).one('mouseup', function(){ |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
131 |
clearTimeout(tk); btn.attr('src', spinBtnImage); |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
132 |
}); |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
133 |
})(); |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
134 |
return false; |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
135 |
}); |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
136 |
}); |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
137 |
} |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
138 |
}); |
69e9d5cc643f
jQuery Spin plugin updated to version 1.1.1
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
139 |
})(jQuery); |