All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.googlecode.wicket.jquery.ui.plugins.fixedheadertable.resource.jquery.fixedheadertable.min.js Maven / Gradle / Ivy

There is a newer version: 10.0.0-M1
Show newest version
/*! Copyright (c) 2010 Brandon Aaron (http://brandonaaron.net)
 * Licensed under the MIT License (LICENSE.txt).
 *
 * Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers.
 * Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix.
 * Thanks to: Seamus Leahy for adding deltaX and deltaY
 *
 * Version: 3.0.4
 * 
 * Requires: 1.2.2+
 */

/*!
 * 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.3
 * Released: May 9th, 2011
 *
 * 
 * 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:true,fixedColumns:0,fixedColumn:false,sortable:false,autoShow:true,footer:false,cloneHeadToFoot:false,autoResize:false,create:null};var r={};var i={init:function(t){r=e.extend({},n,t);return this.each(function(){var t=e(this),n=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(t){var n=e(this),o=this,u=n.find("thead"),a=n.find("tfoot"),f=n.find("tbody"),l,c,h,p,d,v,m=0;r.originalTable=e(this).clone();r.includePadding=s._isPaddingIncludedWithWidth();r.scrollbarOffset=s._getScrollbarWidth();r.themeClassName=r.themeClass;if(r.width.search("%")>-1){var g=n.parent().width()-r.scrollbarOffset}else{var g=r.width-r.scrollbarOffset}n.css({width:g});if(!n.closest(".fht-table-wrapper").length){n.addClass("fht-table");n.wrap('
')}l=n.closest(".fht-table-wrapper");if(r.fixedColumn==true&&r.fixedColumns<=0){r.fixedColumns=1}if(r.fixedColumns>0&&l.find(".fht-fixed-column").length==0){n.wrap('
');var y=e('
').prependTo(l),b=l.find(".fht-fixed-body")}l.css({width:r.width,height:r.height}).addClass(r.themeClassName);if(!n.hasClass("fht-table-init")){n.wrap('
')}p=n.closest(".fht-tbody");var w=s._getTableProps(n);s._setupClone(p,w.tbody);if(!n.hasClass("fht-table-init")){if(r.fixedColumns>0){c=e('
').prependTo(b)}else{c=e('
').prependTo(l)}c.find("table.fht-table").addClass(r.originalTable.attr("class"));u.clone().appendTo(c.find("table"))}else{c=l.find("div.fht-thead")}s._setupClone(c,w.thead);n.css({"margin-top":-c.outerHeight(true)});if(r.footer==true){s._setupTableFooter(n,o,w);if(!a.length){a=l.find("div.fht-tfoot table")}m=a.outerHeight(true)}var E=l.height()-u.outerHeight(true)-m-w.border;p.css({height:E});n.addClass("fht-table-init");if(typeof r.altClass!=="undefined"){i.altRows.apply(o)}if(r.fixedColumns>0){s._setupFixedColumn(n,o,w)}if(!r.autoShow){l.hide()}s._bindScroll(p,w);return o},resize:function(t){var n=e(this),r=this;return r},altRows:function(t){var n=e(this),i=this,s=typeof t!=="undefined"?t:r.altClass;n.closest(".fht-table-wrapper").find("tbody tr:odd:not(:hidden)").addClass(s)},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}else 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}else 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}};var s={_isTable:function(e){var t=e,n=t.is("table"),r=t.find("thead").length>0,i=t.find("tbody").length>0;if(n&&r&&i){return true}return false},_bindScroll:function(e,t){var n=e,i=n.closest(".fht-table-wrapper"),s=n.siblings(".fht-thead"),o=n.siblings(".fht-tfoot");n.bind("scroll",function(){if(r.fixedColumns>0){var e=i.find(".fht-fixed-column");e.find(".fht-tbody table").css({"margin-top":-n.scrollTop()})}s.find("table").css({"margin-left":-this.scrollLeft});if(r.footer||r.cloneHeadToFoot){o.find("table").css({"margin-left":-this.scrollLeft})}})},_fixHeightWithCss:function(e,t){if(r.includePadding){e.css({height:e.height()+t.border})}else{e.css({height:e.parent().height()+t.border})}},_fixWidthWithCss:function(t,n,i){if(r.includePadding){t.each(function(t){e(this).css({width:i==undefined?e(this).width()+n.border:i+n.border})})}else{t.each(function(t){e(this).css({width:i==undefined?e(this).parent().width()+n.border:i+n.border})})}},_setupFixedColumn:function(t,n,i){var o=t,u=n,a=o.closest(".fht-table-wrapper"),f=a.find(".fht-fixed-body"),l=a.find(".fht-fixed-column"),c=e('
'),h=e('
'),p=e('
'),d,v,m,g=a.width(),y=f.find(".fht-tbody").height()-r.scrollbarOffset,b;c.find("table.fht-table").addClass(r.originalTable.attr("class"));h.find("table.fht-table").addClass(r.originalTable.attr("class"));p.find("table.fht-table").addClass(r.originalTable.attr("class"));d=f.find(".fht-thead thead tr > *:lt("+r.fixedColumns+")");m=r.fixedColumns*i.border;d.each(function(t){m+=e(this).outerWidth(true)});s._fixHeightWithCss(d,i);s._fixWidthWithCss(d,i);var w=[];d.each(function(t){w.push(e(this).width())});firstTdChildrenSelector="tbody tr > *:not(:nth-child(n+"+(r.fixedColumns+1)+"))";v=f.find(firstTdChildrenSelector).each(function(t){s._fixHeightWithCss(e(this),i);s._fixWidthWithCss(e(this),i,w[t%r.fixedColumns])});c.appendTo(l).find("tr").append(d.clone());h.appendTo(l).css({"margin-top":-1,height:y+i.border});var b;v.each(function(t){if(t%r.fixedColumns==0){b=e("").appendTo(h.find("tbody"));if(r.altClass&&e(this).parent().hasClass(r.altClass)){b.addClass(r.altClass)}}e(this).clone().appendTo(b)});l.css({height:0,width:m});var E=l.find(".fht-tbody .fht-table").height()-l.find(".fht-tbody").height();l.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);if(s>0)s=0;if(s<-E)s=-E;e(this).css("marginTop",s);f.find(".fht-tbody").scrollTop(-s).scroll();return false});f.css({width:g});if(r.footer==true||r.cloneHeadToFoot==true){var S=f.find(".fht-tfoot tr > *:lt("+r.fixedColumns+")");s._fixHeightWithCss(S,i);p.appendTo(l).find("tr").append(S.clone());footwidth=p.find("table").innerWidth();p.css({top:r.scrollbarOffset,width:footwidth})}},_setupTableFooter:function(t,n,i){var o=t,u=n,a=o.closest(".fht-table-wrapper"),f=o.find("tfoot"),l=a.find("div.fht-tfoot");if(!l.length){if(r.fixedColumns>0){l=e('
').appendTo(a.find(".fht-fixed-body"))}else{l=e('
').appendTo(a)}}l.find("table.fht-table").addClass(r.originalTable.attr("class"));switch(true){case!f.length&&r.cloneHeadToFoot==true&&r.footer==true:var c=a.find("div.fht-thead");l.empty();c.find("table").clone().appendTo(l);break;case f.length&&r.cloneHeadToFoot==false&&r.footer==true:l.find("table").append(f).css({"margin-top":-i.border});s._setupClone(l,i.tfoot);break}},_getTableProps:function(t){var n={thead:{},tbody:{},tfoot:{},border:0},i=1;if(r.borderCollapse==true){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])});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('
test
'),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();if(n!=i){return true}else{return false}},_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))}else if(typeof t==="object"||!t){return i.init.apply(this,arguments)}else{e.error('Method "'+t+'" does not exist in fixedHeaderTable plugin!')}}})(jQuery)




© 2015 - 2025 Weber Informatics LLC | Privacy Policy