fix widget init code - fixes #28

This commit is contained in:
Rob Garrison 2012-02-20 16:21:42 -06:00
parent 580f4e548d
commit bf553daf8d
6 changed files with 32 additions and 16 deletions

View File

@ -34,6 +34,11 @@ Included all original [document pages](http://mottie.github.com/tablesorter/docs
View the [complete listing here](http://mottie.github.com/tablesorter/changelog.txt). View the [complete listing here](http://mottie.github.com/tablesorter/changelog.txt).
#### Version 2.0.29 (2012-2-20)
* Fixed a problem with the addWidget init function which apparently was always being called, even if you didn't want it! Fix for [issue #28](https://github.com/Mottie/tablesorter/issues/28). Thanks to thezoggy for helping with troubleshooting!
* Minor cleanup of sorting class names code.
#### Version 2.0.28.1 (2012-2-16) #### Version 2.0.28.1 (2012-2-16)
* Modified the plugin pager to ignore child rows. Fix for [issue #27](https://github.com/Mottie/tablesorter/issues/27). * Modified the plugin pager to ignore child rows. Fix for [issue #27](https://github.com/Mottie/tablesorter/issues/27).

View File

@ -1,5 +1,11 @@
TableSorter Change Log TableSorter Change Log
Version 2.0.29 (2012-2-20)
============================
* Fixed a problem with the addWidget init function which apparently was always being called, even if you didn't want it! Fix for [issue #28](https://github.com/Mottie/tablesorter/issues/28). Thanks to thezoggy for helping with troubleshooting!
* Minor cleanup of sorting class names code.
Version 2.0.28.1 (2012-2-16) Version 2.0.28.1 (2012-2-16)
============================ ============================

View File

@ -5,7 +5,7 @@
<title>jQuery plugin: Tablesorter 2.0 - Save Sort Widget</title> <title>jQuery plugin: Tablesorter 2.0 - Save Sort Widget</title>
<!-- jQuery --> <!-- jQuery -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js"></script> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
<!-- Demo stuff --> <!-- Demo stuff -->
<link rel="stylesheet" href="css/jq.css"> <link rel="stylesheet" href="css/jq.css">
@ -109,6 +109,14 @@
</tbody> </tbody>
</table></div> </table></div>
<h1>Page Header</h1>
<div>
<pre class="html">
&lt;link rel="stylesheet" href="css/blue/style.css"&gt;
&lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"&gt;&lt;/script&gt;
&lt;script src="js/jquery.tablesorter.min.js"&gt;&lt;/script&gt;
&lt;script src="js/jquery.tablesorter.widgets.min.js">&lt;/script&gt;</pre>
</div>
<h1>Javascript</h1> <h1>Javascript</h1>
<div id="javascript"> <div id="javascript">
<pre class="js"></pre> <pre class="js"></pre>

View File

@ -1,6 +1,6 @@
/* /*
* TableSorter 2.0 - Client-side table sorting with ease! * TableSorter 2.0 - Client-side table sorting with ease!
* Version 2.0.28 * Version 2.0.29
* @requires jQuery v1.2.3 * @requires jQuery v1.2.3
* *
* Copyright (c) 2007 Christian Bach * Copyright (c) 2007 Christian Bach
@ -267,11 +267,10 @@
} }
function initWidgets(table){ function initWidgets(table){
var i, w, l = widgets.length; var i, w = table.config.widgets, l = w.length;
for (i = 0; i < l; i++) { for (i = 0; i < l; i++) {
w = widgets[i]; if (w[i] && w[i].hasOwnProperty('init')) {
if (w && w.hasOwnProperty('init')) { w[i].init(table, widgets, w[i]);
w.init(table, widgets, w);
} }
} }
} }
@ -461,10 +460,10 @@
return false; return false;
} }
function setHeadersCss(table, $headers, list, css) { function setHeadersCss(table, $headers, list) {
var h = [], i, l, css = [table.config.cssDesc, table.config.cssAsc];
// remove all header information // remove all header information
$headers.removeClass(css[0]).removeClass(css[1]); $headers.removeClass(css[0]).removeClass(css[1]);
var h = [], i, l;
$headers.each(function (offset) { $headers.each(function (offset) {
if (!this.sortDisabled) { if (!this.sortDisabled) {
h[this.column] = $(this); h[this.column] = $(this);
@ -616,7 +615,7 @@
if (!this.tHead || !this.tBodies) { return; } if (!this.tHead || !this.tBodies) { return; }
// declare // declare
var $this, $document, $headers, cache, config, shiftDown = 0, var $this, $document, $headers, cache, config, shiftDown = 0,
sortOrder, sortCSS, totalRows, $cell, i, j, a, s, o; sortOrder, totalRows, $cell, i, j, a, s, o;
// new blank config object // new blank config object
this.config = {}; this.config = {};
// merge and extend. // merge and extend.
@ -633,8 +632,6 @@
this.config.string = { max: 1, 'max+': 1, 'max-': -1, none: 0 }; this.config.string = { max: 1, 'max+': 1, 'max-': -1, none: 0 };
// build the cache for the tbody cells // build the cache for the tbody cells
cache = buildCache(this); cache = buildCache(this);
// get the css class names, could be done else where.
sortCSS = [config.cssDesc, config.cssAsc];
// fixate columns if the users supplies the fixedWidth option // fixate columns if the users supplies the fixedWidth option
fixColumnWidth(this); fixColumnWidth(this);
// apply event handling to headers // apply event handling to headers
@ -702,7 +699,7 @@
$this.trigger("sortBegin", tbl[0]); $this.trigger("sortBegin", tbl[0]);
setTimeout(function () { setTimeout(function () {
// set css for headers // set css for headers
setHeadersCss($this[0], $headers, config.sortList, sortCSS); setHeadersCss($this[0], $headers, config.sortList);
appendToTable($this[0], multisort($this[0], config.sortList, cache)); appendToTable($this[0], multisort($this[0], config.sortList, cache));
}, 1); }, 1);
// stop normal event by returning false // stop normal event by returning false
@ -767,7 +764,7 @@
// update header count index // update header count index
updateHeaderSortCount(this, sortList); updateHeaderSortCount(this, sortList);
// set css for headers // set css for headers
setHeadersCss(this, $headers, sortList, sortCSS); setHeadersCss(this, $headers, sortList);
// sort the table and append it to the dom // sort the table and append it to the dom
appendToTable(this, multisort(this, sortList, cache)); appendToTable(this, multisort(this, sortList, cache));
}) })

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
{ {
"name": "tablesorter", "name": "tablesorter",
"version": "2.0.28.1", "version": "2.0.29",
"title": "tablesorter", "title": "tablesorter",
"author": { "author": {
"name": "Christian Bach", "name": "Christian Bach",