jquery-tablesorter 1.22.5 → 1.22.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +3 -0
- data/Rakefile +6 -0
- data/lib/jquery-tablesorter/version.rb +1 -1
- data/vendor/assets/javascripts/jquery-tablesorter/beta-testing/pager-custom-controls.js +143 -0
- data/vendor/assets/javascripts/jquery-tablesorter/beta-testing/widget-reorder.js +182 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d4211cee46a8b2e91b6dd361b142750090fa50d7
|
4
|
+
data.tar.gz: 058c8b7d5ba30eee2876e2a704e5f3a9558677ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae56e4a242b95b3cb41dfc3d98ad15c04ef067628b33b47870759590c3aa013d31f5cdf8f30e8684eecdf2b8f48d4b72d45c25c2803d726404875e3e9616b287
|
7
|
+
data.tar.gz: c736f92638d4397fd1b9be8b49a6fa7a6a5c213002b16bd5e5efcd1bdab806f8b8540b77fc6a9cb0ff4c58e55bcca141df3b96aebc4190bb17cc13a84982978c
|
data/README.md
CHANGED
@@ -49,8 +49,11 @@ Or you can include single file with:
|
|
49
49
|
//= require jquery-tablesorter/widgets/widget-repeatheaders
|
50
50
|
//= require jquery-tablesorter/parsers/parser-metric
|
51
51
|
//= require jquery-tablesorter/extras/jquery.quicksearch
|
52
|
+
//= require jquery-tablesorter/beta-testing/pager-custom-controls
|
52
53
|
```
|
53
54
|
|
55
|
+
Please note that files in the beta-testing directory might move into the stable tablesorter or get renamed with upcoming tablesorter releases and thus could have to be required in an updated way after upgrading this gem.
|
56
|
+
|
54
57
|
### Stylesheet files
|
55
58
|
|
56
59
|
In your `application.css`
|
data/Rakefile
CHANGED
@@ -44,6 +44,12 @@ namespace :jquery_tablesorter do
|
|
44
44
|
copy_files(files, folder_javascript_dir)
|
45
45
|
end
|
46
46
|
|
47
|
+
# beta-testing
|
48
|
+
#
|
49
|
+
beta_dir = File.join(javascript_dir, 'beta-testing')
|
50
|
+
beta_files = Dir.glob(File.join('tablesorter', 'beta-testing', '*.js')).reject{|file| file =~ /.min.js\Z/}
|
51
|
+
copy_files(beta_files, beta_dir)
|
52
|
+
|
47
53
|
end
|
48
54
|
|
49
55
|
def copy_files(files, target_dir)
|
@@ -0,0 +1,143 @@
|
|
1
|
+
/*!
|
2
|
+
* custom pager controls (beta) for Tablesorter - updated 9/1/2016 (v2.27.6)
|
3
|
+
initialize custom pager script BEFORE initializing tablesorter/tablesorter pager
|
4
|
+
custom pager looks like this:
|
5
|
+
1 | 2 … 5 | 6 | 7 … 99 | 100
|
6
|
+
_ _ _ _ adjacentSpacer
|
7
|
+
_ _ distanceSpacer
|
8
|
+
_____ ________ ends (2 default)
|
9
|
+
_________ aroundCurrent (1 default)
|
10
|
+
|
11
|
+
*/
|
12
|
+
/*jshint browser:true, jquery:true, unused:false, loopfunc:true */
|
13
|
+
/*global jQuery: false */
|
14
|
+
|
15
|
+
;(function($) {
|
16
|
+
"use strict";
|
17
|
+
|
18
|
+
$.tablesorter = $.tablesorter || {};
|
19
|
+
|
20
|
+
$.tablesorter.customPagerControls = function(settings) {
|
21
|
+
var defaults = {
|
22
|
+
table : 'table',
|
23
|
+
pager : '.pager',
|
24
|
+
pageSize : '.left a',
|
25
|
+
currentPage : '.right a',
|
26
|
+
ends : 2, // number of pages to show of either end
|
27
|
+
aroundCurrent : 1, // number of pages surrounding the current page
|
28
|
+
link : '<a href="#">{page}</a>', // page element; use {page} to include the page number
|
29
|
+
currentClass : 'current', // current page class name
|
30
|
+
adjacentSpacer : '<span> | </span>', // spacer for page numbers next to each other
|
31
|
+
distanceSpacer : '<span> … <span>', // spacer for page numbers away from each other (ellipsis)
|
32
|
+
addKeyboard : true, // use left,right,up,down,pageUp,pageDown,home, or end to change current page
|
33
|
+
pageKeyStep : 10 // page step to use for pageUp and pageDown
|
34
|
+
},
|
35
|
+
options = $.extend({}, defaults, settings),
|
36
|
+
$table = $(options.table),
|
37
|
+
$pager = $(options.pager);
|
38
|
+
|
39
|
+
$table
|
40
|
+
.on('pagerInitialized pagerComplete', function (e, c) {
|
41
|
+
var indx,
|
42
|
+
p = c.pager ? c.pager : c, // using widget
|
43
|
+
pages = $('<div/>'),
|
44
|
+
cur = p.page + 1,
|
45
|
+
pageArray = [],
|
46
|
+
max = p.filteredPages,
|
47
|
+
around = options.aroundCurrent;
|
48
|
+
for (indx = -around; indx <= around; indx++) {
|
49
|
+
if (cur + indx >= 1 && cur + indx <= max) {
|
50
|
+
pageArray.push(cur + indx);
|
51
|
+
}
|
52
|
+
}
|
53
|
+
if (pageArray.length) {
|
54
|
+
// include first and last pages (ends) in the pagination
|
55
|
+
for (indx = 0; indx < options.ends; indx++) {
|
56
|
+
if ((indx + 1 <= max) && $.inArray(indx + 1, pageArray) === -1) {
|
57
|
+
pageArray.push(indx + 1);
|
58
|
+
}
|
59
|
+
if ((max - indx > 0) && $.inArray(max - indx, pageArray) === -1) {
|
60
|
+
pageArray.push(max - indx);
|
61
|
+
}
|
62
|
+
}
|
63
|
+
// sort the list
|
64
|
+
pageArray = pageArray.sort(function(a, b) { return a - b; });
|
65
|
+
// only include unique pages
|
66
|
+
pageArray = $.grep(pageArray, function(value, key) {
|
67
|
+
return $.inArray(value, pageArray) === key;
|
68
|
+
});
|
69
|
+
// make links and spacers
|
70
|
+
if (pageArray.length) {
|
71
|
+
max = pageArray.length - 1;
|
72
|
+
$.each(pageArray, function(indx, value) {
|
73
|
+
pages
|
74
|
+
.append(
|
75
|
+
$(options.link.replace(/\{page\}/g, value))
|
76
|
+
.toggleClass(options.currentClass, value === cur)
|
77
|
+
.attr('data-page', value)
|
78
|
+
)
|
79
|
+
.append((indx < max && (pageArray[ indx + 1 ] - 1 !== value) ?
|
80
|
+
options.distanceSpacer :
|
81
|
+
(indx >= max ? '' : options.adjacentSpacer)
|
82
|
+
));
|
83
|
+
});
|
84
|
+
}
|
85
|
+
}
|
86
|
+
$pager
|
87
|
+
.find('.pagecount')
|
88
|
+
.html(pages.html())
|
89
|
+
.find('.' + options.currentClass)
|
90
|
+
.focus();
|
91
|
+
});
|
92
|
+
|
93
|
+
// set up pager controls
|
94
|
+
$pager
|
95
|
+
.find(options.pageSize)
|
96
|
+
.on('click', function () {
|
97
|
+
$(this)
|
98
|
+
.addClass(options.currentClass)
|
99
|
+
.siblings()
|
100
|
+
.removeClass(options.currentClass);
|
101
|
+
$table.trigger('pageSize', $(this).html());
|
102
|
+
return false;
|
103
|
+
})
|
104
|
+
.end()
|
105
|
+
.on('click', options.currentPage, function() {
|
106
|
+
var $el = $(this);
|
107
|
+
$el
|
108
|
+
.addClass(options.currentClass)
|
109
|
+
.siblings()
|
110
|
+
.removeClass(options.currentClass);
|
111
|
+
$table.trigger('pageSet', $el.attr('data-page'));
|
112
|
+
return false;
|
113
|
+
});
|
114
|
+
|
115
|
+
// make right/left arrow keys work
|
116
|
+
if (options.addKeyboard) {
|
117
|
+
$(document).on('keydown', function(events) {
|
118
|
+
// ignore arrows inside form elements
|
119
|
+
if (/input|select|textarea/i.test(events.target.nodeName) ||
|
120
|
+
!(events.which > 32 && events.which < 41)) {
|
121
|
+
return;
|
122
|
+
}
|
123
|
+
// only allow keyboard use if element inside of pager is focused
|
124
|
+
if ($(document.activeElement).closest(options.pager).is($pager)) {
|
125
|
+
events.preventDefault();
|
126
|
+
var key = events.which,
|
127
|
+
max = $table[0].config.totalRows,
|
128
|
+
$el = $pager.find(options.currentPage).filter('.' + options.currentClass),
|
129
|
+
page = $el.length ? parseInt($el.attr('data-page'), 10) : null;
|
130
|
+
if (page) {
|
131
|
+
if (key === 33) { page -= options.pageKeyStep; } // pageUp
|
132
|
+
if (key === 34) { page += options.pageKeyStep; } // pageDown
|
133
|
+
if (key === 35) { page = max; } // end
|
134
|
+
if (key === 36) { page = 1; } // home
|
135
|
+
if (key === 37 || key === 38) { page -= 1; } // left/up
|
136
|
+
if (key === 39 || key === 40) { page += 1; } // right/down
|
137
|
+
$table.trigger('pageSet', page);
|
138
|
+
}
|
139
|
+
}
|
140
|
+
});
|
141
|
+
}
|
142
|
+
};
|
143
|
+
})(jQuery);
|
@@ -0,0 +1,182 @@
|
|
1
|
+
/*! tablesorter column reorder - beta testing
|
2
|
+
* Requires tablesorter v2.8+ and jQuery 1.7+
|
3
|
+
* by Rob Garrison
|
4
|
+
*/
|
5
|
+
/*jshint browser:true, jquery:true, unused:false */
|
6
|
+
/*global jQuery: false */
|
7
|
+
;(function($){
|
8
|
+
"use strict";
|
9
|
+
|
10
|
+
$.tablesorter.addWidget({
|
11
|
+
id: 'reorder',
|
12
|
+
priority: 70,
|
13
|
+
options : {
|
14
|
+
reorder_axis : 'xy', // x or xy
|
15
|
+
reorder_delay : 300,
|
16
|
+
reorder_helperClass : 'tablesorter-reorder-helper',
|
17
|
+
reorder_helperBar : 'tablesorter-reorder-helper-bar',
|
18
|
+
reorder_noReorder : 'reorder-false',
|
19
|
+
reorder_blocked : 'reorder-block-left reorder-block-end',
|
20
|
+
reorder_complete : null // callback
|
21
|
+
},
|
22
|
+
init: function(table, thisWidget, c, wo) {
|
23
|
+
var i, timer, $helper, $bar, clickOffset,
|
24
|
+
lastIndx = -1,
|
25
|
+
ts = $.tablesorter,
|
26
|
+
endIndex = -1,
|
27
|
+
startIndex = -1,
|
28
|
+
t = wo.reorder_blocked.split(' '),
|
29
|
+
noReorderLeft = t[0] || 'reorder-block-left',
|
30
|
+
noReorderLast = t[1] || 'reorder-block-end',
|
31
|
+
lastOffset = c.$headers.not('.' + noReorderLeft).first(),
|
32
|
+
offsets = c.$headers.map(function(i){
|
33
|
+
var s, $t = $(this);
|
34
|
+
if ($t.hasClass(noReorderLeft)) {
|
35
|
+
s = lastOffset;
|
36
|
+
$t = s;
|
37
|
+
//lastOffset = $t;
|
38
|
+
}
|
39
|
+
lastOffset = $t;
|
40
|
+
return $t.offset().left;
|
41
|
+
}).get(),
|
42
|
+
len = offsets.length,
|
43
|
+
startReorder = function(e, $th){
|
44
|
+
var p = $th.position(),
|
45
|
+
r = $th.parent().position(),
|
46
|
+
i = startIndex = $th.index();
|
47
|
+
clickOffset = [ e.pageX - p.left, e.pageY - r.top ];
|
48
|
+
$helper = c.$table.clone();
|
49
|
+
$helper.find('> thead > tr:first').children('[data-column!=' + i + ']').remove();
|
50
|
+
$helper.find('thead tr:gt(0), caption, colgroup, tbody, tfoot').remove();
|
51
|
+
$helper
|
52
|
+
.css({
|
53
|
+
position: 'absolute',
|
54
|
+
zIndex : 1,
|
55
|
+
left: p.left - clickOffset[0],
|
56
|
+
top: r.top - clickOffset[1],
|
57
|
+
width: $th.outerWidth()
|
58
|
+
})
|
59
|
+
.appendTo('body')
|
60
|
+
.find('th, td').addClass(wo.reorder_helperClass);
|
61
|
+
$bar = $('<div class="' + wo.reorder_helperBar + '" />')
|
62
|
+
.css({
|
63
|
+
position : 'absolute',
|
64
|
+
top : c.$table.find('thead').offset().top,
|
65
|
+
height : $th.closest('thead').outerHeight() + c.$table.find('tbody').height()
|
66
|
+
})
|
67
|
+
.appendTo('body');
|
68
|
+
positionBar(e);
|
69
|
+
lastIndx = endIndex;
|
70
|
+
},
|
71
|
+
positionBar = function(e){
|
72
|
+
for (i = 0; i <= len; i++) {
|
73
|
+
if ( i > 0 && e.pageX < offsets[i-1] + (offsets[i] - offsets[i-1])/2 && !c.$headers.eq(i).hasClass(noReorderLeft) ) {
|
74
|
+
endIndex = i - 1;
|
75
|
+
// endIndex = offsets.lastIndexOf( offsets[i-1] ); // lastIndexOf not supported by IE8 and older
|
76
|
+
if (endIndex >= 0 && lastIndx === endIndex) { return false; }
|
77
|
+
lastIndx = endIndex;
|
78
|
+
if (c.debug) {
|
79
|
+
console.log( endIndex === 0 ? 'target before column 0' : endIndex === len ? 'target after last column' : 'target between columns ' + startIndex + ' and ' + endIndex);
|
80
|
+
}
|
81
|
+
$bar.css('left', offsets[i-1]);
|
82
|
+
return false;
|
83
|
+
}
|
84
|
+
}
|
85
|
+
if (endIndex < 0) {
|
86
|
+
endIndex = len;
|
87
|
+
$bar.css('left', offsets[len]);
|
88
|
+
}
|
89
|
+
},
|
90
|
+
finishReorder = function(){
|
91
|
+
$helper.remove();
|
92
|
+
$bar.remove();
|
93
|
+
// finish reorder
|
94
|
+
var adj, s = startIndex,
|
95
|
+
rows = c.$table.find('tr'),
|
96
|
+
cols;
|
97
|
+
startIndex = -1; // stop mousemove updates
|
98
|
+
if ( s > -1 && endIndex > -1 && s != endIndex && s + 1 !== endIndex ) {
|
99
|
+
adj = endIndex !== 0;
|
100
|
+
if (c.debug) {
|
101
|
+
console.log( 'Inserting column ' + s + (adj ? ' after' : ' before') + ' column ' + (endIndex - adj ? 1 : 0) );
|
102
|
+
}
|
103
|
+
rows.each(function() {
|
104
|
+
cols = $(this).children();
|
105
|
+
cols.eq(s)[ adj ? 'insertAfter' : 'insertBefore' ]( cols.eq( endIndex - (adj ? 1 : 0) ) );
|
106
|
+
});
|
107
|
+
cols = [];
|
108
|
+
// stored header info needs to be modified too!
|
109
|
+
for (i = 0; i < len; i++) {
|
110
|
+
if (i === s) { continue; }
|
111
|
+
if (i === endIndex - (adj ? 1 : 0)) {
|
112
|
+
if (!adj) { cols.push(c.headerContent[s]); }
|
113
|
+
cols.push(c.headerContent[i]);
|
114
|
+
if (adj) { cols.push(c.headerContent[s]); }
|
115
|
+
} else {
|
116
|
+
cols.push(c.headerContent[i]);
|
117
|
+
}
|
118
|
+
}
|
119
|
+
c.headerContent = cols;
|
120
|
+
// cols = c.headerContent.splice(s, 1);
|
121
|
+
// c.headerContent.splice(endIndex - (adj ? 1 : 0), 0, cols);
|
122
|
+
c.$table.trigger('updateAll', [ true, wo.reorder_complete ]);
|
123
|
+
}
|
124
|
+
endIndex = -1;
|
125
|
+
},
|
126
|
+
mdown = function(e, el){
|
127
|
+
var $t = $(el), evt = e;
|
128
|
+
if ($t.hasClass(wo.reorder_noReorder)) { return; }
|
129
|
+
timer = setTimeout(function(){
|
130
|
+
$t.addClass('tablesorter-reorder');
|
131
|
+
startReorder(evt, $t);
|
132
|
+
}, wo.reorder_delay);
|
133
|
+
};
|
134
|
+
|
135
|
+
console.log( c.$headers.last().hasClass(noReorderLast) );
|
136
|
+
|
137
|
+
if ( c.$headers.last().hasClass(noReorderLast) ) {
|
138
|
+
offsets.push( offsets[ offsets.length - 1 ] );
|
139
|
+
} else {
|
140
|
+
offsets.push( c.$table.offset().left + c.$table.outerWidth() );
|
141
|
+
}
|
142
|
+
|
143
|
+
c.$headers.not('.' + wo.reorder_noReorder).bind('mousedown.reorder', function(e){
|
144
|
+
mdown(e, this);
|
145
|
+
});
|
146
|
+
|
147
|
+
$(document)
|
148
|
+
.bind('mousemove.reorder', function(e){
|
149
|
+
if (startIndex !== -1){
|
150
|
+
var c = { left : e.pageX - clickOffset[0] };
|
151
|
+
endIndex = -1;
|
152
|
+
if (/y/.test(wo.reorder_axis)) {
|
153
|
+
c.top = e.pageY - clickOffset[1];
|
154
|
+
}
|
155
|
+
$helper.css(c);
|
156
|
+
positionBar(e);
|
157
|
+
}
|
158
|
+
})
|
159
|
+
.add( c.$headers )
|
160
|
+
.bind('mouseup.reorder', function(){
|
161
|
+
clearTimeout(timer);
|
162
|
+
if (startIndex !== -1 && endIndex !== -1){
|
163
|
+
finishReorder();
|
164
|
+
} else {
|
165
|
+
startIndex = -1;
|
166
|
+
}
|
167
|
+
});
|
168
|
+
|
169
|
+
// has sticky headers?
|
170
|
+
c.$table.bind('stickyHeadersInit', function(){
|
171
|
+
wo.$sticky.find('thead').children().not('.' + wo.reorder_noReorder).bind('mousedown.reorder', function(e){
|
172
|
+
mdown(e, this);
|
173
|
+
});
|
174
|
+
});
|
175
|
+
|
176
|
+
}
|
177
|
+
});
|
178
|
+
|
179
|
+
// add mouse coordinates
|
180
|
+
$x = $('#main h1:last'); $(document).mousemove(function(e){ $x.html( e.pageX ); });
|
181
|
+
|
182
|
+
})(jQuery);
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jquery-tablesorter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.22.
|
4
|
+
version: 1.22.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jun Lin
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-09-
|
12
|
+
date: 2016-09-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: railties
|
@@ -79,6 +79,8 @@ files:
|
|
79
79
|
- vendor/assets/images/jquery-tablesorter/white-unsorted.gif
|
80
80
|
- vendor/assets/javascripts/jquery-tablesorter.js
|
81
81
|
- vendor/assets/javascripts/jquery-tablesorter/addons/pager/jquery.tablesorter.pager.js
|
82
|
+
- vendor/assets/javascripts/jquery-tablesorter/beta-testing/pager-custom-controls.js
|
83
|
+
- vendor/assets/javascripts/jquery-tablesorter/beta-testing/widget-reorder.js
|
82
84
|
- vendor/assets/javascripts/jquery-tablesorter/extras/jquery.dragtable.mod.js
|
83
85
|
- vendor/assets/javascripts/jquery-tablesorter/extras/jquery.metadata.js
|
84
86
|
- vendor/assets/javascripts/jquery-tablesorter/extras/semver-mod.js
|