Merge branch 'master' of github.com:Mottie/tablesorter

This commit is contained in:
Mottie 2013-05-15 22:12:20 -05:00
commit 9b9a42b718
2 changed files with 17 additions and 8 deletions

View File

@ -16,6 +16,7 @@
*/ */
/*jshint browser:true, jquery:true, unused:false, expr: true */ /*jshint browser:true, jquery:true, unused:false, expr: true */
/*global console:false, alert:false */ /*global console:false, alert:false */
!(function($) { !(function($) {
"use strict"; "use strict";
$.extend({ $.extend({
@ -408,6 +409,8 @@
c.headerList[index] = this; c.headerList[index] = this;
// add to parent in case there are multiple rows // add to parent in case there are multiple rows
$t.parent().addClass(c.cssHeaderRow); $t.parent().addClass(c.cssHeaderRow);
// allow keyboard cursor to focus on element
$t.attr("tabindex", 0);
}); });
// enable/disable sorting // enable/disable sorting
updateHeader(table); updateHeader(table);
@ -666,19 +669,25 @@
c.$headers c.$headers
// http://stackoverflow.com/questions/5312849/jquery-find-self; // http://stackoverflow.com/questions/5312849/jquery-find-self;
.find(c.selectorSort).add( c.$headers.filter(c.selectorSort) ) .find(c.selectorSort).add( c.$headers.filter(c.selectorSort) )
.unbind('mousedown.tablesorter mouseup.tablesorter sort.tablesorter') .unbind('mousedown.tablesorter mouseup.tablesorter sort.tablesorter keypress.tablesorter')
.bind('mousedown.tablesorter mouseup.tablesorter sort.tablesorter', function(e, external) { .bind('mousedown.tablesorter mouseup.tablesorter sort.tablesorter keypress.tablesorter', function(e, external) {
if (e.keyCode && e.keyCode !== 13) { return; }
// jQuery v1.2.6 doesn't have closest() // jQuery v1.2.6 doesn't have closest()
var $cell = /TH|TD/.test(this.tagName) ? $(this) : $(this).parents('th, td').filter(':last'), cell = $cell[0]; var $cell = /TH|TD/.test(this.tagName) ? $(this) : $(this).parents('th, td').filter(':last'), cell = $cell[0];
// only recognize left clicks // only recognize left clicks or enter
if ((e.which || e.button) !== 1 && e.type !== 'sort') { return false; } if (e.keyCode) {
if (e.keyCode !== 13) { return false; }
}
else if ( (e.which || e.button) !== 1 && e.type !== 'sort') {
return false;
}
// set timer on mousedown // set timer on mousedown
if (e.type === 'mousedown') { if (e.type === 'mousedown') {
downTime = new Date().getTime(); downTime = new Date().getTime();
return e.target.tagName === "INPUT" ? '' : !c.cancelSelection; return e.target.tagName === "INPUT" ? '' : !c.cancelSelection;
} }
// ignore long clicks (prevents resizable widget from initializing a sort) // ignore long clicks (prevents resizable widget from initializing a sort)
if (external !== true && (new Date().getTime() - downTime > 250)) { return false; } if (e.type === 'mouseup' && external !== true && (new Date().getTime() - downTime > 250)) { return false; }
if (c.delayInit && !c.cache) { buildCache(table); } if (c.delayInit && !c.cache) { buildCache(table); }
if (!cell.sortDisabled) { if (!cell.sortDisabled) {
initSort(table, cell, e); initSort(table, cell, e);
@ -955,11 +964,11 @@
// disable tablesorter // disable tablesorter
$t $t
.removeData('tablesorter') .removeData('tablesorter')
.unbind('sortReset update updateAll updateRows updateCell addRows sorton appendCache applyWidgetId applyWidgets refreshWidgets destroy mouseup mouseleave sortBegin sortEnd '.split(' ').join('.tablesorter ')); .unbind('sortReset update updateAll updateRows updateCell addRows sorton appendCache applyWidgetId applyWidgets refreshWidgets destroy mouseup mouseleave keypress sortBegin sortEnd '.split(' ').join('.tablesorter '));
c.$headers.add($f) c.$headers.add($f)
.removeClass(c.cssHeader + ' ' + c.cssAsc + ' ' + c.cssDesc) .removeClass(c.cssHeader + ' ' + c.cssAsc + ' ' + c.cssDesc)
.removeAttr('data-column'); .removeAttr('data-column');
$r.find(c.selectorSort).unbind('mousedown.tablesorter mouseup.tablesorter'); $r.find(c.selectorSort).unbind('mousedown.tablesorter mouseup.tablesorter keypress.tablesorter');
ts.restoreHeaders(table); ts.restoreHeaders(table);
if (removeClasses !== false) { if (removeClasses !== false) {
$t.removeClass(c.tableClass + ' tablesorter-' + c.theme); $t.removeClass(c.tableClass + ' tablesorter-' + c.theme);

File diff suppressed because one or more lines are too long