-
Notifications
You must be signed in to change notification settings - Fork 0
/
ras.nav.js
53 lines (41 loc) · 1.58 KB
/
ras.nav.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
/* [URL] */
;(function($, window, document, undefined) {
var r = $.ras.slideshow;
r.nav = {
options : {}
};
$.fn.nav = function(options) {
options = $.extend({}, r.nav.options, options);
return this.each(function(){
var container = $(this),
navigation = container.closest('.allRas').find('#navRAS'),
childs = container.children(),
dataW = container.data('width'),
numberChild = childs.length;
container.addClass('navRas');
container.find('li:first-child').addClass('activeSlide');
container.children().each(function(e){
$(this).attr('data-left', dataW*e);
});
navigation.prepend('<div id="navMultiple"/>');
for(var i = numberChild; i>=1; i--) {
$('#navMultiple').prepend('<button data-slide="'+(i-1)+'">'+i+'</button>');
}
$('#navMultiple').find('button:eq(0)').addClass('active');
$('#navMultiple').find('button').each(function(e){
var slide = $(this).data('slide');
$(this).click(function(){
$('#navMultiple').find('.active').removeClass('active');
$(this).addClass('active');
var childSelected = container.find('li:eq('+slide+')'),
leftContainer = childSelected.data('left');
container.find('.activeSlide').removeClass('activeSlide');
childSelected.addClass('activeSlide');
container.animate({
'margin-left': -leftContainer
})
})
});
});
};
})(jQuery, window, document);