mirror of
https://github.com/Mottie/tablesorter.git
synced 2025-01-12 15:24:21 +00:00
Core: revert pull #849; changed sort initiation method
A click event can now be triggered on the header to initiate a sort
This commit is contained in:
parent
9f9e4bef91
commit
ac89d509c7
25
dist/js/jquery.tablesorter.js
vendored
25
dist/js/jquery.tablesorter.js
vendored
@ -59,7 +59,6 @@
|
||||
delayInit : false, // if false, the parsed table contents will not update until the first sort
|
||||
serverSideSorting: false, // if true, server-side sorting should be performed because client-side sorting will be disabled, but the ui and events will still be used.
|
||||
resort : true, // default setting to trigger a resort after an 'update', 'addRows', 'updateCell', etc has completed
|
||||
ignoreLongClick : true, // if true, ignore clicks longer than 250ms in case of column resizing widget, disable for sorting on slower devices
|
||||
|
||||
// *** sort options
|
||||
headers : {}, // set sorter, string, empty, locked order, sortInitialOrder, filter, etc.
|
||||
@ -1335,7 +1334,7 @@
|
||||
|
||||
ts.bindEvents = function(table, $headers, core){
|
||||
table = $(table)[0];
|
||||
var downTime,
|
||||
var downTarget = null,
|
||||
c = table.config;
|
||||
if (core !== true) {
|
||||
c.$extraHeaders = c.$extraHeaders ? c.$extraHeaders.add($headers) : $headers;
|
||||
@ -1344,23 +1343,27 @@
|
||||
$headers
|
||||
// http://stackoverflow.com/questions/5312849/jquery-find-self;
|
||||
.find(c.selectorSort).add( $headers.filter(c.selectorSort) )
|
||||
.unbind( ('mousedown mouseup sort keyup '.split(' ').join(c.namespace + ' ')).replace(/\s+/g, ' ') )
|
||||
.bind( 'mousedown mouseup sort keyup '.split(' ').join(c.namespace + ' '), function(e, external) {
|
||||
.unbind( ('mousedown mouseup click sort keyup '.split(' ').join(c.namespace + ' ')).replace(/\s+/g, ' ') )
|
||||
.bind( 'mousedown mouseup click sort keyup '.split(' ').join(c.namespace + ' '), function(e, external) {
|
||||
var cell,
|
||||
$target = $(e.target),
|
||||
type = e.type;
|
||||
// only recognize left clicks or enter
|
||||
if ( ((e.which || e.button) !== 1 && !/sort|keyup/.test(type)) || (type === 'keyup' && e.which !== 13) ) {
|
||||
// only recognize left clicks
|
||||
if ( ( ( e.which || e.button ) !== 1 && !/sort|keyup|click/.test(type) ) ||
|
||||
// allow pressing enter
|
||||
( type === 'keyup' && e.which !== 13 ) ||
|
||||
// allow triggering a click event (e.which is undefined) & ignore physical clicks
|
||||
( type === 'click' && typeof e.which !== 'undefined' ) ) {
|
||||
return;
|
||||
}
|
||||
// ignore long clicks (prevents resizable widget from initializing a sort)
|
||||
if (type === 'mouseup' && external !== true && (new Date().getTime() - downTime > 250) && c.ignoreLongClick) { return; }
|
||||
// ignore mouseup if mousedown wasn't on the same target
|
||||
if ( type === 'mouseup' && downTarget !== e.target && external !== true ) { return; }
|
||||
// set timer on mousedown
|
||||
if (type === 'mousedown') {
|
||||
downTime = new Date().getTime();
|
||||
if ( type === 'mousedown' ) {
|
||||
downTarget = e.target;
|
||||
return;
|
||||
}
|
||||
cell = $.fn.closest ? $target.closest('td,th') : $target.parents('td,th').filter(':first');
|
||||
downTarget = null;
|
||||
// prevent sort being triggered on form elements
|
||||
if ( /(input|select|button|textarea)/i.test(e.target.tagName) ||
|
||||
// nosort class name, or elements within a nosort container
|
||||
|
4
dist/js/jquery.tablesorter.min.js
vendored
4
dist/js/jquery.tablesorter.min.js
vendored
File diff suppressed because one or more lines are too long
@ -1050,14 +1050,6 @@
|
||||
<td></td>
|
||||
</tr>
|
||||
|
||||
<tr id="ignorelongclick">
|
||||
<td><span class="permalink">ignoreLongClick</span></td>
|
||||
<td>Boolean</td>
|
||||
<td>true</td>
|
||||
<td>If true, tablesorter will ignore clicks longer than 250ms to prevent sorting when dragging columns in case of column resizing widget. Set to false for issues sorting on slower devices.</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
|
||||
<tr id="imgattr">
|
||||
<td><a href="#" class="permalink">imgAttr</a></td>
|
||||
<td>String</td>
|
||||
|
@ -59,7 +59,6 @@
|
||||
delayInit : false, // if false, the parsed table contents will not update until the first sort
|
||||
serverSideSorting: false, // if true, server-side sorting should be performed because client-side sorting will be disabled, but the ui and events will still be used.
|
||||
resort : true, // default setting to trigger a resort after an 'update', 'addRows', 'updateCell', etc has completed
|
||||
ignoreLongClick : true, // if true, ignore clicks longer than 250ms in case of column resizing widget, disable for sorting on slower devices
|
||||
|
||||
// *** sort options
|
||||
headers : {}, // set sorter, string, empty, locked order, sortInitialOrder, filter, etc.
|
||||
@ -1335,7 +1334,7 @@
|
||||
|
||||
ts.bindEvents = function(table, $headers, core){
|
||||
table = $(table)[0];
|
||||
var downTime,
|
||||
var downTarget = null,
|
||||
c = table.config;
|
||||
if (core !== true) {
|
||||
c.$extraHeaders = c.$extraHeaders ? c.$extraHeaders.add($headers) : $headers;
|
||||
@ -1344,23 +1343,27 @@
|
||||
$headers
|
||||
// http://stackoverflow.com/questions/5312849/jquery-find-self;
|
||||
.find(c.selectorSort).add( $headers.filter(c.selectorSort) )
|
||||
.unbind( ('mousedown mouseup sort keyup '.split(' ').join(c.namespace + ' ')).replace(/\s+/g, ' ') )
|
||||
.bind( 'mousedown mouseup sort keyup '.split(' ').join(c.namespace + ' '), function(e, external) {
|
||||
.unbind( ('mousedown mouseup click sort keyup '.split(' ').join(c.namespace + ' ')).replace(/\s+/g, ' ') )
|
||||
.bind( 'mousedown mouseup click sort keyup '.split(' ').join(c.namespace + ' '), function(e, external) {
|
||||
var cell,
|
||||
$target = $(e.target),
|
||||
type = e.type;
|
||||
// only recognize left clicks or enter
|
||||
if ( ((e.which || e.button) !== 1 && !/sort|keyup/.test(type)) || (type === 'keyup' && e.which !== 13) ) {
|
||||
// only recognize left clicks
|
||||
if ( ( ( e.which || e.button ) !== 1 && !/sort|keyup|click/.test(type) ) ||
|
||||
// allow pressing enter
|
||||
( type === 'keyup' && e.which !== 13 ) ||
|
||||
// allow triggering a click event (e.which is undefined) & ignore physical clicks
|
||||
( type === 'click' && typeof e.which !== 'undefined' ) ) {
|
||||
return;
|
||||
}
|
||||
// ignore long clicks (prevents resizable widget from initializing a sort)
|
||||
if (type === 'mouseup' && external !== true && (new Date().getTime() - downTime > 250) && c.ignoreLongClick) { return; }
|
||||
// ignore mouseup if mousedown wasn't on the same target
|
||||
if ( type === 'mouseup' && downTarget !== e.target && external !== true ) { return; }
|
||||
// set timer on mousedown
|
||||
if (type === 'mousedown') {
|
||||
downTime = new Date().getTime();
|
||||
if ( type === 'mousedown' ) {
|
||||
downTarget = e.target;
|
||||
return;
|
||||
}
|
||||
cell = $.fn.closest ? $target.closest('td,th') : $target.parents('td,th').filter(':first');
|
||||
downTarget = null;
|
||||
// prevent sort being triggered on form elements
|
||||
if ( /(input|select|button|textarea)/i.test(e.target.tagName) ||
|
||||
// nosort class name, or elements within a nosort container
|
||||
|
Loading…
Reference in New Issue
Block a user