/* * File: ColVis.js * Version: 1.0.7 * CVS: $Id$ * Description: Controls for column visiblity in DataTables * Author: Allan Jardine (www.sprymedia.co.uk) * Created: Wed Sep 15 18:23:29 BST 2010 * Modified: $Date$ by $Author$ * Language: Javascript * License: GPL v2 or BSD 3 point style * Project: Just a little bit of fun :-) * Contact: www.sprymedia.co.uk/contact * * Copyright 2010-2011 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 */ (function($){ColVis=function(oDTSettings,oInit){if(!this.CLASS||this.CLASS!="ColVis"){alert("Warning: ColVis must be initialised with the keyword 'new'");}if(typeof oInit=="undefined"){oInit={};}this.s={"dt":null,"oInit":oInit,"fnStateChange":null,"activate":"click","sAlign":"left","buttonText":"Show / hide columns","hidden":true,"aiExclude":[],"abOriginal":[],"bShowAll":false,"sShowAll":"Show All","bRestore":false,"sRestore":"Restore original","iOverlayFade":500,"fnLabel":null,"sSize":"158","bCssPosition":false};this.dom={"wrapper":null,"button":null,"collection":null,"background":null,"catcher":null,"buttons":[],"restore":null};ColVis.aInstances.push(this);this.s.dt=oDTSettings;this._fnConstruct();return this;};ColVis.prototype={"fnRebuild":function(){for(var i=this.dom.buttons.length-1;i>=0;i--){if(this.dom.buttons[i]!==null){this.dom.collection.removeChild(this.dom.buttons[i]);}}this.dom.buttons.splice(0,this.dom.buttons.length);if(this.dom.restore){this.dom.restore.parentNode(this.dom.restore);}this._fnAddButtons();this._fnDrawCallback();},"_fnConstruct":function(){this._fnApplyCustomisation();var that=this;this.dom.wrapper=document.createElement("div");this.dom.wrapper.className="ColVis TableTools";this.dom.button=this._fnDomBaseButton(this.s.buttonText);this.dom.button.className+=" ColVis_MasterButton";this.dom.wrapper.appendChild(this.dom.button);this.dom.catcher=this._fnDomCatcher();this.dom.collection=this._fnDomCollection();this.dom.background=this._fnDomBackground();this._fnAddButtons();for(var i=0,iLen=this.s.dt.aoColumns.length;i'+this.s.sRestore+"");$(nButton).click(function(e){for(var i=0,iLen=that.s.abOriginal.length;i'+this.s.sShowAll+"");$(nButton).click(function(e){for(var i=0,iLen=that.s.abOriginal.length;i'+''+sTitle+"");$(nButton).click(function(e){var showHide=!$("input",this).is(":checked");if(e.target.nodeName.toLowerCase()=="input"){showHide=$("input",this).is(":checked");}var oldIndex=$.fn.dataTableExt.iApiIndex;$.fn.dataTableExt.iApiIndex=that._fnDataTablesApiIndex.call(that);if(dt.oFeatures.bServerSide&&(dt.oScroll.sX!==""||dt.oScroll.sY!=="")){that.s.dt.oInstance.fnSetColumnVis(i,showHide,false);that.s.dt.oInstance.oApi._fnScrollDraw(that.s.dt);that._fnDrawCallback();}else{that.s.dt.oInstance.fnSetColumnVis(i,showHide);}$.fn.dataTableExt.iApiIndex=oldIndex;if(that.s.fnStateChange!==null){that.s.fnStateChange.call(that,i,showHide);}});return nButton;},"_fnDataTablesApiIndex":function(){for(var i=0,iLen=this.s.dt.oInstance.length;iiDocHeight)?iWinHeight:iDocHeight)+"px";nBackground.style.width=((iWinWidthiDocWidth){nHidden.style.left=(iDocWidth-iDivWidth)+"px";}}setTimeout(function(){$(nHidden).animate({"opacity":1},that.s.iOverlayFade);$(nBackground).animate({"opacity":0.1},that.s.iOverlayFade,"linear",function(){if(jQuery.browser.msie&&jQuery.browser.version=="6.0"){that._fnDrawCallback();}});},10);this.s.hidden=false;},"_fnCollectionHide":function(){var that=this;if(!this.s.hidden&&this.dom.collection!==null){this.s.hidden=true;$(this.dom.collection).animate({"opacity":0},that.s.iOverlayFade,function(e){this.style.display="none";});$(this.dom.background).animate({"opacity":0},that.s.iOverlayFade,function(e){document.body.removeChild(that.dom.background);document.body.removeChild(that.dom.catcher);});}},"_fnAdjustOpenRows":function(){var aoOpen=this.s.dt.aoOpenRows;var iVisible=this.s.dt.oApi._fnVisbleColumns(this.s.dt);for(var i=0,iLen=aoOpen.length;i