sliderkit.counter.1.0.js
2.07 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/**
* Slider Kit Counter, v1.0 - 2011/09/23
* http://www.kyrielles.net/sliderkit
*
* Copyright (c) 2010-2012 Alan Frog
* Licensed under the GNU General Public License
* See <license.txt> or <http://www.gnu.org/licenses/>
*
* Requires : jQuery Slider Kit v1.7.1+
*
*/
(function( $ ) {
SliderKit.prototype.Counter = (function() {
var obj = this;
var csslib = {
countItems: obj.options.cssprefix+"-count-items",
countLines: obj.options.cssprefix+"-count-lines",
countCur: obj.options.cssprefix+"-count-current",
countTot: obj.options.cssprefix+"-count-total"
};
// Panels counter
if( obj.arePanels ){
var countItemsObj = $( "."+csslib.countItems, obj.domObj );
var countItemsCur = $( "."+csslib.countCur, countItemsObj );
if( countItemsObj.size() > 0 && countItemsCur.size() > 0 ) {
var itemsCounter = 1;
var _countItems = function(){
countItemsCur.text( (obj.currId != 0 ? obj.currId : obj.startId) + 1 );
};
// First time display
if( obj.firstTime ){
$( "."+ csslib.countTot, countItemsObj ).text( obj.allItems );
_countItems();
}
// Store the function into the callback list
obj.panelAnteFns.push( _countItems );
}
}
// Nav lines counter
if( obj.isNavClip ){
var countLinesObj = $( "."+csslib.countLines, obj.domObj );
var countLinesCur = $( "."+csslib.countCur, countLinesObj );
if( countLinesObj.size() > 0 && countLinesCur.size() > 0) {
var linesNum = Math.ceil( obj.navLINum / obj.options.shownavitems );
var _countLines = function(){
var currLine = Math.ceil( (obj.currId +1) / obj.options.shownavitems );
countLinesCur.text( currLine );
};
// First time display
if( obj.firstTime ){
$( "."+ csslib.countTot, countLinesObj ).text( linesNum );
_countLines();
}
// Store the function into the callback list
obj.navAnteFns.push( _countLines );
obj.panelPostFns.push( _countLines );
}
}
});
})( jQuery );