mirror of
https://github.com/Mottie/tablesorter.git
synced 2024-10-08 13:44:18 +00:00
Resizable: integrate with columnSelector. See #859
This commit is contained in:
parent
655a0f09b4
commit
bbaa88ab98
63
dist/js/jquery.tablesorter.combined.js
vendored
63
dist/js/jquery.tablesorter.combined.js
vendored
@ -1,4 +1,4 @@
|
||||
/*! tablesorter (FORK) - updated 03-30-2015 (v2.21.4)*/
|
||||
/*! tablesorter (FORK) - updated 04-02-2015 (v2.21.4)*/
|
||||
/* Includes widgets ( storage,uitheme,columns,filter,stickyHeaders,resizable,saveSort ) */
|
||||
(function(factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
@ -4180,7 +4180,7 @@ ts.resizable = {
|
||||
if ( storedSizes.length ) {
|
||||
for ( column = 0; column < c.columns; column++ ) {
|
||||
// set saved resizable widths
|
||||
c.$headers.eq( column ).width( storedSizes[ column ] );
|
||||
c.$headerIndexed[ column ].width( storedSizes[ column ] );
|
||||
if ( $extra.length ) {
|
||||
// stickyHeaders needs to modify min & max width as well
|
||||
ts.resizable.setWidth( $extra.eq( column ).add( $col.eq( column ) ), storedSizes[ column ] );
|
||||
@ -4212,8 +4212,11 @@ ts.resizable = {
|
||||
column = parseInt( $this.attr( 'data-column' ), 10 ),
|
||||
columns = c.columns - 1,
|
||||
$header = $this.data( 'header' );
|
||||
if ( column < columns || column === columns && wo.resizable_addLastColumn ) {
|
||||
if ( !$header.is(':visible') ) {
|
||||
$this.hide();
|
||||
} else if ( column < columns || column === columns && wo.resizable_addLastColumn ) {
|
||||
$this.css({
|
||||
display: 'inline-block',
|
||||
height : tableHeight,
|
||||
left : $header.position().left + $header.width() - handleCenter
|
||||
});
|
||||
@ -4241,7 +4244,7 @@ ts.resizable = {
|
||||
var namespace = c.namespace + 'tsresize';
|
||||
wo.$resizable_container.children().bind( 'mousedown', function( event ) {
|
||||
// save header cell and mouse position
|
||||
var column,
|
||||
var column, $this,
|
||||
vars = wo.resizable_,
|
||||
$extras = $( c.namespace + '_extra_headers' ),
|
||||
$header = $( event.target ).data( 'header' );
|
||||
@ -4260,7 +4263,11 @@ ts.resizable = {
|
||||
vars.next = column;
|
||||
|
||||
vars.mouseXPosition = event.pageX;
|
||||
vars.storedSizes = c.$headers.map(function(){ return $(this).width(); }).get();
|
||||
vars.storedSizes = [];
|
||||
for ( column = 0; column < c.columns; column++ ) {
|
||||
$this = c.$headerIndexed[ column ];
|
||||
vars.storedSizes[ column ] = $this.is(':visible') ? $this.width() : 0;
|
||||
}
|
||||
ts.resizable.toggleTextSelection( c, true );
|
||||
});
|
||||
|
||||
@ -4291,15 +4298,20 @@ ts.resizable = {
|
||||
});
|
||||
|
||||
// right click to reset columns to default widths
|
||||
c.$table.find( 'thead:first' ).add( $( c.namespace + '_extra_table' ).find( 'thead:first' ) )
|
||||
.bind( 'contextmenu' + namespace, function() {
|
||||
// $.isEmptyObject() needs jQuery 1.4+; allow right click if already reset
|
||||
var allowClick = wo.resizable_.storedSizes.length === 0;
|
||||
ts.resizableReset( c.table );
|
||||
ts.resizable.setHandlePosition( c, wo );
|
||||
wo.resizable_.storedSizes = [];
|
||||
return allowClick;
|
||||
});
|
||||
c.$table
|
||||
.bind( 'columnUpdate' + namespace, function() {
|
||||
ts.resizable.setHandlePosition( c, wo );
|
||||
})
|
||||
.find( 'thead:first' )
|
||||
.add( $( c.namespace + '_extra_table' ).find( 'thead:first' ) )
|
||||
.bind( 'contextmenu' + namespace, function() {
|
||||
// $.isEmptyObject() needs jQuery 1.4+; allow right click if already reset
|
||||
var allowClick = wo.resizable_.storedSizes.length === 0;
|
||||
ts.resizableReset( c.table );
|
||||
ts.resizable.setHandlePosition( c, wo );
|
||||
wo.resizable_.storedSizes = [];
|
||||
return allowClick;
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
@ -4332,10 +4344,15 @@ ts.resizable = {
|
||||
},
|
||||
|
||||
stopResize : function( c, wo ) {
|
||||
var vars = wo.resizable_;
|
||||
var $this, column,
|
||||
vars = wo.resizable_;
|
||||
vars.storedSizes = [];
|
||||
if ( ts.storage ) {
|
||||
vars.storedSizes = c.$headers.map(function(){ return $(this).width(); }).get();
|
||||
vars.storedSizes = [];
|
||||
for ( column = 0; column < c.columns; column++ ) {
|
||||
$this = c.$headerIndexed[ column ];
|
||||
vars.storedSizes[ column ] = $this.is(':visible') ? $this.width() : 0;
|
||||
}
|
||||
if ( wo.resizable !== false ) {
|
||||
// save all column widths
|
||||
ts.storage( c.table, ts.css.resizableStorage, vars.storedSizes );
|
||||
@ -4380,19 +4397,19 @@ ts.addWidget({
|
||||
|
||||
ts.resizableReset = function( table, nosave ) {
|
||||
$( table ).each(function(){
|
||||
var $t,
|
||||
var index, $t,
|
||||
c = this.config,
|
||||
wo = c && c.widgetOptions;
|
||||
if ( table && c ) {
|
||||
c.$headers.each( function( i ) {
|
||||
$t = $(this);
|
||||
if ( wo.resizable_widths && wo.resizable_widths[ i ] ) {
|
||||
$t.css( 'width', wo.resizable_widths[ i ] );
|
||||
if ( table && c && c.$headerIndexed.length ) {
|
||||
for ( index = 0; index < c.columns; index++ ) {
|
||||
$t = c.$headerIndexed[ index ];
|
||||
if ( wo.resizable_widths && wo.resizable_widths[ index ] ) {
|
||||
$t.css( 'width', wo.resizable_widths[ index ] );
|
||||
} else if ( !$t.hasClass( 'resizable-false' ) ) {
|
||||
// don't clear the width of any column that is not resizable
|
||||
$t.css( 'width', '' );
|
||||
}
|
||||
});
|
||||
}
|
||||
// reset stickyHeader widths
|
||||
$( window ).trigger( 'resize' );
|
||||
if ( ts.storage && !nosave ) {
|
||||
|
4
dist/js/jquery.tablesorter.combined.min.js
vendored
4
dist/js/jquery.tablesorter.combined.min.js
vendored
File diff suppressed because one or more lines are too long
63
dist/js/jquery.tablesorter.widgets.js
vendored
63
dist/js/jquery.tablesorter.widgets.js
vendored
@ -1,4 +1,4 @@
|
||||
/*! tablesorter (FORK) - updated 03-30-2015 (v2.21.4)*/
|
||||
/*! tablesorter (FORK) - updated 04-02-2015 (v2.21.4)*/
|
||||
/* Includes widgets ( storage,uitheme,columns,filter,stickyHeaders,resizable,saveSort ) */
|
||||
(function(factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
@ -2051,7 +2051,7 @@ ts.resizable = {
|
||||
if ( storedSizes.length ) {
|
||||
for ( column = 0; column < c.columns; column++ ) {
|
||||
// set saved resizable widths
|
||||
c.$headers.eq( column ).width( storedSizes[ column ] );
|
||||
c.$headerIndexed[ column ].width( storedSizes[ column ] );
|
||||
if ( $extra.length ) {
|
||||
// stickyHeaders needs to modify min & max width as well
|
||||
ts.resizable.setWidth( $extra.eq( column ).add( $col.eq( column ) ), storedSizes[ column ] );
|
||||
@ -2083,8 +2083,11 @@ ts.resizable = {
|
||||
column = parseInt( $this.attr( 'data-column' ), 10 ),
|
||||
columns = c.columns - 1,
|
||||
$header = $this.data( 'header' );
|
||||
if ( column < columns || column === columns && wo.resizable_addLastColumn ) {
|
||||
if ( !$header.is(':visible') ) {
|
||||
$this.hide();
|
||||
} else if ( column < columns || column === columns && wo.resizable_addLastColumn ) {
|
||||
$this.css({
|
||||
display: 'inline-block',
|
||||
height : tableHeight,
|
||||
left : $header.position().left + $header.width() - handleCenter
|
||||
});
|
||||
@ -2112,7 +2115,7 @@ ts.resizable = {
|
||||
var namespace = c.namespace + 'tsresize';
|
||||
wo.$resizable_container.children().bind( 'mousedown', function( event ) {
|
||||
// save header cell and mouse position
|
||||
var column,
|
||||
var column, $this,
|
||||
vars = wo.resizable_,
|
||||
$extras = $( c.namespace + '_extra_headers' ),
|
||||
$header = $( event.target ).data( 'header' );
|
||||
@ -2131,7 +2134,11 @@ ts.resizable = {
|
||||
vars.next = column;
|
||||
|
||||
vars.mouseXPosition = event.pageX;
|
||||
vars.storedSizes = c.$headers.map(function(){ return $(this).width(); }).get();
|
||||
vars.storedSizes = [];
|
||||
for ( column = 0; column < c.columns; column++ ) {
|
||||
$this = c.$headerIndexed[ column ];
|
||||
vars.storedSizes[ column ] = $this.is(':visible') ? $this.width() : 0;
|
||||
}
|
||||
ts.resizable.toggleTextSelection( c, true );
|
||||
});
|
||||
|
||||
@ -2162,15 +2169,20 @@ ts.resizable = {
|
||||
});
|
||||
|
||||
// right click to reset columns to default widths
|
||||
c.$table.find( 'thead:first' ).add( $( c.namespace + '_extra_table' ).find( 'thead:first' ) )
|
||||
.bind( 'contextmenu' + namespace, function() {
|
||||
// $.isEmptyObject() needs jQuery 1.4+; allow right click if already reset
|
||||
var allowClick = wo.resizable_.storedSizes.length === 0;
|
||||
ts.resizableReset( c.table );
|
||||
ts.resizable.setHandlePosition( c, wo );
|
||||
wo.resizable_.storedSizes = [];
|
||||
return allowClick;
|
||||
});
|
||||
c.$table
|
||||
.bind( 'columnUpdate' + namespace, function() {
|
||||
ts.resizable.setHandlePosition( c, wo );
|
||||
})
|
||||
.find( 'thead:first' )
|
||||
.add( $( c.namespace + '_extra_table' ).find( 'thead:first' ) )
|
||||
.bind( 'contextmenu' + namespace, function() {
|
||||
// $.isEmptyObject() needs jQuery 1.4+; allow right click if already reset
|
||||
var allowClick = wo.resizable_.storedSizes.length === 0;
|
||||
ts.resizableReset( c.table );
|
||||
ts.resizable.setHandlePosition( c, wo );
|
||||
wo.resizable_.storedSizes = [];
|
||||
return allowClick;
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
@ -2203,10 +2215,15 @@ ts.resizable = {
|
||||
},
|
||||
|
||||
stopResize : function( c, wo ) {
|
||||
var vars = wo.resizable_;
|
||||
var $this, column,
|
||||
vars = wo.resizable_;
|
||||
vars.storedSizes = [];
|
||||
if ( ts.storage ) {
|
||||
vars.storedSizes = c.$headers.map(function(){ return $(this).width(); }).get();
|
||||
vars.storedSizes = [];
|
||||
for ( column = 0; column < c.columns; column++ ) {
|
||||
$this = c.$headerIndexed[ column ];
|
||||
vars.storedSizes[ column ] = $this.is(':visible') ? $this.width() : 0;
|
||||
}
|
||||
if ( wo.resizable !== false ) {
|
||||
// save all column widths
|
||||
ts.storage( c.table, ts.css.resizableStorage, vars.storedSizes );
|
||||
@ -2251,19 +2268,19 @@ ts.addWidget({
|
||||
|
||||
ts.resizableReset = function( table, nosave ) {
|
||||
$( table ).each(function(){
|
||||
var $t,
|
||||
var index, $t,
|
||||
c = this.config,
|
||||
wo = c && c.widgetOptions;
|
||||
if ( table && c ) {
|
||||
c.$headers.each( function( i ) {
|
||||
$t = $(this);
|
||||
if ( wo.resizable_widths && wo.resizable_widths[ i ] ) {
|
||||
$t.css( 'width', wo.resizable_widths[ i ] );
|
||||
if ( table && c && c.$headerIndexed.length ) {
|
||||
for ( index = 0; index < c.columns; index++ ) {
|
||||
$t = c.$headerIndexed[ index ];
|
||||
if ( wo.resizable_widths && wo.resizable_widths[ index ] ) {
|
||||
$t.css( 'width', wo.resizable_widths[ index ] );
|
||||
} else if ( !$t.hasClass( 'resizable-false' ) ) {
|
||||
// don't clear the width of any column that is not resizable
|
||||
$t.css( 'width', '' );
|
||||
}
|
||||
});
|
||||
}
|
||||
// reset stickyHeader widths
|
||||
$( window ).trigger( 'resize' );
|
||||
if ( ts.storage && !nosave ) {
|
||||
|
4
dist/js/jquery.tablesorter.widgets.min.js
vendored
4
dist/js/jquery.tablesorter.widgets.min.js
vendored
File diff suppressed because one or more lines are too long
2
dist/js/widgets/widget-resizable.min.js
vendored
2
dist/js/widgets/widget-resizable.min.js
vendored
File diff suppressed because one or more lines are too long
@ -4,7 +4,7 @@
|
||||
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██▀▀ ▀▀▀▀██
|
||||
█████▀ ▀████▀ ██ ██ ▀████▀ ██ ██ ██ ██ ▀████▀ █████▀ ██ ██ █████▀
|
||||
*/
|
||||
/*! tablesorter (FORK) - updated 03-30-2015 (v2.21.4)*/
|
||||
/*! tablesorter (FORK) - updated 04-02-2015 (v2.21.4)*/
|
||||
/* Includes widgets ( storage,uitheme,columns,filter,stickyHeaders,resizable,saveSort ) */
|
||||
(function(factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
@ -4186,7 +4186,7 @@ ts.resizable = {
|
||||
if ( storedSizes.length ) {
|
||||
for ( column = 0; column < c.columns; column++ ) {
|
||||
// set saved resizable widths
|
||||
c.$headers.eq( column ).width( storedSizes[ column ] );
|
||||
c.$headerIndexed[ column ].width( storedSizes[ column ] );
|
||||
if ( $extra.length ) {
|
||||
// stickyHeaders needs to modify min & max width as well
|
||||
ts.resizable.setWidth( $extra.eq( column ).add( $col.eq( column ) ), storedSizes[ column ] );
|
||||
@ -4218,8 +4218,11 @@ ts.resizable = {
|
||||
column = parseInt( $this.attr( 'data-column' ), 10 ),
|
||||
columns = c.columns - 1,
|
||||
$header = $this.data( 'header' );
|
||||
if ( column < columns || column === columns && wo.resizable_addLastColumn ) {
|
||||
if ( !$header.is(':visible') ) {
|
||||
$this.hide();
|
||||
} else if ( column < columns || column === columns && wo.resizable_addLastColumn ) {
|
||||
$this.css({
|
||||
display: 'inline-block',
|
||||
height : tableHeight,
|
||||
left : $header.position().left + $header.width() - handleCenter
|
||||
});
|
||||
@ -4247,7 +4250,7 @@ ts.resizable = {
|
||||
var namespace = c.namespace + 'tsresize';
|
||||
wo.$resizable_container.children().bind( 'mousedown', function( event ) {
|
||||
// save header cell and mouse position
|
||||
var column,
|
||||
var column, $this,
|
||||
vars = wo.resizable_,
|
||||
$extras = $( c.namespace + '_extra_headers' ),
|
||||
$header = $( event.target ).data( 'header' );
|
||||
@ -4266,7 +4269,11 @@ ts.resizable = {
|
||||
vars.next = column;
|
||||
|
||||
vars.mouseXPosition = event.pageX;
|
||||
vars.storedSizes = c.$headers.map(function(){ return $(this).width(); }).get();
|
||||
vars.storedSizes = [];
|
||||
for ( column = 0; column < c.columns; column++ ) {
|
||||
$this = c.$headerIndexed[ column ];
|
||||
vars.storedSizes[ column ] = $this.is(':visible') ? $this.width() : 0;
|
||||
}
|
||||
ts.resizable.toggleTextSelection( c, true );
|
||||
});
|
||||
|
||||
@ -4297,15 +4304,20 @@ ts.resizable = {
|
||||
});
|
||||
|
||||
// right click to reset columns to default widths
|
||||
c.$table.find( 'thead:first' ).add( $( c.namespace + '_extra_table' ).find( 'thead:first' ) )
|
||||
.bind( 'contextmenu' + namespace, function() {
|
||||
// $.isEmptyObject() needs jQuery 1.4+; allow right click if already reset
|
||||
var allowClick = wo.resizable_.storedSizes.length === 0;
|
||||
ts.resizableReset( c.table );
|
||||
ts.resizable.setHandlePosition( c, wo );
|
||||
wo.resizable_.storedSizes = [];
|
||||
return allowClick;
|
||||
});
|
||||
c.$table
|
||||
.bind( 'columnUpdate' + namespace, function() {
|
||||
ts.resizable.setHandlePosition( c, wo );
|
||||
})
|
||||
.find( 'thead:first' )
|
||||
.add( $( c.namespace + '_extra_table' ).find( 'thead:first' ) )
|
||||
.bind( 'contextmenu' + namespace, function() {
|
||||
// $.isEmptyObject() needs jQuery 1.4+; allow right click if already reset
|
||||
var allowClick = wo.resizable_.storedSizes.length === 0;
|
||||
ts.resizableReset( c.table );
|
||||
ts.resizable.setHandlePosition( c, wo );
|
||||
wo.resizable_.storedSizes = [];
|
||||
return allowClick;
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
@ -4338,10 +4350,15 @@ ts.resizable = {
|
||||
},
|
||||
|
||||
stopResize : function( c, wo ) {
|
||||
var vars = wo.resizable_;
|
||||
var $this, column,
|
||||
vars = wo.resizable_;
|
||||
vars.storedSizes = [];
|
||||
if ( ts.storage ) {
|
||||
vars.storedSizes = c.$headers.map(function(){ return $(this).width(); }).get();
|
||||
vars.storedSizes = [];
|
||||
for ( column = 0; column < c.columns; column++ ) {
|
||||
$this = c.$headerIndexed[ column ];
|
||||
vars.storedSizes[ column ] = $this.is(':visible') ? $this.width() : 0;
|
||||
}
|
||||
if ( wo.resizable !== false ) {
|
||||
// save all column widths
|
||||
ts.storage( c.table, ts.css.resizableStorage, vars.storedSizes );
|
||||
@ -4386,19 +4403,19 @@ ts.addWidget({
|
||||
|
||||
ts.resizableReset = function( table, nosave ) {
|
||||
$( table ).each(function(){
|
||||
var $t,
|
||||
var index, $t,
|
||||
c = this.config,
|
||||
wo = c && c.widgetOptions;
|
||||
if ( table && c ) {
|
||||
c.$headers.each( function( i ) {
|
||||
$t = $(this);
|
||||
if ( wo.resizable_widths && wo.resizable_widths[ i ] ) {
|
||||
$t.css( 'width', wo.resizable_widths[ i ] );
|
||||
if ( table && c && c.$headerIndexed.length ) {
|
||||
for ( index = 0; index < c.columns; index++ ) {
|
||||
$t = c.$headerIndexed[ index ];
|
||||
if ( wo.resizable_widths && wo.resizable_widths[ index ] ) {
|
||||
$t.css( 'width', wo.resizable_widths[ index ] );
|
||||
} else if ( !$t.hasClass( 'resizable-false' ) ) {
|
||||
// don't clear the width of any column that is not resizable
|
||||
$t.css( 'width', '' );
|
||||
}
|
||||
});
|
||||
}
|
||||
// reset stickyHeader widths
|
||||
$( window ).trigger( 'resize' );
|
||||
if ( ts.storage && !nosave ) {
|
||||
|
@ -4,7 +4,7 @@
|
||||
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██▀▀ ▀▀▀▀██
|
||||
█████▀ ▀████▀ ██ ██ ▀████▀ ██ ██ ██ ██ ▀████▀ █████▀ ██ ██ █████▀
|
||||
*/
|
||||
/*! tablesorter (FORK) - updated 03-30-2015 (v2.21.4)*/
|
||||
/*! tablesorter (FORK) - updated 04-02-2015 (v2.21.4)*/
|
||||
/* Includes widgets ( storage,uitheme,columns,filter,stickyHeaders,resizable,saveSort ) */
|
||||
(function(factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
@ -2057,7 +2057,7 @@ ts.resizable = {
|
||||
if ( storedSizes.length ) {
|
||||
for ( column = 0; column < c.columns; column++ ) {
|
||||
// set saved resizable widths
|
||||
c.$headers.eq( column ).width( storedSizes[ column ] );
|
||||
c.$headerIndexed[ column ].width( storedSizes[ column ] );
|
||||
if ( $extra.length ) {
|
||||
// stickyHeaders needs to modify min & max width as well
|
||||
ts.resizable.setWidth( $extra.eq( column ).add( $col.eq( column ) ), storedSizes[ column ] );
|
||||
@ -2089,8 +2089,11 @@ ts.resizable = {
|
||||
column = parseInt( $this.attr( 'data-column' ), 10 ),
|
||||
columns = c.columns - 1,
|
||||
$header = $this.data( 'header' );
|
||||
if ( column < columns || column === columns && wo.resizable_addLastColumn ) {
|
||||
if ( !$header.is(':visible') ) {
|
||||
$this.hide();
|
||||
} else if ( column < columns || column === columns && wo.resizable_addLastColumn ) {
|
||||
$this.css({
|
||||
display: 'inline-block',
|
||||
height : tableHeight,
|
||||
left : $header.position().left + $header.width() - handleCenter
|
||||
});
|
||||
@ -2118,7 +2121,7 @@ ts.resizable = {
|
||||
var namespace = c.namespace + 'tsresize';
|
||||
wo.$resizable_container.children().bind( 'mousedown', function( event ) {
|
||||
// save header cell and mouse position
|
||||
var column,
|
||||
var column, $this,
|
||||
vars = wo.resizable_,
|
||||
$extras = $( c.namespace + '_extra_headers' ),
|
||||
$header = $( event.target ).data( 'header' );
|
||||
@ -2137,7 +2140,11 @@ ts.resizable = {
|
||||
vars.next = column;
|
||||
|
||||
vars.mouseXPosition = event.pageX;
|
||||
vars.storedSizes = c.$headers.map(function(){ return $(this).width(); }).get();
|
||||
vars.storedSizes = [];
|
||||
for ( column = 0; column < c.columns; column++ ) {
|
||||
$this = c.$headerIndexed[ column ];
|
||||
vars.storedSizes[ column ] = $this.is(':visible') ? $this.width() : 0;
|
||||
}
|
||||
ts.resizable.toggleTextSelection( c, true );
|
||||
});
|
||||
|
||||
@ -2168,15 +2175,20 @@ ts.resizable = {
|
||||
});
|
||||
|
||||
// right click to reset columns to default widths
|
||||
c.$table.find( 'thead:first' ).add( $( c.namespace + '_extra_table' ).find( 'thead:first' ) )
|
||||
.bind( 'contextmenu' + namespace, function() {
|
||||
// $.isEmptyObject() needs jQuery 1.4+; allow right click if already reset
|
||||
var allowClick = wo.resizable_.storedSizes.length === 0;
|
||||
ts.resizableReset( c.table );
|
||||
ts.resizable.setHandlePosition( c, wo );
|
||||
wo.resizable_.storedSizes = [];
|
||||
return allowClick;
|
||||
});
|
||||
c.$table
|
||||
.bind( 'columnUpdate' + namespace, function() {
|
||||
ts.resizable.setHandlePosition( c, wo );
|
||||
})
|
||||
.find( 'thead:first' )
|
||||
.add( $( c.namespace + '_extra_table' ).find( 'thead:first' ) )
|
||||
.bind( 'contextmenu' + namespace, function() {
|
||||
// $.isEmptyObject() needs jQuery 1.4+; allow right click if already reset
|
||||
var allowClick = wo.resizable_.storedSizes.length === 0;
|
||||
ts.resizableReset( c.table );
|
||||
ts.resizable.setHandlePosition( c, wo );
|
||||
wo.resizable_.storedSizes = [];
|
||||
return allowClick;
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
@ -2209,10 +2221,15 @@ ts.resizable = {
|
||||
},
|
||||
|
||||
stopResize : function( c, wo ) {
|
||||
var vars = wo.resizable_;
|
||||
var $this, column,
|
||||
vars = wo.resizable_;
|
||||
vars.storedSizes = [];
|
||||
if ( ts.storage ) {
|
||||
vars.storedSizes = c.$headers.map(function(){ return $(this).width(); }).get();
|
||||
vars.storedSizes = [];
|
||||
for ( column = 0; column < c.columns; column++ ) {
|
||||
$this = c.$headerIndexed[ column ];
|
||||
vars.storedSizes[ column ] = $this.is(':visible') ? $this.width() : 0;
|
||||
}
|
||||
if ( wo.resizable !== false ) {
|
||||
// save all column widths
|
||||
ts.storage( c.table, ts.css.resizableStorage, vars.storedSizes );
|
||||
@ -2257,19 +2274,19 @@ ts.addWidget({
|
||||
|
||||
ts.resizableReset = function( table, nosave ) {
|
||||
$( table ).each(function(){
|
||||
var $t,
|
||||
var index, $t,
|
||||
c = this.config,
|
||||
wo = c && c.widgetOptions;
|
||||
if ( table && c ) {
|
||||
c.$headers.each( function( i ) {
|
||||
$t = $(this);
|
||||
if ( wo.resizable_widths && wo.resizable_widths[ i ] ) {
|
||||
$t.css( 'width', wo.resizable_widths[ i ] );
|
||||
if ( table && c && c.$headerIndexed.length ) {
|
||||
for ( index = 0; index < c.columns; index++ ) {
|
||||
$t = c.$headerIndexed[ index ];
|
||||
if ( wo.resizable_widths && wo.resizable_widths[ index ] ) {
|
||||
$t.css( 'width', wo.resizable_widths[ index ] );
|
||||
} else if ( !$t.hasClass( 'resizable-false' ) ) {
|
||||
// don't clear the width of any column that is not resizable
|
||||
$t.css( 'width', '' );
|
||||
}
|
||||
});
|
||||
}
|
||||
// reset stickyHeader widths
|
||||
$( window ).trigger( 'resize' );
|
||||
if ( ts.storage && !nosave ) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
/*! Widget: resizable - updated 3/26/2015 (v2.21.3) */
|
||||
/*! Widget: resizable - updated 4/2/2015 (v2.21.5) */
|
||||
;(function ($, window) {
|
||||
'use strict';
|
||||
var ts = $.tablesorter = $.tablesorter || {};
|
||||
@ -89,7 +89,7 @@ ts.resizable = {
|
||||
if ( storedSizes.length ) {
|
||||
for ( column = 0; column < c.columns; column++ ) {
|
||||
// set saved resizable widths
|
||||
c.$headers.eq( column ).width( storedSizes[ column ] );
|
||||
c.$headerIndexed[ column ].width( storedSizes[ column ] );
|
||||
if ( $extra.length ) {
|
||||
// stickyHeaders needs to modify min & max width as well
|
||||
ts.resizable.setWidth( $extra.eq( column ).add( $col.eq( column ) ), storedSizes[ column ] );
|
||||
@ -121,8 +121,11 @@ ts.resizable = {
|
||||
column = parseInt( $this.attr( 'data-column' ), 10 ),
|
||||
columns = c.columns - 1,
|
||||
$header = $this.data( 'header' );
|
||||
if ( column < columns || column === columns && wo.resizable_addLastColumn ) {
|
||||
if ( !$header.is(':visible') ) {
|
||||
$this.hide();
|
||||
} else if ( column < columns || column === columns && wo.resizable_addLastColumn ) {
|
||||
$this.css({
|
||||
display: 'inline-block',
|
||||
height : tableHeight,
|
||||
left : $header.position().left + $header.width() - handleCenter
|
||||
});
|
||||
@ -150,7 +153,7 @@ ts.resizable = {
|
||||
var namespace = c.namespace + 'tsresize';
|
||||
wo.$resizable_container.children().bind( 'mousedown', function( event ) {
|
||||
// save header cell and mouse position
|
||||
var column,
|
||||
var column, $this,
|
||||
vars = wo.resizable_,
|
||||
$extras = $( c.namespace + '_extra_headers' ),
|
||||
$header = $( event.target ).data( 'header' );
|
||||
@ -169,7 +172,11 @@ ts.resizable = {
|
||||
vars.next = column;
|
||||
|
||||
vars.mouseXPosition = event.pageX;
|
||||
vars.storedSizes = c.$headers.map(function(){ return $(this).width(); }).get();
|
||||
vars.storedSizes = [];
|
||||
for ( column = 0; column < c.columns; column++ ) {
|
||||
$this = c.$headerIndexed[ column ];
|
||||
vars.storedSizes[ column ] = $this.is(':visible') ? $this.width() : 0;
|
||||
}
|
||||
ts.resizable.toggleTextSelection( c, true );
|
||||
});
|
||||
|
||||
@ -200,15 +207,20 @@ ts.resizable = {
|
||||
});
|
||||
|
||||
// right click to reset columns to default widths
|
||||
c.$table.find( 'thead:first' ).add( $( c.namespace + '_extra_table' ).find( 'thead:first' ) )
|
||||
.bind( 'contextmenu' + namespace, function() {
|
||||
// $.isEmptyObject() needs jQuery 1.4+; allow right click if already reset
|
||||
var allowClick = wo.resizable_.storedSizes.length === 0;
|
||||
ts.resizableReset( c.table );
|
||||
ts.resizable.setHandlePosition( c, wo );
|
||||
wo.resizable_.storedSizes = [];
|
||||
return allowClick;
|
||||
});
|
||||
c.$table
|
||||
.bind( 'columnUpdate' + namespace, function() {
|
||||
ts.resizable.setHandlePosition( c, wo );
|
||||
})
|
||||
.find( 'thead:first' )
|
||||
.add( $( c.namespace + '_extra_table' ).find( 'thead:first' ) )
|
||||
.bind( 'contextmenu' + namespace, function() {
|
||||
// $.isEmptyObject() needs jQuery 1.4+; allow right click if already reset
|
||||
var allowClick = wo.resizable_.storedSizes.length === 0;
|
||||
ts.resizableReset( c.table );
|
||||
ts.resizable.setHandlePosition( c, wo );
|
||||
wo.resizable_.storedSizes = [];
|
||||
return allowClick;
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
@ -241,10 +253,15 @@ ts.resizable = {
|
||||
},
|
||||
|
||||
stopResize : function( c, wo ) {
|
||||
var vars = wo.resizable_;
|
||||
var $this, column,
|
||||
vars = wo.resizable_;
|
||||
vars.storedSizes = [];
|
||||
if ( ts.storage ) {
|
||||
vars.storedSizes = c.$headers.map(function(){ return $(this).width(); }).get();
|
||||
vars.storedSizes = [];
|
||||
for ( column = 0; column < c.columns; column++ ) {
|
||||
$this = c.$headerIndexed[ column ];
|
||||
vars.storedSizes[ column ] = $this.is(':visible') ? $this.width() : 0;
|
||||
}
|
||||
if ( wo.resizable !== false ) {
|
||||
// save all column widths
|
||||
ts.storage( c.table, ts.css.resizableStorage, vars.storedSizes );
|
||||
@ -289,19 +306,19 @@ ts.addWidget({
|
||||
|
||||
ts.resizableReset = function( table, nosave ) {
|
||||
$( table ).each(function(){
|
||||
var $t,
|
||||
var index, $t,
|
||||
c = this.config,
|
||||
wo = c && c.widgetOptions;
|
||||
if ( table && c ) {
|
||||
c.$headers.each( function( i ) {
|
||||
$t = $(this);
|
||||
if ( wo.resizable_widths && wo.resizable_widths[ i ] ) {
|
||||
$t.css( 'width', wo.resizable_widths[ i ] );
|
||||
if ( table && c && c.$headerIndexed.length ) {
|
||||
for ( index = 0; index < c.columns; index++ ) {
|
||||
$t = c.$headerIndexed[ index ];
|
||||
if ( wo.resizable_widths && wo.resizable_widths[ index ] ) {
|
||||
$t.css( 'width', wo.resizable_widths[ index ] );
|
||||
} else if ( !$t.hasClass( 'resizable-false' ) ) {
|
||||
// don't clear the width of any column that is not resizable
|
||||
$t.css( 'width', '' );
|
||||
}
|
||||
});
|
||||
}
|
||||
// reset stickyHeader widths
|
||||
$( window ).trigger( 'resize' );
|
||||
if ( ts.storage && !nosave ) {
|
||||
|
Loading…
Reference in New Issue
Block a user