Squashed commit of the following:
commitmaster3c1c3bd18e
Author: Mark Malek <markmmalek@me.com> Date: Sat May 7 23:43:30 2011 -0400 Updated version in comments and minified file Signed-off-by: Mark Malek <markmmalek@me.com> commitcff9699e3e
Author: Mark Malek <markmmalek@me.com> Date: Sat May 7 23:37:50 2011 -0400 New features: Added side scrolling for tables that exceed wrapper width. Signed-off-by: Mark Malek <markmmalek@me.com> commit891d3086cd
Author: Mark Malek <markmmalek@me.com> Date: Sat May 7 05:24:26 2011 -0400 Minified version Signed-off-by: Mark Malek <markmmalek@me.com> commite9fe5297bc
Author: Mark Malek <markmmalek@me.com> Date: Sat May 7 04:57:52 2011 -0400 Updated README.md Signed-off-by: Mark Malek <markmmalek@me.com> commit946077990e
Author: Mark Malek <markmmalek@me.com> Date: Sat May 7 04:54:44 2011 -0400 Removed old readme, added formatted readme Signed-off-by: Mark Malek <markmmalek@me.com> commit9fb59bbe81
Author: Mark Malek <markmmalek@me.com> Date: Sat May 7 03:33:04 2011 -0400 Bug fixes: Added a missing comma. Changed complete callback to create callback Signed-off-by: Mark Malek <markmmalek@me.com> commitdc169731d1
Author: Mark Malek <markmmalek@me.com> Date: Sat May 7 01:36:20 2011 -0400 Bug fix: Get parent wrapper width excluding padding. Signed-off-by: Mark Malek <markmmalek@me.com> commit17df3b5d05
Author: Mark Malek <markmmalek@me.com> Date: Mon May 2 18:32:36 2011 -0400 Updated Readme Signed-off-by: Mark Malek <markmmalek@me.com> commit24d094417e
Author: Mark Malek <markmmalek@me.com> Date: Mon May 2 16:07:46 2011 -0400 Bug fix: - complete callback using settings not options. Signed-off-by: Mark Malek <markmmalek@me.com> Signed-off-by: Mark Malek <markmmalek@me.com>
parent
2e366aaba2
commit
3e9511ce2b
|
@ -0,0 +1,18 @@
|
|||
## Version 1.2
|
||||
- jquery.fixedheadertable.js
|
||||
|
||||
## Methods:
|
||||
|
||||
* show - `$('selector').fixedHeaderTable('show');`
|
||||
* hide - `$('selector').fixedHeaderTable('hide');`
|
||||
* destroy - `$('selector').fixedHeaderTable('destroy');`
|
||||
|
||||
## Options:
|
||||
|
||||
* width - Number - Default: 100%
|
||||
* height - Number - Default: 100%
|
||||
* footer - Boolean - Default: false
|
||||
* cloneHeadToFoot - Boolean - Default: false
|
||||
* autoShow - Boolean - Default: true
|
||||
* altClass - String - Default: none
|
||||
* themeClass - String - Default: none
|
|
@ -39,12 +39,12 @@
|
|||
/* @group Content */
|
||||
|
||||
div.fht-table-wrapper {
|
||||
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
div.fht-tbody {
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
.fht-table .fht-cell {
|
||||
|
|
|
@ -165,7 +165,7 @@
|
|||
color-stop(100%,rgba(255,255,255,0.02)));
|
||||
border-bottom-color: #22272e;
|
||||
border-top-color: #708090;
|
||||
border-right-color: #48535e;
|
||||
border-right-color: #000;
|
||||
border-left-color: #3c454f;
|
||||
|
||||
/* size */
|
||||
|
@ -190,7 +190,7 @@
|
|||
linear, left top, left bottom,
|
||||
color-stop(0%,rgba(255,255,255,0.0)),
|
||||
color-stop(100%,rgba(255,255,255,0.02)));
|
||||
border-right-color: #3c454f;
|
||||
border-right-color: #000;
|
||||
}
|
||||
|
||||
.fancyDarkTable thead tr th,
|
||||
|
|
|
@ -5,7 +5,7 @@ $(document).ready(function() {
|
|||
|
||||
$('.myTable02').fixedHeaderTable({ width: '600', height: '250', footer: true, altClass: 'odd', themeClass: 'fancyDarkTable' });
|
||||
|
||||
$('.myTable03').fixedHeaderTable({ altClass: 'odd', footer: true, themeClass: 'fancyDarkTable' });
|
||||
$('.myTable03').fixedHeaderTable({ width: '400', height: '400', altClass: 'odd', footer: true, themeClass: 'fancyDarkTable' });
|
||||
|
||||
$('a.makeTable').bind('click', function() {
|
||||
|
||||
|
|
215
demo/test.html
215
demo/test.html
|
@ -353,11 +353,14 @@
|
|||
<th>Avg. Time on Site</th>
|
||||
<th>% New Visits</th>
|
||||
<th>Bounce Rate</th>
|
||||
<th>Avg. Time on Site</th>
|
||||
<th>% New Visits</th>
|
||||
<th>Bounce Rate</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td colspan="6"><a class="button pagination" href="#">Prev</a><a class="button pagination" href="#">Next</a></td>
|
||||
<td colspan="9"><a class="button pagination" href="#">Prev</a><a class="button pagination" href="#">Next</a></td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
<tbody>
|
||||
|
@ -368,19 +371,6 @@
|
|||
<td class="numeric">00:04:22</td>
|
||||
<td class="numeric">70.00%</td>
|
||||
<td class="numeric">32.61%</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Firefox</td>
|
||||
<td class="numeric">1,990</td>
|
||||
<td class="numeric">3.11</td>
|
||||
<td class="numeric">00:04:22</td>
|
||||
<td class="numeric">70.00%</td>
|
||||
<td class="numeric">32.61%</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Firefox Web Browser Version 4.0</td>
|
||||
<td class="numeric">1,990</td>
|
||||
<td class="numeric">3.11</td>
|
||||
<td class="numeric">00:04:22</td>
|
||||
<td class="numeric">70.00%</td>
|
||||
<td class="numeric">32.61%</td>
|
||||
|
@ -392,11 +382,6 @@
|
|||
<td class="numeric">00:04:22</td>
|
||||
<td class="numeric">70.00%</td>
|
||||
<td class="numeric">32.61%</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Firefox</td>
|
||||
<td class="numeric">1,990</td>
|
||||
<td class="numeric">3.11</td>
|
||||
<td class="numeric">00:04:22</td>
|
||||
<td class="numeric">70.00%</td>
|
||||
<td class="numeric">32.61%</td>
|
||||
|
@ -408,11 +393,6 @@
|
|||
<td class="numeric">00:04:22</td>
|
||||
<td class="numeric">70.00%</td>
|
||||
<td class="numeric">32.61%</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Firefox</td>
|
||||
<td class="numeric">1,990</td>
|
||||
<td class="numeric">3.11</td>
|
||||
<td class="numeric">00:04:22</td>
|
||||
<td class="numeric">70.00%</td>
|
||||
<td class="numeric">32.61%</td>
|
||||
|
@ -424,11 +404,6 @@
|
|||
<td class="numeric">00:04:22</td>
|
||||
<td class="numeric">70.00%</td>
|
||||
<td class="numeric">32.61%</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Firefox</td>
|
||||
<td class="numeric">1,990</td>
|
||||
<td class="numeric">3.11</td>
|
||||
<td class="numeric">00:04:22</td>
|
||||
<td class="numeric">70.00%</td>
|
||||
<td class="numeric">32.61%</td>
|
||||
|
@ -440,11 +415,6 @@
|
|||
<td class="numeric">00:04:22</td>
|
||||
<td class="numeric">70.00%</td>
|
||||
<td class="numeric">32.61%</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Firefox</td>
|
||||
<td class="numeric">1,990</td>
|
||||
<td class="numeric">3.11</td>
|
||||
<td class="numeric">00:04:22</td>
|
||||
<td class="numeric">70.00%</td>
|
||||
<td class="numeric">32.61%</td>
|
||||
|
@ -456,11 +426,6 @@
|
|||
<td class="numeric">00:04:22</td>
|
||||
<td class="numeric">70.00%</td>
|
||||
<td class="numeric">32.61%</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Firefox</td>
|
||||
<td class="numeric">1,990</td>
|
||||
<td class="numeric">3.11</td>
|
||||
<td class="numeric">00:04:22</td>
|
||||
<td class="numeric">70.00%</td>
|
||||
<td class="numeric">32.61%</td>
|
||||
|
@ -472,11 +437,6 @@
|
|||
<td class="numeric">00:04:22</td>
|
||||
<td class="numeric">70.00%</td>
|
||||
<td class="numeric">32.61%</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Firefox</td>
|
||||
<td class="numeric">1,990</td>
|
||||
<td class="numeric">3.11</td>
|
||||
<td class="numeric">00:04:22</td>
|
||||
<td class="numeric">70.00%</td>
|
||||
<td class="numeric">32.61%</td>
|
||||
|
@ -488,11 +448,6 @@
|
|||
<td class="numeric">00:04:22</td>
|
||||
<td class="numeric">70.00%</td>
|
||||
<td class="numeric">32.61%</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Firefox</td>
|
||||
<td class="numeric">1,990</td>
|
||||
<td class="numeric">3.11</td>
|
||||
<td class="numeric">00:04:22</td>
|
||||
<td class="numeric">70.00%</td>
|
||||
<td class="numeric">32.61%</td>
|
||||
|
@ -504,11 +459,6 @@
|
|||
<td class="numeric">00:04:22</td>
|
||||
<td class="numeric">70.00%</td>
|
||||
<td class="numeric">32.61%</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Firefox</td>
|
||||
<td class="numeric">1,990</td>
|
||||
<td class="numeric">3.11</td>
|
||||
<td class="numeric">00:04:22</td>
|
||||
<td class="numeric">70.00%</td>
|
||||
<td class="numeric">32.61%</td>
|
||||
|
@ -520,6 +470,163 @@
|
|||
<td class="numeric">00:04:22</td>
|
||||
<td class="numeric">70.00%</td>
|
||||
<td class="numeric">32.61%</td>
|
||||
<td class="numeric">00:04:22</td>
|
||||
<td class="numeric">70.00%</td>
|
||||
<td class="numeric">32.61%</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Firefox</td>
|
||||
<td class="numeric">1,990</td>
|
||||
<td class="numeric">3.11</td>
|
||||
<td class="numeric">00:04:22</td>
|
||||
<td class="numeric">70.00%</td>
|
||||
<td class="numeric">32.61%</td>
|
||||
<td class="numeric">00:04:22</td>
|
||||
<td class="numeric">70.00%</td>
|
||||
<td class="numeric">32.61%</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Firefox</td>
|
||||
<td class="numeric">1,990</td>
|
||||
<td class="numeric">3.11</td>
|
||||
<td class="numeric">00:04:22</td>
|
||||
<td class="numeric">70.00%</td>
|
||||
<td class="numeric">32.61%</td>
|
||||
<td class="numeric">00:04:22</td>
|
||||
<td class="numeric">70.00%</td>
|
||||
<td class="numeric">32.61%</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Firefox</td>
|
||||
<td class="numeric">1,990</td>
|
||||
<td class="numeric">3.11</td>
|
||||
<td class="numeric">00:04:22</td>
|
||||
<td class="numeric">70.00%</td>
|
||||
<td class="numeric">32.61%</td>
|
||||
<td class="numeric">00:04:22</td>
|
||||
<td class="numeric">70.00%</td>
|
||||
<td class="numeric">32.61%</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Firefox</td>
|
||||
<td class="numeric">1,990</td>
|
||||
<td class="numeric">3.11</td>
|
||||
<td class="numeric">00:04:22</td>
|
||||
<td class="numeric">70.00%</td>
|
||||
<td class="numeric">32.61%</td>
|
||||
<td class="numeric">00:04:22</td>
|
||||
<td class="numeric">70.00%</td>
|
||||
<td class="numeric">32.61%</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Firefox</td>
|
||||
<td class="numeric">1,990</td>
|
||||
<td class="numeric">3.11</td>
|
||||
<td class="numeric">00:04:22</td>
|
||||
<td class="numeric">70.00%</td>
|
||||
<td class="numeric">32.61%</td>
|
||||
<td class="numeric">00:04:22</td>
|
||||
<td class="numeric">70.00%</td>
|
||||
<td class="numeric">32.61%</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Firefox</td>
|
||||
<td class="numeric">1,990</td>
|
||||
<td class="numeric">3.11</td>
|
||||
<td class="numeric">00:04:22</td>
|
||||
<td class="numeric">70.00%</td>
|
||||
<td class="numeric">32.61%</td>
|
||||
<td class="numeric">00:04:22</td>
|
||||
<td class="numeric">70.00%</td>
|
||||
<td class="numeric">32.61%</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Firefox</td>
|
||||
<td class="numeric">1,990</td>
|
||||
<td class="numeric">3.11</td>
|
||||
<td class="numeric">00:04:22</td>
|
||||
<td class="numeric">70.00%</td>
|
||||
<td class="numeric">32.61%</td>
|
||||
<td class="numeric">00:04:22</td>
|
||||
<td class="numeric">70.00%</td>
|
||||
<td class="numeric">32.61%</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Firefox</td>
|
||||
<td class="numeric">1,990</td>
|
||||
<td class="numeric">3.11</td>
|
||||
<td class="numeric">00:04:22</td>
|
||||
<td class="numeric">70.00%</td>
|
||||
<td class="numeric">32.61%</td>
|
||||
<td class="numeric">00:04:22</td>
|
||||
<td class="numeric">70.00%</td>
|
||||
<td class="numeric">32.61%</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Firefox</td>
|
||||
<td class="numeric">1,990</td>
|
||||
<td class="numeric">3.11</td>
|
||||
<td class="numeric">00:04:22</td>
|
||||
<td class="numeric">70.00%</td>
|
||||
<td class="numeric">32.61%</td>
|
||||
<td class="numeric">00:04:22</td>
|
||||
<td class="numeric">70.00%</td>
|
||||
<td class="numeric">32.61%</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Firefox</td>
|
||||
<td class="numeric">1,990</td>
|
||||
<td class="numeric">3.11</td>
|
||||
<td class="numeric">00:04:22</td>
|
||||
<td class="numeric">70.00%</td>
|
||||
<td class="numeric">32.61%</td>
|
||||
<td class="numeric">00:04:22</td>
|
||||
<td class="numeric">70.00%</td>
|
||||
<td class="numeric">32.61%</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Firefox</td>
|
||||
<td class="numeric">1,990</td>
|
||||
<td class="numeric">3.11</td>
|
||||
<td class="numeric">00:04:22</td>
|
||||
<td class="numeric">70.00%</td>
|
||||
<td class="numeric">32.61%</td>
|
||||
<td class="numeric">00:04:22</td>
|
||||
<td class="numeric">70.00%</td>
|
||||
<td class="numeric">32.61%</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Firefox</td>
|
||||
<td class="numeric">1,990</td>
|
||||
<td class="numeric">3.11</td>
|
||||
<td class="numeric">00:04:22</td>
|
||||
<td class="numeric">70.00%</td>
|
||||
<td class="numeric">32.61%</td>
|
||||
<td class="numeric">00:04:22</td>
|
||||
<td class="numeric">70.00%</td>
|
||||
<td class="numeric">32.61%</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Firefox</td>
|
||||
<td class="numeric">1,990</td>
|
||||
<td class="numeric">3.11</td>
|
||||
<td class="numeric">00:04:22</td>
|
||||
<td class="numeric">70.00%</td>
|
||||
<td class="numeric">32.61%</td>
|
||||
<td class="numeric">00:04:22</td>
|
||||
<td class="numeric">70.00%</td>
|
||||
<td class="numeric">32.61%</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Firefox</td>
|
||||
<td class="numeric">1,990</td>
|
||||
<td class="numeric">3.11</td>
|
||||
<td class="numeric">00:04:22</td>
|
||||
<td class="numeric">70.00%</td>
|
||||
<td class="numeric">32.61%</td>
|
||||
<td class="numeric">00:04:22</td>
|
||||
<td class="numeric">70.00%</td>
|
||||
<td class="numeric">32.61%</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
* jQuery authoring guidelines
|
||||
*
|
||||
* Launch : October 2009
|
||||
* Version : 1.2
|
||||
* Version : 1.2.1
|
||||
* Released: May 2nd, 2011
|
||||
*
|
||||
*
|
||||
|
@ -36,7 +36,7 @@
|
|||
cloneHeadToFoot: false, // clone head and use as footer
|
||||
cloneHeaderToFooter: false, // deprecated option
|
||||
autoResize: false, // resize table if its parent wrapper changes size
|
||||
complete: null // callback after plugin completes
|
||||
create: null // callback after plugin completes
|
||||
|
||||
}
|
||||
|
||||
|
@ -58,7 +58,7 @@
|
|||
if ( helpers._isTable($self) ) {
|
||||
methods.setup.apply(this, Array.prototype.slice.call(arguments, 1));
|
||||
|
||||
$.isFunction(settings.complete) && settings.complete.call(this);
|
||||
$.isFunction(settings.create) && settings.create.call(this);
|
||||
} else {
|
||||
$.error('Invalid table mark-up');
|
||||
}
|
||||
|
@ -87,7 +87,7 @@
|
|||
settings.themeClassName = settings.themeClass;
|
||||
|
||||
if ( settings.width.search('%') > -1 ) {
|
||||
var widthMinusScrollbar = $self.parent().innerWidth() - settings.scrollbarOffset;
|
||||
var widthMinusScrollbar = $self.parent().width() - settings.scrollbarOffset;
|
||||
} else {
|
||||
var widthMinusScrollbar = settings.width - settings.scrollbarOffset;
|
||||
}
|
||||
|
@ -165,6 +165,8 @@
|
|||
.addClass(settings.altClass);
|
||||
}
|
||||
|
||||
helpers._bindScroll( $divBody );
|
||||
|
||||
return self;
|
||||
},
|
||||
|
||||
|
@ -221,7 +223,7 @@
|
|||
*/
|
||||
hide: function( arg1, arg2, arg3 ) {
|
||||
var $self = $(this),
|
||||
self = this
|
||||
self = this,
|
||||
$wrapper = $self.closest('.fht-table-wrapper');
|
||||
|
||||
// User provided show duration without a specific effect
|
||||
|
@ -294,6 +296,30 @@
|
|||
|
||||
},
|
||||
|
||||
/*
|
||||
* return void
|
||||
* bind scroll event
|
||||
*/
|
||||
_bindScroll: function( $obj ) {
|
||||
var $self = $obj,
|
||||
$thead = $self.siblings('.fht-thead'),
|
||||
$tfoot = $self.siblings('.fht-tfoot');
|
||||
|
||||
$self.bind('scroll', function() {
|
||||
$thead.find('table')
|
||||
.css({
|
||||
'margin-left': -this.scrollLeft
|
||||
});
|
||||
|
||||
if ( settings.cloneHeadToFoot ) {
|
||||
$tfoot.find('table')
|
||||
.css({
|
||||
'margin-left': -this.scrollLeft
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/*
|
||||
* return void
|
||||
*/
|
||||
|
@ -330,8 +356,6 @@
|
|||
|
||||
helpers._setupClone( $divFoot, tableProps.tfoot );
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -413,7 +437,7 @@
|
|||
.css({ position: 'absolute', top: -1000, left: -1000 }).appendTo('body'),
|
||||
$textarea2 = $('<textarea cols="10" rows="2" style="overflow: hidden;"></textarea>')
|
||||
.css({ position: 'absolute', top: -1000, left: -1000 }).appendTo('body');
|
||||
scrollbarWidth = $textarea1.width() - $textarea2.width();
|
||||
scrollbarWidth = $textarea1.width() - $textarea2.width() + 2; // + 2 for border offset
|
||||
$textarea1.add($textarea2).remove();
|
||||
} else {
|
||||
var $div = $('<div />')
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
/*!
|
||||
jquery.fixedHeaderTable. The jQuery fixedHeaderTable plugin
|
||||
|
||||
Copyright (c) 2011 Mark Malek
|
||||
http://fixedheadertable.com
|
||||
|
||||
Licensed under MIT
|
||||
http://www.opensource.org/licenses/mit-license.php
|
||||
|
||||
http://docs.jquery.com/Plugins/Authoring
|
||||
jQuery authoring guidelines
|
||||
|
||||
Launch : October 2009
|
||||
Version : 1.2.1
|
||||
Released: May 2nd, 2011
|
||||
|
||||
|
||||
all CSS sizing (width,height) is done in pixels (px)
|
||||
*/
|
||||
(function($){$.fn.fixedHeaderTable=function(method){var defaults={width:'100%',height:'100%',borderCollapse:true,themeClass:'fht-default',autoShow:true,loader:false,footer:false,cloneHeadToFoot:false,cloneHeaderToFooter:false,autoResize:false,create:null}
|
||||
var settings={}
|
||||
var methods={init:function(options){settings=$.extend({},defaults,options);return this.each(function(){var $self=$(this),self=this;if(helpers._isTable($self)){methods.setup.apply(this,Array.prototype.slice.call(arguments,1));$.isFunction(settings.create)&&settings.create.call(this);}else{$.error('Invalid table mark-up');}});},setup:function(options){var $self=$(this),self=this,$thead=$self.find('thead'),$tfoot=$self.find('tfoot'),$tbody=$self.find('tbody'),$wrapper,$divHead,$divFoot,$divBody,$fixedHeadRow,$temp;settings.scrollbarOffset=helpers._getScrollbarWidth();settings.themeClassName=settings.themeClass;if(settings.width.search('%')>-1){var widthMinusScrollbar=$self.parent().width()-settings.scrollbarOffset;}else{var widthMinusScrollbar=settings.width-settings.scrollbarOffset;}
|
||||
$self.css({width:widthMinusScrollbar});if(!$self.closest('.fht-table-wrapper').length){$self.addClass('fht-table');$self.wrap('<div class="fht-table-wrapper"></div>');}
|
||||
$wrapper=$self.closest('.fht-table-wrapper');$wrapper.css({width:settings.width,height:settings.height}).addClass(settings.themeClassName);if(!$self.hasClass('fht-table-init')){$self.wrap('<div class="fht-tbody"></div>');}
|
||||
$divBody=$self.closest('.fht-tbody');var tableProps=helpers._getTableProps($self);helpers._setupClone($divBody,tableProps.tbody);if(!$self.hasClass('fht-table-init')){$divHead=$('<div class="fht-thead"><table class="fht-table"></table></div>').prependTo($wrapper);$thead.clone().appendTo($divHead.find('table'));}else{$divHead=$wrapper.find('div.fht-thead');}
|
||||
helpers._setupClone($divHead,tableProps.thead);$self.css({'margin-top':-$thead.outerHeight(true)-tableProps.border});if(settings.footer){helpers._setupTableFooter($self,self,tableProps);if(!$tfoot.length){$tfoot=$wrapper.find('div.fht-tfoot table');}}
|
||||
var tbodyHeight=$wrapper.height()-$thead.outerHeight(true)-$tfoot.outerHeight(true)-tableProps.border;$divBody.css({'height':tbodyHeight});if(!settings.autoShow){$wrapper.hide();}
|
||||
$self.addClass('fht-table-init');if(typeof(settings.altClass)!=='undefined'){$self.find('tbody tr:odd').addClass(settings.altClass);}
|
||||
helpers._bindScroll($divBody);return self;},resize:function(options){var $self=$(this),self=this;return self;},show:function(arg1,arg2,arg3){var $self=$(this),self=this,$wrapper=$self.closest('.fht-table-wrapper');if(typeof(arg1)!=='undefined'&&typeof(arg1)==='number'){$wrapper.show(arg1,function(){$.isFunction(arg3)&&arg3.call(this);});return self;}else if(typeof(arg1)!=='undefined'&&typeof(arg1)==='string'&&typeof(arg2)!=='undefined'&&typeof(arg2)==='number'){$wrapper.show(arg1,arg2,function(){$.isFunction(arg3)&&arg3.call(this);});return self;}
|
||||
$self.closest('.fht-table-wrapper').show();$.isFunction(arg3)&&arg3.call(this);return self;},hide:function(arg1,arg2,arg3){var $self=$(this),self=this,$wrapper=$self.closest('.fht-table-wrapper');if(typeof(arg1)!=='undefined'&&typeof(arg1)==='number'){$wrapper.hide(arg1,function(){$.isFunction(arg3)&&arg3.call(this);});return self;}else if(typeof(arg1)!=='undefined'&&typeof(arg1)==='string'&&typeof(arg2)!=='undefined'&&typeof(arg2)==='number'){$wrapper.hide(arg1,arg2,function(){$.isFunction(arg3)&&arg3.call(this);});return self;}
|
||||
$self.closest('.fht-table-wrapper').hide();$.isFunction(arg3)&&arg3.call(this);return self;},destroy:function(){var $self=$(this),self=this,$wrapper=$self.closest('.fht-table-wrapper');$self.insertBefore($wrapper).removeAttr('style').append($wrapper.find('tfoot')).removeClass('fht-table fht-table-init').find('.fht-cell').remove();$wrapper.remove();return self;}}
|
||||
var helpers={_isTable:function($obj){var $self=$obj,hasTable=$self.is('table'),hasThead=$self.find('thead').length>0,hasTbody=$self.find('tbody').length>0;if(hasTable&&hasThead&&hasTbody){return true;}
|
||||
return false;},_bindScroll:function($obj){var $self=$obj,$thead=$self.siblings('.fht-thead'),$tfoot=$self.siblings('.fht-tfoot');$self.bind('scroll',function(){$thead.find('table').css({'margin-left':-this.scrollLeft});if(settings.cloneHeadToFoot){$tfoot.find('table').css({'margin-left':-this.scrollLeft});}});},_setupTableFooter:function($obj,obj,tableProps){var $self=$obj,self=obj,$wrapper=$self.closest('.fht-table-wrapper'),$tfoot=$self.find('tfoot'),$divFoot=$wrapper.find('div.fht-tfoot');if(!$divFoot.length){$divFoot=$('<div class="fht-tfoot"><table class="fht-table"></table></div>').appendTo($wrapper);}
|
||||
switch(true){case settings.cloneHeadToFoot&&!$tfoot.length:var $divHead=$wrapper.find('div.fht-thead');$divFoot.empty();$divHead.find('table').clone().appendTo($divFoot);break;case $tfoot.length&&!settings.cloneHeadToFoot&&!$divFoot.find('tr').length:$divFoot.find('table').append($tfoot).css({'margin-top':-tableProps.border});helpers._setupClone($divFoot,tableProps.tfoot);break;}},_getTableProps:function($obj){var tableProp={thead:{},tbody:{},tfoot:{},border:0};tableProp.border=($obj.find('th:first-child').outerWidth()-$obj.find('th:first-child').innerWidth())/2;$obj.find('thead tr:first-child th').each(function(index){tableProp.thead[index]=$(this).width()+tableProp.border;});$obj.find('tfoot tr:first-child td').each(function(index){tableProp.tfoot[index]=$(this).width()+tableProp.border;});$obj.find('tbody tr:first-child td').each(function(index){tableProp.tbody[index]=$(this).width()+tableProp.border;});return tableProp;},_setupClone:function($obj,cellArray){var $self=$obj,selector=($self.find('thead').length)?'thead th':($self.find('tfoot').length)?'tfoot td':'tbody td',$cell;$self.find(selector).each(function(index){$cell=($(this).find('div.fht-cell').length)?$(this).find('div.fht-cell'):$('<div class="fht-cell"></div>').appendTo($(this));$cell.css({'width':parseInt(cellArray[index])});if(!$(this).closest('.fht-tbody').length&&$(this).is(':last-child')){var padding=(($(this).innerWidth()-$(this).width())/2)+settings.scrollbarOffset;$(this).css({'padding-right':padding+'px'});}});},_getScrollbarWidth:function(){var scrollbarWidth=0;if(!scrollbarWidth){if($.browser.msie){var $textarea1=$('<textarea cols="10" rows="2"></textarea>').css({position:'absolute',top:-1000,left:-1000}).appendTo('body'),$textarea2=$('<textarea cols="10" rows="2" style="overflow: hidden;"></textarea>').css({position:'absolute',top:-1000,left:-1000}).appendTo('body');scrollbarWidth=$textarea1.width()-$textarea2.width()+2;$textarea1.add($textarea2).remove();}else{var $div=$('<div />').css({width:100,height:100,overflow:'auto',position:'absolute',top:-1000,left:-1000}).prependTo('body').append('<div />').find('div').css({width:'100%',height:200});scrollbarWidth=100-$div.width();$div.parent().remove();}}
|
||||
return scrollbarWidth;}}
|
||||
if(methods[method]){return methods[method].apply(this,Array.prototype.slice.call(arguments,1));}else if(typeof method==='object'||!method){return methods.init.apply(this,arguments);}else{$.error('Method "'+method+'" does not exist in fixedHeaderTable plugin!');}}})(jQuery);
|
Loading…
Reference in New Issue