effective_datatables 4.23.0 → 4.24.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e28694285e494e1dc825a61c276c8f1f8f79ef433b973aa054488bfd6decfabe
4
- data.tar.gz: 17a2c72b5b817ad34afc938748af1feca8642df80ccde42ede594e5949c8d72c
3
+ metadata.gz: 75aeba8a18f22cd6b4e5b0761e166ae919a10a59c77c918881cb117e13f76932
4
+ data.tar.gz: d84af5dea6afa6093d35a3421f2708321b63bf4f7e3706a28eb5cdd004bb9de7
5
5
  SHA512:
6
- metadata.gz: 7756e1a17ada79b50d8496845eb3e9060cbec84954c2603f356a0735d58bcef14f46132fe9b921ebd412acbd1f9b2b55727f18f28a180a5c6f50277142a58d63
7
- data.tar.gz: 58790be7fb4d4a09e1b5529453fd710ab3f8279dea93164ee101b788dcd4a5e0275737ac25561219e6c43b2d4b00163fc01e41dd5c7defef87e6a73de72dfb72
6
+ metadata.gz: 8b28b5aa883d030911aa842e8478aa641d1effc8c3aa1eaa51fb2a865d14a96183a6dd8079602718685e0f442c53a1e9af42fd0eaeaffc79c72308eb967b88d0
7
+ data.tar.gz: 6cd70258a3e9ad0efd861b4a47a2eb8140f478cf90f6ce1eff0c642b18e8d02d131c0a5574728caf3a99f2803ab8b4d8671297142d8f87c2db5e587b901bc17f
@@ -158,7 +158,8 @@ initializeDataTables = (target) ->
158
158
  if $input.is('select')
159
159
  $input.on 'change', (event) -> dataTableSearch($(event.currentTarget))
160
160
  else if $input.is('input')
161
- $input.delayedChange ($input) -> dataTableSearch($input)
161
+ $input.keyup(delayChange((-> dataTableSearch($input)), 500))
162
+ $input.on 'paste', (event) -> delayChange((-> dataTableSearch($(event.currentTarget))), 100)
162
163
 
163
164
  # Do the actual search
164
165
  dataTableSearch = ($input) -> # This is the function called by a select or input to run the search
@@ -201,6 +202,15 @@ destroyDataTables = ->
201
202
  $('.effective-datatables-inline-expanded').removeClass('effective-datatables-inline-expanded')
202
203
  $('table.effective-datatable').each -> try $(this).removeClass('initialized').DataTable().destroy()
203
204
 
205
+ # https://stackoverflow.com/questions/1909441/how-to-delay-the-keyup-handler-until-the-user-stops-typing
206
+ delayChange = (callback, ms) ->
207
+ timer = 0
208
+ ->
209
+ context = this
210
+ args = arguments
211
+ clearTimeout(timer)
212
+ timer = setTimeout((-> callback.apply(context, args)), ms)
213
+
204
214
  $ -> initializeDataTables()
205
215
  $(document).on 'effective-datatables:initialize', (event) -> initializeDataTables(event.currentTarget)
206
216
 
@@ -11,12 +11,6 @@ $(document).on 'click', '.dataTables_wrapper a.buttons-reset-search', (event) ->
11
11
  $inputs = $thead.find('input')
12
12
  $inputs.val('').removeAttr('checked').removeAttr('selected')
13
13
 
14
- # Reset delayedChange
15
- $.each $inputs, (input) =>
16
- $input = $(input)
17
- if ($input.delayedChange.oldVal)
18
- $input.delayedChange.oldVal = undefined
19
-
20
14
  # Reset the datatable
21
15
  datatable = $table.DataTable()
22
16
 
@@ -1,4 +1,3 @@
1
- //= require vendor/jquery.delayedChange
2
1
  //= require vendor/jquery.fileDownload
3
2
 
4
3
  //= require dataTables/jquery.dataTables
@@ -1,3 +1,3 @@
1
1
  module EffectiveDatatables
2
- VERSION = '4.23.0'.freeze
2
+ VERSION = '4.24.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_datatables
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.23.0
4
+ version: 4.24.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-31 00:00:00.000000000 Z
11
+ date: 2024-02-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -122,7 +122,6 @@ files:
122
122
  - app/assets/javascripts/effective_datatables/reorder.js.coffee
123
123
  - app/assets/javascripts/effective_datatables/reset.js.coffee
124
124
  - app/assets/javascripts/effective_datatables/responsive.js.coffee
125
- - app/assets/javascripts/vendor/jquery.delayedChange.js
126
125
  - app/assets/javascripts/vendor/jquery.fileDownload.js
127
126
  - app/assets/stylesheets/dataTables/buttons/buttons.bootstrap4.scss
128
127
  - app/assets/stylesheets/dataTables/dataTables.bootstrap4.scss
@@ -1,37 +0,0 @@
1
- // http://stackoverflow.com/questions/7373023/throttle-event-calls-in-jquery
2
-
3
- (function($) {
4
- $.fn.delayedChange = function(options) {
5
- var timer; var o;
6
-
7
- if (jQuery.isFunction(options)) {
8
- o = { onChange: options };
9
- } else {
10
- o = options;
11
- }
12
-
13
- o = $.extend({}, $.fn.delayedChange.defaultOptions, o);
14
-
15
- return this.each(function() {
16
- var element = $(this);
17
- element.on('keyup paste', function() {
18
- clearTimeout(timer);
19
- timer = setTimeout(function() {
20
- var newVal = element.val();
21
- if (element.delayedChange.oldVal != newVal) {
22
- element.delayedChange.oldVal = newVal;
23
- o.onChange.call(this, element);
24
- }
25
- }, o.delay);
26
- });
27
- });
28
- };
29
-
30
- $.fn.delayedChange.defaultOptions = {
31
- delay: 700,
32
- onChange: function(element) { }
33
- }
34
-
35
- $.fn.delayedChange.oldVal = 'NO_DELAYED_CHANGE_VALUE';
36
-
37
- })(jQuery);