'
+ )
+ .click( function (e) {
+ var showHide = !$('input', this).is(":checked");
+ if ( e.target.nodeName.toLowerCase() !== "li" )
+ {
+ if ( e.target.nodeName.toLowerCase() == "input" || that.s.fnStateChange === null )
+ {
+ showHide = ! showHide;
+ }
+ }
+
+ /* Need to consider the case where the initialiser created more than one table - change the
+ * API index that DataTables is using
+ */
+ var oldIndex = $.fn.dataTableExt.iApiIndex;
+ $.fn.dataTableExt.iApiIndex = that._fnDataTablesApiIndex.call(that);
+
+ // Optimisation for server-side processing when scrolling - don't do a full redraw
+ if ( dt.oFeatures.bServerSide )
+ {
+ that.s.dt.oInstance.fnSetColumnVis( i, showHide, false );
+ that.s.dt.oInstance.fnAdjustColumnSizing( false );
+ if (dt.oScroll.sX !== "" || dt.oScroll.sY !== "" )
+ {
+ that.s.dt.oInstance.oApi._fnScrollDraw( that.s.dt );
+ }
+ that._fnDrawCallback();
+ }
+ else
+ {
+ that.s.dt.oInstance.fnSetColumnVis( i, showHide );
+ }
+
+ $.fn.dataTableExt.iApiIndex = oldIndex; /* Restore */
+
+ if ( that.s.fnStateChange !== null )
+ {
+ if ( e.target.nodeName.toLowerCase() == "span" )
+ {
+ e.preventDefault();
+ }
+ that.s.fnStateChange.call( that, i, showHide );
+ }
+ } )[0];
},
-
-
+
+
/**
- * Get the position in the DataTables instance array of the table for this instance of ColVis
+ * Get the position in the DataTables instance array of the table for this
+ * instance of ColVis
* @method _fnDataTablesApiIndex
* @returns {int} Index
- * @private
+ * @private
*/
"_fnDataTablesApiIndex": function ()
{
@@ -652,244 +674,189 @@ ColVis.prototype = {
}
return 0;
},
-
-
+
+
/**
- * Create the DOM needed for the button and apply some base properties. All buttons start here
- * @method _fnDomBaseButton
- * @param {String} text Button text
- * @returns {Node} DIV element for the button
- * @private
- */
- "_fnDomBaseButton": function ( text )
- {
- var
- that = this,
- nButton = document.createElement('button'),
- nSpan = document.createElement('span'),
- sEvent = this.s.activate=="mouseover" ? "mouseover" : "click";
-
- nButton.className = !this.s.dt.bJUI ? "ColVis_Button TableTools_Button" :
- "ColVis_Button TableTools_Button ui-button ui-state-default";
- nButton.appendChild( nSpan );
- nSpan.innerHTML = text;
-
- $(nButton).bind( sEvent, function (e) {
- that._fnCollectionShow();
- e.preventDefault();
- } );
-
- return nButton;
- },
-
-
- /**
- * Create the element used to contain list the columns (it is shown and hidden as needed)
+ * Create the element used to contain list the columns (it is shown and
+ * hidden as needed)
* @method _fnDomCollection
* @returns {Node} div container for the collection
- * @private
+ * @private
*/
"_fnDomCollection": function ()
{
- var that = this;
- var nHidden = document.createElement('div');
- nHidden.style.display = "none";
- nHidden.className = !this.s.dt.bJUI ? "ColVis_collection TableTools_collection" :
- "ColVis_collection TableTools_collection ui-buttonset ui-buttonset-multi";
-
- if ( !this.s.bCssPosition )
- {
- nHidden.style.position = "absolute";
- }
- $(nHidden).css('opacity', 0);
-
- return nHidden;
+ return $('
', {
+ 'class': !this.s.dt.bJUI ?
+ "ColVis_collection" :
+ "ColVis_collection ui-buttonset ui-buttonset-multi"
+ } )
+ .css( {
+ 'display': 'none',
+ 'opacity': 0,
+ 'position': ! this.s.bCssPosition ?
+ 'absolute' :
+ ''
+ } )[0];
},
-
-
+
+
/**
* An element to be placed on top of the activate button to catch events
* @method _fnDomCatcher
* @returns {Node} div container for the collection
- * @private
+ * @private
*/
"_fnDomCatcher": function ()
{
- var
+ var
that = this,
nCatcher = document.createElement('div');
- nCatcher.className = "ColVis_catcher TableTools_catcher";
-
+ nCatcher.className = "ColVis_catcher";
+
$(nCatcher).click( function () {
that._fnCollectionHide.call( that, null, null );
} );
-
+
return nCatcher;
},
-
-
+
+
/**
- * Create the element used to shade the background, and capture hide events (it is shown and
+ * Create the element used to shade the background, and capture hide events (it is shown and
* hidden as needed)
* @method _fnDomBackground
* @returns {Node} div container for the background
- * @private
+ * @private
*/
"_fnDomBackground": function ()
{
var that = this;
-
- var nBackground = document.createElement('div');
- nBackground.style.position = "absolute";
- nBackground.style.left = "0px";
- nBackground.style.top = "0px";
- nBackground.className = "ColVis_collectionBackground TableTools_collectionBackground";
- $(nBackground).css('opacity', 0);
-
- $(nBackground).click( function () {
- that._fnCollectionHide.call( that, null, null );
- } );
-
+
+ var background = $('')
+ .addClass( 'ColVis_collectionBackground' )
+ .css( 'opacity', 0 )
+ .click( function () {
+ that._fnCollectionHide.call( that, null, null );
+ } );
+
/* When considering a mouse over action for the activation, we also consider a mouse out
* which is the same as a mouse over the background - without all the messing around of
* bubbling events. Use the catcher element to avoid messing around with bubbling
*/
if ( this.s.activate == "mouseover" )
{
- $(nBackground).mouseover( function () {
+ background.mouseover( function () {
that.s.overcollection = false;
that._fnCollectionHide.call( that, null, null );
} );
}
-
- return nBackground;
+
+ return background[0];
},
-
-
+
+
/**
* Show the show / hide list and the background
* @method _fnCollectionShow
* @returns void
- * @private
+ * @private
*/
"_fnCollectionShow": function ()
{
- var that = this, i, iLen;
+ var that = this, i, iLen, iLeft;
var oPos = $(this.dom.button).offset();
var nHidden = this.dom.collection;
var nBackground = this.dom.background;
var iDivX = parseInt(oPos.left, 10);
var iDivY = parseInt(oPos.top + $(this.dom.button).outerHeight(), 10);
-
- if ( !this.s.bCssPosition )
+
+ if ( ! this.s.bCssPosition )
{
nHidden.style.top = iDivY+"px";
nHidden.style.left = iDivX+"px";
}
- nHidden.style.display = "block";
- $(nHidden).css('opacity',0);
-
- var iWinHeight = $(window).height(), iDocHeight = $(document).height(),
- iWinWidth = $(window).width(), iDocWidth = $(document).width();
-
- nBackground.style.height = ((iWinHeight>iDocHeight)? iWinHeight : iDocHeight) +"px";
- nBackground.style.width = ((iWinWidth iDocWidth )
+ var iDocWidth = $(document).width();
+
+ if ( iLeft + iDivWidth > iDocWidth )
{
nHidden.style.left = (iDocWidth-iDivWidth)+"px";
}
}
-
- /* This results in a very small delay for the end user but it allows the animation to be
- * much smoother. If you don't want the animation, then the setTimeout can be removed
- */
- setTimeout( function () {
- $(nHidden).animate({"opacity": 1}, that.s.iOverlayFade);
- $(nBackground).animate({"opacity": 0.1}, that.s.iOverlayFade, 'linear', function () {
- /* In IE6 if you set the checked attribute of a hidden checkbox, then this is not visually
- * reflected. As such, we need to do it here, once it is visible. Unbelievable.
- */
- if ( jQuery.browser.msie && jQuery.browser.version == "6.0" )
- {
- that._fnDrawCallback();
- }
- });
- }, 10 );
-
+
this.s.hidden = false;
},
-
-
+
+
/**
* Hide the show / hide list and the background
* @method _fnCollectionHide
* @returns void
- * @private
+ * @private
*/
"_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 );
} );
}
},
-
-
+
+
/**
* Alter the colspan on any fnOpen rows
*/
@@ -897,7 +864,7 @@ ColVis.prototype = {
{
var aoOpen = this.s.dt.aoOpenRows;
var iVisible = this.s.dt.oApi._fnVisbleColumns( this.s.dt );
-
+
for ( var i=0, iLen=aoOpen.length ; i'+this.s.sRestore+"");d(b).click(function(){for(var b=0,c=a.s.abOriginal.length;b'+this.s.sShowAll+"");d(b).click(function(){for(var b=0,c=a.s.abOriginal.length;b'+c+"");d(e).click(function(c){var e=!d("input",this).is(":checked");"input"==c.target.nodeName.toLowerCase()&&
-(e=d("input",this).is(":checked"));c=d.fn.dataTableExt.iApiIndex;d.fn.dataTableExt.iApiIndex=b._fnDataTablesApiIndex.call(b);f.oFeatures.bServerSide&&(""!==f.oScroll.sX||""!==f.oScroll.sY)?(b.s.dt.oInstance.fnSetColumnVis(a,e,!1),b.s.dt.oInstance.fnAdjustColumnSizing(!1),b.s.dt.oInstance.oApi._fnScrollDraw(b.s.dt),b._fnDrawCallback()):b.s.dt.oInstance.fnSetColumnVis(a,e);d.fn.dataTableExt.iApiIndex=c;null!==b.s.fnStateChange&&b.s.fnStateChange.call(b,a,e)});return e},_fnDataTablesApiIndex:function(){for(var a=
-0,b=this.s.dt.oInstance.length;ai?c:i)+"px";g.style.width=(jh&&(e.style.left=h-b+"px"));setTimeout(function(){d(e).animate({opacity:1},a.s.iOverlayFade);d(g).animate({opacity:0.1},a.s.iOverlayFade,"linear",function(){jQuery.browser.msie&&jQuery.browser.version=="6.0"&&a._fnDrawCallback()})},10);this.s.hidden=!1},_fnCollectionHide:function(){var a=this;!this.s.hidden&&null!==this.dom.collection&&(this.s.hidden=!0,d(this.dom.collection).animate({opacity:0},
-a.s.iOverlayFade,function(){this.style.display="none"}),d(this.dom.background).animate({opacity:0},a.s.iOverlayFade,function(){document.body.removeChild(a.dom.background);document.body.removeChild(a.dom.catcher)}))},_fnAdjustOpenRows:function(){for(var a=this.s.dt.aoOpenRows,b=this.s.dt.oApi._fnVisbleColumns(this.s.dt),c=0,d=a.length;c",{"class":!this.s.dt.bJUI?"ColVis_Button ColVis_MasterButton":"ColVis_Button ColVis_MasterButton ui-button ui-state-default"}).append(""+this.s.buttonText+"").bind("mouseover"==this.s.activate?"mouseover":"click",function(a){a.preventDefault();b._fnCollectionShow()}).appendTo(this.dom.wrapper)[0];this.dom.catcher=this._fnDomCatcher();this.dom.collection=this._fnDomCollection();
+this.dom.background=this._fnDomBackground();this._fnAddGroups();this._fnAddButtons();c=0;for(f=this.s.dt.aoColumns.length;c'+this.s.restore+"").click(function(){for(var b=0,c=a.s.abOriginal.length;b'+a+"").click(function(){for(var a=0,d=c.s.abOriginal.length;a").click(function(a){var g=!d("input",this).is(":checked");"li"!==a.target.nodeName.toLowerCase()&&(g=!g);for(a=0;a").click(function(c){var e=!d("input",this).is(":checked");if("li"!==c.target.nodeName.toLowerCase()&&("input"==c.target.nodeName.toLowerCase()||null===b.s.fnStateChange))e=!e;var i=d.fn.dataTableExt.iApiIndex;d.fn.dataTableExt.iApiIndex=b._fnDataTablesApiIndex.call(b);f.oFeatures.bServerSide?(b.s.dt.oInstance.fnSetColumnVis(a,e,!1),b.s.dt.oInstance.fnAdjustColumnSizing(!1),(""!==f.oScroll.sX||""!==f.oScroll.sY)&&b.s.dt.oInstance.oApi._fnScrollDraw(b.s.dt),b._fnDrawCallback()):
+b.s.dt.oInstance.fnSetColumnVis(a,e);d.fn.dataTableExt.iApiIndex=i;null!==b.s.fnStateChange&&("span"==c.target.nodeName.toLowerCase()&&c.preventDefault(),b.s.fnStateChange.call(b,a,e))})[0]},_fnDataTablesApiIndex:function(){for(var a=0,b=this.s.dt.oInstance.length;a",{"class":!this.s.dt.bJUI?"ColVis_collection":"ColVis_collection ui-buttonset ui-buttonset-multi"}).css({display:"none",
+opacity:0,position:!this.s.bCssPosition?"absolute":""})[0]},_fnDomCatcher:function(){var a=this,b=i.createElement("div");b.className="ColVis_catcher";d(b).click(function(){a._fnCollectionHide.call(a,null,null)});return b},_fnDomBackground:function(){var a=this,b=d("").addClass("ColVis_collectionBackground").css("opacity",0).click(function(){a._fnCollectionHide.call(a,null,null)});"mouseover"==this.s.activate&&b.mouseover(function(){a.s.overcollection=!1;a._fnCollectionHide.call(a,null,
+null)});return b[0]},_fnCollectionShow:function(){var a=this,b;b=d(this.dom.button).offset();var c=this.dom.collection,f=this.dom.background,e=parseInt(b.left,10),h=parseInt(b.top+d(this.dom.button).outerHeight(),10);this.s.bCssPosition||(c.style.top=h+"px",c.style.left=e+"px");d(c).css({display:"block",opacity:0});f.style.bottom="0px";f.style.right="0px";h=this.dom.catcher.style;h.height=d(this.dom.button).outerHeight()+"px";h.width=d(this.dom.button).outerWidth()+"px";h.top=b.top+"px";h.left=e+
+"px";i.body.appendChild(f);i.body.appendChild(c);i.body.appendChild(this.dom.catcher);d(c).animate({opacity:1},a.s.iOverlayFade);d(f).animate({opacity:0.1},a.s.iOverlayFade,"linear",function(){d.browser&&(d.browser.msie&&d.browser.version=="6.0")&&a._fnDrawCallback()});this.s.bCssPosition||(b="left"==this.s.sAlign?e:e-d(c).outerWidth()+d(this.dom.button).outerWidth(),c.style.left=b+"px",f=d(c).outerWidth(),d(c).outerHeight(),e=d(i).width(),b+f>e&&(c.style.left=e-f+"px"));this.s.hidden=!1},_fnCollectionHide:function(){var a=
+this;!this.s.hidden&&null!==this.dom.collection&&(this.s.hidden=!0,d(this.dom.collection).animate({opacity:0},a.s.iOverlayFade,function(){this.style.display="none"}),d(this.dom.background).animate({opacity:0},a.s.iOverlayFade,function(){i.body.removeChild(a.dom.background);i.body.removeChild(a.dom.catcher)}))},_fnAdjustOpenRows:function(){for(var a=this.s.dt.aoOpenRows,b=this.s.dt.oApi._fnVisbleColumns(this.s.dt),c=0,d=a.length;c