Skip to content

Commit

Permalink
fix widget init code - fixes #28
Browse files Browse the repository at this point in the history
  • Loading branch information
Mottie committed Feb 20, 2012
1 parent 580f4e5 commit bf553da
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 16 deletions.
5 changes: 5 additions & 0 deletions README.markdown
Expand Up @@ -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).
Expand Down
6 changes: 6 additions & 0 deletions changelog.txt
@@ -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)
============================ ============================


Expand Down
10 changes: 9 additions & 1 deletion docs/example-widget-savesort.html
Expand Up @@ -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">
Expand Down Expand Up @@ -109,6 +109,14 @@ <h1>Demo</h1>
</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>
Expand Down
21 changes: 9 additions & 12 deletions js/jquery.tablesorter.js
@@ -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
Expand Down Expand Up @@ -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);
} }
} }
} }
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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));
}) })
Expand Down

0 comments on commit bf553da

Please sign in to comment.