Permalink
Browse files

fix widget init code - fixes #28

  • Loading branch information...
Mottie committed Feb 20, 2012
1 parent 580f4e5 commit bf553daf8d184fd16331c60c28dc05e706039df8
Showing with 32 additions and 16 deletions.
  1. +5 −0 README.markdown
  2. +6 −0 changelog.txt
  3. +9 −1 docs/example-widget-savesort.html
  4. +9 −12 js/jquery.tablesorter.js
  5. +2 −2 js/jquery.tablesorter.min.js
  6. +1 −1 package.json
View
@@ -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).
+#### 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)
* Modified the plugin pager to ignore child rows. Fix for [issue #27](https://github.com/Mottie/tablesorter/issues/27).
View
@@ -1,5 +1,11 @@
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)
============================
@@ -5,7 +5,7 @@
<title>jQuery plugin: Tablesorter 2.0 - Save Sort Widget</title>
<!-- 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 -->
<link rel="stylesheet" href="css/jq.css">
@@ -109,6 +109,14 @@ <h1>Demo</h1>
</tbody>
</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>
<div id="javascript">
<pre class="js"></pre>
View
@@ -1,6 +1,6 @@
/*
* TableSorter 2.0 - Client-side table sorting with ease!
-* Version 2.0.28
+* Version 2.0.29
* @requires jQuery v1.2.3
*
* Copyright (c) 2007 Christian Bach
@@ -267,11 +267,10 @@
}
function initWidgets(table){
- var i, w, l = widgets.length;
+ var i, w = table.config.widgets, l = w.length;
for (i = 0; i < l; i++) {
- w = widgets[i];
- if (w && w.hasOwnProperty('init')) {
- w.init(table, widgets, w);
+ if (w[i] && w[i].hasOwnProperty('init')) {
+ w[i].init(table, widgets, w[i]);
}
}
}
@@ -461,10 +460,10 @@
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
$headers.removeClass(css[0]).removeClass(css[1]);
- var h = [], i, l;
$headers.each(function (offset) {
if (!this.sortDisabled) {
h[this.column] = $(this);
@@ -616,7 +615,7 @@
if (!this.tHead || !this.tBodies) { return; }
// declare
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
this.config = {};
// merge and extend.
@@ -633,8 +632,6 @@
this.config.string = { max: 1, 'max+': 1, 'max-': -1, none: 0 };
// build the cache for the tbody cells
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
fixColumnWidth(this);
// apply event handling to headers
@@ -702,7 +699,7 @@
$this.trigger("sortBegin", tbl[0]);
setTimeout(function () {
// 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));
}, 1);
// stop normal event by returning false
@@ -767,7 +764,7 @@
// update header count index
updateHeaderSortCount(this, sortList);
// set css for headers
- setHeadersCss(this, $headers, sortList, sortCSS);
+ setHeadersCss(this, $headers, sortList);
// sort the table and append it to the dom
appendToTable(this, multisort(this, sortList, cache));
})
Oops, something went wrong.

0 comments on commit bf553da

Please sign in to comment.