/* * File: FixedHeader.nightly.min.js * Version: 2.1.0.dev * Author: Allan Jardine (www.sprymedia.co.uk) * Info: www.datatables.net * * Copyright 2008-2012 Allan Jardine, all rights reserved. * * This source file is free software, under either the GPL v2 license or a * BSD style license, available at: * http://datatables.net/license_gpl2 * http://datatables.net/license_bsd * * This source file is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the license files for details. */ var FixedHeader;(function(b,a,c){FixedHeader=function(e,d){if(typeof this.fnInit!="function"){alert("FixedHeader warning: FixedHeader must be initialised with the 'new' keyword."); return}var f=this;var g={aoCache:[],oSides:{top:true,bottom:false,left:0,right:0},oZIndexes:{top:104,bottom:103,left:102,right:101},oCloneOnDraw:{top:false,bottom:false,left:true,right:true},oMes:{iTableWidth:0,iTableHeight:0,iTableLeft:0,iTableRight:0,iTableTop:0,iTableBottom:0},oOffset:{top:0},nTable:null,bUseAbsPos:false,bFooter:false,bInitComplete:false}; this.fnGetSettings=function(){return g};this.fnUpdate=function(){this._fnUpdateClones(); this._fnUpdatePositions()};this.fnPosition=function(){this._fnUpdatePositions()}; this.fnInit(e,d);if(typeof e.fnSettings=="function"){e._oPluginFixedHeader=this}}; FixedHeader.prototype={fnInit:function(e,d){var f=this.fnGetSettings();var g=this; this.fnInitSettings(f,d);if(typeof e.fnSettings=="function"){if(typeof e.fnVersionCheck=="functon"&&e.fnVersionCheck("1.6.0")!==true){alert("FixedHeader 2 required DataTables 1.6.0 or later. Please upgrade your DataTables installation"); return}var h=e.fnSettings();if(h.oScroll.sX!=""||h.oScroll.sY!=""){alert("FixedHeader 2 is not supported with DataTables' scrolling mode at this time"); return}f.nTable=h.nTable;h.aoDrawCallback.unshift({fn:function(){FixedHeader.fnMeasure(); g._fnUpdateClones.call(g);g._fnUpdatePositions.call(g)},sName:"FixedHeader"})}else{f.nTable=e }f.bFooter=(c(">tfoot",f.nTable).length>0)?true:false;f.bUseAbsPos=(c.browser&&c.browser.msie&&(c.browser.version=="6.0"||c.browser.version=="7.0")); if(f.oSides.top){f.aoCache.push(g._fnCloneTable("fixedHeader","FixedHeader_Header",g._fnCloneThead)) }if(f.oSides.bottom){f.aoCache.push(g._fnCloneTable("fixedFooter","FixedHeader_Footer",g._fnCloneTfoot)) }if(f.oSides.left){f.aoCache.push(g._fnCloneTable("fixedLeft","FixedHeader_Left",g._fnCloneTLeft,f.oSides.left)) }if(f.oSides.right){f.aoCache.push(g._fnCloneTable("fixedRight","FixedHeader_Right",g._fnCloneTRight,f.oSides.right)) }FixedHeader.afnScroll.push(function(){g._fnUpdatePositions.call(g)});c(b).resize(function(){FixedHeader.fnMeasure(); g._fnUpdateClones.call(g);g._fnUpdatePositions.call(g)});FixedHeader.fnMeasure(); g._fnUpdateClones();g._fnUpdatePositions();f.bInitComplete=true},fnInitSettings:function(e,d){if(typeof d!="undefined"){if(typeof d.top!="undefined"){e.oSides.top=d.top }if(typeof d.bottom!="undefined"){e.oSides.bottom=d.bottom}if(typeof d.left=="boolean"){e.oSides.left=d.left?1:0 }else{if(typeof d.left!="undefined"){e.oSides.left=d.left}}if(typeof d.right=="boolean"){e.oSides.right=d.right?1:0 }else{if(typeof d.right!="undefined"){e.oSides.right=d.right}}if(typeof d.zTop!="undefined"){e.oZIndexes.top=d.zTop }if(typeof d.zBottom!="undefined"){e.oZIndexes.bottom=d.zBottom}if(typeof d.zLeft!="undefined"){e.oZIndexes.left=d.zLeft }if(typeof d.zRight!="undefined"){e.oZIndexes.right=d.zRight}if(typeof d.offsetTop!="undefined"){e.oOffset.top=d.offsetTop }if(typeof d.alwaysCloneTop!="undefined"){e.oCloneOnDraw.top=d.alwaysCloneTop}if(typeof d.alwaysCloneBottom!="undefined"){e.oCloneOnDraw.bottom=d.alwaysCloneBottom }if(typeof d.alwaysCloneLeft!="undefined"){e.oCloneOnDraw.left=d.alwaysCloneLeft}if(typeof d.alwaysCloneRight!="undefined"){e.oCloneOnDraw.right=d.alwaysCloneRight }}e.bUseAbsPos=(c.browser&&c.browser.msie&&(c.browser.version=="6.0"||c.browser.version=="7.0")) },_fnCloneTable:function(j,i,h,f){var e=this.fnGetSettings();var d;if(c(e.nTable.parentNode).css("position")!="absolute"){e.nTable.parentNode.style.position="relative" }d=e.nTable.cloneNode(false);d.removeAttribute("id");var g=a.createElement("div"); g.style.position="absolute";g.style.top="0px";g.style.left="0px";g.className+=" FixedHeader_Cloned "+j+" "+i; if(j=="fixedHeader"){g.style.zIndex=e.oZIndexes.top}if(j=="fixedFooter"){g.style.zIndex=e.oZIndexes.bottom }if(j=="fixedLeft"){g.style.zIndex=e.oZIndexes.left}else{if(j=="fixedRight"){g.style.zIndex=e.oZIndexes.right }}d.style.margin="0";g.appendChild(d);a.body.appendChild(g);return{nNode:d,nWrapper:g,sType:j,sPosition:"",sTop:"",sLeft:"",fnClone:h,iCells:f} },_fnMeasure:function(){var g=this.fnGetSettings(),d=g.oMes,f=c(g.nTable),e=f.offset(),i=this._fnSumScroll(g.nTable.parentNode,"scrollTop"),h=this._fnSumScroll(g.nTable.parentNode,"scrollLeft"); d.iTableWidth=f.outerWidth();d.iTableHeight=f.outerHeight();d.iTableLeft=e.left+g.nTable.parentNode.scrollLeft; d.iTableTop=e.top+i;d.iTableRight=d.iTableLeft+d.iTableWidth;d.iTableRight=FixedHeader.oDoc.iWidth-d.iTableLeft-d.iTableWidth; d.iTableBottom=FixedHeader.oDoc.iHeight-d.iTableTop-d.iTableHeight},_fnSumScroll:function(f,e){var d=f[e]; while(f=f.parentNode){if(f.nodeName=="HTML"||f.nodeName=="BODY"){break}d=f[e]}return d },_fnUpdatePositions:function(){var f=this.fnGetSettings();this._fnMeasure();for(var e=0,d=f.aoCache.length; eg.iScrollTop+m.oOffset.top){this._fnUpdateCache(j,"sPosition","absolute","position",e.style); this._fnUpdateCache(j,"sTop",f.iTableTop+"px","top",e.style);this._fnUpdateCache(j,"sLeft",f.iTableLeft+"px","left",e.style) }else{if(g.iScrollTop+m.oOffset.top>f.iTableTop+k){this._fnUpdateCache(j,"sPosition","absolute","position",e.style); this._fnUpdateCache(j,"sTop",(f.iTableTop+k)+"px","top",e.style);this._fnUpdateCache(j,"sLeft",f.iTableLeft+"px","left",e.style) }else{if(m.bUseAbsPos){this._fnUpdateCache(j,"sPosition","absolute","position",e.style); this._fnUpdateCache(j,"sTop",g.iScrollTop+"px","top",e.style);this._fnUpdateCache(j,"sLeft",f.iTableLeft+"px","left",e.style) }else{this._fnUpdateCache(j,"sPosition","fixed","position",e.style);this._fnUpdateCache(j,"sTop",m.oOffset.top+"px","top",e.style); this._fnUpdateCache(j,"sLeft",(f.iTableLeft-g.iScrollLeft)+"px","left",e.style)}}}},_fnUpdateCache:function(h,f,e,g,d){if(h[f]!=e){d[g]=e; h[f]=e}},_fnClassUpdate:function(f,d){var e=this;if(f.nodeName.toUpperCase()==="TR"||f.nodeName.toUpperCase()==="TH"||f.nodeName.toUpperCase()==="TD"||f.nodeName.toUpperCase()==="SPAN"){d.className=f.className }c(f).children().each(function(g){e._fnClassUpdate(c(f).children()[g],c(d).children()[g]) })},_fnCloneThead:function(j){var i=this.fnGetSettings();var f=j.nNode;if(i.bInitComplete&&!i.oCloneOnDraw.top){this._fnClassUpdate(c("thead",i.nTable)[0],c("thead",f)[0]); return}var h=c(i.nTable).outerWidth();j.nWrapper.style.width=h+"px";f.style.width=h+"px"; while(f.childNodes.length>0){c("thead th",f).unbind("click");f.removeChild(f.childNodes[0]) }var g=c("thead",i.nTable).clone(true)[0];f.appendChild(g);var e=[];var d=[];jQuery("thead>tr th",i.nTable).each(function(k){e.push(jQuery(this).width()) });jQuery("thead>tr td",i.nTable).each(function(k){d.push(jQuery(this).width())}); jQuery("thead>tr th",i.nTable).each(function(k){jQuery("thead>tr th:eq("+k+")",f).width(e[k]); c(this).width(e[k])});jQuery("thead>tr td",i.nTable).each(function(k){jQuery("thead>tr td:eq("+k+")",f).width(d[k]); c(this).width(d[k])});c("th.sorting, th.sorting_desc, th.sorting_asc",f).bind("click",function(){this.blur() })},_fnCloneTfoot:function(g){var f=this.fnGetSettings();var d=g.nNode;g.nWrapper.style.width=c(f.nTable).outerWidth()+"px"; while(d.childNodes.length>0){d.removeChild(d.childNodes[0])}var e=c("tfoot",f.nTable).clone(true)[0]; d.appendChild(e);c("tfoot:eq(0)>tr th",f.nTable).each(function(h){c("tfoot:eq(0)>tr th:eq("+h+")",d).width(c(this).width()) });c("tfoot:eq(0)>tr td",f.nTable).each(function(h){c("tfoot:eq(0)>tr th:eq("+h+")",d)[0].style.width(c(this).width()) })},_fnCloneTLeft:function(k){var g=this.fnGetSettings();var e=k.nNode;var j=c("tbody",g.nTable)[0]; var d=(c.browser&&c.browser.msie&&(c.browser.version=="6.0"||c.browser.version=="7.0")); while(e.childNodes.length>0){e.removeChild(e.childNodes[0])}e.appendChild(c("thead",g.nTable).clone(true)[0]); e.appendChild(c("tbody",g.nTable).clone(true)[0]);if(g.bFooter){e.appendChild(c("tfoot",g.nTable).clone(true)[0]) }var l="gt("+(k.iCells-1)+")";c("thead tr",e).each(function(i){c("th:"+l,this).remove() });c("tfoot tr",e).each(function(i){c("th:"+l,this).remove()});c("tbody tr",e).each(function(i){c("td:"+l,this).remove() });this.fnEqualiseHeights("thead",j.parentNode,e);this.fnEqualiseHeights("tbody",j.parentNode,e); this.fnEqualiseHeights("tfoot",j.parentNode,e);var h=0;for(var f=0;f0){e.removeChild(e.childNodes[0])}e.appendChild(c("thead",g.nTable).clone(true)[0]); e.appendChild(c("tbody",g.nTable).clone(true)[0]);if(g.bFooter){e.appendChild(c("tfoot",g.nTable).clone(true)[0]) }c("thead tr th:lt("+(j-l.iCells)+")",e).remove();c("tfoot tr th:lt("+(j-l.iCells)+")",e).remove(); c("tbody tr",e).each(function(i){c("td:lt("+(j-l.iCells)+")",this).remove()});this.fnEqualiseHeights("thead",k.parentNode,e); this.fnEqualiseHeights("tbody",k.parentNode,e);this.fnEqualiseHeights("tfoot",k.parentNode,e); var h=0;for(var f=0;f