diff --git a/media/js/jquery.dataTables.js b/media/js/jquery.dataTables.js index 0fe84b2d..caeb70e1 100644 --- a/media/js/jquery.dataTables.js +++ b/media/js/jquery.dataTables.js @@ -90,15 +90,22 @@ } else { - /* Don't require that the user must specify bRegex and / or bSmart */ - if ( oSettings.aoPreSearchCols[ iCol ].bRegex === undefined ) + var oPre = oSettings.aoPreSearchCols[ iCol ]; + + /* Don't require that the user must specify bRegex, bSmart or bCaseInsensitive */ + if ( oPre.bRegex === undefined ) { - oSettings.aoPreSearchCols[ iCol ].bRegex = true; + oPre.bRegex = true; } - if ( oSettings.aoPreSearchCols[ iCol ].bSmart === undefined ) + if ( oPre.bSmart === undefined ) { - oSettings.aoPreSearchCols[ iCol ].bSmart = true; + oPre.bSmart = true; + } + + if ( oPre.bCaseInsensitive === undefined ) + { + oPre.bCaseInsensitive = true; } } @@ -2025,13 +2032,14 @@ function _fnFilterComplete ( oSettings, oInput, iForce ) { /* Filter on everything */ - _fnFilter( oSettings, oInput.sSearch, iForce, oInput.bRegex, oInput.bSmart ); + _fnFilter( oSettings, oInput.sSearch, iForce, oInput.bRegex, oInput.bSmart, oInput.bCaseInsensitive ); /* Now do the individual column filter */ for ( var i=0 ; i=0 ; i-- ) { @@ -2119,12 +2128,13 @@ * @param {int} iForce optional - force a research of the master array (1) or not (undefined or 0) * @param {bool} bRegex treat as a regular expression or not * @param {bool} bSmart perform smart filtering or not + * @param {bool} bCaseInsensitive Do case insenstive matching or not * @private */ - function _fnFilter( oSettings, sInput, iForce, bRegex, bSmart ) + function _fnFilter( oSettings, sInput, iForce, bRegex, bSmart, bCaseInsensitive ) { var i; - var rpSearch = _fnFilterCreateSearch( sInput, bRegex, bSmart ); + var rpSearch = _fnFilterCreateSearch( sInput, bRegex, bSmart, bCaseInsensitive ); /* Check if we are forcing or not - optional parameter */ if ( !iForce ) @@ -2195,6 +2205,7 @@ oSettings.oPreviousSearch.sSearch = sInput; oSettings.oPreviousSearch.bRegex = bRegex; oSettings.oPreviousSearch.bSmart = bSmart; + oSettings.oPreviousSearch.bCaseInsensitive = bCaseInsensitive; } @@ -2265,10 +2276,11 @@ * @param {string} sSearch string to search for * @param {bool} bRegex treat as a regular expression or not * @param {bool} bSmart perform smart filtering or not + * @param {bool} bCaseInsensitive Do case insenstive matching or not * @returns {RegExp} constructed object * @private */ - function _fnFilterCreateSearch( sSearch, bRegex, bSmart ) + function _fnFilterCreateSearch( sSearch, bRegex, bSmart, bCaseInsensitive ) { var asSearch, sRegExpString; @@ -2279,12 +2291,12 @@ */ asSearch = bRegex ? sSearch.split( ' ' ) : _fnEscapeRegex( sSearch ).split( ' ' ); sRegExpString = '^(?=.*?'+asSearch.join( ')(?=.*?' )+').*$'; - return new RegExp( sRegExpString, "i" ); + return new RegExp( sRegExpString, bCaseInsensitive ? "i" : "" ); } else { sSearch = bRegex ? sSearch : _fnEscapeRegex( sSearch ); - return new RegExp( sSearch, "i" ); + return new RegExp( sSearch, bCaseInsensitive ? "i" : "" ); } } @@ -5192,11 +5204,12 @@ /** * Filter the input based on data - * @param {string} sInput string to filter the table on - * @param {int|null} [iColumn] column to limit filtering to - * @param {bool} [bRegex=false] treat as regular expression or not - * @param {bool} [bSmart=true] perform smart filtering or not - * @param {bool} [bShowGlobal=true] show the input global filter in it's input box(es) + * @param {string} sInput String to filter the table on + * @param {int|null} [iColumn] Column to limit filtering to + * @param {bool} [bRegex=false] Treat as regular expression or not + * @param {bool} [bSmart=true] Perform smart filtering or not + * @param {bool} [bShowGlobal=true] Show the input global filter in it's input box(es) + * @param {bool} [bCaseInsensitive=true] Do case-insensitive matching (true) or not (false) * * @example * $(document).ready(function() { @@ -5206,7 +5219,7 @@ * oTable.fnFilter( 'test string' ); * } ); */ - this.fnFilter = function( sInput, iColumn, bRegex, bSmart, bShowGlobal ) + this.fnFilter = function( sInput, iColumn, bRegex, bSmart, bShowGlobal, bCaseInsensitive ) { var oSettings = _fnSettingsFromNode( this[DataTable.ext.iApiIndex] ); @@ -5215,28 +5228,34 @@ return; } - if ( bRegex === undefined ) + if ( bRegex === undefined || bRegex === null ) { bRegex = false; } - if ( bSmart === undefined ) + if ( bSmart === undefined || bSmart === null ) { bSmart = true; } - if ( bShowGlobal === undefined ) + if ( bShowGlobal === undefined || bShowGlobal === null ) { bShowGlobal = true; } + if ( bCaseInsensitive === undefined || bCaseInsensitive === null ) + { + bCaseInsensitive = true; + } + if ( !iColumn ) { /* Global filter */ _fnFilterComplete( oSettings, { "sSearch":sInput+"", "bRegex": bRegex, - "bSmart": bSmart + "bSmart": bSmart, + "bCaseInsensitive": bCaseInsensitive }, 1 ); if ( bShowGlobal && oSettings.aanFeatures.f ) @@ -5254,7 +5273,8 @@ $.extend( oSettings.aoPreSearchCols[ iColumn ], { "sSearch": sInput+"", "bRegex": bRegex, - "bSmart": bSmart + "bSmart": bSmart, + "bCaseInsensitive": bCaseInsensitive } ); _fnFilterComplete( oSettings, oSettings.oPreviousSearch, 1 ); } @@ -6969,6 +6989,13 @@ * @namespace */ DataTable.models.oSearch = { + /** + * Flag to indicate if the filtering should be case insensitive or not + * @type boolean + * @default true + */ + "bCaseInsensitive": true, + /** * Applied search term * @type string @@ -8815,11 +8842,11 @@ /** * This parameter allows you to have define the global filtering state at * initialisation time. As an object the "sSearch" parameter must be - * defined, but the "bRegex" and "bSmart" parameters are optional. When - * "bRegex" is true, the search string will be treated as a regular - * expression, when false (default) it will be treated as a straight string. - * When "bSmart" DataTables will use it's smart filtering methods (to word - * match at any point in the data), when false this will not be done. + * defined, but all other parameters are optional. When "bRegex" is true, + * the search string will be treated as a regular expression, when false + * (default) it will be treated as a straight string. When "bSmart" + * DataTables will use it's smart filtering methods (to word match at + * any point in the data), when false this will not be done. * @type object * @extends DataTable.models.oSearch * diff --git a/media/src/api/api.methods.js b/media/src/api/api.methods.js index b6e6b217..dba57c55 100644 --- a/media/src/api/api.methods.js +++ b/media/src/api/api.methods.js @@ -509,11 +509,12 @@ this.fnDraw = function( bComplete ) /** * Filter the input based on data - * @param {string} sInput string to filter the table on - * @param {int|null} [iColumn] column to limit filtering to - * @param {bool} [bRegex=false] treat as regular expression or not - * @param {bool} [bSmart=true] perform smart filtering or not - * @param {bool} [bShowGlobal=true] show the input global filter in it's input box(es) + * @param {string} sInput String to filter the table on + * @param {int|null} [iColumn] Column to limit filtering to + * @param {bool} [bRegex=false] Treat as regular expression or not + * @param {bool} [bSmart=true] Perform smart filtering or not + * @param {bool} [bShowGlobal=true] Show the input global filter in it's input box(es) + * @param {bool} [bCaseInsensitive=true] Do case-insensitive matching (true) or not (false) * * @example * $(document).ready(function() { @@ -523,7 +524,7 @@ this.fnDraw = function( bComplete ) * oTable.fnFilter( 'test string' ); * } ); */ -this.fnFilter = function( sInput, iColumn, bRegex, bSmart, bShowGlobal ) +this.fnFilter = function( sInput, iColumn, bRegex, bSmart, bShowGlobal, bCaseInsensitive ) { var oSettings = _fnSettingsFromNode( this[DataTable.ext.iApiIndex] ); @@ -532,28 +533,34 @@ this.fnFilter = function( sInput, iColumn, bRegex, bSmart, bShowGlobal ) return; } - if ( bRegex === undefined ) + if ( bRegex === undefined || bRegex === null ) { bRegex = false; } - if ( bSmart === undefined ) + if ( bSmart === undefined || bSmart === null ) { bSmart = true; } - if ( bShowGlobal === undefined ) + if ( bShowGlobal === undefined || bShowGlobal === null ) { bShowGlobal = true; } + if ( bCaseInsensitive === undefined || bCaseInsensitive === null ) + { + bCaseInsensitive = true; + } + if ( !iColumn ) { /* Global filter */ _fnFilterComplete( oSettings, { "sSearch":sInput+"", "bRegex": bRegex, - "bSmart": bSmart + "bSmart": bSmart, + "bCaseInsensitive": bCaseInsensitive }, 1 ); if ( bShowGlobal && oSettings.aanFeatures.f ) @@ -571,7 +578,8 @@ this.fnFilter = function( sInput, iColumn, bRegex, bSmart, bShowGlobal ) $.extend( oSettings.aoPreSearchCols[ iColumn ], { "sSearch": sInput+"", "bRegex": bRegex, - "bSmart": bSmart + "bSmart": bSmart, + "bCaseInsensitive": bCaseInsensitive } ); _fnFilterComplete( oSettings, oSettings.oPreviousSearch, 1 ); } diff --git a/media/src/core/core.columns.js b/media/src/core/core.columns.js index 425808b0..7b6e73a2 100644 --- a/media/src/core/core.columns.js +++ b/media/src/core/core.columns.js @@ -26,15 +26,22 @@ function _fnAddColumn( oSettings, nTh ) } else { - /* Don't require that the user must specify bRegex and / or bSmart */ - if ( oSettings.aoPreSearchCols[ iCol ].bRegex === undefined ) + var oPre = oSettings.aoPreSearchCols[ iCol ]; + + /* Don't require that the user must specify bRegex, bSmart or bCaseInsensitive */ + if ( oPre.bRegex === undefined ) { - oSettings.aoPreSearchCols[ iCol ].bRegex = true; + oPre.bRegex = true; } - if ( oSettings.aoPreSearchCols[ iCol ].bSmart === undefined ) + if ( oPre.bSmart === undefined ) { - oSettings.aoPreSearchCols[ iCol ].bSmart = true; + oPre.bSmart = true; + } + + if ( oPre.bCaseInsensitive === undefined ) + { + oPre.bCaseInsensitive = true; } } diff --git a/media/src/core/core.filter.js b/media/src/core/core.filter.js index fc0a19b7..aea9b477 100644 --- a/media/src/core/core.filter.js +++ b/media/src/core/core.filter.js @@ -70,13 +70,14 @@ function _fnFeatureHtmlFilter ( oSettings ) function _fnFilterComplete ( oSettings, oInput, iForce ) { /* Filter on everything */ - _fnFilter( oSettings, oInput.sSearch, iForce, oInput.bRegex, oInput.bSmart ); + _fnFilter( oSettings, oInput.sSearch, iForce, oInput.bRegex, oInput.bSmart, oInput.bCaseInsensitive ); /* Now do the individual column filter */ for ( var i=0 ; i=0 ; i-- ) { @@ -164,12 +166,13 @@ function _fnFilterColumn ( oSettings, sInput, iColumn, bRegex, bSmart ) * @param {int} iForce optional - force a research of the master array (1) or not (undefined or 0) * @param {bool} bRegex treat as a regular expression or not * @param {bool} bSmart perform smart filtering or not + * @param {bool} bCaseInsensitive Do case insenstive matching or not * @private */ -function _fnFilter( oSettings, sInput, iForce, bRegex, bSmart ) +function _fnFilter( oSettings, sInput, iForce, bRegex, bSmart, bCaseInsensitive ) { var i; - var rpSearch = _fnFilterCreateSearch( sInput, bRegex, bSmart ); + var rpSearch = _fnFilterCreateSearch( sInput, bRegex, bSmart, bCaseInsensitive ); /* Check if we are forcing or not - optional parameter */ if ( !iForce ) @@ -240,6 +243,7 @@ function _fnFilter( oSettings, sInput, iForce, bRegex, bSmart ) oSettings.oPreviousSearch.sSearch = sInput; oSettings.oPreviousSearch.bRegex = bRegex; oSettings.oPreviousSearch.bSmart = bSmart; + oSettings.oPreviousSearch.bCaseInsensitive = bCaseInsensitive; } @@ -310,10 +314,11 @@ function _fnBuildSearchRow( oSettings, aData ) * @param {string} sSearch string to search for * @param {bool} bRegex treat as a regular expression or not * @param {bool} bSmart perform smart filtering or not + * @param {bool} bCaseInsensitive Do case insenstive matching or not * @returns {RegExp} constructed object * @private */ -function _fnFilterCreateSearch( sSearch, bRegex, bSmart ) +function _fnFilterCreateSearch( sSearch, bRegex, bSmart, bCaseInsensitive ) { var asSearch, sRegExpString; @@ -324,12 +329,12 @@ function _fnFilterCreateSearch( sSearch, bRegex, bSmart ) */ asSearch = bRegex ? sSearch.split( ' ' ) : _fnEscapeRegex( sSearch ).split( ' ' ); sRegExpString = '^(?=.*?'+asSearch.join( ')(?=.*?' )+').*$'; - return new RegExp( sRegExpString, "i" ); + return new RegExp( sRegExpString, bCaseInsensitive ? "i" : "" ); } else { sSearch = bRegex ? sSearch : _fnEscapeRegex( sSearch ); - return new RegExp( sSearch, "i" ); + return new RegExp( sSearch, bCaseInsensitive ? "i" : "" ); } } diff --git a/media/src/model/model.init.js b/media/src/model/model.init.js index 7e1abc50..9a0ac260 100644 --- a/media/src/model/model.init.js +++ b/media/src/model/model.init.js @@ -1499,11 +1499,11 @@ DataTable.models.oInit = { /** * This parameter allows you to have define the global filtering state at * initialisation time. As an object the "sSearch" parameter must be - * defined, but the "bRegex" and "bSmart" parameters are optional. When - * "bRegex" is true, the search string will be treated as a regular - * expression, when false (default) it will be treated as a straight string. - * When "bSmart" DataTables will use it's smart filtering methods (to word - * match at any point in the data), when false this will not be done. + * defined, but all other parameters are optional. When "bRegex" is true, + * the search string will be treated as a regular expression, when false + * (default) it will be treated as a straight string. When "bSmart" + * DataTables will use it's smart filtering methods (to word match at + * any point in the data), when false this will not be done. * @type object * @extends DataTable.models.oSearch * diff --git a/media/src/model/model.search.js b/media/src/model/model.search.js index a5104bb7..455fa297 100644 --- a/media/src/model/model.search.js +++ b/media/src/model/model.search.js @@ -7,6 +7,13 @@ * @namespace */ DataTable.models.oSearch = { + /** + * Flag to indicate if the filtering should be case insensitive or not + * @type boolean + * @default true + */ + "bCaseInsensitive": true, + /** * Applied search term * @type string