Bugzilla – Attachment 158676 Details for
Bug 35284
No more delay between 2 DT requests
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 35284: [DO NOT PUSH] Add DT delay to kohaTable
Bug-35284-DO-NOT-PUSH-Add-DT-delay-to-kohaTable.patch (text/plain), 2.73 KB, created by
Jonathan Druart
on 2023-11-08 21:33:07 UTC
(
hide
)
Description:
Bug 35284: [DO NOT PUSH] Add DT delay to kohaTable
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2023-11-08 21:33:07 UTC
Size:
2.73 KB
patch
obsolete
>From 11fcf4f61d0d0609b0202a1226468288701f22a3 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 8 Nov 2023 22:23:20 +0100 >Subject: [PATCH] Bug 35284: [DO NOT PUSH] Add DT delay to kohaTable > >To test: >* When a specific initComplete exists (general patron search) >* When no specific initComplete exists (cities) > >=> KO >* ERM tables display twice the "show X entries" dropdown list >* Column filters are not affected >--- > koha-tmpl/intranet-tmpl/prog/js/datatables.js | 39 ++++++++++++++++++- > 1 file changed, 38 insertions(+), 1 deletion(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/js/datatables.js b/koha-tmpl/intranet-tmpl/prog/js/datatables.js >index a70d796e145..025b63ea38e 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/datatables.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/datatables.js >@@ -51,7 +51,7 @@ var dataTablesDefaults = { > "lengthMenu": [[10, 20, 50, 100, -1], [10, 20, 50, 100, __('All')]], > "pageLength": 20, > "fixedHeader": true, >- initComplete: function( settings) { >+ initComplete: function( settings ) { > var tableId = settings.nTable.id > var state = settings.oLoadedState; > state && toggledClearFilter(state.search.search, tableId); >@@ -61,6 +61,10 @@ var dataTablesDefaults = { > $(this).on( 'search.dt', function ( e, settings ) { > toggledClearFilter(settings.oPreviousSearch.sSearch, tableId); > }); >+ >+ if (settings.ajax) { >+ _dt_add_delay($("#"+tableId)); >+ } > } > }; > >@@ -922,6 +926,39 @@ function _dt_add_filters(table_node, table_dt, filters_options = {}) { > } ); > } > >+// List of unbind keys (Ctrl, Alt, Direction keys, etc.) >+// These keys must not launch filtering >+var blacklist_keys = new Array(0, 16, 17, 18, 37, 38, 39, 40); >+ >+function _dt_add_delay(table_node, delay_ms) { >+ >+ let dt = table_node.DataTable(); >+ delay = (typeof delay == 'undefined') ? 500 : delay; >+ >+ var previousSearch = null; >+ var timerId = null; >+ $("#"+table_node.attr('id')+"_wrapper").find(".dataTables_filter input") >+ .unbind() >+ .bind("keyup", function(event) { >+ var input = $(this); >+ if (blacklist_keys.indexOf(event.keyCode) != -1) { >+ return; >+ } else if ( event.keyCode == '13' ) { >+ dt.search($(input).val()).draw(); >+ } else { >+ let val = $(input).val(); >+ if (previousSearch === null || previousSearch != val){ >+ window.clearTimeout(timerId); >+ previousSearch = val; >+ timerId = window.setTimeout(function(){ >+ dt.search($(input).val()).draw(); >+ }, delay); >+ } >+ } >+ >+ return; >+ }); >+} > > (function($) { > >-- >2.34.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 35284
:
158676
|
158705
|
158706
|
158707
|
158708
|
158776
|
158777
|
158778
|
158779
|
158783
|
158784
|
158785
|
158786
|
158787