effective_datatables 4.22.3 → 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: 59a32fa9af3a17a46a2f0ba0149dc47a1d6b58301b36a8ee73824552867b1b38
4
- data.tar.gz: e0f6bfaf0037d47b7be43d8ca71f47cf72ca3c547c61a8cf65b1cf4e3fcc8fb2
3
+ metadata.gz: 75aeba8a18f22cd6b4e5b0761e166ae919a10a59c77c918881cb117e13f76932
4
+ data.tar.gz: d84af5dea6afa6093d35a3421f2708321b63bf4f7e3706a28eb5cdd004bb9de7
5
5
  SHA512:
6
- metadata.gz: 1397ea1f8d7941a37cfe0da34a53b0f23843ec72d4200314ac496a9446306f077267a4c261eba9de14b00f6c0943238175613101c5d6c11053fefcd7fba88fc6
7
- data.tar.gz: 5590659c494da1e65936d9ed42eb4f95d56a57e079e2ead6a9b9cb210b8ba9feba4952c21ac56c54bab4b6820b013b30077df79276fc468b71a177d0d75193e3
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
@@ -35,22 +35,6 @@ module Effective
35
35
 
36
36
  # Assign namespace based off controller path unless given
37
37
  @attributes[:namespace] ||= view.controller_path.split('/')[0...-1].join('/')
38
-
39
- # If there are attributes[:user_type] and attributes[:user_id] type attributes load them into attributes[:user]
40
- resource_attributes = @attributes.select do |key, value|
41
- name = key.to_s
42
- base = name.sub('_type', '')
43
-
44
- name.ends_with?('_type') && @attributes.key?("#{base}_id".to_sym) && value.safe_constantize.present?
45
- end
46
-
47
- resource_attributes.each do |key, value|
48
- name = key.to_s
49
- base = name.sub('_type', '')
50
-
51
- klass = value.constantize
52
- @attributes[base.to_sym] ||= klass.find_by_id(attributes["#{base}_id".to_sym])
53
- end
54
38
  end
55
39
 
56
40
  end
@@ -1,3 +1,3 @@
1
1
  module EffectiveDatatables
2
- VERSION = '4.22.3'.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.22.3
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-30 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);