StickyHeaders: make includeCaption option dynamic; add note of new jQuery requirement

This commit is contained in:
Mottie 2014-11-26 21:20:52 -06:00
parent 0c3c439907
commit f9940ac785
2 changed files with 6 additions and 7 deletions

View File

@ -1960,7 +1960,7 @@ $(function(){
<tr><td>55</td><td>pager widget</td><td>v1.7</td><td>1.7 (on)</td></tr>
<tr><td>40</td><td>resizable</td><td>v1.4.1*</td><td>1.4 (isEmptyObject); 1.4.1 (parseJSON)*</td></tr>
<tr><td>20</td><td>saveSort</td><td>v1.4.1</td><td>1.4.1 (parseJSON)*</td></tr>
<tr><td>60</td><td>stickyHeaders</td><td>v1.2.6</td><td></td></tr>
<tr><td>60</td><td>stickyHeaders</td><td>v1.4.3</td><td>1.4.3 (isWindow)**</td></tr>
<tr><td>10</td><td>uitheme</td><td>v1.2.6</td><td></td></tr>
<tr><td>90</td><td>zebra</td><td>v1.2.6</td><td></td></tr>
</tbody>
@ -1974,6 +1974,7 @@ $(function(){
<li>Widget priority values do not need to be unique. Any new widget without a defined priority will automatically have a priority of <code>10</code>.</li>
<li>The pager, being a plugin, is actually initialized after tablesorter has initialized and all selected widgets applied.</li>
<li>* The <code>saveSort</code> and <code>resizable</code> widgets use the <a href="#function-storage"><code>$.tablesorter.storage</code></a> function by default and thus need the <code>parseJSON</code> function which is available in jQuery 1.4.1+.</li>
<li>** The <code>stickyHeaders</code> widget was updated in v2.18.0 to use <code>$.isWindow</code> for the <code>xScroll</code> &amp; <code>yScroll</code> options; and therefore now requires jQuery 1.4.3+.</li>
</ul>
<br class="clear">

View File

@ -1655,7 +1655,7 @@ ts.addWidget({
.wrap('<div class="' + ts.css.stickyWrap + '">'),
$stickyWrap = $stickyTable.parent().css({
position : $attach.length ? 'absolute' : 'fixed',
margin : 0,
padding : parseInt( $stickyTable.parent().parent().css('padding-left'), 10 ),
top : stickyOffset + nestedStickyTop,
left : 0,
visibility : 'hidden',
@ -1709,9 +1709,7 @@ ts.addWidget({
// include caption & filter row (fixes #126 & #249) - don't remove cells to get correct cell indexing
$stickyTable.find('thead:gt(0), tr.sticky-false').hide();
$stickyTable.find('tbody, tfoot').remove();
if (!wo.stickyHeaders_includeCaption) {
$stickyTable.find('caption').remove();
}
$stickyTable.find('caption').toggle(wo.stickyHeaders_includeCaption);
// issue #172 - find td/th in sticky header
$stickyCells = $stickyThead.children().children();
$stickyTable.css({ height:0, width:0, margin: 0 });
@ -1746,12 +1744,12 @@ ts.addWidget({
nestedStickyTop = $nestedSticky.length ? $nestedSticky.offset().top - $yScroll.scrollTop() + $nestedSticky.height() : 0;
var prefix = 'tablesorter-sticky-',
offset = $table.offset(),
yWindow = $.isWindow( $yScroll[0] ),
yWindow = $.isWindow( $yScroll[0] ), // $.isWindow needs jQuery 1.4.3
xWindow = $.isWindow( $xScroll[0] ),
// scrollTop = ( $attach.length ? $attach.offset().top : $yScroll.scrollTop() ) + stickyOffset + nestedStickyTop,
scrollTop = ( $attach.length ? ( yWindow ? $yScroll.scrollTop() : $yScroll.offset().top ) : $yScroll.scrollTop() ) + stickyOffset + nestedStickyTop,
tableHeight = $table.height() - ($stickyWrap.height() + ($tfoot.height() || 0)),
isVisible = ( scrollTop > offset.top) && (scrollTop < offset.top + tableHeight) ? 'visible' : 'hidden',
isVisible = ( scrollTop > offset.top ) && ( scrollTop < offset.top + tableHeight ) ? 'visible' : 'hidden',
cssSettings = { visibility : isVisible };
if ($attach.length) {