fixed resizable widget triggering sort

This commit is contained in:
Rob Garrison 2012-05-28 08:41:12 -05:00
parent d2c6d5786a
commit b5735fd0db

View File

@ -1,4 +1,4 @@
/*! /*!
* TableSorter 2.3.5 - Client-side table sorting with ease! * TableSorter 2.3.5 - Client-side table sorting with ease!
* @requires jQuery v1.2.6+ * @requires jQuery v1.2.6+
* *
@ -600,7 +600,7 @@
if (!this.tHead || this.tBodies.length === 0) { return; } if (!this.tHead || this.tBodies.length === 0) { return; }
// declare // declare
var $headers, $cell, $this, var $headers, $cell, $this,
config, c, i, j, k, a, s, o, config, c, i, j, k, a, s, o, downTime,
m = $.metadata; m = $.metadata;
// new blank config object // new blank config object
this.config = {}; this.config = {};
@ -612,6 +612,7 @@
$this = $(this).addClass(c.tableClass); $this = $(this).addClass(c.tableClass);
// save the settings where they read // save the settings where they read
$.data(this, "tablesorter", c); $.data(this, "tablesorter", c);
c.supportsTextContent = $('<span>x</span>')[0].textContent === 'x';
// build up character equivalent cross-reference // build up character equivalent cross-reference
buildRegex(); buildRegex();
// digit sort text location; keeping max+/- for backwards compatibility // digit sort text location; keeping max+/- for backwards compatibility
@ -627,8 +628,15 @@
fixColumnWidth(this); fixColumnWidth(this);
// apply event handling to headers // apply event handling to headers
// this is to big, perhaps break it out? // this is to big, perhaps break it out?
$headers $headers.bind('mousedown.tablesorter mouseup.tablesorter', function(e, external) {
.click(function(e) { if (e.type === 'mousedown') {
downTime = new Date().getTime();
return !c.cancelSelection;
}
// prevent resizable widget from initializing a sort (long clicks are ignored)
if (external !== true && (new Date().getTime() - downTime > 500)) { return false; }
if (c.delayInit && !c.cache) { buildCache($this[0]); } if (c.delayInit && !c.cache) { buildCache($this[0]); }
if (!this.sortDisabled) { if (!this.sortDisabled) {
// Only call sortStart if sorting is enabled. // Only call sortStart if sorting is enabled.
@ -720,16 +728,16 @@
// stop normal event by returning false // stop normal event by returning false
return false; return false;
} }
// cancel selection });
})
.mousedown(function() {
if (c.cancelSelection) { if (c.cancelSelection) {
// cancel selection
$headers.each(function() {
this.onselectstart = function() { this.onselectstart = function() {
return false; return false;
}; };
return false; return false;
}
}); });
}
// apply easy methods that trigger binded events // apply easy methods that trigger binded events
$this $this
.bind("update", function(e, resort) { .bind("update", function(e, resort) {