1
0
mirror of https://github.com/DataTables/DataTables.git synced 2025-02-27 00:54:15 +01:00

Fixes from JSHint and JSHint configuration. Note that I'm using a slightly modified JSHint to remove checking of mixed spaces/tabs and trailing white space due to issue 21 against JSHint (https://github.com/jshint/jshint/issues/21) - specifically it objects to my comment styling for the JSDoc comments, which I've got _everywhere_!

This commit is contained in:
Allan Jardine 2011-12-12 07:43:54 +00:00
parent 88b2990e53
commit d7d3aeddea
13 changed files with 156 additions and 113 deletions

View File

@ -371,7 +371,7 @@
*/
function _fnApplyColumnDefs( oSettings, aoColDefs, aoCols, fn )
{
var i, iLen;
var i, iLen, j, jLen, k, kLen;
// Column definitions with aTargets
if ( aoColDefs )
@ -1943,9 +1943,10 @@
/* Determine if reordering is required */
var sOrdering = _fnColumnOrdering(oSettings);
var bReOrder = (typeof json.sColumns != 'undefined' && sOrdering !== "" && json.sColumns != sOrdering );
var aiIndex;
if ( bReOrder )
{
var aiIndex = _fnReOrderIndex( oSettings, json.sColumns );
aiIndex = _fnReOrderIndex( oSettings, json.sColumns );
}
var aData = _fnGetObjectDataFn( oSettings.sAjaxDataProp )( json );
@ -2851,7 +2852,7 @@
}
else
{
_fnLog( oSettings, 0, "Unknown paging action: "+sAction );
_fnLog( oSettings, 0, "Unknown paging action: "+mAction );
}
$(oSettings.oInstance).trigger('page', oSettings);
@ -3098,10 +3099,11 @@
o.nTable.removeChild( nTheadSize[0] );
}
var nTfootSize;
if ( o.nTFoot !== null )
{
/* Remove the old minimised footer element in the cloned header */
var nTfootSize = o.nTable.getElementsByTagName('tfoot');
nTfootSize = o.nTable.getElementsByTagName('tfoot');
if ( nTfootSize.length > 0 )
{
o.nTable.removeChild( nTfootSize[0] );
@ -3789,6 +3791,7 @@
{
var
i, iLen, j, jLen, k, kLen,
sDataType,
aaSort = [],
aiOrig = [],
oSort = DataTable.ext.oSort,
@ -3815,7 +3818,7 @@
{
var iColumn = aaSort[i][0];
var iVisColumn = _fnColumnIndexToVisible( oSettings, iColumn );
var sDataType = oSettings.aoColumns[ iColumn ].sSortDataType;
sDataType = oSettings.aoColumns[ iColumn ].sSortDataType;
if ( typeof DataTable.ext.afnSortData[sDataType] != 'undefined' )
{
var aData = DataTable.ext.afnSortData[sDataType]( oSettings, iColumn, iVisColumn );
@ -3839,7 +3842,7 @@
* function runs. This make the sorting function a very simple comparison
*/
var iSortLen = aaSort.length;
var fnSortFormat;
var fnSortFormat, aDataSort;
for ( i=0, iLen=aoData.length ; i<iLen ; i++ )
{
for ( j=0 ; j<iSortLen ; j++ )
@ -3913,7 +3916,7 @@
}
if ( aaSort.length > 0 )
{
var aAriaSort = aaSort[0]
var aAriaSort = aaSort[0];
oSettings.aoColumns[aAriaSort[0]].nTh.setAttribute('aria-sort',
aAriaSort[1]=="asc" ? "ascending" : "descending" );
}
@ -4618,7 +4621,9 @@
*/
function _fnLog( oSettings, iLevel, sMesg )
{
var sAlert = "DataTables warning (table id = '"+oSettings.sTableId+"'): "+sMesg;
var sAlert = (oSettings===null) ?
"DataTables warning: "+sMesg :
"DataTables warning (table id = '"+oSettings.sTableId+"'): "+sMesg;
if ( iLevel === 0 )
{
@ -4736,7 +4741,7 @@
if (typeof oOpts=='undefined')
{
oOpts = {};
};
}
oOpts = $.extend( {}, {
"filter": "none", // applied
@ -5832,6 +5837,23 @@
* publically... - To be fixed in 2.0 using methods on the prototype
*/
/**
* Create a wrapper function for exporting an internal functions to an external API.
* @param {string} sFunc API function name
* @returns {function} wrapped function
* @private
*/
function _fnExternApiFunc (sFunc)
{
return function() {
var aArgs = [_fnSettingsFromNode(this[DataTable.ext.iApiIndex])].concat(
Array.prototype.slice.call(arguments) );
return DataTable.ext.oApi[sFunc].apply( this, aArgs );
};
}
/*
* Variable: oApi
* Purpose: Container for publicly exposed 'private' functions
@ -5920,22 +5942,6 @@
$.extend( DataTable.ext.oApi, this.oApi );
/**
* Create a wrapper function for exporting an internal functions to an external API.
* @param {string} sFunc API function name
* @returns {function} wrapped function
* @private
*/
function _fnExternApiFunc (sFunc)
{
return function() {
var aArgs = [_fnSettingsFromNode(this[DataTable.ext.iApiIndex])].concat(
Array.prototype.slice.call(arguments) );
return DataTable.ext.oApi[sFunc].apply( this, aArgs );
};
}
for ( var sFunc in DataTable.ext.oApi )
{
if ( sFunc )
@ -5957,7 +5963,7 @@
/* Sanity check */
if ( this.nodeName.toLowerCase() != 'table' )
{
_fnLog( oSettings, 0, "Attempted to initialise DataTables on a node which is not a "+
_fnLog( null, 0, "Attempted to initialise DataTables on a node which is not a "+
"table: "+this.nodeName );
return;
}
@ -7985,18 +7991,16 @@
// A small optimisation for what is likely to be the majority of use cases
return iIn;
}
else
var s=(iIn+""), a=s.split(""), out="", iLen=s.length;
for ( var i=0 ; i<iLen ; i++ )
{
var s=(iIn+""), a=s.split(""), out="", iLen=s.length;
for ( var i=0 ; i<iLen ; i++ )
if ( i%3 === 0 && i !== 0 )
{
if ( i%3 === 0 && i !== 0 )
{
out = this.oLanguage.sInfoThousands+out;
}
out = a[iLen-i-1]+out;
out = this.oLanguage.sInfoThousands+out;
}
out = a[iLen-i-1]+out;
}
return out;
},
@ -8813,7 +8817,7 @@
* You can instruct DataTables to load data from an external source using this
* parameter (use aData if you want to pass data in you already have). Simply
* provide a url a JSON object can be obtained from. This object must include
* the parameter 'aaData' which is a 2D array with the source data.
* the parameter 'aaData' which is the data source for the table.
* @type string
* @default null
*
@ -8827,24 +8831,6 @@
"sAjaxSource": null,
/**
* Address from which DataTables should load the remote data from when using
* server-side processing. Note that sAjaxSource can also be used without
* server-side processing to indicate a "one time get" of JSON formatted data.
* @type string
* @default null
*
* @example
* $(document).ready( function () {
* $('#example').dataTable( {
* "bProcessing": false,
* "sAjaxSource": "xhr.php"
* } );
* } );
*/
"sAjaxSource": null,
/**
* This parameter can be used to override the default prefix that DataTables
* assigns to a cookie when state saving is enabled.
@ -9946,7 +9932,7 @@
var els = $('div', nPaging);
var nPrevious = els[0],
nNext = els[1]
nNext = els[1];
$(nPrevious)
.bind( 'click.DT', { action: "previous" }, fnClickHandler )
@ -10131,7 +10117,7 @@
var anButtons, anStatic, nPaginateList;
var fnClick = function(e) {
/* Use the information in the element to jump to the required page */
oSettings.oApi._fnPageChange( oSettings, parseInt(this.innerHTML,10) - 1 )
oSettings.oApi._fnPageChange( oSettings, parseInt(this.innerHTML,10) - 1 );
fnCallbackDraw( oSettings );
e.preventDefault();
};
@ -10410,4 +10396,4 @@
* @param {event} e jQuery event object
* @param {object} o DataTables settings object {@link DataTable.models.oSettings}
*/
})(jQuery, window, document);
}(jQuery, window, document));

View File

@ -180,4 +180,4 @@
* @param {event} e jQuery event object
* @param {object} o DataTables settings object {@link DataTable.models.oSettings}
*/
})(jQuery, window, document);
}(jQuery, window, document));

View File

@ -4,6 +4,23 @@
* publically... - To be fixed in 2.0 using methods on the prototype
*/
/**
* Create a wrapper function for exporting an internal functions to an external API.
* @param {string} sFunc API function name
* @returns {function} wrapped function
* @private
*/
function _fnExternApiFunc (sFunc)
{
return function() {
var aArgs = [_fnSettingsFromNode(this[DataTable.ext.iApiIndex])].concat(
Array.prototype.slice.call(arguments) );
return DataTable.ext.oApi[sFunc].apply( this, aArgs );
};
}
/*
* Variable: oApi
* Purpose: Container for publicly exposed 'private' functions
@ -92,22 +109,6 @@ this.oApi = {
$.extend( DataTable.ext.oApi, this.oApi );
/**
* Create a wrapper function for exporting an internal functions to an external API.
* @param {string} sFunc API function name
* @returns {function} wrapped function
* @private
*/
function _fnExternApiFunc (sFunc)
{
return function() {
var aArgs = [_fnSettingsFromNode(this[DataTable.ext.iApiIndex])].concat(
Array.prototype.slice.call(arguments) );
return DataTable.ext.oApi[sFunc].apply( this, aArgs );
};
}
for ( var sFunc in DataTable.ext.oApi )
{
if ( sFunc )

View File

@ -42,7 +42,7 @@ this.$ = function ( sSelector, oOpts )
if (typeof oOpts=='undefined')
{
oOpts = {};
};
}
oOpts = $.extend( {}, {
"filter": "none", // applied

View File

@ -311,7 +311,7 @@ function _fnColumnOrdering ( oSettings )
*/
function _fnApplyColumnDefs( oSettings, aoColDefs, aoCols, fn )
{
var i, iLen;
var i, iLen, j, jLen, k, kLen;
// Column definitions with aTargets
if ( aoColDefs )

View File

@ -8,7 +8,7 @@ var bUsePassedData = false;
/* Sanity check */
if ( this.nodeName.toLowerCase() != 'table' )
{
_fnLog( oSettings, 0, "Attempted to initialise DataTables on a node which is not a "+
_fnLog( null, 0, "Attempted to initialise DataTables on a node which is not a "+
"table: "+this.nodeName );
return;
}

View File

@ -110,7 +110,7 @@ function _fnPageChange ( oSettings, mAction )
}
else
{
_fnLog( oSettings, 0, "Unknown paging action: "+sAction );
_fnLog( oSettings, 0, "Unknown paging action: "+mAction );
}
$(oSettings.oInstance).trigger('page', oSettings);

View File

@ -196,10 +196,11 @@ function _fnScrollDraw ( o )
o.nTable.removeChild( nTheadSize[0] );
}
var nTfootSize;
if ( o.nTFoot !== null )
{
/* Remove the old minimised footer element in the cloned header */
var nTfootSize = o.nTable.getElementsByTagName('tfoot');
nTfootSize = o.nTable.getElementsByTagName('tfoot');
if ( nTfootSize.length > 0 )
{
o.nTable.removeChild( nTfootSize[0] );

View File

@ -10,6 +10,7 @@ function _fnSort ( oSettings, bApplyClasses )
{
var
i, iLen, j, jLen, k, kLen,
sDataType,
aaSort = [],
aiOrig = [],
oSort = DataTable.ext.oSort,
@ -36,7 +37,7 @@ function _fnSort ( oSettings, bApplyClasses )
{
var iColumn = aaSort[i][0];
var iVisColumn = _fnColumnIndexToVisible( oSettings, iColumn );
var sDataType = oSettings.aoColumns[ iColumn ].sSortDataType;
sDataType = oSettings.aoColumns[ iColumn ].sSortDataType;
if ( typeof DataTable.ext.afnSortData[sDataType] != 'undefined' )
{
var aData = DataTable.ext.afnSortData[sDataType]( oSettings, iColumn, iVisColumn );
@ -60,7 +61,7 @@ function _fnSort ( oSettings, bApplyClasses )
* function runs. This make the sorting function a very simple comparison
*/
var iSortLen = aaSort.length;
var fnSortFormat;
var fnSortFormat, aDataSort;
for ( i=0, iLen=aoData.length ; i<iLen ; i++ )
{
for ( j=0 ; j<iSortLen ; j++ )
@ -134,7 +135,7 @@ function _fnSort ( oSettings, bApplyClasses )
}
if ( aaSort.length > 0 )
{
var aAriaSort = aaSort[0]
var aAriaSort = aaSort[0];
oSettings.aoColumns[aAriaSort[0]].nTh.setAttribute('aria-sort',
aAriaSort[1]=="asc" ? "ascending" : "descending" );
}

View File

@ -133,7 +133,9 @@ function _fnGetTdNodes ( oSettings, iIndividualRow )
*/
function _fnLog( oSettings, iLevel, sMesg )
{
var sAlert = "DataTables warning (table id = '"+oSettings.sTableId+"'): "+sMesg;
var sAlert = (oSettings===null) ?
"DataTables warning: "+sMesg :
"DataTables warning (table id = '"+oSettings.sTableId+"'): "+sMesg;
if ( iLevel === 0 )
{

View File

@ -40,7 +40,7 @@ $.extend( DataTable.ext.oPagination, {
var els = $('div', nPaging);
var nPrevious = els[0],
nNext = els[1]
nNext = els[1];
$(nPrevious)
.bind( 'click.DT', { action: "previous" }, fnClickHandler )
@ -225,7 +225,7 @@ $.extend( DataTable.ext.oPagination, {
var anButtons, anStatic, nPaginateList;
var fnClick = function(e) {
/* Use the information in the element to jump to the required page */
oSettings.oApi._fnPageChange( oSettings, parseInt(this.innerHTML,10) - 1 )
oSettings.oApi._fnPageChange( oSettings, parseInt(this.innerHTML,10) - 1 );
fnCallbackDraw( oSettings );
e.preventDefault();
};

View File

@ -656,18 +656,16 @@ DataTable.models.oInit = {
// A small optimisation for what is likely to be the majority of use cases
return iIn;
}
else
var s=(iIn+""), a=s.split(""), out="", iLen=s.length;
for ( var i=0 ; i<iLen ; i++ )
{
var s=(iIn+""), a=s.split(""), out="", iLen=s.length;
for ( var i=0 ; i<iLen ; i++ )
if ( i%3 === 0 && i !== 0 )
{
if ( i%3 === 0 && i !== 0 )
{
out = this.oLanguage.sInfoThousands+out;
}
out = a[iLen-i-1]+out;
out = this.oLanguage.sInfoThousands+out;
}
out = a[iLen-i-1]+out;
}
return out;
},
@ -1484,7 +1482,7 @@ DataTable.models.oInit = {
* You can instruct DataTables to load data from an external source using this
* parameter (use aData if you want to pass data in you already have). Simply
* provide a url a JSON object can be obtained from. This object must include
* the parameter 'aaData' which is a 2D array with the source data.
* the parameter 'aaData' which is the data source for the table.
* @type string
* @default null
*
@ -1498,24 +1496,6 @@ DataTable.models.oInit = {
"sAjaxSource": null,
/**
* Address from which DataTables should load the remote data from when using
* server-side processing. Note that sAjaxSource can also be used without
* server-side processing to indicate a "one time get" of JSON formatted data.
* @type string
* @default null
*
* @example
* $(document).ready( function () {
* $('#example').dataTable( {
* "bProcessing": false,
* "sAjaxSource": "xhr.php"
* } );
* } );
*/
"sAjaxSource": null,
/**
* This parameter can be used to override the default prefix that DataTables
* assigns to a cookie when state saving is enabled.

72
scripts/jshint.config Normal file
View File

@ -0,0 +1,72 @@
{
// Settings
"passfail" : false, // Stop on first error.
"maxerr" : 100, // Maximum error before stopping.
// Predefined globals whom JSHint will ignore.
"browser" : true, // Standard browser globals e.g. `window`, `document`.
"node" : false,
"rhino" : false,
"couch" : false,
"wsh" : true, // Windows Scripting Host.
"jquery" : true,
"prototypejs" : false,
"mootools" : false,
"dojo" : false,
"predef" : [ // Custom globals.
//"exampleVar",
//"anotherCoolGlobal",
//"iLoveDouglas"
],
// Development.
"debug" : false, // Allow debugger statements e.g. browser breakpoints.
"devel" : true, // Allow developments statements e.g. `console.log();`.
// ECMAScript 5.
"es5" : true, // Allow ECMAScript 5 syntax.
"strict" : false, // Require `use strict` pragma in every file.
"globalstrict" : false, // Allow global "use strict" (also enables 'strict').
// The Good Parts.
"asi" : false, // Tolerate Automatic Semicolon Insertion (no semicolons).
"laxbreak" : true, // Tolerate unsafe line breaks e.g. `return [\n] x` without semicolons.
"bitwise" : true, // Prohibit bitwise operators (&, |, ^, etc.).
"boss" : false, // Tolerate assignments inside if, for & while. Usually conditions & loops are for comparison, not assignments.
"curly" : true, // Require {} for every new block or scope.
"eqeqeq" : false, // Require triple equals i.e. `===`.
"eqnull" : false, // Tolerate use of `== null`.
"evil" : false, // Tolerate use of `eval`.
"expr" : false, // Tolerate `ExpressionStatement` as Programs.
"forin" : false, // Tolerate `for in` loops without `hasOwnPrototype`.
"immed" : true, // Require immediate invocations to be wrapped in parens e.g. `( function(){}() );`
"latedef" : true, // Prohipit variable use before definition.
"loopfunc" : false, // Allow functions to be defined within loops.
"noarg" : true, // Prohibit use of `arguments.caller` and `arguments.callee`.
"regexp" : false, // Prohibit `.` and `[^...]` in regular expressions.
"regexdash" : false, // Tolerate unescaped last dash i.e. `[-...]`.
"scripturl" : true, // Tolerate script-targeted URLs.
"shadow" : false, // Allows re-define variables later in code e.g. `var x=1; x=2;`.
"supernew" : false, // Tolerate `new function () { ... };` and `new Object;`.
"undef" : true, // Require all non-global variables be declared before they are used.
// Personal styling preferences.
"newcap" : true, // Require capitalization of all constructor functions e.g. `new F()`.
"noempty" : true, // Prohibit use of empty blocks.
"nonew" : true, // Prohibit use of constructors for side-effects.
"nomen" : false, // Prohibit use of initial or trailing underbars in names.
"onevar" : false, // Allow only one `var` statement per function.
"plusplus" : false, // Prohibit use of `++` & `--`.
"sub" : false, // Tolerate all forms of subscript notation besides dot notation e.g. `dict['key']` instead of `dict.key`.
"trailing" : true, // Prohibit trailing whitespaces.
"white" : false, // Check against strict whitespace and indentation rules.
"indent" : 4 // Specify indentation spacing
}