Skip to content

Commit

Permalink
Version 1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
webbushka committed Dec 19, 2012
1 parent cb16f40 commit 31f29e2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 13 deletions.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -48,6 +48,7 @@ The max height of the scroll area

Changelog
---------
* v1.1 - Reworked the table header to be the clone
* v1.0.2 - Bug fixes on accounting for the scrollbar.
* v1.0.1 - Remove the padding and margin from the table to ensure the scrollArea and headerHeight are accurate
* v1.0 - Inital Commit
Expand Down
37 changes: 24 additions & 13 deletions jquery.scrollTable.js
@@ -1,6 +1,6 @@
/*global jQuery */
/*!
* ScrollTable.js 1.0.2
* ScrollTable.js 1.1
*
* Copyright 2012, AJ Webb http://ajwebb.me
* Released under the MIT license
Expand Down Expand Up @@ -29,6 +29,10 @@

$.fn.scrollTable = function(options) {

if($(this).data('scrolltable')) {
return this;
}

var settings = $.extend({
headerClass: 'scrollHeader',
headerHeight: $(this).find('thead').height() || $(this).find('tr:eq(0)').height(),
Expand All @@ -50,27 +54,34 @@
return this.each(function() {

var $this = $(this);
var clone = $this.clone().css({
'margin-top': - settings.headerHeight
});

$this.wrap($('<div />', {
'class': settings.headerClass
}).css({
height: settings.headerHeight,
overflow: 'hidden',
width: settings.tableWidth
}));
$this.data('scrolltable', true);

var clone = $this.clone();

$this.parent('.'+settings.headerClass).after($('<div />', {
$this.css({
'margin-top': - settings.headerHeight
}).wrap($('<div />', {
'class': settings.scrollClass
}).append(clone).css({
}).css({
'max-height': settings.scrollHeight,
'overflow-y': 'auto',
'overflow-x': 'hidden',
width: (settings.scrollBar)? settings.tableWidth + settings.scrollBarWidth : settings.tableWidth
}));

$this.parent('.'+settings.scrollClass).before($('<div />', {
'class': settings.headerClass
}).css({
height: settings.headerHeight,
overflow: 'hidden',
width: settings.tableWidth
}).append(clone));

clone.find('tbody').css({
visibility: 'hidden'
});

});
};

Expand Down

0 comments on commit 31f29e2

Please sign in to comment.