-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjquery.liveicon.js
60 lines (54 loc) · 1.47 KB
/
jquery.liveicon.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
54
55
56
57
58
59
60
$.fn.liveicon = function(options){
var opts = $.extend({}, $.fn.liveicon.defaults, options);
// re-render
if(opts.size != "small"){
$(this).animate({
width:"200px"
});
}
$(this).css({"backgroundColor": opts.backgroundColor, "color": opts.color});
// for right click to expand size
$(this).bind("contextmenu", function(e){
if($(this).width() != 200){
$(this).animate({
width:"200px"
});
}
else{
$(this).animate({
width:"100px"
});
}
return false;
});
// for update live icon
// set timeout to update live
var command = "$(this).liveicon.update("+ $(this).attr("id") +")";
window.setInterval(command, opts.stepTime);
};
$.fn.liveicon.update = function(element){
var id = "#" + element.id;
var subpage = $(id).find(".subpage");
if($.fn.liveicon.counter.counter < subpage.length){
var position = ++$.fn.liveicon.counter.counter*90;
$(id+ "> .subpages").animate({
scrollTop:position+ "px"
});
}
else{
$(id+ "> .subpages").animate({
scrollTop: "0px"
}, "300");
$.fn.liveicon.counter.counter = 0;
}
window.clearInterval();
};
$.fn.liveicon.counter = {
counter: 0
};
$.fn.liveicon.defaults = {
size: "small",
stepTime: 3000,
backgroundColor: "#0066ff",
color: "#fff"
};