Rename airtime_mvc/ to legacy/

This commit is contained in:
jo 2021-10-11 13:43:25 +02:00
parent f0879322c2
commit 3e18d42c8b
1316 changed files with 0 additions and 0 deletions

View file

@ -0,0 +1,152 @@
Before you overwrite dataTables.columnFilter.js, note that we have changed a few lines
in this file.
Running a diff between the original column filter plugin (dataTables.columnFilter_orig.js) and
our modified one (dataTables.columnFilter.js):
denise@denise-DX4860:~/airtime/airtime_mvc/public/js/datatables/plugin$ diff -u dataTables.columnFilter_orig.js dataTables.columnFilter.js
--- dataTables.columnFilter_orig.js 2012-10-17 11:41:05.000000000 -0400
+++ dataTables.columnFilter.js 2012-11-22 12:20:03.997107451 -0500
@@ -103,7 +103,8 @@
label = label.replace(/(^\s*)|(\s*$)/g, "");
var currentFilter = oTable.fnSettings().aoPreSearchCols[i].sSearch;
var search_init = 'search_init ';
- var inputvalue = label;
+ //var inputvalue = label;
+ var inputvalue = '';
if (currentFilter != '' && currentFilter != '^') {
if (bIsNumber && currentFilter.charAt(0) == '^')
inputvalue = currentFilter.substr(1); //ignore trailing ^
@@ -133,29 +134,32 @@
});
} else {
input.keyup(function () {
- if (oTable.fnSettings().oFeatures.bServerSide && iFilterLength != 0) {
- //If filter length is set in the server-side processing mode
- //Check has the user entered at least iFilterLength new characters
-
- var currentFilter = oTable.fnSettings().aoPreSearchCols[index].sSearch;
- var iLastFilterLength = $(this).data("dt-iLastFilterLength");
- if (typeof iLastFilterLength == "undefined")
- iLastFilterLength = 0;
- var iCurrentFilterLength = this.value.length;
- if (Math.abs(iCurrentFilterLength - iLastFilterLength) < iFilterLength
- //&& currentFilter.length == 0 //Why this?
- ) {
- //Cancel the filtering
- return;
- }
- else {
- //Remember the current filter length
- $(this).data("dt-iLastFilterLength", iCurrentFilterLength);
+ var advSearchFields = $("div#advanced_search").children(':visible');
+ if(validateAdvancedSearch(advSearchFields)){
+ if (oTable.fnSettings().oFeatures.bServerSide && iFilterLength != 0) {
+ //If filter length is set in the server-side processing mode
+ //Check has the user entered at least iFilterLength new characters
+
+ var currentFilter = oTable.fnSettings().aoPreSearchCols[index].sSearch;
+ var iLastFilterLength = $(this).data("dt-iLastFilterLength");
+ if (typeof iLastFilterLength == "undefined")
+ iLastFilterLength = 0;
+ var iCurrentFilterLength = this.value.length;
+ if (Math.abs(iCurrentFilterLength - iLastFilterLength) < iFilterLength
+ //&& currentFilter.length == 0 //Why this?
+ ) {
+ //Cancel the filtering
+ return;
+ }
+ else {
+ //Remember the current filter length
+ $(this).data("dt-iLastFilterLength", iCurrentFilterLength);
+ }
}
+ /* Filter on the column (the index) of this element */
+ oTable.fnFilter(this.value, _fnColumnIndex(index), regex, smart); //Issue 37
+ fnOnFiltered();
}
- /* Filter on the column (the index) of this element */
- oTable.fnFilter(this.value, _fnColumnIndex(index), regex, smart); //Issue 37
- fnOnFiltered();
});
}
@@ -168,7 +172,8 @@
input.blur(function () {
if (this.value == "") {
$(this).addClass("search_init");
- this.value = asInitVals[index];
+ //this.value = asInitVals[index];
+ this.value = "";
}
});
}
@@ -176,13 +181,25 @@
function fnCreateRangeInput(oTable) {
//var currentFilter = oTable.fnSettings().aoPreSearchCols[i].sSearch;
+
+ var label = "";
+ if (th.attr('id') == "bit_rate") {
+ label = $.i18n._("kbps");
+ } else if (th.attr('id') == "utime" || th.attr('id') == "mtime" || th.attr('id') == "lptime") {
+ label = $.i18n._("yyyy-mm-dd");
+ } else if (th.attr('id') == "length") {
+ label = $.i18n._("hh:mm:ss.t");
+ } else if (th.attr('id') == "sample_rate") {
+ label = $.i18n._("kHz");
+ }
+
th.html(_fnRangeLabelPart(0));
var sFromId = oTable.attr("id") + '_range_from_' + i;
- var from = $('<input type="text" class="number_range_filter" id="' + sFromId + '" rel="' + i + '"/>');
+ var from = $('<input type="text" class="number_range_filter" id="' + sFromId + '" rel="' + i + '" placeholder="' + label + '"/>');
th.append(from);
th.append(_fnRangeLabelPart(1));
var sToId = oTable.attr("id") + '_range_to_' + i;
- var to = $('<input type="text" class="number_range_filter" id="' + sToId + '" rel="' + i + '"/>');
+ var to = $('<input type="text" class="number_range_filter" id="' + sToId + '" rel="' + i + '" placeholder="' + label + '"/>');
th.append(to);
th.append(_fnRangeLabelPart(2));
th.wrapInner('<span class="filterColumn filter_number_range" />');
@@ -228,14 +245,16 @@
$('#' + sFromId + ',#' + sToId, th).keyup(function () {
-
- var iMin = document.getElementById(sFromId).value * 1;
- var iMax = document.getElementById(sToId).value * 1;
- if (iMin != 0 && iMax != 0 && iMin > iMax)
- return;
-
- oTable.fnDraw();
- fnOnFiltered();
+ var advSearchFields = $("div#advanced_search").children(':visible');
+ if(validateAdvancedSearch(advSearchFields)){
+ var iMin = document.getElementById(sFromId).value * 1;
+ var iMax = document.getElementById(sToId).value * 1;
+ if (iMin != 0 && iMax != 0 && iMin > iMax)
+ return;
+
+ oTable.fnDraw();
+ fnOnFiltered();
+ }
});
@@ -566,7 +585,7 @@
sRangeSeparator: "~",
iFilteringDelay: 500,
aoColumns: null,
- sRangeFormat: "From {from} to {to}"
+ sRangeFormat: $.i18n._("From {from} to {to}")
};
properties = $.extend(defaults, options);
@@ -730,4 +749,4 @@
-})(jQuery);
\ No newline at end of file
+})(jQuery);

View file

@ -0,0 +1,33 @@
Before you overwrite dataTables.ColVis.js, note that we have changed a few lines
in this file.
The following function has been modified:
_fnDomBaseButton
The new _fnDomBaseButton looks like this:
"_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.className = "btn-toolbar btn btn-small dropdown-toggle ColVis_MasterButton";
nButton.appendChild( nSpan );
$(nButton).append("<span class='caret'></span>");
nSpan.innerHTML = text;
$(nButton).bind( 'click', function (e) {
that._fnCollectionShow();
e.preventDefault();
} );
return nButton;
},

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,995 @@
/*
* 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 provides column visiblity control for DataTables
* @class ColVis
* @constructor
* @param {object} DataTables settings object
*/
ColVis = function( oDTSettings, oInit )
{
/* Santiy check that we are a new instance */
if ( !this.CLASS || this.CLASS != "ColVis" )
{
alert( "Warning: ColVis must be initialised with the keyword 'new'" );
}
if ( typeof oInit == 'undefined' )
{
oInit = {};
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Public class variables
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/**
* @namespace Settings object which contains customisable information for ColVis instance
*/
this.s = {
/**
* DataTables settings object
* @property dt
* @type Object
* @default null
*/
"dt": null,
/**
* Customisation object
* @property oInit
* @type Object
* @default passed in
*/
"oInit": oInit,
/**
* Callback function to tell the user when the state has changed
* @property fnStateChange
* @type function
* @default null
*/
"fnStateChange": null,
/**
* Mode of activation. Can be 'click' or 'mouseover'
* @property activate
* @type String
* @default click
*/
"activate": "click",
/**
* Position of the collection menu when shown - align "left" or "right"
* @property sAlign
* @type String
* @default right
*/
"sAlign": "left",
/**
* Text used for the button
* @property buttonText
* @type String
* @default Show / hide columns
*/
"buttonText": "Show / hide columns",
/**
* Flag to say if the collection is hidden
* @property hidden
* @type boolean
* @default true
*/
"hidden": true,
/**
* List of columns (integers) which should be excluded from the list
* @property aiExclude
* @type Array
* @default []
*/
"aiExclude": [],
/**
* Store the original viisbility settings so they could be restored
* @property abOriginal
* @type Array
* @default []
*/
"abOriginal": [],
/**
* Show Show-All button
* @property bShowAll
* @type Array
* @default []
*/
"bShowAll": false,
/**
* Show All button text
* @property sShowAll
* @type String
* @default Restore original
*/
"sShowAll": "Show All",
/**
* Show restore button
* @property bRestore
* @type Array
* @default []
*/
"bRestore": false,
/**
* Restore button text
* @property sRestore
* @type String
* @default Restore original
*/
"sRestore": "Restore original",
/**
* Overlay animation duration in mS
* @property iOverlayFade
* @type Integer
* @default 500
*/
"iOverlayFade": 500,
/**
* Label callback for column names. Takes three parameters: 1. the column index, 2. the column
* title detected by DataTables and 3. the TH node for the column
* @property fnLabel
* @type Function
* @default null
*/
"fnLabel": null,
/**
* Indicate if ColVis should automatically calculate the size of buttons or not. The default
* is for it to do so. Set to "css" to disable the automatic sizing
* @property sSize
* @type String
* @default auto
*/
"sSize": "auto",
/**
* Indicate if the column list should be positioned by Javascript, visually below the button
* or allow CSS to do the positioning
* @property bCssPosition
* @type boolean
* @default false
*/
"bCssPosition": false
};
/**
* @namespace Common and useful DOM elements for the class instance
*/
this.dom = {
/**
* Wrapper for the button - given back to DataTables as the node to insert
* @property wrapper
* @type Node
* @default null
*/
"wrapper": null,
/**
* Activation button
* @property button
* @type Node
* @default null
*/
"button": null,
/**
* Collection list node
* @property collection
* @type Node
* @default null
*/
"collection": null,
/**
* Background node used for shading the display and event capturing
* @property background
* @type Node
* @default null
*/
"background": null,
/**
* Element to position over the activation button to catch mouse events when using mouseover
* @property catcher
* @type Node
* @default null
*/
"catcher": null,
/**
* List of button elements
* @property buttons
* @type Array
* @default []
*/
"buttons": [],
/**
* Restore button
* @property restore
* @type Node
* @default null
*/
"restore": null
};
/* Store global reference */
ColVis.aInstances.push( this );
/* Constructor logic */
this.s.dt = oDTSettings;
this._fnConstruct();
return this;
};
ColVis.prototype = {
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Public methods
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/**
* Rebuild the list of buttons for this instance (i.e. if there is a column header update)
* @method fnRebuild
* @returns void
*/
"fnRebuild": function ()
{
/* Remove the old buttons */
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 );
}
/* Re-add them (this is not the optimal way of doing this, it is fast and effective) */
this._fnAddButtons();
/* Update the checkboxes */
this._fnDrawCallback();
},
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Private methods (they are of course public in JS, but recommended as private)
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/**
* Constructor logic
* @method _fnConstruct
* @returns void
* @private
*/
"_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();
/* Store the original visbility information */
for ( var i=0, iLen=this.s.dt.aoColumns.length ; i<iLen ; i++ )
{
this.s.abOriginal.push( this.s.dt.aoColumns[i].bVisible );
}
/* Update on each draw */
this.s.dt.aoDrawCallback.push( {
"fn": function () {
that._fnDrawCallback.call( that );
},
"sName": "ColVis"
} );
},
/**
* Apply any customisation to the settings from the DataTables initialisation
* @method _fnApplyCustomisation
* @returns void
* @private
*/
"_fnApplyCustomisation": function ()
{
var oConfig = this.s.oInit;
if ( typeof oConfig.activate != 'undefined' )
{
this.s.activate = oConfig.activate;
}
if ( typeof oConfig.buttonText != 'undefined' )
{
this.s.buttonText = oConfig.buttonText;
}
if ( typeof oConfig.aiExclude != 'undefined' )
{
this.s.aiExclude = oConfig.aiExclude;
}
if ( typeof oConfig.bRestore != 'undefined' )
{
this.s.bRestore = oConfig.bRestore;
}
if ( typeof oConfig.sRestore != 'undefined' )
{
this.s.sRestore = oConfig.sRestore;
}
if ( typeof oConfig.bShowAll != 'undefined' )
{
this.s.bShowAll = oConfig.bShowAll;
}
if ( typeof oConfig.sShowAll != 'undefined' )
{
this.s.sShowAll = oConfig.sShowAll;
}
if ( typeof oConfig.sAlign != 'undefined' )
{
this.s.sAlign = oConfig.sAlign;
}
if ( typeof oConfig.fnStateChange != 'undefined' )
{
this.s.fnStateChange = oConfig.fnStateChange;
}
if ( typeof oConfig.iOverlayFade != 'undefined' )
{
this.s.iOverlayFade = oConfig.iOverlayFade;
}
if ( typeof oConfig.fnLabel != 'undefined' )
{
this.s.fnLabel = oConfig.fnLabel;
}
if ( typeof oConfig.sSize != 'undefined' )
{
this.s.sSize = oConfig.sSize;
}
if ( typeof oConfig.bCssPosition != 'undefined' )
{
this.s.bCssPosition = oConfig.bCssPosition;
}
},
/**
* On each table draw, check the visiblity checkboxes as needed. This allows any process to
* update the table's column visiblity and ColVis will still be accurate.
* @method _fnDrawCallback
* @returns void
* @private
*/
"_fnDrawCallback": function ()
{
var aoColumns = this.s.dt.aoColumns;
for ( var i=0, iLen=aoColumns.length ; i<iLen ; i++ )
{
if ( this.dom.buttons[i] !== null )
{
if ( aoColumns[i].bVisible )
{
$('input', this.dom.buttons[i]).attr('checked','checked');
}
else
{
$('input', this.dom.buttons[i]).removeAttr('checked');
}
}
}
},
/**
* Loop through the columns in the table and as a new button for each one.
* @method _fnAddButtons
* @returns void
* @private
*/
"_fnAddButtons": function ()
{
var
nButton,
sExclude = ","+this.s.aiExclude.join(',')+",";
for ( var i=0, iLen=this.s.dt.aoColumns.length ; i<iLen ; i++ )
{
if ( sExclude.indexOf( ","+i+"," ) == -1 )
{
nButton = this._fnDomColumnButton( i );
this.dom.buttons.push( nButton );
this.dom.collection.appendChild( nButton );
}
else
{
this.dom.buttons.push( null );
}
}
if ( this.s.bRestore )
{
nButton = this._fnDomRestoreButton();
nButton.className += " ColVis_Restore";
this.dom.buttons.push( nButton );
this.dom.collection.appendChild( nButton );
}
if ( this.s.bShowAll )
{
nButton = this._fnDomShowAllButton();
nButton.className += " ColVis_ShowAll";
this.dom.buttons.push( nButton );
this.dom.collection.appendChild( nButton );
}
},
/**
* Create a button which allows a "restore" action
* @method _fnDomRestoreButton
* @returns {Node} Created button
* @private
*/
"_fnDomRestoreButton": function ()
{
var
that = this,
nButton = document.createElement('button'),
nSpan = document.createElement('span');
nButton.className = !this.s.dt.bJUI ? "ColVis_Button TableTools_Button" :
"ColVis_Button TableTools_Button ui-button ui-state-default";
nButton.appendChild( nSpan );
$(nSpan).html( '<span class="ColVis_title">'+this.s.sRestore+'</span>' );
$(nButton).click( function (e) {
for ( var i=0, iLen=that.s.abOriginal.length ; i<iLen ; i++ )
{
that.s.dt.oInstance.fnSetColumnVis( i, that.s.abOriginal[i], false );
}
that._fnAdjustOpenRows();
that.s.dt.oInstance.fnDraw( false );
} );
return nButton;
},
/**
* Create a button which allows a "show all" action
* @method _fnDomShowAllButton
* @returns {Node} Created button
* @private
*/
"_fnDomShowAllButton": function ()
{
var
that = this,
nButton = document.createElement('button'),
nSpan = document.createElement('span');
nButton.className = !this.s.dt.bJUI ? "ColVis_Button TableTools_Button" :
"ColVis_Button TableTools_Button ui-button ui-state-default";
nButton.appendChild( nSpan );
$(nSpan).html( '<span class="ColVis_title">'+this.s.sShowAll+'</span>' );
$(nButton).click( function (e) {
for ( var i=0, iLen=that.s.abOriginal.length ; i<iLen ; i++ )
{
if (that.s.aiExclude.indexOf(i) === -1)
{
that.s.dt.oInstance.fnSetColumnVis( i, true, false );
}
}
that._fnAdjustOpenRows();
that.s.dt.oInstance.fnDraw( false );
} );
return nButton;
},
/**
* Create the DOM for a show / hide button
* @method _fnDomColumnButton
* @param {int} i Column in question
* @returns {Node} Created button
* @private
*/
"_fnDomColumnButton": function ( i )
{
var
that = this,
oColumn = this.s.dt.aoColumns[i],
nButton = document.createElement('button'),
nSpan = document.createElement('span'),
dt = this.s.dt;
nButton.className = !dt.bJUI ? "ColVis_Button TableTools_Button" :
"ColVis_Button TableTools_Button ui-button ui-state-default";
nButton.appendChild( nSpan );
var sTitle = this.s.fnLabel===null ? oColumn.sTitle : this.s.fnLabel( i, oColumn.sTitle, oColumn.nTh );
$(nSpan).html(
'<span class="ColVis_radio"><input type="checkbox"/></span>'+
'<span class="ColVis_title">'+sTitle+'</span>' );
$(nButton).click( function (e) {
var showHide = !$('input', this).is(":checked");
if ( e.target.nodeName.toLowerCase() == "input" )
{
showHide = $('input', this).is(":checked");
}
/* 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 && (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; /* Restore */
if ( that.s.fnStateChange !== null )
{
that.s.fnStateChange.call( that, i, showHide );
}
} );
return nButton;
},
/**
* Get the position in the DataTables instance array of the table for this instance of ColVis
* @method _fnDataTablesApiIndex
* @returns {int} Index
* @private
*/
"_fnDataTablesApiIndex": function ()
{
for ( var i=0, iLen=this.s.dt.oInstance.length ; i<iLen ; i++ )
{
if ( this.s.dt.oInstance[i] == this.s.dt.nTable )
{
return i;
}
}
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)
* @method _fnDomCollection
* @returns {Node} div container for the collection
* @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;
},
/**
* An element to be placed on top of the activate button to catch events
* @method _fnDomCatcher
* @returns {Node} div container for the collection
* @private
*/
"_fnDomCatcher": function ()
{
var
that = this,
nCatcher = document.createElement('div');
nCatcher.className = "ColVis_catcher TableTools_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
* hidden as needed)
* @method _fnDomBackground
* @returns {Node} div container for the background
* @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 );
} );
/* 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 () {
that.s.overcollection = false;
that._fnCollectionHide.call( that, null, null );
} );
}
return nBackground;
},
/**
* Show the show / hide list and the background
* @method _fnCollectionShow
* @returns void
* @private
*/
"_fnCollectionShow": function ()
{
var that = this, i, iLen;
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 )
{
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)? iWinWidth : iDocWidth) +"px";
var oStyle = this.dom.catcher.style;
oStyle.height = $(this.dom.button).outerHeight()+"px";
oStyle.width = $(this.dom.button).outerWidth()+"px";
oStyle.top = oPos.top+"px";
oStyle.left = iDivX+"px";
document.body.appendChild( nBackground );
document.body.appendChild( nHidden );
document.body.appendChild( this.dom.catcher );
/* Resize the buttons */
if ( this.s.sSize == "auto" )
{
var aiSizes = [];
this.dom.collection.style.width = "auto";
for ( i=0, iLen=this.dom.buttons.length ; i<iLen ; i++ )
{
if ( this.dom.buttons[i] !== null )
{
this.dom.buttons[i].style.width = "auto";
aiSizes.push( $(this.dom.buttons[i]).outerWidth() );
}
}
iMax = Math.max.apply(window, aiSizes);
for ( i=0, iLen=this.dom.buttons.length ; i<iLen ; i++ )
{
if ( this.dom.buttons[i] !== null )
{
this.dom.buttons[i].style.width = iMax+"px";
}
}
this.dom.collection.style.width = iMax+"px";
}
/* Visual corrections to try and keep the collection visible */
if ( !this.s.bCssPosition )
{
nHidden.style.left = this.s.sAlign=="left" ?
iDivX+"px" : (iDivX-$(nHidden).outerWidth()+$(this.dom.button).outerWidth())+"px";
var iDivWidth = $(nHidden).outerWidth();
var iDivHeight = $(nHidden).outerHeight();
if ( iDivX + 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
*/
"_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
*/
"_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<iLen ; i++ ) {
aoOpen[i].nTr.getElementsByTagName('td')[0].colSpan = iVisible;
}
}
};
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Static object methods
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/**
* Rebuild the collection for a given table, or all tables if no parameter given
* @method ColVis.fnRebuild
* @static
* @param object oTable DataTable instance to consider - optional
* @returns void
*/
ColVis.fnRebuild = function ( oTable )
{
var nTable = null;
if ( typeof oTable != 'undefined' )
{
nTable = oTable.fnSettings().nTable;
}
for ( var i=0, iLen=ColVis.aInstances.length ; i<iLen ; i++ )
{
if ( typeof oTable == 'undefined' || nTable == ColVis.aInstances[i].s.dt.nTable )
{
ColVis.aInstances[i].fnRebuild();
}
}
};
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Static object propterties
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/**
* Collection of all ColVis instances
* @property ColVis.aInstances
* @static
* @type Array
* @default []
*/
ColVis.aInstances = [];
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Constants
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/**
* Name of this class
* @constant CLASS
* @type String
* @default ColVis
*/
ColVis.prototype.CLASS = "ColVis";
/**
* ColVis version
* @constant VERSION
* @type String
* @default See code
*/
ColVis.VERSION = "1.0.7";
ColVis.prototype.VERSION = ColVis.VERSION;
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Initialisation
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* Register a new feature with DataTables
*/
if ( typeof $.fn.dataTable == "function" &&
typeof $.fn.dataTableExt.fnVersionCheck == "function" &&
$.fn.dataTableExt.fnVersionCheck('1.7.0') )
{
$.fn.dataTableExt.aoFeatures.push( {
"fnInit": function( oDTSettings ) {
var init = (typeof oDTSettings.oInit.oColVis == 'undefined') ?
{} : oDTSettings.oInit.oColVis;
var oColvis = new ColVis( oDTSettings, init );
return oColvis.dom.wrapper;
},
"cFeature": "C",
"sFeature": "ColVis"
} );
}
else
{
alert( "Warning: ColVis requires DataTables 1.7 or greater - www.datatables.net/download");
}
})(jQuery);

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,916 @@
/*
* File: FixedHeader.js
* Version: 2.0.5
* Description: "Fix" a header at the top of the table, so it scrolls with the table
* Author: Allan Jardine (www.sprymedia.co.uk)
* Created: Wed 16 Sep 2009 19:46:30 BST
* Language: Javascript
* License: GPL v2 or BSD 3 point style
* Project: Just a little bit of fun - enjoy :-)
* Contact: www.sprymedia.co.uk/contact
*
* Copyright 2009-2010 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: FixedHeader
* Purpose: Provide 'fixed' header, footer and columns on an HTML table
* Returns: object:FixedHeader - must be called with 'new'
* Inputs: mixed:mTable - target table
* 1. DataTable object - when using FixedHeader with DataTables, or
* 2. HTML table node - when using FixedHeader without DataTables
* object:oInit - initialisation settings, with the following properties (each optional)
* bool:top - fix the header (default true)
* bool:bottom - fix the footer (default false)
* bool:left - fix the left most column (default false)
* bool:right - fix the right most column (default false)
* int:zTop - fixed header zIndex
* int:zBottom - fixed footer zIndex
* int:zLeft - fixed left zIndex
* int:zRight - fixed right zIndex
*/
var FixedHeader = function ( mTable, oInit ) {
/* Sanity check - you just know it will happen */
if ( typeof this.fnInit != 'function' )
{
alert( "FixedHeader warning: FixedHeader must be initialised with the 'new' keyword." );
return;
}
var that = this;
var oSettings = {
"aoCache": [],
"oSides": {
"top": true,
"bottom": false,
"left": false,
"right": false
},
"oZIndexes": {
"top": 104,
"bottom": 103,
"left": 102,
"right": 101
},
"oMes": {
"iTableWidth": 0,
"iTableHeight": 0,
"iTableLeft": 0,
"iTableRight": 0, /* note this is left+width, not actually "right" */
"iTableTop": 0,
"iTableBottom": 0 /* note this is top+height, not actually "bottom" */
},
"nTable": null,
"bUseAbsPos": false,
"bFooter": false
};
/*
* Function: fnGetSettings
* Purpose: Get the settings for this object
* Returns: object: - settings object
* Inputs: -
*/
this.fnGetSettings = function () {
return oSettings;
};
/*
* Function: fnUpdate
* Purpose: Update the positioning and copies of the fixed elements
* Returns: -
* Inputs: -
*/
this.fnUpdate = function () {
this._fnUpdateClones();
this._fnUpdatePositions();
};
/*
* Function: fnPosition
* Purpose: Update the positioning of the fixed elements
* Returns: -
* Inputs: -
*/
this.fnPosition = function () {
this._fnUpdatePositions();
};
/* Let's do it */
this.fnInit( mTable, oInit );
/* Store the instance on the DataTables object for easy access */
if ( typeof mTable.fnSettings == 'function' )
{
mTable._oPluginFixedHeader = this;
}
};
/*
* Variable: FixedHeader
* Purpose: Prototype for FixedHeader
* Scope: global
*/
FixedHeader.prototype = {
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Initialisation
*/
/*
* Function: fnInit
* Purpose: The "constructor"
* Returns: -
* Inputs: {as FixedHeader function}
*/
fnInit: function ( oTable, oInit )
{
var s = this.fnGetSettings();
var that = this;
/* Record the user definable settings */
this.fnInitSettings( s, oInit );
/* DataTables specific stuff */
if ( typeof oTable.fnSettings == 'function' )
{
if ( typeof oTable.fnVersionCheck == 'functon' &&
oTable.fnVersionCheck( '1.6.0' ) !== true )
{
alert( "FixedHeader 2 required DataTables 1.6.0 or later. "+
"Please upgrade your DataTables installation" );
return;
}
var oDtSettings = oTable.fnSettings();
if ( oDtSettings.oScroll.sX != "" || oDtSettings.oScroll.sY != "" )
{
alert( "FixedHeader 2 is not supported with DataTables' scrolling mode at this time" );
return;
}
s.nTable = oDtSettings.nTable;
oDtSettings.aoDrawCallback.push( {
"fn": function () {
FixedHeader.fnMeasure();
that._fnUpdateClones.call(that);
that._fnUpdatePositions.call(that);
},
"sName": "FixedHeader"
} );
}
else
{
s.nTable = oTable;
}
s.bFooter = ($('>tfoot', s.nTable).length > 0) ? true : false;
/* "Detect" browsers that don't support absolute positioing - or have bugs */
s.bUseAbsPos = (jQuery.browser.msie && (jQuery.browser.version=="6.0"||jQuery.browser.version=="7.0"));
/* Add the 'sides' that are fixed */
if ( s.oSides.top )
{
s.aoCache.push( that._fnCloneTable( "fixedHeader", "FixedHeader_Header", that._fnCloneThead ) );
}
if ( s.oSides.bottom )
{
s.aoCache.push( that._fnCloneTable( "fixedFooter", "FixedHeader_Footer", that._fnCloneTfoot ) );
}
if ( s.oSides.left )
{
s.aoCache.push( that._fnCloneTable( "fixedLeft", "FixedHeader_Left", that._fnCloneTLeft ) );
}
if ( s.oSides.right )
{
s.aoCache.push( that._fnCloneTable( "fixedRight", "FixedHeader_Right", that._fnCloneTRight ) );
}
/* Event listeners for window movement */
FixedHeader.afnScroll.push( function () {
that._fnUpdatePositions.call(that);
} );
jQuery(window).resize( function () {
FixedHeader.fnMeasure();
that._fnUpdateClones.call(that);
that._fnUpdatePositions.call(that);
} );
/* Get things right to start with */
FixedHeader.fnMeasure();
that._fnUpdateClones();
that._fnUpdatePositions();
},
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Support functions
*/
/*
* Function: fnInitSettings
* Purpose: Take the user's settings and copy them to our local store
* Returns: -
* Inputs: object:s - the local settings object
* object:oInit - the user's settings object
*/
fnInitSettings: function ( s, oInit )
{
if ( typeof oInit != 'undefined' )
{
if ( typeof oInit.top != 'undefined' ) {
s.oSides.top = oInit.top;
}
if ( typeof oInit.bottom != 'undefined' ) {
s.oSides.bottom = oInit.bottom;
}
if ( typeof oInit.left != 'undefined' ) {
s.oSides.left = oInit.left;
}
if ( typeof oInit.right != 'undefined' ) {
s.oSides.right = oInit.right;
}
if ( typeof oInit.zTop != 'undefined' ) {
s.oZIndexes.top = oInit.zTop;
}
if ( typeof oInit.zBottom != 'undefined' ) {
s.oZIndexes.bottom = oInit.zBottom;
}
if ( typeof oInit.zLeft != 'undefined' ) {
s.oZIndexes.left = oInit.zLeft;
}
if ( typeof oInit.zRight != 'undefined' ) {
s.oZIndexes.right = oInit.zRight;
}
}
/* Detect browsers which have poor position:fixed support so we can use absolute positions.
* This is much slower since the position must be updated for each scroll, but widens
* compatibility
*/
s.bUseAbsPos = (jQuery.browser.msie &&
(jQuery.browser.version=="6.0"||jQuery.browser.version=="7.0"));
},
/*
* Function: _fnCloneTable
* Purpose: Clone the table node and do basic initialisation
* Returns: -
* Inputs: -
*/
_fnCloneTable: function ( sType, sClass, fnClone )
{
var s = this.fnGetSettings();
var nCTable;
/* We know that the table _MUST_ has a DIV wrapped around it, because this is simply how
* DataTables works. Therefore, we can set this to be relatively position (if it is not
* alreadu absolute, and use this as the base point for the cloned header
*/
if ( jQuery(s.nTable.parentNode).css('position') != "absolute" )
{
s.nTable.parentNode.style.position = "relative";
}
/* Just a shallow clone will do - we only want the table node */
nCTable = s.nTable.cloneNode( false );
nCTable.removeAttribute( 'id' );
var nDiv = document.createElement( 'div' );
nDiv.style.position = "absolute";
nDiv.style.top = "0px";
nDiv.style.left = "0px";
nDiv.className += " FixedHeader_Cloned "+sType+" "+sClass;
/* Set the zIndexes */
if ( sType == "fixedHeader" )
{
nDiv.style.zIndex = s.oZIndexes.top;
}
if ( sType == "fixedFooter" )
{
nDiv.style.zIndex = s.oZIndexes.bottom;
}
if ( sType == "fixedLeft" )
{
nDiv.style.zIndex = s.oZIndexes.left;
}
else if ( sType == "fixedRight" )
{
nDiv.style.zIndex = s.oZIndexes.right;
}
/* remove margins since we are going to poistion it absolutely */
nCTable.style.margin = "0";
/* Insert the newly cloned table into the DOM, on top of the "real" header */
nDiv.appendChild( nCTable );
document.body.appendChild( nDiv );
return {
"nNode": nCTable,
"nWrapper": nDiv,
"sType": sType,
"sPosition": "",
"sTop": "",
"sLeft": "",
"fnClone": fnClone
};
},
/*
* Function: _fnUpdatePositions
* Purpose: Get the current positioning of the table in the DOM
* Returns: -
* Inputs: -
*/
_fnMeasure: function ()
{
var
s = this.fnGetSettings(),
m = s.oMes,
jqTable = jQuery(s.nTable),
oOffset = jqTable.offset(),
iParentScrollTop = this._fnSumScroll( s.nTable.parentNode, 'scrollTop' ),
iParentScrollLeft = this._fnSumScroll( s.nTable.parentNode, 'scrollLeft' );
m.iTableWidth = jqTable.outerWidth();
m.iTableHeight = jqTable.outerHeight();
m.iTableLeft = oOffset.left + s.nTable.parentNode.scrollLeft;
m.iTableTop = oOffset.top + iParentScrollTop;
m.iTableRight = m.iTableLeft + m.iTableWidth;
m.iTableRight = FixedHeader.oDoc.iWidth - m.iTableLeft - m.iTableWidth;
m.iTableBottom = FixedHeader.oDoc.iHeight - m.iTableTop - m.iTableHeight;
},
/*
* Function: _fnSumScroll
* Purpose: Sum node parameters all the way to the top
* Returns: int: sum
* Inputs: node:n - node to consider
* string:side - scrollTop or scrollLeft
*/
_fnSumScroll: function ( n, side )
{
var i = n[side];
while ( n = n.parentNode )
{
if ( n.nodeName != 'HTML' && n.nodeName != 'BODY' )
{
break;
}
i = n[side];
}
return i;
},
/*
* Function: _fnUpdatePositions
* Purpose: Loop over the fixed elements for this table and update their positions
* Returns: -
* Inputs: -
*/
_fnUpdatePositions: function ()
{
var s = this.fnGetSettings();
this._fnMeasure();
for ( var i=0, iLen=s.aoCache.length ; i<iLen ; i++ )
{
if ( s.aoCache[i].sType == "fixedHeader" )
{
this._fnScrollFixedHeader( s.aoCache[i] );
}
else if ( s.aoCache[i].sType == "fixedFooter" )
{
this._fnScrollFixedFooter( s.aoCache[i] );
}
else if ( s.aoCache[i].sType == "fixedLeft" )
{
this._fnScrollHorizontalLeft( s.aoCache[i] );
}
else
{
this._fnScrollHorizontalRight( s.aoCache[i] );
}
}
},
/*
* Function: _fnUpdateClones
* Purpose: Loop over the fixed elements for this table and call their cloning functions
* Returns: -
* Inputs: -
*/
_fnUpdateClones: function ()
{
var s = this.fnGetSettings();
for ( var i=0, iLen=s.aoCache.length ; i<iLen ; i++ )
{
s.aoCache[i].fnClone.call( this, s.aoCache[i] );
}
},
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Scrolling functions
*/
/*
* Function: _fnScrollHorizontalLeft
* Purpose: Update the positioning of the scrolling elements
* Returns: -
* Inputs: object:oCache - the cahced values for this fixed element
*/
_fnScrollHorizontalRight: function ( oCache )
{
var
s = this.fnGetSettings(),
oMes = s.oMes,
oWin = FixedHeader.oWin,
oDoc = FixedHeader.oDoc,
nTable = oCache.nWrapper,
iFixedWidth = jQuery(nTable).outerWidth();
if ( oWin.iScrollRight < oMes.iTableRight )
{
/* Fully right aligned */
this._fnUpdateCache( oCache, 'sPosition', 'absolute', 'position', nTable.style );
this._fnUpdateCache( oCache, 'sTop', oMes.iTableTop+"px", 'top', nTable.style );
this._fnUpdateCache( oCache, 'sLeft', (oMes.iTableLeft+oMes.iTableWidth-iFixedWidth)+"px", 'left', nTable.style );
}
else if ( oMes.iTableLeft < oDoc.iWidth-oWin.iScrollRight-iFixedWidth )
{
/* Middle */
if ( s.bUseAbsPos )
{
this._fnUpdateCache( oCache, 'sPosition', 'absolute', 'position', nTable.style );
this._fnUpdateCache( oCache, 'sTop', oMes.iTableTop+"px", 'top', nTable.style );
this._fnUpdateCache( oCache, 'sLeft', (oDoc.iWidth-oWin.iScrollRight-iFixedWidth)+"px", 'left', nTable.style );
}
else
{
this._fnUpdateCache( oCache, 'sPosition', 'fixed', 'position', nTable.style );
this._fnUpdateCache( oCache, 'sTop', (oMes.iTableTop-oWin.iScrollTop)+"px", 'top', nTable.style );
this._fnUpdateCache( oCache, 'sLeft', (oWin.iWidth-iFixedWidth)+"px", 'left', nTable.style );
}
}
else
{
/* Fully left aligned */
this._fnUpdateCache( oCache, 'sPosition', 'absolute', 'position', nTable.style );
this._fnUpdateCache( oCache, 'sTop', oMes.iTableTop+"px", 'top', nTable.style );
this._fnUpdateCache( oCache, 'sLeft', oMes.iTableLeft+"px", 'left', nTable.style );
}
},
/*
* Function: _fnScrollHorizontalLeft
* Purpose: Update the positioning of the scrolling elements
* Returns: -
* Inputs: object:oCache - the cahced values for this fixed element
*/
_fnScrollHorizontalLeft: function ( oCache )
{
var
s = this.fnGetSettings(),
oMes = s.oMes,
oWin = FixedHeader.oWin,
oDoc = FixedHeader.oDoc,
nTable = oCache.nWrapper,
iCellWidth = jQuery(nTable).outerWidth();
if ( oWin.iScrollLeft < oMes.iTableLeft )
{
/* Fully left align */
this._fnUpdateCache( oCache, 'sPosition', 'absolute', 'position', nTable.style );
this._fnUpdateCache( oCache, 'sTop', oMes.iTableTop+"px", 'top', nTable.style );
this._fnUpdateCache( oCache, 'sLeft', oMes.iTableLeft+"px", 'left', nTable.style );
}
else if ( oWin.iScrollLeft < oMes.iTableLeft+oMes.iTableWidth-iCellWidth )
{
/* Middle */
if ( s.bUseAbsPos )
{
this._fnUpdateCache( oCache, 'sPosition', 'absolute', 'position', nTable.style );
this._fnUpdateCache( oCache, 'sTop', oMes.iTableTop+"px", 'top', nTable.style );
this._fnUpdateCache( oCache, 'sLeft', oWin.iScrollLeft+"px", 'left', nTable.style );
}
else
{
this._fnUpdateCache( oCache, 'sPosition', 'fixed', 'position', nTable.style );
this._fnUpdateCache( oCache, 'sTop', (oMes.iTableTop-oWin.iScrollTop)+"px", 'top', nTable.style );
this._fnUpdateCache( oCache, 'sLeft', "0px", 'left', nTable.style );
}
}
else
{
/* Fully right align */
this._fnUpdateCache( oCache, 'sPosition', 'absolute', 'position', nTable.style );
this._fnUpdateCache( oCache, 'sTop', oMes.iTableTop+"px", 'top', nTable.style );
this._fnUpdateCache( oCache, 'sLeft', (oMes.iTableLeft+oMes.iTableWidth-iCellWidth)+"px", 'left', nTable.style );
}
},
/*
* Function: _fnScrollFixedFooter
* Purpose: Update the positioning of the scrolling elements
* Returns: -
* Inputs: object:oCache - the cahced values for this fixed element
*/
_fnScrollFixedFooter: function ( oCache )
{
var
s = this.fnGetSettings(),
oMes = s.oMes,
oWin = FixedHeader.oWin,
oDoc = FixedHeader.oDoc,
nTable = oCache.nWrapper,
iTheadHeight = jQuery("thead", s.nTable).outerHeight(),
iCellHeight = jQuery(nTable).outerHeight();
if ( oWin.iScrollBottom < oMes.iTableBottom )
{
/* Below */
this._fnUpdateCache( oCache, 'sPosition', 'absolute', 'position', nTable.style );
this._fnUpdateCache( oCache, 'sTop', (oMes.iTableTop+oMes.iTableHeight-iCellHeight)+"px", 'top', nTable.style );
this._fnUpdateCache( oCache, 'sLeft', oMes.iTableLeft+"px", 'left', nTable.style );
}
else if ( oWin.iScrollBottom < oMes.iTableBottom+oMes.iTableHeight-iCellHeight-iTheadHeight )
{
/* Middle */
if ( s.bUseAbsPos )
{
this._fnUpdateCache( oCache, 'sPosition', "absolute", 'position', nTable.style );
this._fnUpdateCache( oCache, 'sTop', (oDoc.iHeight-oWin.iScrollBottom-iCellHeight)+"px", 'top', nTable.style );
this._fnUpdateCache( oCache, 'sLeft', oMes.iTableLeft+"px", 'left', nTable.style );
}
else
{
this._fnUpdateCache( oCache, 'sPosition', 'fixed', 'position', nTable.style );
this._fnUpdateCache( oCache, 'sTop', (oWin.iHeight-iCellHeight)+"px", 'top', nTable.style );
this._fnUpdateCache( oCache, 'sLeft', (oMes.iTableLeft-oWin.iScrollLeft)+"px", 'left', nTable.style );
}
}
else
{
/* Above */
this._fnUpdateCache( oCache, 'sPosition', 'absolute', 'position', nTable.style );
this._fnUpdateCache( oCache, 'sTop', (oMes.iTableTop+iCellHeight)+"px", 'top', nTable.style );
this._fnUpdateCache( oCache, 'sLeft', oMes.iTableLeft+"px", 'left', nTable.style );
}
},
/*
* Function: _fnScrollFixedHeader
* Purpose: Update the positioning of the scrolling elements
* Returns: -
* Inputs: object:oCache - the cahced values for this fixed element
*/
_fnScrollFixedHeader: function ( oCache )
{
var
s = this.fnGetSettings(),
oMes = s.oMes,
oWin = FixedHeader.oWin,
oDoc = FixedHeader.oDoc,
nTable = oCache.nWrapper,
iTbodyHeight = s.nTable.getElementsByTagName('tbody')[0].offsetHeight;
if ( oMes.iTableTop > oWin.iScrollTop )
{
/* Above the table */
this._fnUpdateCache( oCache, 'sPosition', "absolute", 'position', nTable.style );
this._fnUpdateCache( oCache, 'sTop', oMes.iTableTop+"px", 'top', nTable.style );
this._fnUpdateCache( oCache, 'sLeft', oMes.iTableLeft+"px", 'left', nTable.style );
}
else if ( oWin.iScrollTop > oMes.iTableTop+iTbodyHeight )
{
/* At the bottom of the table */
this._fnUpdateCache( oCache, 'sPosition', "absolute", 'position', nTable.style );
this._fnUpdateCache( oCache, 'sTop', (oMes.iTableTop+iTbodyHeight)+"px", 'top', nTable.style );
this._fnUpdateCache( oCache, 'sLeft', oMes.iTableLeft+"px", 'left', nTable.style );
}
else
{
/* In the middle of the table */
if ( s.bUseAbsPos )
{
this._fnUpdateCache( oCache, 'sPosition', "absolute", 'position', nTable.style );
this._fnUpdateCache( oCache, 'sTop', oWin.iScrollTop+"px", 'top', nTable.style );
this._fnUpdateCache( oCache, 'sLeft', oMes.iTableLeft+"px", 'left', nTable.style );
}
else
{
this._fnUpdateCache( oCache, 'sPosition', 'fixed', 'position', nTable.style );
this._fnUpdateCache( oCache, 'sTop', "0px", 'top', nTable.style );
this._fnUpdateCache( oCache, 'sLeft', (oMes.iTableLeft-oWin.iScrollLeft)+"px", 'left', nTable.style );
}
}
},
/*
* Function: _fnUpdateCache
* Purpose: Check the cache and update cache and value if needed
* Returns: -
* Inputs: object:oCache - local cache object
* string:sCache - cache property
* string:sSet - value to set
* string:sProperty - object property to set
* object:oObj - object to update
*/
_fnUpdateCache: function ( oCache, sCache, sSet, sProperty, oObj )
{
if ( oCache[sCache] != sSet )
{
oObj[sProperty] = sSet;
oCache[sCache] = sSet;
}
},
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Cloning functions
*/
/*
* Function: _fnCloneThead
* Purpose: Clone the thead element
* Returns: -
* Inputs: object:oCache - the cahced values for this fixed element
*/
_fnCloneThead: function ( oCache )
{
var s = this.fnGetSettings();
var nTable = oCache.nNode;
/* Set the wrapper width to match that of the cloned table */
oCache.nWrapper.style.width = jQuery(s.nTable).outerWidth()+"px";
/* Remove any children the cloned table has */
while ( nTable.childNodes.length > 0 )
{
jQuery('thead th', nTable).unbind( 'click' );
nTable.removeChild( nTable.childNodes[0] );
}
/* Clone the DataTables header */
var nThead = jQuery('thead', s.nTable).clone(true)[0];
nTable.appendChild( nThead );
/* Copy the widths across - apparently a clone isn't good enough for this */
jQuery("thead>tr th", s.nTable).each( function (i) {
jQuery("thead>tr th:eq("+i+")", nTable).width( jQuery(this).width() );
} );
jQuery("thead>tr td", s.nTable).each( function (i) {
jQuery("thead>tr td:eq("+i+")", nTable).width( jQuery(this).width() );
} );
},
/*
* Function: _fnCloneTfoot
* Purpose: Clone the tfoot element
* Returns: -
* Inputs: object:oCache - the cahced values for this fixed element
*/
_fnCloneTfoot: function ( oCache )
{
var s = this.fnGetSettings();
var nTable = oCache.nNode;
/* Set the wrapper width to match that of the cloned table */
oCache.nWrapper.style.width = jQuery(s.nTable).outerWidth()+"px";
/* Remove any children the cloned table has */
while ( nTable.childNodes.length > 0 )
{
nTable.removeChild( nTable.childNodes[0] );
}
/* Clone the DataTables footer */
var nTfoot = jQuery('tfoot', s.nTable).clone(true)[0];
nTable.appendChild( nTfoot );
/* Copy the widths across - apparently a clone isn't good enough for this */
jQuery("tfoot:eq(0)>tr th", s.nTable).each( function (i) {
jQuery("tfoot:eq(0)>tr th:eq("+i+")", nTable).width( jQuery(this).width() );
} );
jQuery("tfoot:eq(0)>tr td", s.nTable).each( function (i) {
jQuery("tfoot:eq(0)>tr th:eq("+i+")", nTable)[0].style.width( jQuery(this).width() );
} );
},
/*
* Function: _fnCloneTLeft
* Purpose: Clone the left column
* Returns: -
* Inputs: object:oCache - the cahced values for this fixed element
*/
_fnCloneTLeft: function ( oCache )
{
var s = this.fnGetSettings();
var nTable = oCache.nNode;
var nBody = $('tbody', s.nTable)[0];
var iCols = $('tbody tr:eq(0) td', s.nTable).length;
var bRubbishOldIE = ($.browser.msie && ($.browser.version == "6.0" || $.browser.version == "7.0"));
/* Remove any children the cloned table has */
while ( nTable.childNodes.length > 0 )
{
nTable.removeChild( nTable.childNodes[0] );
}
/* Is this the most efficient way to do this - it looks horrible... */
nTable.appendChild( jQuery("thead", s.nTable).clone(true)[0] );
nTable.appendChild( jQuery("tbody", s.nTable).clone(true)[0] );
if ( s.bFooter )
{
nTable.appendChild( jQuery("tfoot", s.nTable).clone(true)[0] );
}
jQuery('thead tr th:gt(0)', nTable).remove();
jQuery('tfoot tr th:gt(0)', nTable).remove();
/* Remove unneeded cells */
$('tbody tr', nTable).each( function (k) {
$('td:gt(0)', this).remove();
} );
this.fnEqualiseHeights( 'tbody', nBody.parentNode, nTable );
var iWidth = jQuery('thead tr th:eq(0)', s.nTable).outerWidth();
nTable.style.width = iWidth+"px";
oCache.nWrapper.style.width = iWidth+"px";
},
/*
* Function: _fnCloneTRight
* Purpose: Clone the right most colun
* Returns: -
* Inputs: object:oCache - the cahced values for this fixed element
*/
_fnCloneTRight: function ( oCache )
{
var s = this.fnGetSettings();
var nBody = $('tbody', s.nTable)[0];
var nTable = oCache.nNode;
var iCols = jQuery('tbody tr:eq(0) td', s.nTable).length;
var bRubbishOldIE = ($.browser.msie && ($.browser.version == "6.0" || $.browser.version == "7.0"));
/* Remove any children the cloned table has */
while ( nTable.childNodes.length > 0 )
{
nTable.removeChild( nTable.childNodes[0] );
}
/* Is this the most efficient way to do this - it looks horrible... */
nTable.appendChild( jQuery("thead", s.nTable).clone(true)[0] );
nTable.appendChild( jQuery("tbody", s.nTable).clone(true)[0] );
if ( s.bFooter )
{
nTable.appendChild( jQuery("tfoot", s.nTable).clone(true)[0] );
}
jQuery('thead tr th:not(:nth-child('+iCols+'n))', nTable).remove();
jQuery('tfoot tr th:not(:nth-child('+iCols+'n))', nTable).remove();
/* Remove unneeded cells */
$('tbody tr', nTable).each( function (k) {
$('td:lt('+(iCols-1)+')', this).remove();
} );
this.fnEqualiseHeights( 'tbody', nBody.parentNode, nTable );
var iWidth = jQuery('thead tr th:eq('+(iCols-1)+')', s.nTable).outerWidth();
nTable.style.width = iWidth+"px";
oCache.nWrapper.style.width = iWidth+"px";
},
/**
* Equalise the heights of the rows in a given table node in a cross browser way. Note that this
* is more or less lifted as is from FixedColumns
* @method fnEqualiseHeights
* @returns void
* @param {string} parent Node type - thead, tbody or tfoot
* @param {element} original Original node to take the heights from
* @param {element} clone Copy the heights to
* @private
*/
"fnEqualiseHeights": function ( parent, original, clone )
{
var that = this,
jqBoxHack = $(parent+' tr:eq(0)', original).children(':eq(0)'),
iBoxHack = jqBoxHack.outerHeight() - jqBoxHack.height(),
bRubbishOldIE = ($.browser.msie && ($.browser.version == "6.0" || $.browser.version == "7.0"));
/* Remove cells which are not needed and copy the height from the original table */
$(parent+' tr', clone).each( function (k) {
/* Can we use some kind of object detection here?! This is very nasty - damn browsers */
if ( $.browser.mozilla || $.browser.opera )
{
$(this).children().height( $(parent+' tr:eq('+k+')', original).outerHeight() );
}
else
{
$(this).children().height( $(parent+' tr:eq('+k+')', original).outerHeight() - iBoxHack );
}
if ( !bRubbishOldIE )
{
$(parent+' tr:eq('+k+')', original).height( $(parent+' tr:eq('+k+')', original).outerHeight() );
}
} );
}
};
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Static properties and methods
* We use these for speed! This information is common to all instances of FixedHeader, so no
* point if having them calculated and stored for each different instance.
*/
/*
* Variable: oWin
* Purpose: Store information about the window positioning
* Scope: FixedHeader
*/
FixedHeader.oWin = {
"iScrollTop": 0,
"iScrollRight": 0,
"iScrollBottom": 0,
"iScrollLeft": 0,
"iHeight": 0,
"iWidth": 0
};
/*
* Variable: oDoc
* Purpose: Store information about the document size
* Scope: FixedHeader
*/
FixedHeader.oDoc = {
"iHeight": 0,
"iWidth": 0
};
/*
* Variable: afnScroll
* Purpose: Array of functions that are to be used for the scrolling components
* Scope: FixedHeader
*/
FixedHeader.afnScroll = [];
/*
* Function: fnMeasure
* Purpose: Update the measurements for the window and document
* Returns: -
* Inputs: -
*/
FixedHeader.fnMeasure = function ()
{
var
jqWin = jQuery(window),
jqDoc = jQuery(document),
oWin = FixedHeader.oWin,
oDoc = FixedHeader.oDoc;
oDoc.iHeight = jqDoc.height();
oDoc.iWidth = jqDoc.width();
oWin.iHeight = jqWin.height();
oWin.iWidth = jqWin.width();
oWin.iScrollTop = jqWin.scrollTop();
oWin.iScrollLeft = jqWin.scrollLeft();
oWin.iScrollRight = oDoc.iWidth - oWin.iScrollLeft - oWin.iWidth;
oWin.iScrollBottom = oDoc.iHeight - oWin.iScrollTop - oWin.iHeight;
};
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Global processing
*/
/*
* Just one 'scroll' event handler in FixedHeader, which calls the required components. This is
* done as an optimisation, to reduce calculation and proagation time
*/
jQuery(window).scroll( function () {
FixedHeader.fnMeasure();
for ( var i=0, iLen=FixedHeader.afnScroll.length ; i<iLen ; i++ )
{
FixedHeader.afnScroll[i]();
}
} );

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,26 @@
/*!
ColReorder 1.1.3
©2010-2014 SpryMedia Ltd - datatables.net/license
*/
(function(o,r,s){function p(d){for(var f=[],a=0,b=d.length;a<b;a++)f[d[a]]=a;return f}function l(d,f,a){f=d.splice(f,1)[0];d.splice(a,0,f)}function q(d,f,a){for(var b=[],e=0,h=d.childNodes.length;e<h;e++)1==d.childNodes[e].nodeType&&b.push(d.childNodes[e]);f=b[f];null!==a?d.insertBefore(f,b[a]):d.appendChild(f)}o=function(d){d.fn.dataTableExt.oApi.fnColReorder=function(a,b,e){var h=d.fn.dataTable.Api?!0:!1,c,g,f,m,n=a.aoColumns.length,i,j;i=function(a,b,c){if(a[b]){var e=a[b].split("."),d=e.shift();
isNaN(1*d)||(a[b]=c[1*d]+"."+e.join("."))}};if(b!=e)if(0>b||b>=n)this.oApi._fnLog(a,1,"ColReorder 'from' index is out of bounds: "+b);else if(0>e||e>=n)this.oApi._fnLog(a,1,"ColReorder 'to' index is out of bounds: "+e);else{f=[];c=0;for(g=n;c<g;c++)f[c]=c;l(f,b,e);var k=p(f);c=0;for(g=a.aaSorting.length;c<g;c++)a.aaSorting[c][0]=k[a.aaSorting[c][0]];if(null!==a.aaSortingFixed){c=0;for(g=a.aaSortingFixed.length;c<g;c++)a.aaSortingFixed[c][0]=k[a.aaSortingFixed[c][0]]}c=0;for(g=n;c<g;c++){j=a.aoColumns[c];
f=0;for(m=j.aDataSort.length;f<m;f++)j.aDataSort[f]=k[j.aDataSort[f]];h&&(j.idx=k[j.idx])}h&&d.each(a.aLastSort,function(b,c){a.aLastSort[b].src=k[c.src]});c=0;for(g=n;c<g;c++)j=a.aoColumns[c],"number"==typeof j.mData?(j.mData=k[j.mData],a.oApi._fnColumnOptions(a,c,{})):d.isPlainObject(j.mData)&&(i(j.mData,"_",k),i(j.mData,"filter",k),i(j.mData,"sort",k),i(j.mData,"type",k),a.oApi._fnColumnOptions(a,c,{}));if(a.aoColumns[b].bVisible){f=this.oApi._fnColumnIndexToVisible(a,b);m=null;for(c=e<b?e:e+1;null===
m&&c<n;)m=this.oApi._fnColumnIndexToVisible(a,c),c++;i=a.nTHead.getElementsByTagName("tr");c=0;for(g=i.length;c<g;c++)q(i[c],f,m);if(null!==a.nTFoot){i=a.nTFoot.getElementsByTagName("tr");c=0;for(g=i.length;c<g;c++)q(i[c],f,m)}c=0;for(g=a.aoData.length;c<g;c++)null!==a.aoData[c].nTr&&q(a.aoData[c].nTr,f,m)}l(a.aoColumns,b,e);l(a.aoPreSearchCols,b,e);c=0;for(g=a.aoData.length;c<g;c++)i=a.aoData[c],h?(i.anCells&&l(i.anCells,b,e),"dom"!==i.src&&d.isArray(i._aData)&&l(i._aData,b,e)):(d.isArray(i._aData)&&
l(i._aData,b,e),l(i._anHidden,b,e));c=0;for(g=a.aoHeader.length;c<g;c++)l(a.aoHeader[c],b,e);if(null!==a.aoFooter){c=0;for(g=a.aoFooter.length;c<g;c++)l(a.aoFooter[c],b,e)}h&&(new d.fn.dataTable.Api(a)).rows().invalidate();c=0;for(g=n;c<g;c++)d(a.aoColumns[c].nTh).off("click.DT"),this.oApi._fnSortAttachListener(a,a.aoColumns[c].nTh,c);d(a.oInstance).trigger("column-reorder",[a,{iFrom:b,iTo:e,aiInvertMapping:k}])}};var f=function(a,b){var e;d.fn.dataTable.Api?e=(new d.fn.dataTable.Api(a)).settings()[0]:
a.fnSettings?e=a.fnSettings():"string"===typeof a?d.fn.dataTable.fnIsDataTable(d(a)[0])&&(e=d(a).eq(0).dataTable().fnSettings()):a.nodeName&&"table"===a.nodeName.toLowerCase()?d.fn.dataTable.fnIsDataTable(a.nodeName)&&(e=d(a.nodeName).dataTable().fnSettings()):a instanceof jQuery?d.fn.dataTable.fnIsDataTable(a[0])&&(e=a.eq(0).dataTable().fnSettings()):e=a;if(e._colReorder)throw"ColReorder already initialised on table #"+e.nTable.id;var h=d.fn.dataTable.camelToHungarian;h&&(h(f.defaults,f.defaults,
!0),h(f.defaults,b||{}));this.s={dt:null,init:d.extend(!0,{},f.defaults,b),fixed:0,fixedRight:0,reorderCallback:null,mouse:{startX:-1,startY:-1,offsetX:-1,offsetY:-1,target:-1,targetIndex:-1,fromIndex:-1},aoTargets:[]};this.dom={drag:null,pointer:null};this.s.dt=e;this.s.dt._colReorder=this;this._fnConstruct();e.oApi._fnCallbackReg(e,"aoDestroyCallback",d.proxy(this._fnDestroy,this),"ColReorder");return this};f.prototype={fnReset:function(){for(var a=[],b=0,e=this.s.dt.aoColumns.length;b<e;b++)a.push(this.s.dt.aoColumns[b]._ColReorder_iOrigCol);
this._fnOrderColumns(a);return this},fnGetCurrentOrder:function(){return this.fnOrder()},fnOrder:function(a){if(a===s){for(var a=[],b=0,e=this.s.dt.aoColumns.length;b<e;b++)a.push(this.s.dt.aoColumns[b]._ColReorder_iOrigCol);return a}this._fnOrderColumns(p(a));return this},_fnConstruct:function(){var a=this,b=this.s.dt.aoColumns.length,e;this.s.init.iFixedColumns&&(this.s.fixed=this.s.init.iFixedColumns);this.s.fixedRight=this.s.init.iFixedColumnsRight?this.s.init.iFixedColumnsRight:0;this.s.init.fnReorderCallback&&
(this.s.reorderCallback=this.s.init.fnReorderCallback);for(e=0;e<b;e++)e>this.s.fixed-1&&e<b-this.s.fixedRight&&this._fnMouseListener(e,this.s.dt.aoColumns[e].nTh),this.s.dt.aoColumns[e]._ColReorder_iOrigCol=e;this.s.dt.oApi._fnCallbackReg(this.s.dt,"aoStateSaveParams",function(b,c){a._fnStateSave.call(a,c)},"ColReorder_State");var d=null;this.s.init.aiOrder&&(d=this.s.init.aiOrder.slice());this.s.dt.oLoadedState&&("undefined"!=typeof this.s.dt.oLoadedState.ColReorder&&this.s.dt.oLoadedState.ColReorder.length==
this.s.dt.aoColumns.length)&&(d=this.s.dt.oLoadedState.ColReorder);if(d)if(a.s.dt._bInitComplete)b=p(d),a._fnOrderColumns.call(a,b);else{var c=!1;this.s.dt.aoDrawCallback.push({fn:function(){if(!a.s.dt._bInitComplete&&!c){c=true;var b=p(d);a._fnOrderColumns.call(a,b)}},sName:"ColReorder_Pre"})}else this._fnSetColumnIndexes()},_fnOrderColumns:function(a){if(a.length!=this.s.dt.aoColumns.length)this.s.dt.oInstance.oApi._fnLog(this.s.dt,1,"ColReorder - array reorder does not match known number of columns. Skipping.");
else{for(var b=0,e=a.length;b<e;b++){var h=d.inArray(b,a);b!=h&&(l(a,h,b),this.s.dt.oInstance.fnColReorder(h,b))}(""!==this.s.dt.oScroll.sX||""!==this.s.dt.oScroll.sY)&&this.s.dt.oInstance.fnAdjustColumnSizing(!1);this.s.dt.oInstance.oApi._fnSaveState(this.s.dt);this._fnSetColumnIndexes();null!==this.s.reorderCallback&&this.s.reorderCallback.call(this)}},_fnStateSave:function(a){var b,e,h,c=this.s.dt.aoColumns;a.ColReorder=[];if(a.aaSorting){for(b=0;b<a.aaSorting.length;b++)a.aaSorting[b][0]=c[a.aaSorting[b][0]]._ColReorder_iOrigCol;
var f=d.extend(!0,[],a.aoSearchCols);b=0;for(e=c.length;b<e;b++)h=c[b]._ColReorder_iOrigCol,a.aoSearchCols[h]=f[b],a.abVisCols[h]=c[b].bVisible,a.ColReorder.push(h)}else if(a.order){for(b=0;b<a.order.length;b++)a.order[b][0]=c[a.order[b][0]]._ColReorder_iOrigCol;f=d.extend(!0,[],a.columns);b=0;for(e=c.length;b<e;b++)h=c[b]._ColReorder_iOrigCol,a.columns[h]=f[b],a.ColReorder.push(h)}},_fnMouseListener:function(a,b){var e=this;d(b).on("mousedown.ColReorder",function(a){a.preventDefault();e._fnMouseDown.call(e,
a,b)})},_fnMouseDown:function(a,b){var e=this,f=d(a.target).closest("th, td").offset(),c=parseInt(d(b).attr("data-column-index"),10);c!==s&&(this.s.mouse.startX=a.pageX,this.s.mouse.startY=a.pageY,this.s.mouse.offsetX=a.pageX-f.left,this.s.mouse.offsetY=a.pageY-f.top,this.s.mouse.target=this.s.dt.aoColumns[c].nTh,this.s.mouse.targetIndex=c,this.s.mouse.fromIndex=c,this._fnRegions(),d(r).on("mousemove.ColReorder",function(a){e._fnMouseMove.call(e,a)}).on("mouseup.ColReorder",function(a){e._fnMouseUp.call(e,
a)}))},_fnMouseMove:function(a){if(null===this.dom.drag){if(5>Math.pow(Math.pow(a.pageX-this.s.mouse.startX,2)+Math.pow(a.pageY-this.s.mouse.startY,2),0.5))return;this._fnCreateDragNode()}this.dom.drag.css({left:a.pageX-this.s.mouse.offsetX,top:a.pageY-this.s.mouse.offsetY});for(var b=!1,e=this.s.mouse.toIndex,d=1,c=this.s.aoTargets.length;d<c;d++)if(a.pageX<this.s.aoTargets[d-1].x+(this.s.aoTargets[d].x-this.s.aoTargets[d-1].x)/2){this.dom.pointer.css("left",this.s.aoTargets[d-1].x);this.s.mouse.toIndex=
this.s.aoTargets[d-1].to;b=!0;break}b||(this.dom.pointer.css("left",this.s.aoTargets[this.s.aoTargets.length-1].x),this.s.mouse.toIndex=this.s.aoTargets[this.s.aoTargets.length-1].to);this.s.init.bRealtime&&e!==this.s.mouse.toIndex&&(this.s.dt.oInstance.fnColReorder(this.s.mouse.fromIndex,this.s.mouse.toIndex),this.s.mouse.fromIndex=this.s.mouse.toIndex,this._fnRegions())},_fnMouseUp:function(){d(r).off("mousemove.ColReorder mouseup.ColReorder");null!==this.dom.drag&&(this.dom.drag.remove(),this.dom.pointer.remove(),
this.dom.drag=null,this.dom.pointer=null,this.s.dt.oInstance.fnColReorder(this.s.mouse.fromIndex,this.s.mouse.toIndex),this._fnSetColumnIndexes(),(""!==this.s.dt.oScroll.sX||""!==this.s.dt.oScroll.sY)&&this.s.dt.oInstance.fnAdjustColumnSizing(!1),this.s.dt.oInstance.oApi._fnSaveState(this.s.dt),null!==this.s.reorderCallback&&this.s.reorderCallback.call(this))},_fnRegions:function(){var a=this.s.dt.aoColumns;this.s.aoTargets.splice(0,this.s.aoTargets.length);this.s.aoTargets.push({x:d(this.s.dt.nTable).offset().left,
to:0});for(var b=0,e=0,f=a.length;e<f;e++)e!=this.s.mouse.fromIndex&&b++,a[e].bVisible&&this.s.aoTargets.push({x:d(a[e].nTh).offset().left+d(a[e].nTh).outerWidth(),to:b});0!==this.s.fixedRight&&this.s.aoTargets.splice(this.s.aoTargets.length-this.s.fixedRight);0!==this.s.fixed&&this.s.aoTargets.splice(0,this.s.fixed)},_fnCreateDragNode:function(){var a=""!==this.s.dt.oScroll.sX||""!==this.s.dt.oScroll.sY,b=this.s.dt.aoColumns[this.s.mouse.targetIndex].nTh,e=b.parentNode,f=e.parentNode,c=f.parentNode,
g=d(b).clone();this.dom.drag=d(c.cloneNode(!1)).addClass("DTCR_clonedTable").append(d(f.cloneNode(!1)).append(d(e.cloneNode(!1)).append(g[0]))).css({position:"absolute",top:0,left:0,width:d(b).outerWidth(),height:d(b).outerHeight()}).appendTo("body");this.dom.pointer=d("<div></div>").addClass("DTCR_pointer").css({position:"absolute",top:a?d("div.dataTables_scroll",this.s.dt.nTableWrapper).offset().top:d(this.s.dt.nTable).offset().top,height:a?d("div.dataTables_scroll",this.s.dt.nTableWrapper).height():
d(this.s.dt.nTable).height()}).appendTo("body")},_fnDestroy:function(){var a,b;a=0;for(b=this.s.dt.aoDrawCallback.length;a<b;a++)if("ColReorder_Pre"===this.s.dt.aoDrawCallback[a].sName){this.s.dt.aoDrawCallback.splice(a,1);break}d(this.s.dt.nTHead).find("*").off(".ColReorder");d.each(this.s.dt.aoColumns,function(a,b){d(b.nTh).removeAttr("data-column-index")});this.s=this.s.dt._colReorder=null},_fnSetColumnIndexes:function(){d.each(this.s.dt.aoColumns,function(a,b){d(b.nTh).attr("data-column-index",
a)})}};f.defaults={aiOrder:null,bRealtime:!1,iFixedColumns:0,iFixedColumnsRight:0,fnReorderCallback:null};f.version="1.1.3";d.fn.dataTable.ColReorder=f;d.fn.DataTable.ColReorder=f;"function"==typeof d.fn.dataTable&&"function"==typeof d.fn.dataTableExt.fnVersionCheck&&d.fn.dataTableExt.fnVersionCheck("1.9.3")?d.fn.dataTableExt.aoFeatures.push({fnInit:function(a){var b=a.oInstance;a._colReorder?b.oApi._fnLog(a,1,"ColReorder attempted to initialise twice. Ignoring second"):(b=a.oInit,new f(a,b.colReorder||
b.oColReorder||{}));return null},cFeature:"R",sFeature:"ColReorder"}):alert("Warning: ColReorder requires DataTables 1.9.3 or greater - www.datatables.net/download");d.fn.dataTable.Api&&(d.fn.dataTable.Api.register("colReorder.reset()",function(){return this.iterator("table",function(a){a._colReorder.fnReset()})}),d.fn.dataTable.Api.register("colReorder.order()",function(a){return a?this.iterator("table",function(b){b._colReorder.fnOrder(a)}):this.context.length?this.context[0]._colReorder.fnOrder():
null}));return f};"function"===typeof define&&define.amd?define(["jquery","datatables"],o):"object"===typeof exports?o(require("jquery"),require("datatables")):jQuery&&!jQuery.fn.dataTable.ColReorder&&o(jQuery,jQuery.fn.dataTable)})(window,document);

View file

@ -0,0 +1,752 @@
/*
* File: jquery.dataTables.columnFilter.js
* Version: 1.4.8.
* Author: Jovan Popovic
*
* Copyright 2011-2012 Jovan Popovic, all rights reserved.
*
* This source file is free software, under either the GPL v2 license or a
* BSD 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.
*
* Parameters:"
* @sPlaceHolder String Place where inline filtering function should be placed ("tfoot", "thead:before", "thead:after"). Default is "tfoot"
* @sRangeSeparator String Separator that will be used when range values are sent to the server-side. Default value is "~".
* @sRangeFormat string Default format of the From ... to ... range inputs. Default is From {from} to {to}
* @aoColumns Array Array of the filter settings that will be applied on the columns
*/
(function ($) {
$.fn.columnFilter = function (options) {
var asInitVals, i, label, th;
//var sTableId = "table";
var sRangeFormat = "From {from} to {to}";
//Array of the functions that will override sSearch_ parameters
var afnSearch_ = new Array();
var aiCustomSearch_Indexes = new Array();
var oFunctionTimeout = null;
var fnOnFiltered = function () { };
function _fnGetColumnValues(oSettings, iColumn, bUnique, bFiltered, bIgnoreEmpty) {
///<summary>
///Return values in the column
///</summary>
///<param name="oSettings" type="Object">DataTables settings</param>
///<param name="iColumn" type="int">Id of the column</param>
///<param name="bUnique" type="bool">Return only distinct values</param>
///<param name="bFiltered" type="bool">Return values only from the filtered rows</param>
///<param name="bIgnoreEmpty" type="bool">Ignore empty cells</param>
// check that we have a column id
if (typeof iColumn == "undefined") return new Array();
// by default we only wany unique data
if (typeof bUnique == "undefined") bUnique = true;
// by default we do want to only look at filtered data
if (typeof bFiltered == "undefined") bFiltered = true;
// by default we do not wany to include empty values
if (typeof bIgnoreEmpty == "undefined") bIgnoreEmpty = true;
// list of rows which we're going to loop through
var aiRows;
// use only filtered rows
if (bFiltered == true) aiRows = oSettings.aiDisplay;
// use all rows
else aiRows = oSettings.aiDisplayMaster; // all row numbers
// set up data array
var asResultData = new Array();
for (var i = 0, c = aiRows.length; i < c; i++) {
iRow = aiRows[i];
var aData = oTable.fnGetData(iRow);
var sValue = aData[iColumn];
// ignore empty values?
if (bIgnoreEmpty == true && sValue.length == 0) continue;
// ignore unique values?
else if (bUnique == true && jQuery.inArray(sValue, asResultData) > -1) continue;
// else push the value onto the result data array
else asResultData.push(sValue);
}
return asResultData.sort();
}
function _fnColumnIndex(iColumnIndex) {
if (properties.bUseColVis)
return iColumnIndex;
else
return oTable.fnSettings().oApi._fnVisibleToColumnIndex(oTable.fnSettings(), iColumnIndex);
//return iColumnIndex;
//return oTable.fnSettings().oApi._fnColumnIndexToVisible(oTable.fnSettings(), iColumnIndex);
}
function fnCreateInput(oTable, regex, smart, bIsNumber, iFilterLength, iMaxLenght) {
var sCSSClass = "text_filter";
if (bIsNumber)
sCSSClass = "number_filter";
label = label.replace(/(^\s*)|(\s*$)/g, "");
var currentFilter = oTable.fnSettings().aoPreSearchCols[i].sSearch;
var search_init = 'search_init ';
//var inputvalue = label;
var inputvalue = '';
if (currentFilter != '' && currentFilter != '^') {
if (bIsNumber && currentFilter.charAt(0) == '^')
inputvalue = currentFilter.substr(1); //ignore trailing ^
else
inputvalue = currentFilter;
search_init = '';
}
var input = $('<input type="text" class="' + search_init + sCSSClass + '" value="' + inputvalue + '"/>');
if (iMaxLenght != undefined && iMaxLenght != -1) {
input.attr('maxlength', iMaxLenght);
}
th.html(input);
if (bIsNumber)
th.wrapInner('<span class="filter_column filter_number" />');
else
th.wrapInner('<span class="filter_column filter_text" />');
asInitVals[i] = label;
var index = i;
if (bIsNumber && !oTable.fnSettings().oFeatures.bServerSide) {
input.keyup(function () {
/* Filter on the column all numbers that starts with the entered value */
oTable.fnFilter('^' + this.value, _fnColumnIndex(index), true, false); //Issue 37
fnOnFiltered();
});
} else {
input.keyup(function () {
var advSearchFields = $("div#advanced_search").children(':visible');
if(validateAdvancedSearch(advSearchFields)){
if (oTable.fnSettings().oFeatures.bServerSide && iFilterLength != 0) {
//If filter length is set in the server-side processing mode
//Check has the user entered at least iFilterLength new characters
var currentFilter = oTable.fnSettings().aoPreSearchCols[index].sSearch;
var iLastFilterLength = $(this).data("dt-iLastFilterLength");
if (typeof iLastFilterLength == "undefined")
iLastFilterLength = 0;
var iCurrentFilterLength = this.value.length;
if (Math.abs(iCurrentFilterLength - iLastFilterLength) < iFilterLength
//&& currentFilter.length == 0 //Why this?
) {
//Cancel the filtering
return;
}
else {
//Remember the current filter length
$(this).data("dt-iLastFilterLength", iCurrentFilterLength);
}
}
/* Filter on the column (the index) of this element */
oTable.fnFilter(this.value, _fnColumnIndex(index), regex, smart); //Issue 37
fnOnFiltered();
}
});
}
input.focus(function () {
if ($(this).hasClass("search_init")) {
$(this).removeClass("search_init");
this.value = "";
}
});
input.blur(function () {
if (this.value == "") {
$(this).addClass("search_init");
//this.value = asInitVals[index];
this.value = "";
}
});
}
function fnCreateRangeInput(oTable) {
//var currentFilter = oTable.fnSettings().aoPreSearchCols[i].sSearch;
var label = "";
if (th.attr('id') == "bit_rate") {
label = $.i18n._("kbps");
} else if (th.attr('id') == "utime" || th.attr('id') == "mtime" || th.attr('id') == "lptime") {
label = $.i18n._("yyyy-mm-dd");
} else if (th.attr('id') == "length" || th.attr('id') == "cuein" || th.attr('id') == "cueout") {
label = $.i18n._("hh:mm:ss.t");
} else if (th.attr('id') == "sample_rate") {
label = $.i18n._("kHz");
}
th.html(_fnRangeLabelPart(0));
var sFromId = oTable.attr("id") + '_range_from_' + i;
var from = $('<input type="text" class="number_range_filter" id="' + sFromId + '" rel="' + i + '" placeholder="' + label + '"/>');
th.append(from);
th.append(_fnRangeLabelPart(1));
var sToId = oTable.attr("id") + '_range_to_' + i;
var to = $('<input type="text" class="number_range_filter" id="' + sToId + '" rel="' + i + '" placeholder="' + label + '"/>');
th.append(to);
th.append(_fnRangeLabelPart(2));
th.wrapInner('<span class="filterColumn filter_number_range" />');
var index = i;
aiCustomSearch_Indexes.push(i);
//------------start range filtering function
/* Custom filtering function which will filter data in column four between two values
* Author: Allan Jardine, Modified by Jovan Popovic
*/
//$.fn.dataTableExt.afnFiltering.push(
oTable.dataTableExt.afnFiltering.push(
function (oSettings, aData, iDataIndex) {
if (oTable.attr("id") != oSettings.sTableId)
return true;
// Try to handle missing nodes more gracefully
if (document.getElementById(sFromId) == null)
return true;
var iMin = document.getElementById(sFromId).value * 1;
var iMax = document.getElementById(sToId).value * 1;
var iValue = aData[_fnColumnIndex(index)] == "-" ? 0 : aData[_fnColumnIndex(index)] * 1;
if (iMin == "" && iMax == "") {
return true;
}
else if (iMin == "" && iValue <= iMax) {
return true;
}
else if (iMin <= iValue && "" == iMax) {
return true;
}
else if (iMin <= iValue && iValue <= iMax) {
return true;
}
return false;
}
);
//------------end range filtering function
$('#' + sFromId + ',#' + sToId, th).keyup(function () {
var advSearchFields = $("div#advanced_search").children(':visible');
if(validateAdvancedSearch(advSearchFields)){
var iMin = document.getElementById(sFromId).value * 1;
var iMax = document.getElementById(sToId).value * 1;
if (iMin != 0 && iMax != 0 && iMin > iMax)
return;
oTable.fnDraw();
fnOnFiltered();
}
});
}
function fnCreateDateRangeInput(oTable) {
th.html(_fnRangeLabelPart(0));
var sFromId = oTable.attr("id") + '_range_from_' + i;
var from = $('<input type="text" class="date_range_filter" id="' + sFromId + '" rel="' + i + '"/>');
from.datepicker();
th.append(from);
th.append(_fnRangeLabelPart(1));
var sToId = oTable.attr("id") + '_range_to_' + i;
var to = $('<input type="text" class="date_range_filter" id="' + sToId + '" rel="' + i + '"/>');
th.append(to);
th.append(_fnRangeLabelPart(2));
th.wrapInner('<span class="filterColumn filter_date_range" />');
to.datepicker();
var index = i;
aiCustomSearch_Indexes.push(i);
//------------start date range filtering function
//$.fn.dataTableExt.afnFiltering.push(
oTable.dataTableExt.afnFiltering.push(
function (oSettings, aData, iDataIndex) {
if (oTable.attr("id") != oSettings.sTableId)
return true;
var dStartDate = from.datepicker("getDate");
var dEndDate = to.datepicker("getDate");
if (dStartDate == null && dEndDate == null) {
return true;
}
var dCellDate = null;
try {
if (aData[_fnColumnIndex(index)] == null || aData[_fnColumnIndex(index)] == "")
return false;
dCellDate = $.datepicker.parseDate($.datepicker.regional[""].dateFormat, aData[_fnColumnIndex(index)]);
} catch (ex) {
return false;
}
if (dCellDate == null)
return false;
if (dStartDate == null && dCellDate <= dEndDate) {
return true;
}
else if (dStartDate <= dCellDate && dEndDate == null) {
return true;
}
else if (dStartDate <= dCellDate && dCellDate <= dEndDate) {
return true;
}
return false;
}
);
//------------end date range filtering function
$('#' + sFromId + ',#' + sToId, th).change(function () {
oTable.fnDraw();
fnOnFiltered();
});
}
function fnCreateColumnSelect(oTable, aData, iColumn, nTh, sLabel, bRegex) {
if (aData == null)
aData = _fnGetColumnValues(oTable.fnSettings(), iColumn, true, false, true);
var index = iColumn;
var currentFilter = oTable.fnSettings().aoPreSearchCols[i].sSearch;
var r = '<select class="search_init select_filter"><option value="" class="search_init">' + sLabel + '</option>';
var j = 0;
var iLen = aData.length;
for (j = 0; j < iLen; j++) {
if (typeof (aData[j]) != 'object') {
var selected = '';
if (escape(aData[j]) == currentFilter || escape(aData[j]) == escape(currentFilter)) selected = 'selected '
r += '<option ' + selected + ' value="' + escape(aData[j]) + '">' + aData[j] + '</option>';
}
else {
var selected = '';
if (bRegex) {
//Do not escape values if they are explicitely set to avoid escaping special characters in the regexp
if (aData[j].value == currentFilter) selected = 'selected ';
r += '<option ' + selected + 'value="' + aData[j].value + '">' + aData[j].label + '</option>';
} else {
if (escape(aData[j].value) == currentFilter) selected = 'selected ';
r += '<option ' + selected + 'value="' + escape(aData[j].value) + '">' + aData[j].label + '</option>';
}
}
}
var select = $(r + '</select>');
nTh.html(select);
nTh.wrapInner('<span class="filterColumn filter_select" />');
select.change(function () {
//var val = $(this).val();
if ($(this).val() != "") {
$(this).removeClass("search_init");
} else {
$(this).addClass("search_init");
}
if (bRegex)
oTable.fnFilter($(this).val(), iColumn, bRegex); //Issue 41
else
oTable.fnFilter(unescape($(this).val()), iColumn); //Issue 25
fnOnFiltered();
});
}
function fnCreateSelect(oTable, aData, bRegex) {
var oSettings = oTable.fnSettings();
if (aData == null && oSettings.sAjaxSource != "" && !oSettings.oFeatures.bServerSide) {
// Add a function to the draw callback, which will check for the Ajax data having
// been loaded. Use a closure for the individual column elements that are used to
// built the column filter, since 'i' and 'th' (etc) are locally "global".
oSettings.aoDrawCallback.push({
"fn": (function (iColumn, nTh, sLabel) {
return function () {
// Only rebuild the select on the second draw - i.e. when the Ajax
// data has been loaded.
if (oSettings.iDraw == 2 && oSettings.sAjaxSource != null && oSettings.sAjaxSource != "" && !oSettings.oFeatures.bServerSide) {
return fnCreateColumnSelect(oTable, null, _fnColumnIndex(iColumn), nTh, sLabel, bRegex); //Issue 37
}
};
})(i, th, label),
"sName": "column_filter_" + i
});
}
// Regardless of the Ajax state, build the select on first pass
fnCreateColumnSelect(oTable, aData, _fnColumnIndex(i), th, label, bRegex); //Issue 37
}
function fnCreateCheckbox(oTable, aData) {
if (aData == null)
aData = _fnGetColumnValues(oTable.fnSettings(), i, true, true, true);
var index = i;
var r = '', j, iLen = aData.length;
//clean the string
var localLabel = label.replace('%', 'Perc').replace("&", "AND").replace("$", "DOL").replace("£", "STERL").replace("@", "AT").replace(/\s/g, "_");
localLabel = localLabel.replace(/[^a-zA-Z 0-9]+/g, '');
//clean the string
//button label override
if (properties.sFilterButtonText != null || properties.sFilterButtonText != undefined) {
labelBtn = properties.sFilterButtonText;
} else {
labelBtn = label;
}
var relativeDivWidthToggleSize = 10;
var numRow = 12; //numero di checkbox per colonna
var numCol = Math.floor(iLen / numRow);
if (iLen % numRow > 0) {
numCol = numCol + 1;
};
//count how many column should be generated and split the div size
var divWidth = 100 / numCol - 2;
var divWidthToggle = relativeDivWidthToggleSize * numCol;
if (numCol == 1) {
divWidth = 20;
}
var divRowDef = '<div style="float:left; min-width: ' + divWidth + '%; " >';
var divClose = '</div>';
var uniqueId = oTable.attr("id") + localLabel;
var buttonId = "chkBtnOpen" + uniqueId;
var checkToggleDiv = uniqueId + "-flt-toggle";
r += '<button id="' + buttonId + '" class="checkbox_filter" > ' + labelBtn + '</button>'; //filter button witch open dialog
r += '<div id="' + checkToggleDiv + '" '
+ 'title="' + label + '" '
+ 'class="toggle-check ui-widget-content ui-corner-all" style="width: ' + (divWidthToggle) + '%; " >'; //dialog div
//r+= '<div align="center" style="margin-top: 5px; "> <button id="'+buttonId+'Reset" class="checkbox_filter" > reset </button> </div>'; //reset button and its div
r += divRowDef;
for (j = 0; j < iLen; j++) {
//if last check close div
if (j % numRow == 0 && j != 0) {
r += divClose + divRowDef;
}
//check button
r += '<input class="search_init checkbox_filter" type="checkbox" id= "' + aData[j] + '" name= "' + localLabel + '" value="' + aData[j] + '" >' + aData[j] + '<br/>';
var checkbox = $(r);
th.html(checkbox);
th.wrapInner('<span class="filterColumn filter_checkbox" />');
//on every checkbox selection
checkbox.change(function () {
var search = '';
var or = '|'; //var for select checks in 'or' into the regex
var resSize = $('input:checkbox[name="' + localLabel + '"]:checked').size();
$('input:checkbox[name="' + localLabel + '"]:checked').each(function (index) {
//search = search + ' ' + $(this).val();
//concatenation for selected checks in or
if ((index == 0 && resSize == 1)
|| (index != 0 && index == resSize - 1)) {
or = '';
}
//trim
search = search.replace(/^\s+|\s+$/g, "");
search = search + $(this).val() + or;
or = '|';
});
for (var jj = 0; jj < iLen; jj++) {
if (search != "") {
$('#' + aData[jj]).removeClass("search_init");
} else {
$('#' + aData[jj]).addClass("search_init");
}
}
//execute search
oTable.fnFilter(search, index, true, false);
fnOnFiltered();
});
}
//filter button
$('#' + buttonId).button();
//dialog
$('#' + checkToggleDiv).dialog({
//height: 140,
autoOpen: false,
//show: "blind",
hide: "blind",
buttons: [{
text: "Reset",
click: function () {
//$('#'+buttonId).removeClass("filter_selected"); //LM remove border if filter selected
$('input:checkbox[name="' + localLabel + '"]:checked').each(function (index3) {
$(this).attr('checked', false);
$(this).addClass("search_init");
});
oTable.fnFilter('', index, true, false);
fnOnFiltered();
return false;
}
},
{
text: "Close",
click: function () { $(this).dialog("close"); }
}
]
});
$('#' + buttonId).click(function () {
$('#' + checkToggleDiv).dialog('open');
var target = $(this);
$('#' + checkToggleDiv).dialog("widget").position({ my: 'top',
at: 'bottom',
of: target
});
return false;
});
var fnOnFilteredCurrent = fnOnFiltered;
fnOnFiltered = function () {
var target = $('#' + buttonId);
$('#' + checkToggleDiv).dialog("widget").position({ my: 'top',
at: 'bottom',
of: target
});
fnOnFilteredCurrent();
};
//reset
/*
$('#'+buttonId+"Reset").button();
$('#'+buttonId+"Reset").click(function(){
$('#'+buttonId).removeClass("filter_selected"); //LM remove border if filter selected
$('input:checkbox[name="'+localLabel+'"]:checked').each(function(index3) {
$(this).attr('checked', false);
$(this).addClass("search_init");
});
oTable.fnFilter('', index, true, false);
return false;
});
*/
}
function _fnRangeLabelPart(iPlace) {
switch (iPlace) {
case 0:
return sRangeFormat.substring(0, sRangeFormat.indexOf("{from}"));
case 1:
return sRangeFormat.substring(sRangeFormat.indexOf("{from}") + 6, sRangeFormat.indexOf("{to}"));
default:
return sRangeFormat.substring(sRangeFormat.indexOf("{to}") + 4);
}
}
oTable = this;
var defaults = {
sPlaceHolder: "foot",
sRangeSeparator: "~",
iFilteringDelay: 500,
aoColumns: null,
sRangeFormat: $.i18n._("From {from} to {to}")
};
properties = $.extend(defaults, options);
return this.each(function () {
if (!oTable.fnSettings().oFeatures.bFilter)
return;
asInitVals = new Array();
aoFilterCells = oTable.fnSettings().aoFooter[0];
var oHost = oTable.fnSettings().nTFoot; //Before fix for ColVis
var sFilterRow = "tr"; //Before fix for ColVis
if (properties.sPlaceHolder == "head:after") {
var tr = $("tr:first", oTable.fnSettings().nTHead).detach();
//tr.appendTo($(oTable.fnSettings().nTHead));
if (oTable.fnSettings().bSortCellsTop) {
tr.prependTo($(oTable.fnSettings().nTHead));
//tr.appendTo($("thead", oTable));
aoFilterCells = oTable.fnSettings().aoHeader[1];
}
else {
tr.appendTo($(oTable.fnSettings().nTHead));
//tr.prependTo($("thead", oTable));
aoFilterCells = oTable.fnSettings().aoHeader[0];
}
sFilterRow = "tr:last";
oHost = oTable.fnSettings().nTHead;
} else if (properties.sPlaceHolder == "head:before") {
if (oTable.fnSettings().bSortCellsTop) {
var tr = $("tr:first", oTable.fnSettings().nTHead).detach();
tr.appendTo($(oTable.fnSettings().nTHead));
aoFilterCells = oTable.fnSettings().aoHeader[1];
} else {
aoFilterCells = oTable.fnSettings().aoHeader[0];
}
/*else {
//tr.prependTo($("thead", oTable));
sFilterRow = "tr:first";
}*/
sFilterRow = "tr:first";
oHost = oTable.fnSettings().nTHead;
}
//$(sFilterRow + " th", oHost).each(function (index) {//bug with ColVis
$(aoFilterCells).each(function (index) {//fix for ColVis
i = index;
var aoColumn = { type: "text",
bRegex: false,
bSmart: true,
iMaxLenght: -1,
iFilterLength: 0
};
if (properties.aoColumns != null) {
if (properties.aoColumns.length < i || properties.aoColumns[i] == null)
return;
aoColumn = properties.aoColumns[i];
}
//label = $(this).text(); //Before fix for ColVis
label = $($(this)[0].cell).text(); //Fix for ColVis
if (aoColumn.sSelector == null) {
//th = $($(this)[0]);//Before fix for ColVis
th = $($(this)[0].cell); //Fix for ColVis
}
else {
th = $(aoColumn.sSelector);
if (th.length == 0)
th = $($(this)[0].cell);
}
if (aoColumn != null) {
if (aoColumn.sRangeFormat != null)
sRangeFormat = aoColumn.sRangeFormat;
else
sRangeFormat = properties.sRangeFormat;
switch (aoColumn.type) {
case "null":
break;
case "number":
fnCreateInput(oTable, true, false, true, aoColumn.iFilterLength, aoColumn.iMaxLenght);
break;
case "select":
if (aoColumn.bRegex != true)
aoColumn.bRegex = false;
fnCreateSelect(oTable, aoColumn.values, aoColumn.bRegex);
break;
case "number-range":
fnCreateRangeInput(oTable);
break;
case "date-range":
fnCreateDateRangeInput(oTable);
break;
case "checkbox":
fnCreateCheckbox(oTable, aoColumn.values);
break;
case "text":
default:
bRegex = (aoColumn.bRegex == null ? false : aoColumn.bRegex);
bSmart = (aoColumn.bSmart == null ? false : aoColumn.bSmart);
fnCreateInput(oTable, bRegex, bSmart, false, aoColumn.iFilterLength, aoColumn.iMaxLenght);
break;
}
}
});
for (j = 0; j < aiCustomSearch_Indexes.length; j++) {
//var index = aiCustomSearch_Indexes[j];
var fnSearch_ = function () {
var id = oTable.attr("id");
return $("#" + id + "_range_from_" + aiCustomSearch_Indexes[j]).val() + properties.sRangeSeparator + $("#" + id + "_range_to_" + aiCustomSearch_Indexes[j]).val()
}
afnSearch_.push(fnSearch_);
}
if (oTable.fnSettings().oFeatures.bServerSide) {
var fnServerDataOriginal = oTable.fnSettings().fnServerData;
oTable.fnSettings().fnServerData = function (sSource, aoData, fnCallback) {
for (j = 0; j < aiCustomSearch_Indexes.length; j++) {
var index = aiCustomSearch_Indexes[j];
for (k = 0; k < aoData.length; k++) {
if (aoData[k].name == "sSearch_" + index)
aoData[k].value = afnSearch_[j]();
}
}
aoData.push({ "name": "sRangeSeparator", "value": properties.sRangeSeparator });
if (fnServerDataOriginal != null) {
try {
fnServerDataOriginal(sSource, aoData, fnCallback, oTable.fnSettings()); //TODO: See Issue 18
} catch (ex) {
fnServerDataOriginal(sSource, aoData, fnCallback);
}
}
else {
$.getJSON(sSource, aoData, function (json) {
fnCallback(json)
});
}
};
}
});
};
})(jQuery);

View file

@ -0,0 +1,733 @@
/*
* File: jquery.dataTables.columnFilter.js
* Version: 1.4.8.
* Author: Jovan Popovic
*
* Copyright 2011-2012 Jovan Popovic, all rights reserved.
*
* This source file is free software, under either the GPL v2 license or a
* BSD 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.
*
* Parameters:"
* @sPlaceHolder String Place where inline filtering function should be placed ("tfoot", "thead:before", "thead:after"). Default is "tfoot"
* @sRangeSeparator String Separator that will be used when range values are sent to the server-side. Default value is "~".
* @sRangeFormat string Default format of the From ... to ... range inputs. Default is From {from} to {to}
* @aoColumns Array Array of the filter settings that will be applied on the columns
*/
(function ($) {
$.fn.columnFilter = function (options) {
var asInitVals, i, label, th;
//var sTableId = "table";
var sRangeFormat = "From {from} to {to}";
//Array of the functions that will override sSearch_ parameters
var afnSearch_ = new Array();
var aiCustomSearch_Indexes = new Array();
var oFunctionTimeout = null;
var fnOnFiltered = function () { };
function _fnGetColumnValues(oSettings, iColumn, bUnique, bFiltered, bIgnoreEmpty) {
///<summary>
///Return values in the column
///</summary>
///<param name="oSettings" type="Object">DataTables settings</param>
///<param name="iColumn" type="int">Id of the column</param>
///<param name="bUnique" type="bool">Return only distinct values</param>
///<param name="bFiltered" type="bool">Return values only from the filtered rows</param>
///<param name="bIgnoreEmpty" type="bool">Ignore empty cells</param>
// check that we have a column id
if (typeof iColumn == "undefined") return new Array();
// by default we only wany unique data
if (typeof bUnique == "undefined") bUnique = true;
// by default we do want to only look at filtered data
if (typeof bFiltered == "undefined") bFiltered = true;
// by default we do not wany to include empty values
if (typeof bIgnoreEmpty == "undefined") bIgnoreEmpty = true;
// list of rows which we're going to loop through
var aiRows;
// use only filtered rows
if (bFiltered == true) aiRows = oSettings.aiDisplay;
// use all rows
else aiRows = oSettings.aiDisplayMaster; // all row numbers
// set up data array
var asResultData = new Array();
for (var i = 0, c = aiRows.length; i < c; i++) {
iRow = aiRows[i];
var aData = oTable.fnGetData(iRow);
var sValue = aData[iColumn];
// ignore empty values?
if (bIgnoreEmpty == true && sValue.length == 0) continue;
// ignore unique values?
else if (bUnique == true && jQuery.inArray(sValue, asResultData) > -1) continue;
// else push the value onto the result data array
else asResultData.push(sValue);
}
return asResultData.sort();
}
function _fnColumnIndex(iColumnIndex) {
if (properties.bUseColVis)
return iColumnIndex;
else
return oTable.fnSettings().oApi._fnVisibleToColumnIndex(oTable.fnSettings(), iColumnIndex);
//return iColumnIndex;
//return oTable.fnSettings().oApi._fnColumnIndexToVisible(oTable.fnSettings(), iColumnIndex);
}
function fnCreateInput(oTable, regex, smart, bIsNumber, iFilterLength, iMaxLenght) {
var sCSSClass = "text_filter";
if (bIsNumber)
sCSSClass = "number_filter";
label = label.replace(/(^\s*)|(\s*$)/g, "");
var currentFilter = oTable.fnSettings().aoPreSearchCols[i].sSearch;
var search_init = 'search_init ';
var inputvalue = label;
if (currentFilter != '' && currentFilter != '^') {
if (bIsNumber && currentFilter.charAt(0) == '^')
inputvalue = currentFilter.substr(1); //ignore trailing ^
else
inputvalue = currentFilter;
search_init = '';
}
var input = $('<input type="text" class="' + search_init + sCSSClass + '" value="' + inputvalue + '"/>');
if (iMaxLenght != undefined && iMaxLenght != -1) {
input.attr('maxlength', iMaxLenght);
}
th.html(input);
if (bIsNumber)
th.wrapInner('<span class="filter_column filter_number" />');
else
th.wrapInner('<span class="filter_column filter_text" />');
asInitVals[i] = label;
var index = i;
if (bIsNumber && !oTable.fnSettings().oFeatures.bServerSide) {
input.keyup(function () {
/* Filter on the column all numbers that starts with the entered value */
oTable.fnFilter('^' + this.value, _fnColumnIndex(index), true, false); //Issue 37
fnOnFiltered();
});
} else {
input.keyup(function () {
if (oTable.fnSettings().oFeatures.bServerSide && iFilterLength != 0) {
//If filter length is set in the server-side processing mode
//Check has the user entered at least iFilterLength new characters
var currentFilter = oTable.fnSettings().aoPreSearchCols[index].sSearch;
var iLastFilterLength = $(this).data("dt-iLastFilterLength");
if (typeof iLastFilterLength == "undefined")
iLastFilterLength = 0;
var iCurrentFilterLength = this.value.length;
if (Math.abs(iCurrentFilterLength - iLastFilterLength) < iFilterLength
//&& currentFilter.length == 0 //Why this?
) {
//Cancel the filtering
return;
}
else {
//Remember the current filter length
$(this).data("dt-iLastFilterLength", iCurrentFilterLength);
}
}
/* Filter on the column (the index) of this element */
oTable.fnFilter(this.value, _fnColumnIndex(index), regex, smart); //Issue 37
fnOnFiltered();
});
}
input.focus(function () {
if ($(this).hasClass("search_init")) {
$(this).removeClass("search_init");
this.value = "";
}
});
input.blur(function () {
if (this.value == "") {
$(this).addClass("search_init");
this.value = asInitVals[index];
}
});
}
function fnCreateRangeInput(oTable) {
//var currentFilter = oTable.fnSettings().aoPreSearchCols[i].sSearch;
th.html(_fnRangeLabelPart(0));
var sFromId = oTable.attr("id") + '_range_from_' + i;
var from = $('<input type="text" class="number_range_filter" id="' + sFromId + '" rel="' + i + '"/>');
th.append(from);
th.append(_fnRangeLabelPart(1));
var sToId = oTable.attr("id") + '_range_to_' + i;
var to = $('<input type="text" class="number_range_filter" id="' + sToId + '" rel="' + i + '"/>');
th.append(to);
th.append(_fnRangeLabelPart(2));
th.wrapInner('<span class="filterColumn filter_number_range" />');
var index = i;
aiCustomSearch_Indexes.push(i);
//------------start range filtering function
/* Custom filtering function which will filter data in column four between two values
* Author: Allan Jardine, Modified by Jovan Popovic
*/
//$.fn.dataTableExt.afnFiltering.push(
oTable.dataTableExt.afnFiltering.push(
function (oSettings, aData, iDataIndex) {
if (oTable.attr("id") != oSettings.sTableId)
return true;
// Try to handle missing nodes more gracefully
if (document.getElementById(sFromId) == null)
return true;
var iMin = document.getElementById(sFromId).value * 1;
var iMax = document.getElementById(sToId).value * 1;
var iValue = aData[_fnColumnIndex(index)] == "-" ? 0 : aData[_fnColumnIndex(index)] * 1;
if (iMin == "" && iMax == "") {
return true;
}
else if (iMin == "" && iValue <= iMax) {
return true;
}
else if (iMin <= iValue && "" == iMax) {
return true;
}
else if (iMin <= iValue && iValue <= iMax) {
return true;
}
return false;
}
);
//------------end range filtering function
$('#' + sFromId + ',#' + sToId, th).keyup(function () {
var iMin = document.getElementById(sFromId).value * 1;
var iMax = document.getElementById(sToId).value * 1;
if (iMin != 0 && iMax != 0 && iMin > iMax)
return;
oTable.fnDraw();
fnOnFiltered();
});
}
function fnCreateDateRangeInput(oTable) {
th.html(_fnRangeLabelPart(0));
var sFromId = oTable.attr("id") + '_range_from_' + i;
var from = $('<input type="text" class="date_range_filter" id="' + sFromId + '" rel="' + i + '"/>');
from.datepicker();
th.append(from);
th.append(_fnRangeLabelPart(1));
var sToId = oTable.attr("id") + '_range_to_' + i;
var to = $('<input type="text" class="date_range_filter" id="' + sToId + '" rel="' + i + '"/>');
th.append(to);
th.append(_fnRangeLabelPart(2));
th.wrapInner('<span class="filterColumn filter_date_range" />');
to.datepicker();
var index = i;
aiCustomSearch_Indexes.push(i);
//------------start date range filtering function
//$.fn.dataTableExt.afnFiltering.push(
oTable.dataTableExt.afnFiltering.push(
function (oSettings, aData, iDataIndex) {
if (oTable.attr("id") != oSettings.sTableId)
return true;
var dStartDate = from.datepicker("getDate");
var dEndDate = to.datepicker("getDate");
if (dStartDate == null && dEndDate == null) {
return true;
}
var dCellDate = null;
try {
if (aData[_fnColumnIndex(index)] == null || aData[_fnColumnIndex(index)] == "")
return false;
dCellDate = $.datepicker.parseDate($.datepicker.regional[""].dateFormat, aData[_fnColumnIndex(index)]);
} catch (ex) {
return false;
}
if (dCellDate == null)
return false;
if (dStartDate == null && dCellDate <= dEndDate) {
return true;
}
else if (dStartDate <= dCellDate && dEndDate == null) {
return true;
}
else if (dStartDate <= dCellDate && dCellDate <= dEndDate) {
return true;
}
return false;
}
);
//------------end date range filtering function
$('#' + sFromId + ',#' + sToId, th).change(function () {
oTable.fnDraw();
fnOnFiltered();
});
}
function fnCreateColumnSelect(oTable, aData, iColumn, nTh, sLabel, bRegex) {
if (aData == null)
aData = _fnGetColumnValues(oTable.fnSettings(), iColumn, true, false, true);
var index = iColumn;
var currentFilter = oTable.fnSettings().aoPreSearchCols[i].sSearch;
var r = '<select class="search_init select_filter"><option value="" class="search_init">' + sLabel + '</option>';
var j = 0;
var iLen = aData.length;
for (j = 0; j < iLen; j++) {
if (typeof (aData[j]) != 'object') {
var selected = '';
if (escape(aData[j]) == currentFilter || escape(aData[j]) == escape(currentFilter)) selected = 'selected '
r += '<option ' + selected + ' value="' + escape(aData[j]) + '">' + aData[j] + '</option>';
}
else {
var selected = '';
if (bRegex) {
//Do not escape values if they are explicitely set to avoid escaping special characters in the regexp
if (aData[j].value == currentFilter) selected = 'selected ';
r += '<option ' + selected + 'value="' + aData[j].value + '">' + aData[j].label + '</option>';
} else {
if (escape(aData[j].value) == currentFilter) selected = 'selected ';
r += '<option ' + selected + 'value="' + escape(aData[j].value) + '">' + aData[j].label + '</option>';
}
}
}
var select = $(r + '</select>');
nTh.html(select);
nTh.wrapInner('<span class="filterColumn filter_select" />');
select.change(function () {
//var val = $(this).val();
if ($(this).val() != "") {
$(this).removeClass("search_init");
} else {
$(this).addClass("search_init");
}
if (bRegex)
oTable.fnFilter($(this).val(), iColumn, bRegex); //Issue 41
else
oTable.fnFilter(unescape($(this).val()), iColumn); //Issue 25
fnOnFiltered();
});
}
function fnCreateSelect(oTable, aData, bRegex) {
var oSettings = oTable.fnSettings();
if (aData == null && oSettings.sAjaxSource != "" && !oSettings.oFeatures.bServerSide) {
// Add a function to the draw callback, which will check for the Ajax data having
// been loaded. Use a closure for the individual column elements that are used to
// built the column filter, since 'i' and 'th' (etc) are locally "global".
oSettings.aoDrawCallback.push({
"fn": (function (iColumn, nTh, sLabel) {
return function () {
// Only rebuild the select on the second draw - i.e. when the Ajax
// data has been loaded.
if (oSettings.iDraw == 2 && oSettings.sAjaxSource != null && oSettings.sAjaxSource != "" && !oSettings.oFeatures.bServerSide) {
return fnCreateColumnSelect(oTable, null, _fnColumnIndex(iColumn), nTh, sLabel, bRegex); //Issue 37
}
};
})(i, th, label),
"sName": "column_filter_" + i
});
}
// Regardless of the Ajax state, build the select on first pass
fnCreateColumnSelect(oTable, aData, _fnColumnIndex(i), th, label, bRegex); //Issue 37
}
function fnCreateCheckbox(oTable, aData) {
if (aData == null)
aData = _fnGetColumnValues(oTable.fnSettings(), i, true, true, true);
var index = i;
var r = '', j, iLen = aData.length;
//clean the string
var localLabel = label.replace('%', 'Perc').replace("&", "AND").replace("$", "DOL").replace("£", "STERL").replace("@", "AT").replace(/\s/g, "_");
localLabel = localLabel.replace(/[^a-zA-Z 0-9]+/g, '');
//clean the string
//button label override
if (properties.sFilterButtonText != null || properties.sFilterButtonText != undefined) {
labelBtn = properties.sFilterButtonText;
} else {
labelBtn = label;
}
var relativeDivWidthToggleSize = 10;
var numRow = 12; //numero di checkbox per colonna
var numCol = Math.floor(iLen / numRow);
if (iLen % numRow > 0) {
numCol = numCol + 1;
};
//count how many column should be generated and split the div size
var divWidth = 100 / numCol - 2;
var divWidthToggle = relativeDivWidthToggleSize * numCol;
if (numCol == 1) {
divWidth = 20;
}
var divRowDef = '<div style="float:left; min-width: ' + divWidth + '%; " >';
var divClose = '</div>';
var uniqueId = oTable.attr("id") + localLabel;
var buttonId = "chkBtnOpen" + uniqueId;
var checkToggleDiv = uniqueId + "-flt-toggle";
r += '<button id="' + buttonId + '" class="checkbox_filter" > ' + labelBtn + '</button>'; //filter button witch open dialog
r += '<div id="' + checkToggleDiv + '" '
+ 'title="' + label + '" '
+ 'class="toggle-check ui-widget-content ui-corner-all" style="width: ' + (divWidthToggle) + '%; " >'; //dialog div
//r+= '<div align="center" style="margin-top: 5px; "> <button id="'+buttonId+'Reset" class="checkbox_filter" > reset </button> </div>'; //reset button and its div
r += divRowDef;
for (j = 0; j < iLen; j++) {
//if last check close div
if (j % numRow == 0 && j != 0) {
r += divClose + divRowDef;
}
//check button
r += '<input class="search_init checkbox_filter" type="checkbox" id= "' + aData[j] + '" name= "' + localLabel + '" value="' + aData[j] + '" >' + aData[j] + '<br/>';
var checkbox = $(r);
th.html(checkbox);
th.wrapInner('<span class="filterColumn filter_checkbox" />');
//on every checkbox selection
checkbox.change(function () {
var search = '';
var or = '|'; //var for select checks in 'or' into the regex
var resSize = $('input:checkbox[name="' + localLabel + '"]:checked').size();
$('input:checkbox[name="' + localLabel + '"]:checked').each(function (index) {
//search = search + ' ' + $(this).val();
//concatenation for selected checks in or
if ((index == 0 && resSize == 1)
|| (index != 0 && index == resSize - 1)) {
or = '';
}
//trim
search = search.replace(/^\s+|\s+$/g, "");
search = search + $(this).val() + or;
or = '|';
});
for (var jj = 0; jj < iLen; jj++) {
if (search != "") {
$('#' + aData[jj]).removeClass("search_init");
} else {
$('#' + aData[jj]).addClass("search_init");
}
}
//execute search
oTable.fnFilter(search, index, true, false);
fnOnFiltered();
});
}
//filter button
$('#' + buttonId).button();
//dialog
$('#' + checkToggleDiv).dialog({
//height: 140,
autoOpen: false,
//show: "blind",
hide: "blind",
buttons: [{
text: "Reset",
click: function () {
//$('#'+buttonId).removeClass("filter_selected"); //LM remove border if filter selected
$('input:checkbox[name="' + localLabel + '"]:checked').each(function (index3) {
$(this).attr('checked', false);
$(this).addClass("search_init");
});
oTable.fnFilter('', index, true, false);
fnOnFiltered();
return false;
}
},
{
text: "Close",
click: function () { $(this).dialog("close"); }
}
]
});
$('#' + buttonId).click(function () {
$('#' + checkToggleDiv).dialog('open');
var target = $(this);
$('#' + checkToggleDiv).dialog("widget").position({ my: 'top',
at: 'bottom',
of: target
});
return false;
});
var fnOnFilteredCurrent = fnOnFiltered;
fnOnFiltered = function () {
var target = $('#' + buttonId);
$('#' + checkToggleDiv).dialog("widget").position({ my: 'top',
at: 'bottom',
of: target
});
fnOnFilteredCurrent();
};
//reset
/*
$('#'+buttonId+"Reset").button();
$('#'+buttonId+"Reset").click(function(){
$('#'+buttonId).removeClass("filter_selected"); //LM remove border if filter selected
$('input:checkbox[name="'+localLabel+'"]:checked').each(function(index3) {
$(this).attr('checked', false);
$(this).addClass("search_init");
});
oTable.fnFilter('', index, true, false);
return false;
});
*/
}
function _fnRangeLabelPart(iPlace) {
switch (iPlace) {
case 0:
return sRangeFormat.substring(0, sRangeFormat.indexOf("{from}"));
case 1:
return sRangeFormat.substring(sRangeFormat.indexOf("{from}") + 6, sRangeFormat.indexOf("{to}"));
default:
return sRangeFormat.substring(sRangeFormat.indexOf("{to}") + 4);
}
}
oTable = this;
var defaults = {
sPlaceHolder: "foot",
sRangeSeparator: "~",
iFilteringDelay: 500,
aoColumns: null,
sRangeFormat: "From {from} to {to}"
};
properties = $.extend(defaults, options);
return this.each(function () {
if (!oTable.fnSettings().oFeatures.bFilter)
return;
asInitVals = new Array();
aoFilterCells = oTable.fnSettings().aoFooter[0];
var oHost = oTable.fnSettings().nTFoot; //Before fix for ColVis
var sFilterRow = "tr"; //Before fix for ColVis
if (properties.sPlaceHolder == "head:after") {
var tr = $("tr:first", oTable.fnSettings().nTHead).detach();
//tr.appendTo($(oTable.fnSettings().nTHead));
if (oTable.fnSettings().bSortCellsTop) {
tr.prependTo($(oTable.fnSettings().nTHead));
//tr.appendTo($("thead", oTable));
aoFilterCells = oTable.fnSettings().aoHeader[1];
}
else {
tr.appendTo($(oTable.fnSettings().nTHead));
//tr.prependTo($("thead", oTable));
aoFilterCells = oTable.fnSettings().aoHeader[0];
}
sFilterRow = "tr:last";
oHost = oTable.fnSettings().nTHead;
} else if (properties.sPlaceHolder == "head:before") {
if (oTable.fnSettings().bSortCellsTop) {
var tr = $("tr:first", oTable.fnSettings().nTHead).detach();
tr.appendTo($(oTable.fnSettings().nTHead));
aoFilterCells = oTable.fnSettings().aoHeader[1];
} else {
aoFilterCells = oTable.fnSettings().aoHeader[0];
}
/*else {
//tr.prependTo($("thead", oTable));
sFilterRow = "tr:first";
}*/
sFilterRow = "tr:first";
oHost = oTable.fnSettings().nTHead;
}
//$(sFilterRow + " th", oHost).each(function (index) {//bug with ColVis
$(aoFilterCells).each(function (index) {//fix for ColVis
i = index;
var aoColumn = { type: "text",
bRegex: false,
bSmart: true,
iMaxLenght: -1,
iFilterLength: 0
};
if (properties.aoColumns != null) {
if (properties.aoColumns.length < i || properties.aoColumns[i] == null)
return;
aoColumn = properties.aoColumns[i];
}
//label = $(this).text(); //Before fix for ColVis
label = $($(this)[0].cell).text(); //Fix for ColVis
if (aoColumn.sSelector == null) {
//th = $($(this)[0]);//Before fix for ColVis
th = $($(this)[0].cell); //Fix for ColVis
}
else {
th = $(aoColumn.sSelector);
if (th.length == 0)
th = $($(this)[0].cell);
}
if (aoColumn != null) {
if (aoColumn.sRangeFormat != null)
sRangeFormat = aoColumn.sRangeFormat;
else
sRangeFormat = properties.sRangeFormat;
switch (aoColumn.type) {
case "null":
break;
case "number":
fnCreateInput(oTable, true, false, true, aoColumn.iFilterLength, aoColumn.iMaxLenght);
break;
case "select":
if (aoColumn.bRegex != true)
aoColumn.bRegex = false;
fnCreateSelect(oTable, aoColumn.values, aoColumn.bRegex);
break;
case "number-range":
fnCreateRangeInput(oTable);
break;
case "date-range":
fnCreateDateRangeInput(oTable);
break;
case "checkbox":
fnCreateCheckbox(oTable, aoColumn.values);
break;
case "text":
default:
bRegex = (aoColumn.bRegex == null ? false : aoColumn.bRegex);
bSmart = (aoColumn.bSmart == null ? false : aoColumn.bSmart);
fnCreateInput(oTable, bRegex, bSmart, false, aoColumn.iFilterLength, aoColumn.iMaxLenght);
break;
}
}
});
for (j = 0; j < aiCustomSearch_Indexes.length; j++) {
//var index = aiCustomSearch_Indexes[j];
var fnSearch_ = function () {
var id = oTable.attr("id");
return $("#" + id + "_range_from_" + aiCustomSearch_Indexes[j]).val() + properties.sRangeSeparator + $("#" + id + "_range_to_" + aiCustomSearch_Indexes[j]).val()
}
afnSearch_.push(fnSearch_);
}
if (oTable.fnSettings().oFeatures.bServerSide) {
var fnServerDataOriginal = oTable.fnSettings().fnServerData;
oTable.fnSettings().fnServerData = function (sSource, aoData, fnCallback) {
for (j = 0; j < aiCustomSearch_Indexes.length; j++) {
var index = aiCustomSearch_Indexes[j];
for (k = 0; k < aoData.length; k++) {
if (aoData[k].name == "sSearch_" + index)
aoData[k].value = afnSearch_[j]();
}
}
aoData.push({ "name": "sRangeSeparator", "value": properties.sRangeSeparator });
if (fnServerDataOriginal != null) {
try {
fnServerDataOriginal(sSource, aoData, fnCallback, oTable.fnSettings()); //TODO: See Issue 18
} catch (ex) {
fnServerDataOriginal(sSource, aoData, fnCallback);
}
}
else {
$.getJSON(sSource, aoData, function (json) {
fnCallback(json)
});
}
};
}
});
};
})(jQuery);

View file

@ -0,0 +1,38 @@
jQuery.fn.dataTableExt.oApi.fnSetFilteringDelay = function ( oSettings, iDelay ) {
/*
* Inputs: object:oSettings - dataTables settings object - automatically given
* integer:iDelay - delay in milliseconds
* Usage: $('#example').dataTable().fnSetFilteringDelay(250);
* Author: Zygimantas Berziunas (www.zygimantas.com) and Allan Jardine
* License: GPL v2 or BSD 3 point style
* Contact: zygimantas.berziunas /AT\ hotmail.com
*/
var
_that = this,
iDelay = (typeof iDelay == 'undefined') ? 250 : iDelay;
this.each( function ( i ) {
$.fn.dataTableExt.iApiIndex = i;
var
$this = this,
oTimerId = null,
sPreviousSearch = null,
anControl = $( 'input', _that.fnSettings().aanFeatures.f );
anControl.unbind( 'keyup' ).bind( 'keyup', function() {
var $$this = $this;
if (sPreviousSearch === null || sPreviousSearch != anControl.val()) {
window.clearTimeout(oTimerId);
sPreviousSearch = anControl.val();
oTimerId = window.setTimeout(function() {
$.fn.dataTableExt.iApiIndex = i;
_that.fnFilter( anControl.val() );
}, iDelay);
}
});
return this;
} );
return this;
}

View file

@ -0,0 +1,55 @@
$.fn.dataTableExt.oApi.fnStandingRedraw = function(oSettings) {
//redraw to account for filtering and sorting
// concept here is that (for client side) there is a row got inserted at the end (for an add)
// or when a record was modified it could be in the middle of the table
// that is probably not supposed to be there - due to filtering / sorting
// so we need to re process filtering and sorting
// BUT - if it is server side - then this should be handled by the server - so skip this step
if(oSettings.oFeatures.bServerSide === false){
var before = oSettings._iDisplayStart;
oSettings.oApi._fnReDraw(oSettings);
//iDisplayStart has been reset to zero - so lets change it back
oSettings._iDisplayStart = before;
oSettings.oApi._fnCalculateEnd(oSettings);
}
//draw the 'current' page
oSettings.oApi._fnDraw(oSettings);
};
$.fn.dataTableExt.oApi.fnAddDataAndDisplay = function ( oSettings, aData )
{
/* Add the data */
var iAdded = this.oApi._fnAddData( oSettings, aData );
var nAdded = oSettings.aoData[ iAdded ].nTr;
/* Need to re-filter and re-sort the table to get positioning correct, not perfect
* as this will actually redraw the table on screen, but the update should be so fast (and
* possibly not alter what is already on display) that the user will not notice
*/
this.oApi._fnReDraw( oSettings );
/* Find it's position in the table */
var iPos = -1;
for( var i=0, iLen=oSettings.aiDisplay.length ; i<iLen ; i++ )
{
if( oSettings.aoData[ oSettings.aiDisplay[i] ].nTr == nAdded )
{
iPos = i;
break;
}
}
/* Get starting point, taking account of paging */
if( iPos >= 0 )
{
oSettings._iDisplayStart = ( Math.floor(i / oSettings._iDisplayLength) ) * oSettings._iDisplayLength;
this.oApi._fnCalculateEnd( oSettings );
}
this.oApi._fnDraw( oSettings );
return {
"nTr": nAdded,
"iPos": iAdded
};
}