/** * @summary datatables * @description paginate, search and sort html tables * @version 1.9.4 * @file jquery.datatables.js * @author allan jardine (www.sprymedia.co.uk) * @contact www.sprymedia.co.uk/contact * * @copyright copyright 2008-2012 allan jardine, all rights reserved. * * this source file is free software, under either the gpl v2 license or a * bsd style license, available at: * http://datatables.net/license_gpl2 * http://datatables.net/license_bsd * * this source file is distributed in the hope that it will be useful, but * without any warranty; without even the implied warranty of merchantability * or fitness for a particular purpose. see the license files for details. * * for details please refer to: http://www.datatables.net */ /*jslint evil: true, undef: true, browser: true */ /*globals $, jquery,define,_fnexternapifunc,_fninitialise,_fninitcomplete,_fnlanguagecompat,_fnaddcolumn,_fncolumnoptions,_fnadddata,_fncreatetr,_fngatherdata,_fnbuildhead,_fndrawhead,_fndraw,_fnredraw,_fnajaxupdate,_fnajaxparameters,_fnajaxupdatedraw,_fnserverparams,_fnaddoptionshtml,_fnfeaturehtmltable,_fnscrolldraw,_fnadjustcolumnsizing,_fnfeaturehtmlfilter,_fnfiltercomplete,_fnfiltercustom,_fnfiltercolumn,_fnfilter,_fnbuildsearcharray,_fnbuildsearchrow,_fnfiltercreatesearch,_fndatatosearch,_fnsort,_fnsortattachlistener,_fnsortingclasses,_fnfeaturehtmlpaginate,_fnpagechange,_fnfeaturehtmlinfo,_fnupdateinfo,_fnfeaturehtmllength,_fnfeaturehtmlprocessing,_fnprocessingdisplay,_fnvisibletocolumnindex,_fncolumnindextovisible,_fnnodetodataindex,_fnvisblecolumns,_fncalculateend,_fnconverttowidth,_fncalculatecolumnwidths,_fnscrollingwidthadjust,_fngetwidestnode,_fngetmaxlenstring,_fnstringtocss,_fndetecttype,_fnsettingsfromnode,_fngetdatamaster,_fngettrnodes,_fngettdnodes,_fnescaperegex,_fndeleteindex,_fnreorderindex,_fncolumnordering,_fnlog,_fncleartable,_fnsavestate,_fnloadstate,_fncreatecookie,_fnreadcookie,_fndetectheader,_fngetuniqueths,_fnscrollbarwidth,_fnapplytochildren,_fnmap,_fngetrowdata,_fngetcelldata,_fnsetcelldata,_fngetobjectdatafn,_fnsetobjectdatafn,_fnapplycolumndefs,_fnbindaction,_fncallbackreg,_fncallbackfire,_fnjsonstring,_fnrender,_fnnodetocolumnindex,_fninfomacros,_fnbrowserdetect,_fngetcolumns*/ (/** @lends */function( window, document, undefined ) { (function( factory ) { "use strict"; // define as an amd module if possible if ( typeof define === 'function' && define.amd ) { define( ['jquery'], factory ); } /* define using browser globals otherwise * prevent multiple instantiations if the script is loaded twice */ else if ( jquery && !jquery.fn.datatable ) { factory( jquery ); } } (/** @lends */function( $ ) { "use strict"; /** * datatables is a plug-in for the jquery javascript library. it is a * highly flexible tool, based upon the foundations of progressive * enhancement, which will add advanced interaction controls to any * html table. for a full list of features please refer to * datatables.net. * * note that the datatable object is not a global variable but is * aliased to jquery.fn.datatable and jquery.fn.datatable through which * it may be accessed. * * @class * @param {object} [oinit={}] configuration object for datatables. options * are defined by {@link datatable.defaults} * @requires jquery 1.3+ * * @example * // basic initialisation * $(document).ready( function { * $('#example').datatable(); * } ); * * @example * // initialisation with configuration options - in this case, disable * // pagination and sorting. * $(document).ready( function { * $('#example').datatable( { * "bpaginate": false, * "bsort": false * } ); * } ); */ var datatable = function( oinit ) { /** * add a column to the list used for the table with default values * @param {object} osettings datatables settings object * @param {node} nth the th element for this column * @memberof datatable#oapi */ function _fnaddcolumn( osettings, nth ) { var odefaults = datatable.defaults.columns; var icol = osettings.aocolumns.length; var ocol = $.extend( {}, datatable.models.ocolumn, odefaults, { "ssortingclass": osettings.oclasses.ssortable, "ssortingclassjui": osettings.oclasses.ssortjui, "nth": nth ? nth : document.createelement('th'), "stitle": odefaults.stitle ? odefaults.stitle : nth ? nth.innerhtml : '', "adatasort": odefaults.adatasort ? odefaults.adatasort : [icol], "mdata": odefaults.mdata ? odefaults.odefaults : icol } ); osettings.aocolumns.push( ocol ); /* add a column specific filter */ if ( osettings.aopresearchcols[ icol ] === undefined || osettings.aopresearchcols[ icol ] === null ) { osettings.aopresearchcols[ icol ] = $.extend( {}, datatable.models.osearch ); } else { var opre = osettings.aopresearchcols[ icol ]; /* don't require that the user must specify bregex, bsmart or bcaseinsensitive */ if ( opre.bregex === undefined ) { opre.bregex = true; } if ( opre.bsmart === undefined ) { opre.bsmart = true; } if ( opre.bcaseinsensitive === undefined ) { opre.bcaseinsensitive = true; } } /* use the column options function to initialise classes etc */ _fncolumnoptions( osettings, icol, null ); } /** * apply options for a column * @param {object} osettings datatables settings object * @param {int} icol column index to consider * @param {object} ooptions object with stype, bvisible and bsearchable etc * @memberof datatable#oapi */ function _fncolumnoptions( osettings, icol, ooptions ) { var ocol = osettings.aocolumns[ icol ]; /* user specified column options */ if ( ooptions !== undefined && ooptions !== null ) { /* backwards compatibility for mdataprop */ if ( ooptions.mdataprop && !ooptions.mdata ) { ooptions.mdata = ooptions.mdataprop; } if ( ooptions.stype !== undefined ) { ocol.stype = ooptions.stype; ocol._bautotype = false; } $.extend( ocol, ooptions ); _fnmap( ocol, ooptions, "swidth", "swidthorig" ); /* idatasort to be applied (backwards compatibility), but adatasort will take * priority if defined */ if ( ooptions.idatasort !== undefined ) { ocol.adatasort = [ ooptions.idatasort ]; } _fnmap( ocol, ooptions, "adatasort" ); } /* cache the data get and set functions for speed */ var mrender = ocol.mrender ? _fngetobjectdatafn( ocol.mrender ) : null; var mdata = _fngetobjectdatafn( ocol.mdata ); ocol.fngetdata = function (odata, sspecific) { var innerdata = mdata( odata, sspecific ); if ( ocol.mrender && (sspecific && sspecific !== '') ) { return mrender( innerdata, sspecific, odata ); } return innerdata; }; ocol.fnsetdata = _fnsetobjectdatafn( ocol.mdata ); /* feature sorting overrides column specific when off */ if ( !osettings.ofeatures.bsort ) { ocol.bsortable = false; } /* check that the class assignment is correct for sorting */ if ( !ocol.bsortable || ($.inarray('asc', ocol.assorting) == -1 && $.inarray('desc', ocol.assorting) == -1) ) { ocol.ssortingclass = osettings.oclasses.ssortablenone; ocol.ssortingclassjui = ""; } else if ( $.inarray('asc', ocol.assorting) == -1 && $.inarray('desc', ocol.assorting) == -1 ) { ocol.ssortingclass = osettings.oclasses.ssortable; ocol.ssortingclassjui = osettings.oclasses.ssortjui; } else if ( $.inarray('asc', ocol.assorting) != -1 && $.inarray('desc', ocol.assorting) == -1 ) { ocol.ssortingclass = osettings.oclasses.ssortableasc; ocol.ssortingclassjui = osettings.oclasses.ssortjuiascallowed; } else if ( $.inarray('asc', ocol.assorting) == -1 && $.inarray('desc', ocol.assorting) != -1 ) { ocol.ssortingclass = osettings.oclasses.ssortabledesc; ocol.ssortingclassjui = osettings.oclasses.ssortjuidescallowed; } } /** * adjust the table column widths for new data. note: you would probably want to * do a redraw after calling this function! * @param {object} osettings datatables settings object * @memberof datatable#oapi */ function _fnadjustcolumnsizing ( osettings ) { /* not interested in doing column width calculation if auto-width is disabled */ if ( osettings.ofeatures.bautowidth === false ) { return false; } _fncalculatecolumnwidths( osettings ); for ( var i=0 , ilen=osettings.aocolumns.length ; i