-
Notifications
You must be signed in to change notification settings - Fork 1
/
fns.js
46 lines (43 loc) · 1.51 KB
/
fns.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
$(function() {
$('input.field').
focus(function() {
if(this.title==this.value) {
this.value = '';
}
}).
blur(function(){
if(this.value=='') {
this.value = this.title;
}
});
var currentPage = 1;
$('#slider .buttons span').live('click', function() {
var timeout = setTimeout(function() {$("img").trigger("slidermove")}, 300);
var fragments_count = $(this).parents('#slider:eq(0)').find('.fragment').length;
var fragmet_width = $(this).parents('#slider:eq(0)').find('.fragment').width();
var perPage = 1;
var numPages = Math.ceil(fragments_count/perPage);
var stepMove = fragmet_width*perPage;
var container = $(this).parents('#slider:eq(0)').find('.content');
var firstPosition = 0;
var lastPosition = -((numPages-1)*stepMove);
if ($(this).hasClass('next')) {
currentPage ++;
if (currentPage > numPages) {
currentPage = 1;
container.animate({'left': firstPosition});
return;
};
container.animate({'left': -((currentPage - 1)*stepMove)});
};
if ($(this).hasClass('prev')) {
currentPage --;
if (currentPage < 1) {
currentPage = numPages;
container.animate({'left': lastPosition});
return;
};
container.animate({'left': -((currentPage-1)*stepMove)});
};
});
});