auto_select2 0.5.4 → 0.5.5

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
  SHA1:
3
- metadata.gz: 4f1c055e2012182da247df66908f6fdf0e6f951a
4
- data.tar.gz: f44e5ae3cce3f1a19d5b522ad25b738552e03df2
3
+ metadata.gz: b230fd0e72d2e58bfb6c25728aa3738c9389b80c
4
+ data.tar.gz: 6bc427fd0b7d7e1d9ab66cf906d19a34b4482a07
5
5
  SHA512:
6
- metadata.gz: 022f35da345225b0559ccfbc85490df14f858fa76a20690e044fd7d3090f6b6d66b0a180134856f807711f25656a105c482d1f30287160b05d4d7d2ba4d75a25
7
- data.tar.gz: 115d3fd414588db14f967cb5395206c68cca1b163efda0454780918ac5e43c4fc8e26fd5e2a1250e2abec5c12e4daae80e6bcac249945bc365aa9eb515bb3d9b
6
+ metadata.gz: 596f421d092e950d7a753d0c7df5bf8177873ff2d85f22130b4ca34d386e8041bce2e5c978b6a8946d89208e486bbfaa06995f5a30d3e730992ad4ebe85e55d0
7
+ data.tar.gz: 35802aaca28c933e56b04e775b8fedfb42fb85cbd01d91a324171ec53dffaa278fd0540e1275cb837fce28011e7139ef9d943a95b778fd324745306142d8e33b
data/auto_select2.gemspec CHANGED
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
23
23
  spec.require_paths = ["lib"]
24
24
 
25
25
  spec.add_dependency "railties", ">= 3.1"
26
- spec.add_dependency 'select2-rails'
26
+ spec.add_dependency 'select2-rails', '~> 3.5'
27
27
  spec.add_dependency 'coffee-rails'
28
28
 
29
29
  spec.add_development_dependency "bundler", "~> 1.5"
@@ -1,3 +1,3 @@
1
1
  module AutoSelect2
2
- VERSION = '0.5.4'
2
+ VERSION = '0.5.5'
3
3
  end
@@ -37,9 +37,10 @@ jQuery ($) ->
37
37
 
38
38
  window.initAutoAjaxSelect2 = ->
39
39
  # @todo: need to refactor this hell
40
- $inputs = $('input.auto-ajax-select2').not('.select2-offscreen')
40
+ $inputs = $('input.auto-ajax-select2')
41
41
  $inputs.each ->
42
42
  $input = $(this)
43
+ return if $input.data('select2')
43
44
  path = $input.data('s2-href')
44
45
  limit = $input.data('s2-limit') || 25
45
46
  customFormatSelection = $input.data('s2-format-selection')
@@ -1,7 +1,8 @@
1
1
  jQuery ($) ->
2
2
  window.initAutoCustomSelect2 = ->
3
- $('input.auto-custom-select2').not('.select2-offscreen').each ->
3
+ $('input.auto-custom-select2').each ->
4
4
  $input = $(this)
5
+ return if $input.data('select2')
5
6
 
6
7
  s2Options = $input.data("s2-options")
7
8
  if s2Options != undefined
@@ -1,7 +1,8 @@
1
1
  jQuery ($) ->
2
2
  window.initAutoDataSelect2 = ->
3
- $('input.auto-data-select2').not('.select2-offscreen').each ->
3
+ $('input.auto-data-select2').each ->
4
4
  $input = $(this)
5
+ return if $input.data('select2')
5
6
  customFormatSelection = $input.data('s2-format-selection')
6
7
  customFormatResult = $input.data('s2-format-result')
7
8
  if customFormatSelection isnt `undefined` && (window[customFormatSelection] isnt `undefined`)
@@ -7,13 +7,16 @@ jQuery ($) ->
7
7
  data = $multi.select2('data')
8
8
  name = $multi.attr('name')
9
9
  $multi.remove()
10
+ new_name = name
11
+ if !name.endsWith('[]')
12
+ new_name = "#{name}[]"
10
13
  if data.length == 0
11
14
  # Create hidden field with blank value for detect clean select2 on server side
12
- $form.append $('<input/>', type: 'hidden', name: "#{name}[]", value: '')
15
+ $form.append $('<input/>', type: 'hidden', name: new_name, value: '')
13
16
  else
14
17
  # Create hidden fields with array-like names
15
18
  for item in data
16
- $form.append $('<input/>', type: 'hidden', name: "#{name}[]", value: item.id)
19
+ $form.append $('<input/>', type: 'hidden', name: new_name, value: item.id)
17
20
  return
18
21
  return
19
22
  return
@@ -1,8 +1,9 @@
1
1
  jQuery ($) ->
2
2
  window.initAutoStaticSelect2 = ->
3
- $("select.auto-static-select2").not(".select2-offscreen").each (index, el) ->
4
- $el = $(el)
5
- s2UserOptions = $el.data("s2options")
3
+ $("select.auto-static-select2").each ->
4
+ $input = $(this)
5
+ return if $input.data('select2')
6
+ s2UserOptions = $input.data("s2options")
6
7
 
7
8
  s2DefaultOptions =
8
9
  allowClear: true
@@ -13,7 +14,7 @@ jQuery ($) ->
13
14
  else
14
15
  s2FullOptions = $.extend({}, s2DefaultOptions, s2UserOptions)
15
16
 
16
- $el.select2(s2FullOptions)
17
+ $input.select2(s2FullOptions)
17
18
 
18
19
  return
19
20
  return
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: auto_select2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.4
4
+ version: 0.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitriy Lisichkin
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-09-02 00:00:00.000000000 Z
12
+ date: 2016-09-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: railties
@@ -29,16 +29,16 @@ dependencies:
29
29
  name: select2-rails
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - ">="
32
+ - - "~>"
33
33
  - !ruby/object:Gem::Version
34
- version: '0'
34
+ version: '3.5'
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - ">="
39
+ - - "~>"
40
40
  - !ruby/object:Gem::Version
41
- version: '0'
41
+ version: '3.5'
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: coffee-rails
44
44
  requirement: !ruby/object:Gem::Requirement