-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsection-indicator.js
More file actions
44 lines (33 loc) · 1.1 KB
/
section-indicator.js
File metadata and controls
44 lines (33 loc) · 1.1 KB
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
function sectionIndicator(opt) {
var $si = $('.section-indicator');
var $si_list = $si.find('li');
var $si_numbering = $si.find('.numbering');
this.activeIndex = 0;
this.changeIndicator = function(i) {
$si_list.removeClass('active');
$si_list.eq(i).addClass('active');
}
this.init = function() {
var that = this;
$si_list.each(function(i) {
var $li = $(this);
var $el = $(this).find('a');
/*if(opt && opt.animate) {
setTimeout(function() {
$li.addClass('show');
}, i * 70);
}*/
$el.on('click', function(e) {
e.preventDefault();
that.changeIndicator(i);
that.activeIndex = i;
var current_val = that.activeIndex < 10 ? '0'+(that.activeIndex + 1) : (that.activeIndex + 1);
$si_numbering.find('.current').text(current_val);
});
});
/*if(opt && opt.animate) {
$si.addClass('show');
}*/
}
this.init();
}