jquery-tablesorter 1.17.2 → 1.17.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/jquery-tablesorter/version.rb +1 -1
- data/vendor/assets/javascripts/jquery-tablesorter/addons/pager/jquery.tablesorter.pager.js +76 -71
- data/vendor/assets/javascripts/jquery-tablesorter/extras/jquery.dragtable.mod.js +1 -1
- data/vendor/assets/javascripts/jquery-tablesorter/jquery.tablesorter.combined.js +2647 -2576
- data/vendor/assets/javascripts/jquery-tablesorter/jquery.tablesorter.js +174 -119
- data/vendor/assets/javascripts/jquery-tablesorter/jquery.tablesorter.widgets.js +2487 -2471
- data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-date-extract.js +15 -15
- data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-date-iso8601.js +1 -1
- data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-date-month.js +4 -4
- data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-date-range.js +1 -1
- data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-date-two-digit-year.js +12 -12
- data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-date-weekday.js +4 -4
- data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-date.js +1 -1
- data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-duration.js +1 -1
- data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-feet-inch-fraction.js +6 -6
- data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-file-type.js +22 -22
- data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-globalize.js +1 -1
- data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-ignore-articles.js +15 -15
- data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-image.js +3 -3
- data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-input-select.js +10 -3
- data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-metric.js +2 -2
- data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-named-numbers.js +3 -3
- data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-network.js +1 -1
- data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-roman.js +4 -4
- data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-alignChar.js +122 -121
- data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-build-table.js +13 -13
- data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-chart.js +2 -2
- data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-columnSelector.js +324 -324
- data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-columns.js +60 -60
- data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-editable.js +219 -219
- data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-filter-formatter-html5.js +360 -361
- data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-filter-formatter-jui.js +666 -666
- data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-filter-formatter-select2.js +124 -124
- data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-filter-type-insideRange.js +1 -1
- data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-filter.js +1448 -1433
- data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-formatter.js +1 -1
- data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-grouping.js +213 -213
- data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-headerTitles.js +3 -3
- data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-math.js +271 -216
- data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-output.js +339 -320
- data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-pager.js +1057 -1045
- data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-print.js +109 -109
- data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-reflow.js +114 -115
- data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-resizable.js +360 -359
- data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-saveSort.js +59 -59
- data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-scroller.js +818 -806
- data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-sort2Hash.js +128 -0
- data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-sortTbodies.js +195 -195
- data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-staticRow.js +90 -90
- data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-stickyHeaders.js +257 -257
- data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-storage.js +76 -76
- data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-uitheme.js +170 -170
- metadata +3 -3
- data/vendor/assets/javascripts/jquery-tablesorter/extras/jquery.quicksearch.js +0 -195
@@ -1,393 +1,394 @@
|
|
1
1
|
/*! Widget: resizable - updated 6/26/2015 (v2.22.2) */
|
2
2
|
/*jshint browser:true, jquery:true, unused:false */
|
3
3
|
;(function ($, window) {
|
4
|
-
'use strict';
|
5
|
-
var ts = $.tablesorter || {};
|
6
|
-
|
7
|
-
$.extend(ts.css, {
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
});
|
13
|
-
|
14
|
-
// Add extra scroller css
|
15
|
-
$(function(){
|
16
|
-
var s = '<style>' +
|
17
|
-
'body.' + ts.css.resizableNoSelect + ' { -ms-user-select: none; -moz-user-select: -moz-none;' +
|
18
|
-
'-khtml-user-select: none; -webkit-user-select: none; user-select: none; }' +
|
19
|
-
'.' + ts.css.resizableContainer + ' { position: relative; height: 1px; }' +
|
20
|
-
// make handle z-index > than stickyHeader z-index, so the handle stays above sticky header
|
21
|
-
'.' + ts.css.resizableHandle + ' { position: absolute; display: inline-block; width: 8px;' +
|
22
|
-
'top: 1px; cursor: ew-resize; z-index: 3; user-select: none; -moz-user-select: none; }' +
|
23
|
-
'</style>';
|
24
|
-
$(s).appendTo('body');
|
25
|
-
});
|
26
|
-
|
27
|
-
ts.resizable = {
|
28
|
-
init : function( c, wo ) {
|
29
|
-
if ( c.$table.hasClass( 'hasResizable' ) ) { return; }
|
30
|
-
c.$table.addClass( 'hasResizable' );
|
31
|
-
|
32
|
-
var noResize, $header, column, storedSizes, tmp,
|
33
|
-
$table = c.$table,
|
34
|
-
$parent = $table.parent(),
|
35
|
-
marginTop = parseInt( $table.css( 'margin-top' ), 10 ),
|
36
|
-
|
37
|
-
// internal variables
|
38
|
-
vars = wo.resizable_ = {
|
39
|
-
useStorage : ts.storage && wo.resizable !== false,
|
40
|
-
$wrap : $parent,
|
41
|
-
mouseXPosition : 0,
|
42
|
-
$target : null,
|
43
|
-
$next : null,
|
44
|
-
overflow : $parent.css('overflow') === 'auto' ||
|
45
|
-
$parent.css('overflow') === 'scroll' ||
|
46
|
-
$parent.css('overflow-x') === 'auto' ||
|
47
|
-
$parent.css('overflow-x') === 'scroll',
|
48
|
-
storedSizes : []
|
49
|
-
};
|
50
|
-
|
51
|
-
// set default widths
|
52
|
-
ts.resizableReset( c.table, true );
|
53
|
-
|
54
|
-
// now get measurements!
|
55
|
-
vars.tableWidth = $table.width();
|
56
|
-
// attempt to autodetect
|
57
|
-
vars.fullWidth = Math.abs( $parent.width() - vars.tableWidth ) < 20;
|
58
|
-
|
59
|
-
/*
|
60
|
-
// Hacky method to determine if table width is set to "auto"
|
61
|
-
// http://stackoverflow.com/a/20892048/145346
|
62
|
-
if ( !vars.fullWidth ) {
|
63
|
-
tmp = $table.width();
|
64
|
-
$header = $table.wrap('<span>').parent(); // temp variable
|
65
|
-
storedSizes = parseInt( $table.css( 'margin-left' ), 10 ) || 0;
|
66
|
-
$table.css( 'margin-left', storedSizes + 50 );
|
67
|
-
vars.tableWidth = $header.width() > tmp ? 'auto' : tmp;
|
68
|
-
$table.css( 'margin-left', storedSizes ? storedSizes : '' );
|
69
|
-
$header = null;
|
70
|
-
$table.unwrap('<span>');
|
71
|
-
}
|
72
|
-
*/
|
4
|
+
'use strict';
|
5
|
+
var ts = $.tablesorter || {};
|
6
|
+
|
7
|
+
$.extend(ts.css, {
|
8
|
+
resizableContainer : 'tablesorter-resizable-container',
|
9
|
+
resizableHandle : 'tablesorter-resizable-handle',
|
10
|
+
resizableNoSelect : 'tablesorter-disableSelection',
|
11
|
+
resizableStorage : 'tablesorter-resizable'
|
12
|
+
});
|
73
13
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
14
|
+
// Add extra scroller css
|
15
|
+
$(function(){
|
16
|
+
var s = '<style>' +
|
17
|
+
'body.' + ts.css.resizableNoSelect + ' { -ms-user-select: none; -moz-user-select: -moz-none;' +
|
18
|
+
'-khtml-user-select: none; -webkit-user-select: none; user-select: none; }' +
|
19
|
+
'.' + ts.css.resizableContainer + ' { position: relative; height: 1px; }' +
|
20
|
+
// make handle z-index > than stickyHeader z-index, so the handle stays above sticky header
|
21
|
+
'.' + ts.css.resizableHandle + ' { position: absolute; display: inline-block; width: 8px;' +
|
22
|
+
'top: 1px; cursor: ew-resize; z-index: 3; user-select: none; -moz-user-select: none; }' +
|
23
|
+
'</style>';
|
24
|
+
$(s).appendTo('body');
|
25
|
+
});
|
26
|
+
|
27
|
+
ts.resizable = {
|
28
|
+
init : function( c, wo ) {
|
29
|
+
if ( c.$table.hasClass( 'hasResizable' ) ) { return; }
|
30
|
+
c.$table.addClass( 'hasResizable' );
|
31
|
+
|
32
|
+
var noResize, $header, column, storedSizes, tmp,
|
33
|
+
$table = c.$table,
|
34
|
+
$parent = $table.parent(),
|
35
|
+
marginTop = parseInt( $table.css( 'margin-top' ), 10 ),
|
36
|
+
|
37
|
+
// internal variables
|
38
|
+
vars = wo.resizable_vars = {
|
39
|
+
useStorage : ts.storage && wo.resizable !== false,
|
40
|
+
$wrap : $parent,
|
41
|
+
mouseXPosition : 0,
|
42
|
+
$target : null,
|
43
|
+
$next : null,
|
44
|
+
overflow : $parent.css('overflow') === 'auto' ||
|
45
|
+
$parent.css('overflow') === 'scroll' ||
|
46
|
+
$parent.css('overflow-x') === 'auto' ||
|
47
|
+
$parent.css('overflow-x') === 'scroll',
|
48
|
+
storedSizes : []
|
49
|
+
};
|
50
|
+
|
51
|
+
// set default widths
|
52
|
+
ts.resizableReset( c.table, true );
|
53
|
+
|
54
|
+
// now get measurements!
|
55
|
+
vars.tableWidth = $table.width();
|
56
|
+
// attempt to autodetect
|
57
|
+
vars.fullWidth = Math.abs( $parent.width() - vars.tableWidth ) < 20;
|
58
|
+
|
59
|
+
/*
|
60
|
+
// Hacky method to determine if table width is set to 'auto'
|
61
|
+
// http://stackoverflow.com/a/20892048/145346
|
62
|
+
if ( !vars.fullWidth ) {
|
63
|
+
tmp = $table.width();
|
64
|
+
$header = $table.wrap('<span>').parent(); // temp variable
|
65
|
+
storedSizes = parseInt( $table.css( 'margin-left' ), 10 ) || 0;
|
66
|
+
$table.css( 'margin-left', storedSizes + 50 );
|
67
|
+
vars.tableWidth = $header.width() > tmp ? 'auto' : tmp;
|
68
|
+
$table.css( 'margin-left', storedSizes ? storedSizes : '' );
|
69
|
+
$header = null;
|
70
|
+
$table.unwrap('<span>');
|
103
71
|
}
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
setWidth : function( $el, width, overflow ) {
|
123
|
-
// overflow tables need min & max width set as well
|
124
|
-
$el.css({
|
125
|
-
'width' : width,
|
126
|
-
'min-width' : overflow ? width : '',
|
127
|
-
'max-width' : overflow ? width : ''
|
128
|
-
});
|
129
|
-
},
|
130
|
-
|
131
|
-
setWidths : function( c, wo, storedSizes ) {
|
132
|
-
var column, $temp,
|
133
|
-
vars = wo.resizable_,
|
134
|
-
$extra = $( c.namespace + '_extra_headers' ),
|
135
|
-
$col = c.$table.children( 'colgroup' ).children( 'col' );
|
136
|
-
storedSizes = storedSizes || vars.storedSizes || [];
|
137
|
-
// process only if table ID or url match
|
138
|
-
if ( storedSizes.length ) {
|
72
|
+
*/
|
73
|
+
|
74
|
+
if ( vars.useStorage && vars.overflow ) {
|
75
|
+
// save table width
|
76
|
+
ts.storage( c.table, 'tablesorter-table-original-css-width', vars.tableWidth );
|
77
|
+
tmp = ts.storage( c.table, 'tablesorter-table-resized-width' ) || 'auto';
|
78
|
+
ts.resizable.setWidth( $table, tmp, true );
|
79
|
+
}
|
80
|
+
wo.resizable_vars.storedSizes = storedSizes = ( vars.useStorage ?
|
81
|
+
ts.storage( c.table, ts.css.resizableStorage ) :
|
82
|
+
[] ) || [];
|
83
|
+
ts.resizable.setWidths( c, wo, storedSizes );
|
84
|
+
ts.resizable.updateStoredSizes( c, wo );
|
85
|
+
|
86
|
+
wo.$resizable_container = $( '<div class="' + ts.css.resizableContainer + '">' )
|
87
|
+
.css({ top : marginTop })
|
88
|
+
.insertBefore( $table );
|
89
|
+
// add container
|
139
90
|
for ( column = 0; column < c.columns; column++ ) {
|
140
|
-
|
141
|
-
ts.
|
142
|
-
|
143
|
-
|
144
|
-
$
|
145
|
-
|
91
|
+
$header = c.$headerIndexed[ column ];
|
92
|
+
tmp = ts.getColumnData( c.table, c.headers, column );
|
93
|
+
noResize = ts.getData( $header, tmp, 'resizable' ) === 'false';
|
94
|
+
if ( !noResize ) {
|
95
|
+
$( '<div class="' + ts.css.resizableHandle + '">' )
|
96
|
+
.appendTo( wo.$resizable_container )
|
97
|
+
.attr({
|
98
|
+
'data-column' : column,
|
99
|
+
'unselectable' : 'on'
|
100
|
+
})
|
101
|
+
.data( 'header', $header )
|
102
|
+
.bind( 'selectstart', false );
|
146
103
|
}
|
147
104
|
}
|
148
|
-
$
|
149
|
-
|
150
|
-
ts.resizable.
|
105
|
+
$table.one('tablesorter-initialized', function() {
|
106
|
+
ts.resizable.setHandlePosition( c, wo );
|
107
|
+
ts.resizable.bindings( this.config, this.config.widgetOptions );
|
108
|
+
});
|
109
|
+
},
|
110
|
+
|
111
|
+
updateStoredSizes : function( c, wo ) {
|
112
|
+
var column, $header,
|
113
|
+
len = c.columns,
|
114
|
+
vars = wo.resizable_vars;
|
115
|
+
vars.storedSizes = [];
|
116
|
+
for ( column = 0; column < len; column++ ) {
|
117
|
+
$header = c.$headerIndexed[ column ];
|
118
|
+
vars.storedSizes[ column ] = $header.is(':visible') ? $header.width() : 0;
|
151
119
|
}
|
152
|
-
}
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
handleCenter = Math.floor( $handles.width() / 2 );
|
161
|
-
|
162
|
-
if ( hasScroller ) {
|
163
|
-
tableHeight = 0;
|
164
|
-
c.$table.closest( '.' + ts.css.scrollerWrap ).children().each(function(){
|
165
|
-
var $this = $(this);
|
166
|
-
// center table has a max-height set
|
167
|
-
tableHeight += $this.filter('[style*="height"]').length ? $this.height() : $this.children('table').height();
|
120
|
+
},
|
121
|
+
|
122
|
+
setWidth : function( $el, width, overflow ) {
|
123
|
+
// overflow tables need min & max width set as well
|
124
|
+
$el.css({
|
125
|
+
'width' : width,
|
126
|
+
'min-width' : overflow ? width : '',
|
127
|
+
'max-width' : overflow ? width : ''
|
168
128
|
});
|
169
|
-
}
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
if (
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
129
|
+
},
|
130
|
+
|
131
|
+
setWidths : function( c, wo, storedSizes ) {
|
132
|
+
var column, $temp,
|
133
|
+
vars = wo.resizable_vars,
|
134
|
+
$extra = $( c.namespace + '_extra_headers' ),
|
135
|
+
$col = c.$table.children( 'colgroup' ).children( 'col' );
|
136
|
+
storedSizes = storedSizes || vars.storedSizes || [];
|
137
|
+
// process only if table ID or url match
|
138
|
+
if ( storedSizes.length ) {
|
139
|
+
for ( column = 0; column < c.columns; column++ ) {
|
140
|
+
// set saved resizable widths
|
141
|
+
ts.resizable.setWidth( c.$headerIndexed[ column ], storedSizes[ column ], vars.overflow );
|
142
|
+
if ( $extra.length ) {
|
143
|
+
// stickyHeaders needs to modify min & max width as well
|
144
|
+
$temp = $extra.eq( column ).add( $col.eq( column ) );
|
145
|
+
ts.resizable.setWidth( $temp, storedSizes[ column ], vars.overflow );
|
146
|
+
}
|
147
|
+
}
|
148
|
+
$temp = $( c.namespace + '_extra_table' );
|
149
|
+
if ( $temp.length && !ts.hasWidget( c.table, 'scroller' ) ) {
|
150
|
+
ts.resizable.setWidth( $temp, c.$table.outerWidth(), vars.overflow );
|
151
|
+
}
|
152
|
+
}
|
153
|
+
},
|
154
|
+
|
155
|
+
setHandlePosition : function( c, wo ) {
|
156
|
+
var startPosition,
|
157
|
+
hasScroller = ts.hasWidget( c.table, 'scroller' ),
|
158
|
+
tableHeight = c.$table.height(),
|
159
|
+
$handles = wo.$resizable_container.children(),
|
160
|
+
handleCenter = Math.floor( $handles.width() / 2 );
|
161
|
+
|
162
|
+
if ( hasScroller ) {
|
163
|
+
tableHeight = 0;
|
164
|
+
c.$table.closest( '.' + ts.css.scrollerWrap ).children().each(function(){
|
165
|
+
var $this = $(this);
|
166
|
+
// center table has a max-height set
|
167
|
+
tableHeight += $this.filter('[style*="height"]').length ? $this.height() : $this.children('table').height();
|
185
168
|
});
|
186
169
|
}
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
bindings : function( c, wo ) {
|
207
|
-
var namespace = c.namespace + 'tsresize';
|
208
|
-
wo.$resizable_container.children().bind( 'mousedown', function( event ) {
|
209
|
-
// save header cell and mouse position
|
210
|
-
var column,
|
211
|
-
vars = wo.resizable_,
|
212
|
-
$extras = $( c.namespace + '_extra_headers' ),
|
213
|
-
$header = $( event.target ).data( 'header' );
|
214
|
-
|
215
|
-
column = parseInt( $header.attr( 'data-column' ), 10 );
|
216
|
-
vars.$target = $header = $header.add( $extras.filter('[data-column="' + column + '"]') );
|
217
|
-
vars.target = column;
|
218
|
-
|
219
|
-
// if table is not as wide as it's parent, then resize the table
|
220
|
-
vars.$next = event.shiftKey || wo.resizable_targetLast ?
|
221
|
-
$header.parent().children().not( '.resizable-false' ).filter( ':last' ) :
|
222
|
-
$header.nextAll( ':not(.resizable-false)' ).eq( 0 );
|
170
|
+
// subtract out table left position from resizable handles. Fixes #864
|
171
|
+
startPosition = c.$table.position().left;
|
172
|
+
$handles.each( function() {
|
173
|
+
var $this = $(this),
|
174
|
+
column = parseInt( $this.attr( 'data-column' ), 10 ),
|
175
|
+
columns = c.columns - 1,
|
176
|
+
$header = $this.data( 'header' );
|
177
|
+
if ( !$header ) { return; } // see #859
|
178
|
+
if ( !$header.is(':visible') ) {
|
179
|
+
$this.hide();
|
180
|
+
} else if ( column < columns || column === columns && wo.resizable_addLastColumn ) {
|
181
|
+
$this.css({
|
182
|
+
display: 'inline-block',
|
183
|
+
height : tableHeight,
|
184
|
+
left : $header.position().left - startPosition + $header.outerWidth() - handleCenter
|
185
|
+
});
|
186
|
+
}
|
187
|
+
});
|
188
|
+
},
|
223
189
|
|
224
|
-
|
225
|
-
|
226
|
-
|
190
|
+
// prevent text selection while dragging resize bar
|
191
|
+
toggleTextSelection : function( c, toggle ) {
|
192
|
+
var namespace = c.namespace + 'tsresize';
|
193
|
+
c.widgetOptions.resizable_vars.disabled = toggle;
|
194
|
+
$( 'body' ).toggleClass( ts.css.resizableNoSelect, toggle );
|
195
|
+
if ( toggle ) {
|
196
|
+
$( 'body' )
|
197
|
+
.attr( 'unselectable', 'on' )
|
198
|
+
.bind( 'selectstart' + namespace, false );
|
199
|
+
} else {
|
200
|
+
$( 'body' )
|
201
|
+
.removeAttr( 'unselectable' )
|
202
|
+
.unbind( 'selectstart' + namespace );
|
203
|
+
}
|
204
|
+
},
|
227
205
|
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
206
|
+
bindings : function( c, wo ) {
|
207
|
+
var namespace = c.namespace + 'tsresize';
|
208
|
+
wo.$resizable_container.children().bind( 'mousedown', function( event ) {
|
209
|
+
// save header cell and mouse position
|
210
|
+
var column,
|
211
|
+
vars = wo.resizable_vars,
|
212
|
+
$extras = $( c.namespace + '_extra_headers' ),
|
213
|
+
$header = $( event.target ).data( 'header' );
|
214
|
+
|
215
|
+
column = parseInt( $header.attr( 'data-column' ), 10 );
|
216
|
+
vars.$target = $header = $header.add( $extras.filter('[data-column="' + column + '"]') );
|
217
|
+
vars.target = column;
|
218
|
+
|
219
|
+
// if table is not as wide as it's parent, then resize the table
|
220
|
+
vars.$next = event.shiftKey || wo.resizable_targetLast ?
|
221
|
+
$header.parent().children().not( '.resizable-false' ).filter( ':last' ) :
|
222
|
+
$header.nextAll( ':not(.resizable-false)' ).eq( 0 );
|
223
|
+
|
224
|
+
column = parseInt( vars.$next.attr( 'data-column' ), 10 );
|
225
|
+
vars.$next = vars.$next.add( $extras.filter('[data-column="' + column + '"]') );
|
226
|
+
vars.next = column;
|
227
|
+
|
228
|
+
vars.mouseXPosition = event.pageX;
|
229
|
+
ts.resizable.updateStoredSizes( c, wo );
|
230
|
+
ts.resizable.toggleTextSelection( c, true );
|
231
|
+
});
|
232
232
|
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
233
|
+
$( document )
|
234
|
+
.bind( 'mousemove' + namespace, function( event ) {
|
235
|
+
var vars = wo.resizable_vars;
|
236
|
+
// ignore mousemove if no mousedown
|
237
|
+
if ( !vars.disabled || vars.mouseXPosition === 0 || !vars.$target ) { return; }
|
238
|
+
if ( wo.resizable_throttle ) {
|
239
|
+
clearTimeout( vars.timer );
|
240
|
+
vars.timer = setTimeout( function() {
|
241
|
+
ts.resizable.mouseMove( c, wo, event );
|
242
|
+
}, isNaN( wo.resizable_throttle ) ? 5 : wo.resizable_throttle );
|
243
|
+
} else {
|
241
244
|
ts.resizable.mouseMove( c, wo, event );
|
242
|
-
}
|
243
|
-
}
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
245
|
+
}
|
246
|
+
})
|
247
|
+
.bind( 'mouseup' + namespace, function() {
|
248
|
+
if (!wo.resizable_vars.disabled) { return; }
|
249
|
+
ts.resizable.toggleTextSelection( c, false );
|
250
|
+
ts.resizable.stopResize( c, wo );
|
251
|
+
ts.resizable.setHandlePosition( c, wo );
|
252
|
+
});
|
253
|
+
|
254
|
+
// resizeEnd event triggered by scroller widget
|
255
|
+
$( window ).bind( 'resize' + namespace + ' resizeEnd' + namespace, function() {
|
251
256
|
ts.resizable.setHandlePosition( c, wo );
|
252
257
|
});
|
253
258
|
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
259
|
+
// right click to reset columns to default widths
|
260
|
+
c.$table
|
261
|
+
.bind( 'columnUpdate' + namespace, function() {
|
262
|
+
ts.resizable.setHandlePosition( c, wo );
|
263
|
+
})
|
264
|
+
.find( 'thead:first' )
|
265
|
+
.add( $( c.namespace + '_extra_table' ).find( 'thead:first' ) )
|
266
|
+
.bind( 'contextmenu' + namespace, function() {
|
267
|
+
// $.isEmptyObject() needs jQuery 1.4+; allow right click if already reset
|
268
|
+
var allowClick = wo.resizable_vars.storedSizes.length === 0;
|
269
|
+
ts.resizableReset( c.table );
|
270
|
+
ts.resizable.setHandlePosition( c, wo );
|
271
|
+
wo.resizable_vars.storedSizes = [];
|
272
|
+
return allowClick;
|
273
|
+
});
|
258
274
|
|
259
|
-
|
260
|
-
c.$table
|
261
|
-
.bind( 'columnUpdate' + namespace, function() {
|
262
|
-
ts.resizable.setHandlePosition( c, wo );
|
263
|
-
})
|
264
|
-
.find( 'thead:first' )
|
265
|
-
.add( $( c.namespace + '_extra_table' ).find( 'thead:first' ) )
|
266
|
-
.bind( 'contextmenu' + namespace, function() {
|
267
|
-
// $.isEmptyObject() needs jQuery 1.4+; allow right click if already reset
|
268
|
-
var allowClick = wo.resizable_.storedSizes.length === 0;
|
269
|
-
ts.resizableReset( c.table );
|
270
|
-
ts.resizable.setHandlePosition( c, wo );
|
271
|
-
wo.resizable_.storedSizes = [];
|
272
|
-
return allowClick;
|
273
|
-
});
|
275
|
+
},
|
274
276
|
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
277
|
+
mouseMove : function( c, wo, event ) {
|
278
|
+
if ( wo.resizable_vars.mouseXPosition === 0 || !wo.resizable_vars.$target ) { return; }
|
279
|
+
// resize columns
|
280
|
+
var column,
|
281
|
+
total = 0,
|
282
|
+
vars = wo.resizable_vars,
|
283
|
+
$next = vars.$next,
|
284
|
+
tar = vars.storedSizes[ vars.target ],
|
285
|
+
leftEdge = event.pageX - vars.mouseXPosition;
|
286
|
+
if ( vars.overflow ) {
|
287
|
+
if ( tar + leftEdge > 0 ) {
|
288
|
+
vars.storedSizes[ vars.target ] += leftEdge;
|
289
|
+
ts.resizable.setWidth( vars.$target, vars.storedSizes[ vars.target ], true );
|
290
|
+
// update the entire table width
|
291
|
+
for ( column = 0; column < c.columns; column++ ) {
|
292
|
+
total += vars.storedSizes[ column ];
|
293
|
+
}
|
294
|
+
ts.resizable.setWidth( c.$table.add( $( c.namespace + '_extra_table' ) ), total );
|
293
295
|
}
|
294
|
-
|
296
|
+
if ( !$next.length ) {
|
297
|
+
// if expanding right-most column, scroll the wrapper
|
298
|
+
vars.$wrap[0].scrollLeft = c.$table.width();
|
299
|
+
}
|
300
|
+
} else if ( vars.fullWidth ) {
|
301
|
+
vars.storedSizes[ vars.target ] += leftEdge;
|
302
|
+
vars.storedSizes[ vars.next ] -= leftEdge;
|
303
|
+
ts.resizable.setWidths( c, wo );
|
304
|
+
} else {
|
305
|
+
vars.storedSizes[ vars.target ] += leftEdge;
|
306
|
+
ts.resizable.setWidths( c, wo );
|
295
307
|
}
|
296
|
-
|
297
|
-
|
298
|
-
|
308
|
+
vars.mouseXPosition = event.pageX;
|
309
|
+
// dynamically update sticky header widths
|
310
|
+
c.$table.trigger('stickyHeadersUpdate');
|
311
|
+
},
|
312
|
+
|
313
|
+
stopResize : function( c, wo ) {
|
314
|
+
var vars = wo.resizable_vars;
|
315
|
+
ts.resizable.updateStoredSizes( c, wo );
|
316
|
+
if ( vars.useStorage ) {
|
317
|
+
// save all column widths
|
318
|
+
ts.storage( c.table, ts.css.resizableStorage, vars.storedSizes );
|
319
|
+
ts.storage( c.table, 'tablesorter-table-resized-width', c.$table.width() );
|
299
320
|
}
|
300
|
-
|
301
|
-
vars
|
302
|
-
|
303
|
-
|
304
|
-
} else {
|
305
|
-
vars.storedSizes[ vars.target ] += leftEdge;
|
306
|
-
ts.resizable.setWidths( c, wo );
|
321
|
+
vars.mouseXPosition = 0;
|
322
|
+
vars.$target = vars.$next = null;
|
323
|
+
// will update stickyHeaders, just in case, see #912
|
324
|
+
c.$table.trigger('stickyHeadersUpdate');
|
307
325
|
}
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
// save
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
c
|
325
|
-
|
326
|
-
}
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
options: {
|
335
|
-
resizable : true, // save column widths to storage
|
336
|
-
resizable_addLastColumn : false,
|
337
|
-
resizable_widths : [],
|
338
|
-
resizable_throttle : false, // set to true (5ms) or any number 0-10 range
|
339
|
-
resizable_targetLast : false,
|
340
|
-
resizable_fullWidth : null
|
341
|
-
},
|
342
|
-
init: function(table, thisWidget, c, wo) {
|
343
|
-
ts.resizable.init( c, wo );
|
344
|
-
},
|
345
|
-
remove: function( table, c, wo, refreshing ) {
|
346
|
-
if (wo.$resizable_container) {
|
347
|
-
var namespace = c.namespace + 'tsresize';
|
348
|
-
c.$table.add( $( c.namespace + '_extra_table' ) )
|
349
|
-
.removeClass('hasResizable')
|
350
|
-
.children( 'thead' ).unbind( 'contextmenu' + namespace );
|
326
|
+
};
|
327
|
+
|
328
|
+
// this widget saves the column widths if
|
329
|
+
// $.tablesorter.storage function is included
|
330
|
+
// **************************
|
331
|
+
ts.addWidget({
|
332
|
+
id: 'resizable',
|
333
|
+
priority: 40,
|
334
|
+
options: {
|
335
|
+
resizable : true, // save column widths to storage
|
336
|
+
resizable_addLastColumn : false,
|
337
|
+
resizable_widths : [],
|
338
|
+
resizable_throttle : false, // set to true (5ms) or any number 0-10 range
|
339
|
+
resizable_targetLast : false,
|
340
|
+
resizable_fullWidth : null
|
341
|
+
},
|
342
|
+
init: function(table, thisWidget, c, wo) {
|
343
|
+
ts.resizable.init( c, wo );
|
344
|
+
},
|
345
|
+
remove: function( table, c, wo, refreshing ) {
|
346
|
+
if (wo.$resizable_container) {
|
347
|
+
var namespace = c.namespace + 'tsresize';
|
348
|
+
c.$table.add( $( c.namespace + '_extra_table' ) )
|
349
|
+
.removeClass('hasResizable')
|
350
|
+
.children( 'thead' )
|
351
|
+
.unbind( 'contextmenu' + namespace );
|
351
352
|
|
352
353
|
wo.$resizable_container.remove();
|
353
|
-
|
354
|
-
|
355
|
-
|
354
|
+
ts.resizable.toggleTextSelection( c, false );
|
355
|
+
ts.resizableReset( table, refreshing );
|
356
|
+
$( document ).unbind( 'mousemove' + namespace + ' mouseup' + namespace );
|
357
|
+
}
|
356
358
|
}
|
357
|
-
}
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
359
|
+
});
|
360
|
+
|
361
|
+
ts.resizableReset = function( table, refreshing ) {
|
362
|
+
$( table ).each(function(){
|
363
|
+
var index, $t,
|
364
|
+
c = this.config,
|
365
|
+
wo = c && c.widgetOptions,
|
366
|
+
vars = wo.resizable_vars;
|
367
|
+
if ( table && c && c.$headerIndexed.length ) {
|
368
|
+
// restore the initial table width
|
369
|
+
if ( vars.overflow && vars.tableWidth ) {
|
370
|
+
ts.resizable.setWidth( c.$table, vars.tableWidth, true );
|
371
|
+
if ( vars.useStorage ) {
|
372
|
+
ts.storage( table, 'tablesorter-table-resized-width', 'auto' );
|
373
|
+
}
|
372
374
|
}
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
375
|
+
for ( index = 0; index < c.columns; index++ ) {
|
376
|
+
$t = c.$headerIndexed[ index ];
|
377
|
+
if ( wo.resizable_widths && wo.resizable_widths[ index ] ) {
|
378
|
+
ts.resizable.setWidth( $t, wo.resizable_widths[ index ], vars.overflow );
|
379
|
+
} else if ( !$t.hasClass( 'resizable-false' ) ) {
|
380
|
+
// don't clear the width of any column that is not resizable
|
381
|
+
ts.resizable.setWidth( $t, '', vars.overflow );
|
382
|
+
}
|
381
383
|
}
|
382
|
-
}
|
383
384
|
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
385
|
+
// reset stickyHeader widths
|
386
|
+
c.$table.trigger( 'stickyHeadersUpdate' );
|
387
|
+
if ( ts.storage && !refreshing ) {
|
388
|
+
ts.storage( this, ts.css.resizableStorage, {} );
|
389
|
+
}
|
388
390
|
}
|
389
|
-
}
|
390
|
-
}
|
391
|
-
};
|
391
|
+
});
|
392
|
+
};
|
392
393
|
|
393
394
|
})( jQuery, window );
|