Bug 35309: Remove DT's fnSetFilteringDelay

On bug 35284 we added the delay on the column filters using dt's
throttle builtin function.

From doc:
https://datatables.net/plug-ins/api/fnSetFilteringDelay
"""
Please note that this plug-in has been deprecated and the dt-init searchDelay option in DataTables 1.10 should now be used. This plug-in will not operate with v1.10+.

Test plan:
Note that column filtering still work as before (test on different
tables, see bug 35284 for the list)

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
(cherry picked from commit 8bb8282d68)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
This commit is contained in:
Jonathan Druart 2023-11-15 11:44:37 +01:00 committed by Fridolin Somers
parent 79f32e210f
commit 967ed52dd2

View file

@ -120,56 +120,9 @@ $.fn.dataTableExt.oApi.fnGetColumnData = function ( oSettings, iColumn, bUnique,
// These keys must not launch filtering // These keys must not launch filtering
var blacklist_keys = new Array(0, 16, 17, 18, 37, 38, 39, 40); var blacklist_keys = new Array(0, 16, 17, 18, 37, 38, 39, 40);
// Set a filtering delay for global search field
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.DT' ).bind( 'keyup.DT', function(event) {
var $$this = $this;
if (blacklist_keys.indexOf(event.keyCode) != -1) {
return this;
}else if ( event.keyCode == '13' ) {
$.fn.dataTableExt.iApiIndex = i;
_that.fnFilter( $(this).val() );
} else {
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;
}
// Add a filtering delay on general search and on all input (with a class 'filter') // Add a filtering delay on general search and on all input (with a class 'filter')
jQuery.fn.dataTableExt.oApi.fnAddFilters = function ( oSettings, sClass, iDelay ) { jQuery.fn.dataTableExt.oApi.fnAddFilters = function ( oSettings, sClass, iDelay ) {
var table = this; var table = this;
this.fnSetFilteringDelay(iDelay);
var filterTimerId = null; var filterTimerId = null;
$(table).find("input."+sClass).keyup(function(event) { $(table).find("input."+sClass).keyup(function(event) {
if (blacklist_keys.indexOf(event.keyCode) != -1) { if (blacklist_keys.indexOf(event.keyCode) != -1) {