~alexharrington/xibo/pyclient-1.1.0a22

« back to all changes in this revision

Viewing changes to server/lib/js/jquery/jquery.tablesorter.pager.js

  • Committer: Dan Garner
  • Date: 2008-12-14 14:42:52 UTC
  • mto: (1.1.80 Xibo)
  • mto: This revision was merged to the branch mainline in revision 2.
  • Revision ID: mail@dangarner.co.uk-20081214144252-8dosaegtfwvv0dsl
Moved 3rd Party libraries to their own folder.
Updated jQuery to the latest revision and now use jQuery UI instead of individual plugins.

Tabs are not currently working

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * 
3
 
 * TableSorter 2.0 - Client-side table sorting with ease!
4
 
 * Version 2.0
5
 
 * @requires jQuery v1.1.3
6
 
 * 
7
 
 * Copyright (c) 2007 Christian Bach
8
 
 * Examples and docs at: http://tablesorter.com
9
 
 * Dual licensed under the MIT and GPL licenses:
10
 
 * http://www.opensource.org/licenses/mit-license.php
11
 
 * http://www.gnu.org/licenses/gpl.html
12
 
 * 
13
 
 */
14
 
(function($) {
15
 
        $.extend({
16
 
                tablesorterPager: new function() {
17
 
                        
18
 
                        function updatePageDisplay(c) {
19
 
                                var s = $(c.cssPageDisplay,c.container).val((c.page+1) + c.seperator + c.totalPages);
20
 
                                
21
 
                                //add the tr hover class
22
 
                                $(".info_table table tr").hover(
23
 
                                        function(){
24
 
                                                $(this).addClass("hover");
25
 
                                        },function() {
26
 
                                                $(this).removeClass("hover");
27
 
                                        }
28
 
                                );
29
 
                        }
30
 
                        
31
 
                        function setPageSize(table,size) {
32
 
                                var c = table.config;
33
 
                                c.size = size;
34
 
                                c.totalPages = Math.ceil(c.totalRows / c.size);
35
 
                                moveToPage(table);
36
 
                                
37
 
                                if(!c.pagerPositionSet && c.positionFixed) fixPosition(table);
38
 
                        }
39
 
                        
40
 
                        function fixPosition(table) {
41
 
                                var c = table.config, o = $(table);
42
 
                                if(o.offset) {
43
 
                                        c.container.css({
44
 
                                                top: o.offset().top + o.height() + 'px',
45
 
                                                position: 'absolute'
46
 
                                        });
47
 
                                }
48
 
                                c.pagerPositionSet = true;
49
 
                        }
50
 
                        
51
 
                        function moveToFirstPage(table) {
52
 
                                var c = table.config;
53
 
                                c.page = 0;
54
 
                                moveToPage(table);
55
 
                        }
56
 
                        
57
 
                        function moveToLastPage(table) {
58
 
                                var c = table.config;
59
 
                                c.page = (c.totalPages-1);
60
 
                                moveToPage(table);
61
 
                        }
62
 
                        
63
 
                        function moveToNextPage(table) {
64
 
                                var c = table.config;
65
 
                                c.page++;
66
 
                                if(c.page >= (c.totalPages-1)) {
67
 
                                        c.page = (c.totalPages-1);
68
 
                                }
69
 
                                moveToPage(table);
70
 
                        }
71
 
                        
72
 
                        function moveToPrevPage(table) {
73
 
                                var c = table.config;
74
 
                                c.page--;
75
 
                                if(c.page <= 0) {
76
 
                                        c.page = 0;
77
 
                                }
78
 
                                moveToPage(table);
79
 
                        }
80
 
                                                
81
 
                        
82
 
                        function moveToPage(table) {
83
 
                                var c = table.config;
84
 
                                if(c.page < 0 || c.page > (c.totalPages-1)) {
85
 
                                        c.page = 0;
86
 
                                }
87
 
                                
88
 
                                renderTable(table,c.rowsCopy);
89
 
                        }
90
 
                        
91
 
                        function renderTable(table,rows) {
92
 
                                
93
 
                                var c = table.config;
94
 
                                var l = rows.length;
95
 
                                var s = (c.page * c.size);
96
 
                                var e = (s + c.size);
97
 
                                if(e > rows.length ) {
98
 
                                        e = rows.length;
99
 
                                }
100
 
                                var tableBody = $('tbody:first',table).empty();
101
 
                                
102
 
                                for(var i = s; i < e; i++) {
103
 
                                        
104
 
                                        tableBody.append(rows[i]);
105
 
                                }
106
 
                                
107
 
                                if(!c.pagerPositionSet && c.positionFixed) fixPosition(table,tableBody);
108
 
                                
109
 
                                updatePageDisplay(c);
110
 
                        }
111
 
                        
112
 
                        this.appender = function(table,rows) {
113
 
                                
114
 
                                var c = table.config;
115
 
                                
116
 
                                c.rowsCopy = rows;
117
 
                                c.totalRows = rows.length;
118
 
                                c.totalPages = Math.ceil(c.totalRows / c.size);
119
 
                                
120
 
                                renderTable(table,rows);
121
 
                        };
122
 
                        
123
 
                        this.defaults = {
124
 
                                size: 10,
125
 
                                offset: 0,
126
 
                                page: 0,
127
 
                                totalRows: 0,
128
 
                                totalPages: 0,
129
 
                                container: null,
130
 
                                cssNext: '.next',
131
 
                                cssPrev: '.prev',
132
 
                                cssFirst: '.first',
133
 
                                cssLast: '.last',
134
 
                                cssPageDisplay: '.pagedisplay',
135
 
                                cssPageSize: '.pagesize',
136
 
                                seperator: "/",
137
 
                                positionFixed: false,
138
 
                                appender: this.appender
139
 
                        };
140
 
                        
141
 
                        this.construct = function(settings) {
142
 
                                
143
 
                                return this.each(function() {   
144
 
                                        
145
 
                                        config = $.extend(this.config, $.tablesorterPager.defaults, settings);
146
 
                                        
147
 
                                        var table = this, pager = config.container;
148
 
                                
149
 
                                        $(this).trigger("appendCache");
150
 
                                        
151
 
                                        config.size = parseInt($(".pagesize",pager).val());
152
 
                                        
153
 
                                        $(config.cssFirst,pager).click(function() {
154
 
                                                moveToFirstPage(table);
155
 
                                                return false;
156
 
                                        });
157
 
                                        $(config.cssNext,pager).click(function() {
158
 
                                                moveToNextPage(table);
159
 
                                                return false;
160
 
                                        });
161
 
                                        $(config.cssPrev,pager).click(function() {
162
 
                                                moveToPrevPage(table);
163
 
                                                return false;
164
 
                                        });
165
 
                                        $(config.cssLast,pager).click(function() {
166
 
                                                moveToLastPage(table);
167
 
                                                return false;
168
 
                                        });
169
 
                                        $(config.cssPageSize,pager).change(function() {
170
 
                                                setPageSize(table,parseInt($(this).val()));
171
 
                                                return false;
172
 
                                        });
173
 
                                });
174
 
                        };
175
 
                        
176
 
                }
177
 
        });
178
 
        // extend plugin scope
179
 
        $.fn.extend({
180
 
        tablesorterPager: $.tablesorterPager.construct
181
 
        });
182
 
        
183
 
})(jQuery);                             
 
 
b'\\ No newline at end of file'