Permalink
Browse files

fixed the add widget init mess

  • Loading branch information...
Mottie committed Feb 21, 2012
1 parent bf553da commit 799609662f66b5b9c9caf354d2604542cb5a4dc0
View
@@ -34,6 +34,10 @@ 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.30 (2012-2-20)
+
+* Fixed the total mess I just made with the addWidget init functionality... I need a vacation :P
+
#### 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!
@@ -76,25 +80,3 @@ View the [complete listing here](http://mottie.github.com/tablesorter/changelog.
* This widget will save the last sort to local storage, and will fallback to cookies.
* The widget does use the `JSON.stringify` function which is [not fully supported](http://caniuse.com/#search=json) (IE7), so if you plan to support it and use this widget, please include this [JSON library](https://github.com/douglascrockford/JSON-js).
* Fixed pager page size not sticking. Fix for [issue #24](https://github.com/Mottie/tablesorter/issues/24).
-
-#### Version 2.0.26 (2012-1-30)
-
-* Widgets should no longer be applied twice when an initial sort direction is added. Fix for [issue #21](https://github.com/Mottie/tablesorter/issues/21).
-* Modified Green theme:
- * The Green theme sort direction icon is now applied to only the first span it encounters inside the header. The UI theme adds a second span for it's icon.
- * Essentially to fix [this demo](http://mottie.github.com/tablesorter/docs/example-widget-ui-theme.html) which allows switching between all of the themes.
-* Modified the UI theme to now add a div that wraps all of the header cell content to allow positioning of the sort direction icon.
-
-#### Version 2.0.25.2 (2012-1-27)
-
-* Changed Blue theme to vertically align arrows. Fix for [issue #12](https://github.com/Mottie/tablesorter/issues/12).
-* Fixed sticky header widget so varing width columns now update when the pager plugin changes pages. Thanks to locationRoura for reporting this issue.
-
-#### Version 2.0.25.1 (2011-12-15)
-
-* Fixed disabled column style for the ui theme widget. Thanks to [bbbco](https://github.com/bbbco) for the fix in [issue #17](https://github.com/Mottie/tablesorter/issues/17).
-
-#### Version 2.0.25 (2011-12-14)
-
-* The ui theme and sticky header widgets now work together and update the arrow direction. Fix for [issue #15](https://github.com/Mottie/tablesorter/issues/15).
-* Empty cells with only a tab or space will now sort at the bottom. Thanks to [pursual](https://github.com/pursual) for the fix for [issue #16](https://github.com/Mottie/tablesorter/issues/16).
View
@@ -1,5 +1,10 @@
TableSorter Change Log
+Version 2.0.30 (2012-2-20)
+============================
+
+* Fixed the total mess I just made with the addWidget init functionality... I need a vacation :P
+
Version 2.0.29 (2012-2-20)
============================
View
@@ -1,6 +1,6 @@
/*
* TableSorter 2.0 - Client-side table sorting with ease!
-* Version 2.0.29
+* Version 2.0.30
* @requires jQuery v1.2.3
*
* Copyright (c) 2007 Christian Bach
@@ -117,10 +117,11 @@
}
function benchmark(s, d) {
- log(s + "," + (new Date().getTime() - d.getTime()) + "ms");
+ log(s + " (" + (new Date().getTime() - d.getTime()) + "ms)");
}
this.benchmark = benchmark;
+ this.hasInitialized = false;
function getElementText(config, node, cellIndex) {
var text = "", te = config.textExtraction;
@@ -178,7 +179,7 @@
node = getNodeFromRowAndCellIndex(rows, rowIndex, cellIndex);
nodeValue = trimAndGetNodeText(table.config, node, cellIndex);
if (table.config.debug) {
- log('Checking if value was empty on row:' + rowIndex);
+ log('Checking if value was empty on row ' + rowIndex + ', column:' + cellIndex + ": " + nodeValue);
}
} else {
keepLooking = false;
@@ -215,7 +216,7 @@
p = detectParserForColumn(table, rows, -1, i);
}
if (table.config.debug) {
- parsersDebug += "column:" + i + " parser:" + p.id + "\n";
+ parsersDebug += "column:" + i + "; parser:" + p.id + "\n";
}
list.push(p);
}
@@ -260,21 +261,12 @@
cache.normalized.push(cols);
}
if (table.config.debug) {
- benchmark("Building cache for " + totalRows + " rows:", cacheTime);
+ benchmark("Building cache for " + totalRows + " rows", cacheTime);
}
table.config.cache = cache;
return cache;
}
- function initWidgets(table){
- var i, w = table.config.widgets, l = w.length;
- for (i = 0; i < l; i++) {
- if (w[i] && w[i].hasOwnProperty('init')) {
- w[i].init(table, widgets, w[i]);
- }
- }
- }
-
function getWidgetById(name) {
var i, w, l = widgets.length;
for (i = 0; i < l; i++) {
@@ -285,13 +277,17 @@
}
}
- function applyWidget(table) {
+ function applyWidget(table, init) {
var c = table.config.widgets,
i, w, l = c.length;
for (i = 0; i < l; i++) {
w = getWidgetById(c[i]);
- if ( w && w.hasOwnProperty('format') ) {
- w.format(table);
+ if ( w ) {
+ if (init && w.hasOwnProperty('init')) {
+ w.init(table, widgets, w);
+ } else if (!init && w.hasOwnProperty('format')) {
+ w.format(table);
+ }
}
}
}
@@ -322,7 +318,7 @@
c.appender(table, rows);
}
if (c.debug) {
- benchmark("Rebuilt table:", appendTime);
+ benchmark("Rebuilt table", appendTime);
}
// apply table widgets
applyWidget(table);
@@ -427,7 +423,7 @@
c.headerList[index] = this;
});
if (c.debug) {
- benchmark("Built headers:", time);
+ benchmark("Built headers", time);
log($tableHeaders);
}
return $tableHeaders;
@@ -534,7 +530,7 @@
dynamicExp += "}; ";
eval(dynamicExp);
cache.normalized.sort(sortWrapper); // sort using eval expression
- if (tc.debug) { benchmark("Sorting on " + sortList.toString() + " and dir " + order+ " time:", sortTime); }
+ if (tc.debug) { benchmark("Sorting on " + sortList.toString() + " and dir " + order+ " time", sortTime); }
return cache;
}
@@ -781,15 +777,16 @@
if ($.metadata && ($(this).metadata() && $(this).metadata().sortlist)) {
config.sortList = $(this).metadata().sortlist;
}
- // initialize widgets
- initWidgets(this);
+ // apply widget init code
+ applyWidget(this, true);
// if user has supplied a sort list to constructor.
if (config.sortList.length > 0) {
$this.trigger("sorton", [config.sortList]);
} else {
- // apply widgets
+ // apply widget format
applyWidget(this);
}
+ this.hasInitialized = true;
});
};
this.addParser = function(parser) {
Oops, something went wrong.

0 comments on commit 7996096

Please sign in to comment.