-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinputScroll.js
More file actions
47 lines (37 loc) · 979 Bytes
/
inputScroll.js
File metadata and controls
47 lines (37 loc) · 979 Bytes
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
$.fn.inputScroll = function(direction, increment) {
if (typeof rolling == 'undefined') {
rolling = false;
}
if (!rolling) {
rolling = true;
increment = increment || 10;
self = $(this);
$newAmount = self.clone();
self.attr('name', self.attr('name')+'_old');
height = self.height();
dollas = parseInt(self.val().replace('$', ''));
if (direction == 'down') {
if (dollas <= 0) {
dollas = 0;
} else {
dollas -= increment;
go = false;
}
modifier = '';
move = '-';
} else {
dollas += increment;
modifier = '-';
move = '+';
}
$newAmount.val('$'+dollas).css('top', modifier+height+'px');
self.parent().append($newAmount);
$('.'+self.attr('class')).stop(true, true).animate({top: move + '=' + height}, 200, function(){
self.remove();
rolling = false;
});
return true;
} else {
return false;
}
}