diff --git a/media/js/jquery.dataTables.js b/media/js/jquery.dataTables.js index af80c257..e02ca66a 100644 --- a/media/js/jquery.dataTables.js +++ b/media/js/jquery.dataTables.js @@ -25,9 +25,9 @@ * When considering jsLint, we need to allow eval() as it it is used for reading cookies */ /*jslint evil: true, undef: true, browser: true */ -/*globals $, jQuery,_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*/ +/*globals $, jQuery,_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*/ -(/** @lends */function($, window, document) { +(/** @lends */function($, window, document, undefined) { /** * DataTables is a plug-in for the jQuery Javascript library. It is a * highly flexible tool, based upon the foundations of progressive @@ -80,20 +80,19 @@ oSettings.aoColumns.push( oCol ); /* Add a column specific filter */ - if ( typeof oSettings.aoPreSearchCols[ iCol ] == 'undefined' || - oSettings.aoPreSearchCols[ iCol ] === null ) + if ( !oSettings.aoPreSearchCols[ iCol ] ) { oSettings.aoPreSearchCols[ iCol ] = $.extend( {}, DataTable.models.oSearch ); } else { /* Don't require that the user must specify bRegex and / or bSmart */ - if ( typeof oSettings.aoPreSearchCols[ iCol ].bRegex == 'undefined' ) + if ( oSettings.aoPreSearchCols[ iCol ].bRegex === undefined ) { oSettings.aoPreSearchCols[ iCol ].bRegex = true; } - if ( typeof oSettings.aoPreSearchCols[ iCol ].bSmart == 'undefined' ) + if ( oSettings.aoPreSearchCols[ iCol ].bSmart === undefined ) { oSettings.aoPreSearchCols[ iCol ].bSmart = true; } @@ -116,9 +115,9 @@ var oCol = oSettings.aoColumns[ iCol ]; /* User specified column options */ - if ( typeof oOptions != 'undefined' && oOptions !== null ) + if ( oOptions !== undefined && oOptions !== null ) { - if ( typeof oOptions.sType != 'undefined' ) + if ( oOptions.sType !== undefined ) { oCol.sType = oOptions.sType; oCol._bAutoType = false; @@ -130,7 +129,7 @@ /* iDataSort to be applied (backwards compatibility), but aDataSort will take * priority if defined */ - if ( typeof oOptions.iDataSort != 'undefined' ) + if ( oOptions.iDataSort !== undefined ) { oCol.aDataSort = [ oOptions.iDataSort ]; } @@ -374,7 +373,7 @@ for ( j=0, jLen=aTargets.length ; j= 0 ) + if ( typeof aTargets[j] === 'number' && aTargets[j] >= 0 ) { /* Add columns that we don't yet know about */ while( oSettings.aoColumns.length <= aTargets[j] ) @@ -385,12 +384,12 @@ /* Integer, basic index */ fn( aTargets[j], aoColDefs[i] ); } - else if ( typeof aTargets[j] == 'number' && aTargets[j] < 0 ) + else if ( typeof aTargets[j] === 'number' && aTargets[j] < 0 ) { /* Negative integer, right to left column counting */ fn( oSettings.aoColumns.length+aTargets[j], aoColDefs[i] ); } - else if ( typeof aTargets[j] == 'string' ) + else if ( typeof aTargets[j] === 'string' ) { /* Class name matching on TH element */ for ( k=0, kLen=oSettings.aoColumns.length ; k'; - if ( typeof oSettings.aanFeatures.f == "undefined" ) + if ( !oSettings.aanFeatures.f ) { nFilter.id = oSettings.sTableId+'_filter'; } @@ -2125,7 +2123,7 @@ var rpSearch = _fnFilterCreateSearch( sInput, bRegex, bSmart ); /* Check if we are forcing or not - optional parameter */ - if ( typeof iForce == 'undefined' || iForce === null ) + if ( !iForce ) { iForce = 0; } @@ -2209,7 +2207,7 @@ /* Clear out the old data */ oSettings.asDataSearch.splice( 0, oSettings.asDataSearch.length ); - var aArray = (typeof iMaster != 'undefined' && iMaster == 1) ? + var aArray = (iMaster && iMaster===1) ? oSettings.aiDisplayMaster : oSettings.aiDisplay; for ( var i=0, iLen=aArray.length ; i/g, "" ); } - else if ( typeof sData == "string" ) + else if ( typeof sData === "string" ) { return sData.replace(/[\r\n]/g," "); } @@ -2342,7 +2341,7 @@ nInfo.className = oSettings.oClasses.sInfo; /* Actions that are to be taken once only for this feature */ - if ( typeof oSettings.aanFeatures.i == "undefined" ) + if ( !oSettings.aanFeatures.i ) { /* Add draw callback */ oSettings.aoDrawCallback.push( { @@ -2547,21 +2546,16 @@ /** * Draw the table for the first time, adding all required features * @param {object} oSettings dataTables settings object + * @param {object} [json] JSON from the server that completed the table, if using Ajax source + * with client-side processing (optional) * @private */ function _fnInitComplete ( oSettings, json ) { oSettings._bInitComplete = true; - if ( typeof oSettings.fnInitComplete == 'function' ) + if ( oSettings.fnInitComplete ) { - if ( typeof json != 'undefined' ) - { - oSettings.fnInitComplete.call( oSettings.oInstance, oSettings, json ); - } - else - { - oSettings.fnInitComplete.call( oSettings.oInstance, oSettings ); - } + oSettings.fnInitComplete.call( oSettings.oInstance, oSettings, json ); } } @@ -2578,15 +2572,13 @@ /* Backwards compatibility - if there is no sEmptyTable given, then use the same as * sZeroRecords - assuming that is given. */ - if ( typeof oLanguage.sEmptyTable == 'undefined' && - typeof oLanguage.sZeroRecords != 'undefined' ) + if ( !oLanguage.sEmptyTable && oLanguage.sZeroRecords ) { _fnMap( oLanguage, oLanguage, 'sZeroRecords', 'sEmptyTable' ); } /* Likewise with loading records */ - if ( typeof oLanguage.sLoadingRecords == 'undefined' && - typeof oLanguage.sZeroRecords != 'undefined' ) + if ( !oLanguage.sLoadingRecords && oLanguage.sZeroRecords ) { _fnMap( oLanguage, oLanguage, 'sZeroRecords', 'sLoadingRecords' ); } @@ -2612,8 +2604,8 @@ var sStdMenu = ''; var i, iLen; - if ( oSettings.aLengthMenu.length == 2 && typeof oSettings.aLengthMenu[0] == 'object' && - typeof oSettings.aLengthMenu[1] == 'object' ) + if ( oSettings.aLengthMenu.length == 2 && typeof oSettings.aLengthMenu[0] === 'object' && + typeof oSettings.aLengthMenu[1] === 'object' ) { for ( i=0, iLen=oSettings.aLengthMenu[0].length ; i oSettings.fnRecordsDisplay() ) diff --git a/media/src/core/core.processing.js b/media/src/core/core.processing.js index 593ec25e..315cac58 100644 --- a/media/src/core/core.processing.js +++ b/media/src/core/core.processing.js @@ -10,7 +10,7 @@ function _fnFeatureHtmlProcessing ( oSettings ) { var nProcessing = document.createElement( 'div' ); - if ( typeof oSettings.aanFeatures.r == "undefined" ) + if ( !oSettings.aanFeatures.r ) { nProcessing.id = oSettings.sTableId+'_processing'; } diff --git a/media/src/core/core.scrolling.js b/media/src/core/core.scrolling.js index 72d10991..5ed2a2cd 100644 --- a/media/src/core/core.scrolling.js +++ b/media/src/core/core.scrolling.js @@ -468,7 +468,7 @@ function _fnApplyToChildren( fn, an1, an2 ) { if ( an1[i].childNodes[j].nodeType == 1 ) { - if ( typeof an2 != 'undefined' ) + if ( an2 ) { fn( an1[i].childNodes[j], an2[i].childNodes[j] ); } diff --git a/media/src/core/core.sizing.js b/media/src/core/core.sizing.js index 772f6ebb..129c60a3 100644 --- a/media/src/core/core.sizing.js +++ b/media/src/core/core.sizing.js @@ -14,7 +14,7 @@ function _fnConvertToWidth ( sWidth, nParent ) return 0; } - if ( typeof nParent == "undefined" ) + if ( !nParent ) { nParent = document.getElementsByTagName('body')[0]; } diff --git a/media/src/core/core.sort.js b/media/src/core/core.sort.js index 840836b8..d780df63 100644 --- a/media/src/core/core.sort.js +++ b/media/src/core/core.sort.js @@ -10,7 +10,7 @@ function _fnSort ( oSettings, bApplyClasses ) { var i, iLen, j, jLen, k, kLen, - sDataType, + sDataType, nTh, aaSort = [], aiOrig = [], oSort = DataTable.ext.oSort, @@ -39,7 +39,7 @@ function _fnSort ( oSettings, bApplyClasses ) var iColumn = aaSort[i][0]; var iVisColumn = _fnColumnIndexToVisible( oSettings, iColumn ); sDataType = oSettings.aoColumns[ iColumn ].sSortDataType; - if ( typeof DataTable.ext.afnSortData[sDataType] != 'undefined' ) + if ( DataTable.ext.afnSortData[sDataType] ) { var aData = DataTable.ext.afnSortData[sDataType]( oSettings, iColumn, iVisColumn ); for ( j=0, jLen=aoData.length ; j') != -1 ) + if ( typeof sData === 'string' && sData.indexOf('<') != -1 && sData.indexOf('>') != -1 ) { return 'html'; } diff --git a/media/unit_testing/tests_onhold/1_dom/fnInitComplete.js b/media/unit_testing/tests_onhold/1_dom/fnInitComplete.js index 14a9197c..1659d124 100755 --- a/media/unit_testing/tests_onhold/1_dom/fnInitComplete.js +++ b/media/unit_testing/tests_onhold/1_dom/fnInitComplete.js @@ -17,18 +17,18 @@ $(document).ready( function () { oTest.fnTest( - "One argument passed (for DOM!)", + "Two arguments passed", function () { oSession.fnRestore(); mPass = -1; $('#example').dataTable( { "fnInitComplete": function ( ) { - mPass = arguments.length; + mPass = arguments.length===2 && arguments[1]===undefined; } } ); }, - function () { return mPass == 1; } + function () { return mPass; } ); diff --git a/media/unit_testing/tests_onhold/2_js/fnInitComplete.js b/media/unit_testing/tests_onhold/2_js/fnInitComplete.js index 57547913..08580e5b 100644 --- a/media/unit_testing/tests_onhold/2_js/fnInitComplete.js +++ b/media/unit_testing/tests_onhold/2_js/fnInitComplete.js @@ -19,7 +19,7 @@ $(document).ready( function () { oTest.fnTest( - "One argument passed (for DOM!)", + "Two arguments passed", function () { oSession.fnRestore(); @@ -27,11 +27,11 @@ $(document).ready( function () { $('#example').dataTable( { "aaData": gaaData, "fnInitComplete": function ( ) { - mPass = arguments.length; + mPass = arguments.length===2 && arguments[1]===undefined; } } ); }, - function () { return mPass == 1; } + function () { return mPass; } ); diff --git a/media/unit_testing/tests_onhold/4_server-side/fnInitComplete.js b/media/unit_testing/tests_onhold/4_server-side/fnInitComplete.js index 800743c4..8da655f3 100644 --- a/media/unit_testing/tests_onhold/4_server-side/fnInitComplete.js +++ b/media/unit_testing/tests_onhold/4_server-side/fnInitComplete.js @@ -20,7 +20,7 @@ $(document).ready( function () { oTest.fnWaitTest( - "One argument passed", + "Two arguments passed", function () { oSession.fnRestore(); @@ -29,11 +29,11 @@ $(document).ready( function () { "bServerSide": true, "sAjaxSource": "../../../examples/server_side/scripts/server_processing.php", "fnInitComplete": function ( ) { - mPass = arguments.length; + mPass = arguments.length===2 && arguments[1]===undefined; } } ); }, - function () { return mPass == 1; } + function () { return mPass; } );