effective_datatables 4.23.0 → 4.24.1

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: 4ead89fb1377a2310bef8d72b4ddba32369f369be7b5c49f48def4b43cfca364
4
+ data.tar.gz: b2633a0f7bbcc366d10b84c92c48be6dffeb0eb44e9f2fd9e055d32552154cf3
5
5
  SHA512:
6
- metadata.gz: 7756e1a17ada79b50d8496845eb3e9060cbec84954c2603f356a0735d58bcef14f46132fe9b921ebd412acbd1f9b2b55727f18f28a180a5c6f50277142a58d63
7
- data.tar.gz: 58790be7fb4d4a09e1b5529453fd710ab3f8279dea93164ee101b788dcd4a5e0275737ac25561219e6c43b2d4b00163fc01e41dd5c7defef87e6a73de72dfb72
6
+ metadata.gz: 64cca992852889e969d3ad811b60392ef42f1ee4132d543ef11f6266c8fa6c4dcfee06f6e1db76a5c20ab6a7facb3da7074bffd80773c42fb56912e9e498ed1a
7
+ data.tar.gz: d32031a018c8a819896d3901ca46c359ddc60296434d1f8ac83e66b4bad9f6efbb8ff9712d4c77db10f8af1e6c63e82248d83970d091a6db6e2d9c7b592a4b08
@@ -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)), 700))
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.1'.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.1
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);