Permalink
Browse files

pager ajax works with stickyheaders now

  • Loading branch information...
1 parent 16330a2 commit 04aacd54493b7a4652f4d5d1f160d52ecbf63484 @Mottie committed Mar 8, 2012
View
@@ -42,6 +42,7 @@ View the [complete listing here](http://mottie.github.com/tablesorter/changelog.
* The `sortInitialOrder` will work in either the main options or specifically within the headers option when a particular column needs a different initial sort order.
* Added a [sortReset/sortRestart](http://mottie.github.com/tablesorter/docs/example-option-sortreset-sortrestart.html) demo.
* Resolves [issue #30](https://github.com/Mottie/tablesorter/issues/29).
+* Updated pager plugin to better work with the sticky header widget.
#### Version 2.1 (3/7/2012)
@@ -24,4 +24,15 @@ div.tablesorterPager input {
background: rgba(255,255,255,0.8) url(icons/loading.gif) center center no-repeat;
position: absolute;
z-index: 1000;
+}
+/*** css used when "updateArrows" option is true ***/
+/* the pager itself gets a disabled class when the number of rows is less than the size */
+.pager.disabled {
+ display: none;
+}
+/* hide or fade out pager arrows when the first or last row is visible */
+.pager img.disabled {
+ /* visibility: hidden */
+ opacity: 0.5;
+ filter: alpha(opacity=50);
}
@@ -1,6 +1,6 @@
/*
* tablesorter pager plugin
- * updated 3/7/2012
+ * updated 3/8/2012
*/
(function($) {
@@ -149,7 +149,9 @@
// process data
if (typeof(c.ajaxProcessing) === "function") {
var result = c.ajaxProcessing(data), d = result[0], l = d.length,
- i, k, th = [], tds = '', tf = '';
+ i, k, th = [], tds = '', tf = '', hsh = $(table).addClass('hasStickyHeaders'),
+ sh = '.' + ((table.config.widgetOptions && table.config.widgetOptions.stickyHeaders) || 'tablesorter-stickyheader'),
+ $sh = $t.find(sh);
for ( i=0; i < l; i++ ) {
tds += '<tr>';
for (k in d[i]) {
@@ -162,11 +164,17 @@
}
tds += '</tr>';
}
- $t.find('thead th').each(function(j){
+ $t.find('thead tr.tablesorter-header th').each(function(j){
var $t = $(this),
// add new test within the first span it finds, or just in the header
tar = ($t.find('span').length) ? $t.find('span:first') : $t;
- $t.html(th[j]);
+ tar.html(th[j]);
+ // update sticky headers
+ if (hsh && $sh.length){
+ tar = $sh.find('th').eq(j);
+ tar = (tar.find('span').length) ? tar.find('span:first') : tar;
+ tar.html(th[j]);
+ }
tf += '<th>' + th[j] + '</th>';
});
$t.find('tfoot').html('<tr>' + tf + '</tr>');
Oops, something went wrong.
@@ -21,7 +21,33 @@
<link rel="stylesheet" href="../addons/pager/jquery.tablesorter.pager.css">
<script src="../addons/pager/jquery.tablesorter.pager.js"></script>
- <style id="css">/*** css used when "updateArrows" option is true ***/
+ <style id="css">div.tablesorterPager {
+ padding: 10px 0 10px 0;
+ background-color: #D6D2C2;
+ text-align: center;
+}
+div.tablesorterPager span {
+ padding: 0 5px 0 5px;
+}
+div.tablesorterPager input.prev {
+ width: auto;
+ margin-right: 10px;
+}
+div.tablesorterPager input.next {
+ width: auto;
+ margin-left: 10px;
+}
+div.tablesorterPager input {
+ font-size: 8px;
+ width: 50px;
+ border: 1px solid #330000;
+ text-align: center;
+}
+#tablesorterPagerLoading {
+ background: rgba(255,255,255,0.8) url(icons/loading.gif) center center no-repeat;
+ position: absolute;
+ z-index: 1000;
+}/*** css used when "updateArrows" option is true ***/
/* the pager itself gets a disabled class when the number of rows is less than the size */
.pager.disabled {
display: none;
@@ -21,7 +21,33 @@
<link rel="stylesheet" href="../addons/pager/jquery.tablesorter.pager.css">
<script src="../addons/pager/jquery.tablesorter.pager.js"></script>
- <style id="css">/*** css used when "updateArrows" option is true ***/
+ <style id="css">div.tablesorterPager {
+ padding: 10px 0 10px 0;
+ background-color: #D6D2C2;
+ text-align: center;
+}
+div.tablesorterPager span {
+ padding: 0 5px 0 5px;
+}
+div.tablesorterPager input.prev {
+ width: auto;
+ margin-right: 10px;
+}
+div.tablesorterPager input.next {
+ width: auto;
+ margin-left: 10px;
+}
+div.tablesorterPager input {
+ font-size: 8px;
+ width: 50px;
+ border: 1px solid #330000;
+ text-align: center;
+}
+#tablesorterPagerLoading {
+ background: rgba(255,255,255,0.8) url(icons/loading.gif) center center no-repeat;
+ position: absolute;
+ z-index: 1000;
+}/*** css used when "updateArrows" option is true ***/
/* the pager itself gets a disabled class when the number of rows is less than the size */
.pager.disabled {
display: none;
View
@@ -12,7 +12,7 @@
<!-- Pick a theme, load the plugin & initialize plugin -->
<link href="css/blue/style.css" rel="stylesheet">
- <script src="js/jquery.tablesorter.js"></script>
+ <script src="js/jquery.tablesorter.min.js"></script>
<script src="js/jquery.tablesorter.widgets.js"></script>
<script>
$(function(){
@@ -34,7 +34,7 @@
<table class="tablesorter">
<thead>
<tr>
- <th>AlphaNumeric Sort *New*</th>
+ <th>AlphaNumeric Sort</th>
<th>Currency</th>
<th>Alphabetical</th>
<th>Sites</th>
@@ -363,6 +363,7 @@
}
// add cell to headerList
c.headerList[index] = this;
+ $(this).parent().addClass('tablesorter-header');
});
if (c.debug) {
benchmark("Built headers", time);
Oops, something went wrong.
@@ -1,4 +1,4 @@
-/* TableSorter 2.1 Widgets - updated 3/7/2012
+/* TableSorter 2.1 Widgets - updated 3/8/2012
*
* jQuery UI Theme
* Column Styles
@@ -226,7 +226,8 @@ $.tablesorter.addWidget({
css = wo.stickyHeaders || 'tablesorter-stickyheader',
firstCell = hdrCells.eq(0),
brdr = parseInt(hdrCells.eq(0).css('border-left-width'),10),
- sticky = header.find('tr:not(.' + (wo.filter_cssFilter || 'tablesorter-filter') + ')').clone()
+ sticky = header.find('tr.tablesorter-header').clone()
+ .removeClass('tablesorter-header')
.addClass(css)
.css({
width : header.outerWidth() + brdr * 2,
@@ -239,7 +240,7 @@ $.tablesorter.addWidget({
}),
stkyCells = sticky.children(),
laststate;
- // update sticky header class names to match real header
+ // update sticky header class names to match real header after sorting
$table.bind('sortEnd', function(e,t){
var th = $(t).find('thead tr'),
sh = th.filter('.' + css).children();
Oops, something went wrong.

0 comments on commit 04aacd5

Please sign in to comment.