/* * File: FixedColumns.min.js * Version: 1.1.0 * Author: Allan Jardine (www.sprymedia.co.uk) * * Copyright 2010-2011 Allan Jardine, all rights reserved. * * This source file is free software, under either the GPL v2 license or a * BSD (3 point) style license, as supplied with this software. * * 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 FixedColumns=function(a,b){if(typeof this._fnConstruct!="function")alert("FixedColumns warning: FixedColumns must be initialised with the 'new' keyword.");else{if(typeof b=="undefined")b={};this.s={dt:a.fnSettings(),leftColumns:1,rightColumns:0,heights:[]};this.dom={scroller:null,scrollContainer:null,header:null,body:null,footer:null,clone:{left:{header:null,body:null,footer:null},right:{header:null,body:null,footer:null}}};this._fnConstruct(b)}}; FixedColumns.prototype={fnUpdate:function(){this._fnDraw(true)},_fnConstruct:function(a){var b=this;if(typeof this.s.dt.oInstance.fnVersionCheck!="function"||this.s.dt.oInstance.fnVersionCheck("1.7.0")!==true)alert("FixedColumns 2 required DataTables 1.7.0 or later. Please upgrade your DataTables installation");else if(this.s.dt.oScroll.sX==="")this.s.dt.oInstance.oApi._fnLog(this.s.dt,1,"FixedColumns is not needed (no x-scrolling in DataTables enabled), so no action will be taken. Use 'FixedHeader' for column fixing when scrolling is not enabled"); else{if(typeof a.columns!="undefined")this.s.leftColumns=a.columns;if(typeof a.iColumns!="undefined")this.s.leftColumns=a.iColumns;if(typeof a.iRightColumns!="undefined")this.s.rightColumns=a.iRightColumns;this.dom.scrollContainer=$(this.s.dt.nTable).parents("div.dataTables_scroll")[0];this.dom.scrollContainer.style.position="relative";this.dom.body=this.s.dt.nTable;this.dom.scroller=this.dom.body.parentNode;this.dom.scroller.style.position="relative";this.dom.header=this.s.dt.nTHead.parentNode;this.dom.header.parentNode.parentNode.style.position= "relative";if(this.s.dt.nTFoot){this.dom.footer=this.s.dt.nTFoot.parentNode;this.dom.footer.parentNode.parentNode.style.position="relative"}this.s.position=this.s.dt.oScroll.sY===""?"absolute":"relative";this.s.position!="absolute"&&$(this.dom.scroller).scroll(function(){b._fnPosition.call(b)});this.s.dt.aoDrawCallback.push({fn:function(){b._fnDraw.call(b,false)},sName:"FixedColumns"});this._fnDraw(true)}},_fnDraw:function(a){this._fnCloneLeft(a);this._fnCloneRight(a);this._fnPosition();this.s.heights.splice(0, this.s.heights.length)},_fnCloneRight:function(a){if(!(this.s.rightColumns<=0)){var b=0,c=[],d,e,f=$("thead tr:eq(0)",this.dom.header).children().length;for(d=this.s.rightColumns-1;d>=0;d--){e=$("thead tr:eq(0)",this.dom.header).children(":eq("+(f-d-1)+")");b+=e.outerWidth();c.push(e.width())}c.reverse();this._fnClone(this.dom.clone.right,a,c,b,":last",":lt("+(f-this.s.rightColumns)+")")}},_fnCloneLeft:function(a){if(!(this.s.leftColumns<=0)){var b=0,c=[],d,e;d=0;for(iLen=this.s.leftColumns;d0){a.body=$(this.dom.body).clone(true)[0];a.body.className+=" FixedColumns_Cloned"; a.body.getAttribute("id")!==null&&a.body.removeAttribute("id");$("thead tr:eq(0)",a.body).each(function(){$("th"+f,this).remove()});$("thead tr:gt(0)",a.body).remove();this._fnEqualiseHeights("tbody",g.dom.body,a.body,e,f);$("tfoot tr:eq(0)",a.body).each(function(){$("th"+f,this).remove()});$("tfoot tr:gt(0)",a.body).remove();a.body.style.position="absolute";a.body.style.top="0px";a.body.style.left="0px";a.body.style.width=d+"px";h=this.s.position=="absolute"?this.dom.scrollContainer:this.dom.body.parentNode; h.appendChild(a.body)}if(this.s.dt.nTFoot!==null)if(b){a.footer!==null&&a.footer.parentNode.removeChild(a.footer);a.footer=$(this.dom.footer).clone(true)[0];a.footer.className+=" FixedColumns_Cloned";a.footer.style.position="absolute";a.footer.style.top="0px";a.footer.style.left="0px";a.footer.style.width=d+"px";h=this.s.position=="absolute"?this.dom.scrollContainer:this.dom.footer.parentNode;h.appendChild(a.footer);this._fnEqualiseHeights("tfoot",this.dom.footer,a.footer,e,f);$("tfoot tr:eq(0)", a.footer).children().each(function(i){this.style.width=c[i]+"px"})}},_fnCopyClasses:function(a,b){a.className=b.className;for(var c=0,d=a.children.length;c0?false:true;d=$(a+" tr:eq(0)",b).children(d);var i=d.outerHeight()-d.height(),k=$.browser.msie&&($.browser.version=="6.0"||$.browser.version=="7.0");$(a+" tr:eq(0) th",c).attr("rowspan")> 1&&$(a+" tr:gt(0)",c).remove();$(a+" tr",c).each(function(j){$(this).children(e,this).remove();if(h){g=$(a+" tr:eq("+j+")",b).children(":first").height();a=="tbody"&&f.s.heights.push(g)}else g=f.s.heights[j];if($.browser.mozilla||$.browser.opera){$(this).children().height(g+i);$(a+" tr:eq("+j+")",b).height(g+i)}else $.browser.msie&&!k?$(this).children().height(g-1):$(this).children().height(g)})},_fnPosition:function(){var a=this.s.position=="absolute"?0:$(this.dom.scroller).scrollLeft(),b=this.dom.clone.left, c=this.dom.clone.right,d=$(this.s.dt.nTable.parentNode).width();if(this.s.position=="absolute"){var e=$(this.dom.body.parentNode).position().top;if(this.dom.footer)var f=$(this.dom.footer.parentNode.parentNode).position().top}if(this.s.leftColumns>0){b.header.style.left=a+"px";if(b.body!==null){b.body.style.left=a+"px";if(this.s.position=="absolute")b.body.style.top=e+"px"}if(this.dom.footer){b.footer.style.left=a+"px";if(this.s.position=="absolute")b.footer.style.top=f+"px"}}if(this.s.rightColumns> 0){a=d-$(c.body).width()+a;c.header.style.left=a+"px";if(c.body!==null){c.body.style.left=a+"px";if(this.s.position=="absolute")c.body.style.top=e+"px"}if(this.dom.footer){c.footer.style.left=a+"px";if(this.s.position=="absolute")c.footer.style.top=f+"px"}}}};