diff --git a/jquery.fixedheadertable.js b/jquery.fixedheadertable.js
index 09692c2..2d5ec5b 100644
--- a/jquery.fixedheadertable.js
+++ b/jquery.fixedheadertable.js
@@ -126,9 +126,13 @@
if (!$self.hasClass('fht-table-init')) {
if (settings.fixedColumns > 0) {
- $divHead = $('
').prependTo($fixedBody);
+ $divHead = $('').css({
+ 'padding-right': settings.scrollbarOffset
+ }).prependTo($fixedBody);
} else {
- $divHead = $('').prependTo($wrapper);
+ $divHead = $('').css({
+ 'padding-right': settings.scrollbarOffset
+ }).prependTo($wrapper);
}
$divHead.find('table.fht-table').addClass(settings.originalTable.attr('class'));
@@ -601,17 +605,6 @@
$cell.css({
'width': parseInt(cellArray[index], 10)
});
-
- /*
- * Fixed Header and Footer should extend the full width
- * to align with the scrollbar of the body
- */
- if (!$(this).closest('.fht-tbody').length && $(this).is(':last-child') && !$(this).closest('.fht-fixed-column').length) {
- var padding = Math.max((($(this).innerWidth() - $(this).width()) / 2), settings.scrollbarOffset);
- $(this).css({
- 'padding-right': padding + 'px'
- });
- }
});
},
diff --git a/jquery.fixedheadertable.min.js b/jquery.fixedheadertable.min.js
index 3c34dd1..0c50051 100644
--- a/jquery.fixedheadertable.min.js
+++ b/jquery.fixedheadertable.min.js
@@ -16,4 +16,5 @@
*
*
* all CSS sizing (width,height) is done in pixels (px)
- */(function(e){e.fn.fixedHeaderTable=function(t){var n={width:"100%",height:"100%",themeClass:"fht-default",borderCollapse:!0,fixedColumns:0,fixedColumn:!1,sortable:!1,autoShow:!0,footer:!1,cloneHeadToFoot:!1,autoResize:!1,create:null},r={},i={init:function(t){r=e.extend({},n,t);return this.each(function(){var t=e(this);if(s._isTable(t)){i.setup.apply(this,Array.prototype.slice.call(arguments,1));e.isFunction(r.create)&&r.create.call(this)}else e.error("Invalid table mark-up")})},setup:function(){var t=e(this),n=this,o=t.find("thead"),u=t.find("tfoot"),a=0,f,l,c,h,p;r.originalTable=e(this).clone();r.includePadding=s._isPaddingIncludedWithWidth();r.scrollbarOffset=s._getScrollbarWidth();r.themeClassName=r.themeClass;r.width.search("%")>-1?p=t.parent().width()-r.scrollbarOffset:p=r.width-r.scrollbarOffset;t.css({width:p});if(!t.closest(".fht-table-wrapper").length){t.addClass("fht-table");t.wrap('')}f=t.closest(".fht-table-wrapper");r.fixedColumn==1&&r.fixedColumns<=0&&(r.fixedColumns=1);if(r.fixedColumns>0&&f.find(".fht-fixed-column").length==0){t.wrap('');e('').prependTo(f);h=f.find(".fht-fixed-body")}f.css({width:r.width,height:r.height}).addClass(r.themeClassName);t.hasClass("fht-table-init")||t.wrap('');c=t.closest(".fht-tbody");var d=s._getTableProps(t);s._setupClone(c,d.tbody);if(!t.hasClass("fht-table-init")){r.fixedColumns>0?l=e('').prependTo(h):l=e('').prependTo(f);l.find("table.fht-table").addClass(r.originalTable.attr("class"));o.clone().appendTo(l.find("table"))}else l=f.find("div.fht-thead");s._setupClone(l,d.thead);t.css({"margin-top":-l.outerHeight(!0)});if(r.footer==1){s._setupTableFooter(t,n,d);u.length||(u=f.find("div.fht-tfoot table"));a=u.outerHeight(!0)}var v=f.height()-o.outerHeight(!0)-a-d.border;c.css({height:v});t.addClass("fht-table-init");typeof r.altClass!="undefined"&&i.altRows.apply(n);r.fixedColumns>0&&s._setupFixedColumn(t,n,d);r.autoShow||f.hide();s._bindScroll(c,d);return n},resize:function(){var e=this;return e},altRows:function(t){var n=e(this),i=typeof t!="undefined"?t:r.altClass;n.closest(".fht-table-wrapper").find("tbody tr:odd:not(:hidden)").addClass(i)},show:function(t,n,r){var i=e(this),s=this,o=i.closest(".fht-table-wrapper");if(typeof t!="undefined"&&typeof t=="number"){o.show(t,function(){e.isFunction(n)&&n.call(this)});return s}if(typeof t!="undefined"&&typeof t=="string"&&typeof n!="undefined"&&typeof n=="number"){o.show(t,n,function(){e.isFunction(r)&&r.call(this)});return s}i.closest(".fht-table-wrapper").show();e.isFunction(t)&&t.call(this);return s},hide:function(t,n,r){var i=e(this),s=this,o=i.closest(".fht-table-wrapper");if(typeof t!="undefined"&&typeof t=="number"){o.hide(t,function(){e.isFunction(r)&&r.call(this)});return s}if(typeof t!="undefined"&&typeof t=="string"&&typeof n!="undefined"&&typeof n=="number"){o.hide(t,n,function(){e.isFunction(r)&&r.call(this)});return s}i.closest(".fht-table-wrapper").hide();e.isFunction(r)&&r.call(this);return s},destroy:function(){var t=e(this),n=this,r=t.closest(".fht-table-wrapper");t.insertBefore(r).removeAttr("style").append(r.find("tfoot")).removeClass("fht-table fht-table-init").find(".fht-cell").remove();r.remove();return n}},s={_isTable:function(e){var t=e,n=t.is("table"),r=t.find("thead").length>0,i=t.find("tbody").length>0;return n&&r&&i?!0:!1},_bindScroll:function(e){var t=e,n=t.closest(".fht-table-wrapper"),i=t.siblings(".fht-thead"),s=t.siblings(".fht-tfoot");t.bind("scroll",function(){if(r.fixedColumns>0){var e=n.find(".fht-fixed-column");e.find(".fht-tbody table").css({"margin-top":-t.scrollTop()})}i.find("table").css({"margin-left":-this.scrollLeft});(r.footer||r.cloneHeadToFoot)&&s.find("table").css({"margin-left":-this.scrollLeft})})},_fixHeightWithCss:function(e,t){r.includePadding?e.css({height:e.height()+t.border}):e.css({height:e.parent().height()+t.border})},_fixWidthWithCss:function(t,n,i){r.includePadding?t.each(function(){e(this).css({width:i==undefined?e(this).width()+n.border:i+n.border})}):t.each(function(){e(this).css({width:i==undefined?e(this).parent().width()+n.border:i+n.border})})},_setupFixedColumn:function(t,n,i){var o=t,u=o.closest(".fht-table-wrapper"),a=u.find(".fht-fixed-body"),f=u.find(".fht-fixed-column"),l=e(''),c=e(''),h=e(''),p=u.width(),d=a.find(".fht-tbody").height()-r.scrollbarOffset,v,m,g,y,b;l.find("table.fht-table").addClass(r.originalTable.attr("class"));c.find("table.fht-table").addClass(r.originalTable.attr("class"));h.find("table.fht-table").addClass(r.originalTable.attr("class"));v=a.find(".fht-thead thead tr > *:lt("+r.fixedColumns+")");g=r.fixedColumns*i.border;v.each(function(){g+=e(this).outerWidth(!0)});s._fixHeightWithCss(v,i);s._fixWidthWithCss(v,i);var w=[];v.each(function(){w.push(e(this).width())});b="tbody tr > *:not(:nth-child(n+"+(r.fixedColumns+1)+"))";m=a.find(b).each(function(t){s._fixHeightWithCss(e(this),i);s._fixWidthWithCss(e(this),i,w[t%r.fixedColumns])});l.appendTo(f).find("tr").append(v.clone());c.appendTo(f).css({"margin-top":-1,height:d+i.border});m.each(function(t){if(t%r.fixedColumns==0){y=e("
").appendTo(c.find("tbody"));r.altClass&&e(this).parent().hasClass(r.altClass)&&y.addClass(r.altClass)}e(this).clone().appendTo(y)});f.css({height:0,width:g});var E=f.find(".fht-tbody .fht-table").height()-f.find(".fht-tbody").height();f.find(".fht-table").bind("mousewheel",function(t,n,r,i){if(i==0)return;var s=parseInt(e(this).css("marginTop"),10)+(i>0?120:-120);s>0&&(s=0);s<-E&&(s=-E);e(this).css("marginTop",s);a.find(".fht-tbody").scrollTop(-s).scroll();return!1});a.css({width:p});if(r.footer==1||r.cloneHeadToFoot==1){var S=a.find(".fht-tfoot tr > *:lt("+r.fixedColumns+")"),x;s._fixHeightWithCss(S,i);h.appendTo(f).find("tr").append(S.clone());x=h.find("table").innerWidth();h.css({top:r.scrollbarOffset,width:x})}},_setupTableFooter:function(t,n,i){var o=t,u=o.closest(".fht-table-wrapper"),a=o.find("tfoot"),f=u.find("div.fht-tfoot");f.length||(r.fixedColumns>0?f=e('').appendTo(u.find(".fht-fixed-body")):f=e('').appendTo(u));f.find("table.fht-table").addClass(r.originalTable.attr("class"));switch(!0){case!a.length&&r.cloneHeadToFoot==1&&r.footer==1:var l=u.find("div.fht-thead");f.empty();l.find("table").clone().appendTo(f);break;case a.length&&r.cloneHeadToFoot==0&&r.footer==1:f.find("table").append(a).css({"margin-top":-i.border});s._setupClone(f,i.tfoot)}},_getTableProps:function(t){var n={thead:{},tbody:{},tfoot:{},border:0},i=1;r.borderCollapse==1&&(i=2);n.border=(t.find("th:first-child").outerWidth()-t.find("th:first-child").innerWidth())/i;t.find("thead tr:first-child > *").each(function(t){n.thead[t]=e(this).width()+n.border});t.find("tfoot tr:first-child > *").each(function(t){n.tfoot[t]=e(this).width()+n.border});t.find("tbody tr:first-child > *").each(function(t){n.tbody[t]=e(this).width()+n.border});return n},_setupClone:function(t,n){var i=t,s=i.find("thead").length?"thead tr:first-child > *":i.find("tfoot").length?"tfoot tr:first-child > *":"tbody tr:first-child > *",o;i.find(s).each(function(t){o=e(this).find("div.fht-cell").length?e(this).find("div.fht-cell"):e('').appendTo(e(this));o.css({width:parseInt(n[t],10)});if(!e(this).closest(".fht-tbody").length&&e(this).is(":last-child")&&!e(this).closest(".fht-fixed-column").length){var i=Math.max((e(this).innerWidth()-e(this).width())/2,r.scrollbarOffset);e(this).css({"padding-right":i+"px"})}})},_isPaddingIncludedWithWidth:function(){var t=e(''),n,i;t.addClass(r.originalTable.attr("class"));t.appendTo("body");n=t.find("td").height();t.find("td").css("height",t.find("tr").height());i=t.find("td").height();t.remove();return n!=i?!0:!1},_getScrollbarWidth:function(){var t=0;if(!t)if(/msie/.test(navigator.userAgent.toLowerCase())){var n=e('').css({position:"absolute",top:-1e3,left:-1e3}).appendTo("body"),r=e('').css({position:"absolute",top:-1e3,left:-1e3}).appendTo("body");t=n.width()-r.width()+2;n.add(r).remove()}else{var i=e("").css({width:100,height:100,overflow:"auto",position:"absolute",top:-1e3,left:-1e3}).prependTo("body").append("").find("div").css({width:"100%",height:200});t=100-i.width();i.parent().remove()}return t}};if(i[t])return i[t].apply(this,Array.prototype.slice.call(arguments,1));if(typeof t=="object"||!t)return i.init.apply(this,arguments);e.error('Method "'+t+'" does not exist in fixedHeaderTable plugin!')}})(jQuery);
\ No newline at end of file
+ */
+(function(a){a.fn.fixedHeaderTable=function(f){var e={width:"100%",height:"100%",themeClass:"fht-default",borderCollapse:true,fixedColumns:0,fixedColumn:false,sortable:false,autoShow:true,footer:false,cloneHeadToFoot:false,autoResize:false,create:null};var c={};var b={init:function(g){c=a.extend({},e,g);return this.each(function(){var h=a(this);if(d._isTable(h)){b.setup.apply(this,Array.prototype.slice.call(arguments,1));a.isFunction(c.create)&&c.create.call(this);}else{a.error("Invalid table mark-up");}});},setup:function(){var q=a(this),r=this,l=q.find("thead"),o=q.find("tfoot"),m=0,j,n,i,h,p;c.originalTable=a(this).clone();c.includePadding=d._isPaddingIncludedWithWidth();c.scrollbarOffset=d._getScrollbarWidth();c.themeClassName=c.themeClass;if(c.width.search("%")>-1){p=q.parent().width()-c.scrollbarOffset;}else{p=c.width-c.scrollbarOffset;}q.css({width:p});if(!q.closest(".fht-table-wrapper").length){q.addClass("fht-table");q.wrap('');}j=q.closest(".fht-table-wrapper");if(c.fixedColumn==true&&c.fixedColumns<=0){c.fixedColumns=1;}if(c.fixedColumns>0&&j.find(".fht-fixed-column").length==0){q.wrap('');a('').prependTo(j);h=j.find(".fht-fixed-body");}j.css({width:c.width,height:c.height}).addClass(c.themeClassName);if(!q.hasClass("fht-table-init")){q.wrap('');}i=q.closest(".fht-tbody");var g=d._getTableProps(q);d._setupClone(i,g.tbody);if(!q.hasClass("fht-table-init")){if(c.fixedColumns>0){n=a('').css({"padding-right":c.scrollbarOffset}).prependTo(h);}else{n=a('').css({"padding-right":c.scrollbarOffset}).prependTo(j);}n.find("table.fht-table").addClass(c.originalTable.attr("class"));l.clone().appendTo(n.find("table"));}else{n=j.find("div.fht-thead");}d._setupClone(n,g.thead);q.css({"margin-top":-n.outerHeight(true)});if(c.footer==true){d._setupTableFooter(q,r,g);if(!o.length){o=j.find("div.fht-tfoot table");}m=o.outerHeight(true);}var k=j.height()-l.outerHeight(true)-m-g.border;i.css({height:k});q.addClass("fht-table-init");if(typeof(c.altClass)!=="undefined"){b.altRows.apply(r);}if(c.fixedColumns>0){d._setupFixedColumn(q,r,g);}if(!c.autoShow){j.hide();}d._bindScroll(i,g);return r;},resize:function(){var g=this;return g;},altRows:function(h){var i=a(this),g=(typeof(h)!=="undefined")?h:c.altClass;i.closest(".fht-table-wrapper").find("tbody tr:odd:not(:hidden)").addClass(g);},show:function(j,i,g){var l=a(this),h=this,k=l.closest(".fht-table-wrapper");if(typeof(j)!=="undefined"&&typeof(j)==="number"){k.show(j,function(){a.isFunction(i)&&i.call(this);});return h;}else{if(typeof(j)!=="undefined"&&typeof(j)==="string"&&typeof(i)!=="undefined"&&typeof(i)==="number"){k.show(j,i,function(){a.isFunction(g)&&g.call(this);});return h;}}l.closest(".fht-table-wrapper").show();a.isFunction(j)&&j.call(this);return h;},hide:function(j,i,g){var l=a(this),h=this,k=l.closest(".fht-table-wrapper");if(typeof(j)!=="undefined"&&typeof(j)==="number"){k.hide(j,function(){a.isFunction(g)&&g.call(this);});return h;}else{if(typeof(j)!=="undefined"&&typeof(j)==="string"&&typeof(i)!=="undefined"&&typeof(i)==="number"){k.hide(j,i,function(){a.isFunction(g)&&g.call(this);});return h;}}l.closest(".fht-table-wrapper").hide();a.isFunction(g)&&g.call(this);return h;},destroy:function(){var i=a(this),g=this,h=i.closest(".fht-table-wrapper");i.insertBefore(h).removeAttr("style").append(h.find("tfoot")).removeClass("fht-table fht-table-init").find(".fht-cell").remove();h.remove();return g;}};var d={_isTable:function(k){var j=k,h=j.is("table"),i=j.find("thead").length>0,g=j.find("tbody").length>0;if(h&&i&&g){return true;}return false;},_bindScroll:function(k){var j=k,i=j.closest(".fht-table-wrapper"),h=j.siblings(".fht-thead"),g=j.siblings(".fht-tfoot");j.bind("scroll",function(){if(c.fixedColumns>0){var l=i.find(".fht-fixed-column");l.find(".fht-tbody table").css({"margin-top":-j.scrollTop()});}h.find("table").css({"margin-left":-this.scrollLeft});if(c.footer||c.cloneHeadToFoot){g.find("table").css({"margin-left":-this.scrollLeft});}});},_fixHeightWithCss:function(h,g){if(c.includePadding){h.css({height:h.height()+g.border});}else{h.css({height:h.parent().height()+g.border});}},_fixWidthWithCss:function(i,g,h){if(c.includePadding){i.each(function(){a(this).css({width:h==undefined?a(this).width()+g.border:h+g.border});});}else{i.each(function(){a(this).css({width:h==undefined?a(this).parent().width()+g.border:h+g.border});});}},_setupFixedColumn:function(z,q,k){var y=z,x=y.closest(".fht-table-wrapper"),v=x.find(".fht-fixed-body"),o=x.find(".fht-fixed-column"),p=a(''),s=a(''),g=a(''),i=x.width(),t=v.find(".fht-tbody").height()-c.scrollbarOffset,h,u,r,j,l;p.find("table.fht-table").addClass(c.originalTable.attr("class"));s.find("table.fht-table").addClass(c.originalTable.attr("class"));g.find("table.fht-table").addClass(c.originalTable.attr("class"));h=v.find(".fht-thead thead tr > *:lt("+c.fixedColumns+")");r=c.fixedColumns*k.border;h.each(function(){r+=a(this).outerWidth(true);});d._fixHeightWithCss(h,k);d._fixWidthWithCss(h,k);var n=[];h.each(function(){n.push(a(this).width());});l="tbody tr > *:not(:nth-child(n+"+(c.fixedColumns+1)+"))";u=v.find(l).each(function(B){d._fixHeightWithCss(a(this),k);d._fixWidthWithCss(a(this),k,n[B%c.fixedColumns]);});p.appendTo(o).find("tr").append(h.clone());s.appendTo(o).css({"margin-top":-1,height:t+k.border});u.each(function(B){if(B%c.fixedColumns==0){j=a("
").appendTo(s.find("tbody"));if(c.altClass&&a(this).parent().hasClass(c.altClass)){j.addClass(c.altClass);}}a(this).clone().appendTo(j);});o.css({height:0,width:r});var A=o.find(".fht-tbody .fht-table").height()-o.find(".fht-tbody").height();o.find(".fht-table").bind("mousewheel",function(D,F,C,B){if(B==0){return;}var E=parseInt(a(this).css("marginTop"),10)+(B>0?120:-120);if(E>0){E=0;}if(E<-A){E=-A;}a(this).css("marginTop",E);v.find(".fht-tbody").scrollTop(-E).scroll();return false;});v.css({width:i});if(c.footer==true||c.cloneHeadToFoot==true){var m=v.find(".fht-tfoot tr > *:lt("+c.fixedColumns+")"),w;d._fixHeightWithCss(m,k);g.appendTo(o).find("tr").append(m.clone());w=g.find("table").innerWidth();g.css({top:c.scrollbarOffset,width:w});}},_setupTableFooter:function(n,l,g){var m=n,k=m.closest(".fht-table-wrapper"),h=m.find("tfoot"),j=k.find("div.fht-tfoot");if(!j.length){if(c.fixedColumns>0){j=a('').appendTo(k.find(".fht-fixed-body"));}else{j=a('').appendTo(k);}}j.find("table.fht-table").addClass(c.originalTable.attr("class"));switch(true){case !h.length&&c.cloneHeadToFoot==true&&c.footer==true:var i=k.find("div.fht-thead");j.empty();i.find("table").clone().appendTo(j);break;case h.length&&c.cloneHeadToFoot==false&&c.footer==true:j.find("table").append(h).css({"margin-top":-g.border});d._setupClone(j,g.tfoot);break;}},_getTableProps:function(i){var h={thead:{},tbody:{},tfoot:{},border:0},g=1;if(c.borderCollapse==true){g=2;}h.border=(i.find("th:first-child").outerWidth()-i.find("th:first-child").innerWidth())/g;i.find("thead tr:first-child > *").each(function(j){h.thead[j]=a(this).width()+h.border;});i.find("tfoot tr:first-child > *").each(function(j){h.tfoot[j]=a(this).width()+h.border;});i.find("tbody tr:first-child > *").each(function(j){h.tbody[j]=a(this).width()+h.border;});return h;},_setupClone:function(k,j){var i=k,g=(i.find("thead").length)?"thead tr:first-child > *":(i.find("tfoot").length)?"tfoot tr:first-child > *":"tbody tr:first-child > *",h;i.find(g).each(function(l){h=(a(this).find("div.fht-cell").length)?a(this).find("div.fht-cell"):a('').appendTo(a(this));h.css({width:parseInt(j[l],10)});});},_isPaddingIncludedWithWidth:function(){var i=a(''),h,g;i.addClass(c.originalTable.attr("class"));i.appendTo("body");h=i.find("td").height();i.find("td").css("height",i.find("tr").height());g=i.find("td").height();i.remove();if(h!=g){return true;}else{return false;}},_getScrollbarWidth:function(){var h=0;if(!h){if(/msie/.test(navigator.userAgent.toLowerCase())){var j=a('').css({position:"absolute",top:-1000,left:-1000}).appendTo("body"),i=a('').css({position:"absolute",top:-1000,left:-1000}).appendTo("body");h=j.width()-i.width()+2;j.add(i).remove();}else{var g=a("").css({width:100,height:100,overflow:"auto",position:"absolute",top:-1000,left:-1000}).prependTo("body").append("").find("div").css({width:"100%",height:200});h=100-g.width();g.parent().remove();}}return h;}};if(b[f]){return b[f].apply(this,Array.prototype.slice.call(arguments,1));}else{if(typeof f==="object"||!f){return b.init.apply(this,arguments);}else{a.error('Method "'+f+'" does not exist in fixedHeaderTable plugin!');}}};})(jQuery);