activeadmin-select2 0.1.4 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: adc283350cdf3d324b3d8af0ef1e74a3d59c4322
4
- data.tar.gz: b5c5dbae47f21189a47629bb2f9b123f6ece6041
3
+ metadata.gz: f43792ee420d95f4830e98ff61066bdf8d60f95a
4
+ data.tar.gz: fc9ea7e90233527b30532c4032e86464cdf772e9
5
5
  SHA512:
6
- metadata.gz: a9d97f195a17aa311e21e0d3f536c2df83ebbef547a6b3296c7401cac33e409578b113b7013ec9107093b496423cac61ab26c45b840d19373dee71e0da52c5a9
7
- data.tar.gz: 44567b554d2334863df8863ef9c28cd06429c8f2bf4c6d0b8ce8b28c8d7e33fc0a4e7b9acd959947be72a91c4c5f9416c4d7c4f00d6a9063d3ffd76ea455ce47
6
+ metadata.gz: e103104db8122dcf90df1c998e6d09abcf3557e84738d9e239deb0df404b9429a56d280d3f659c0142c8d063e4c28ef6516813b931f8b74f083cf60f080dd5b4
7
+ data.tar.gz: 0a485f2f56c2ae315ed730af95232dd7b59f6b1b104aa60be0448d914f427454a6f75b73dbb3fb6a341773ab7c666f731f78b5b367b120b75aad6de7441bfd60
@@ -1,7 +1,17 @@
1
- $(document).on 'has_many_add:after', '.has_many_container', (e, fieldset) ->
2
- fieldset.find('.select2-input').select2({allowClear: true })
1
+ 'use strict';
2
+
3
+ initSelect2 = (inputs, extra = {}) ->
4
+ inputs.each ->
5
+ item = $(this)
6
+ # reading from data allows <input data-select2='{"tags": ['some']}'> to be passed to select2
7
+ options = $.extend(allowClear: true, extra, item.data('select2'))
8
+ # because select2 reads from input.data to check if it is select2 already
9
+ item.data('select2', null)
10
+ item.select2(options)
3
11
 
12
+ $(document).on 'has_many_add:after', '.has_many_container', (e, fieldset) ->
13
+ initSelect2(fieldset.find('.select2-input'))
4
14
 
5
15
  $(document).ready ->
6
- $(".select2-input").select2 placeholder: "", allowClear: true
16
+ initSelect2($(".select2-input"), placeholder: "")
7
17
  return
@@ -3,4 +3,5 @@ require 'activeadmin/select2'
3
3
  require 'activeadmin/inputs/filter_select2_multiple_input'
4
4
  require 'formtastic/inputs/select2_input'
5
5
  require 'formtastic/inputs/select2_multiple_input'
6
+ require 'formtastic/inputs/select2_tags_input'
6
7
 
@@ -1,5 +1,5 @@
1
1
  module ActiveAdmin
2
2
  module Select2
3
- VERSION = "0.1.4"
3
+ VERSION = "0.1.5"
4
4
  end
5
5
  end
@@ -0,0 +1,16 @@
1
+ require 'formtastic/inputs/string_input'
2
+
3
+ module Formtastic
4
+ module Inputs
5
+
6
+ class Select2TagsInput < Formtastic::Inputs::StringInput
7
+ def input_html_options
8
+ {
9
+ class: 'select2-input select2-tags-input',
10
+ data: { select2: { tags: options[:collection] }}
11
+ }.merge(super)
12
+ end
13
+ end
14
+
15
+ end
16
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activeadmin-select2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Fairburn
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-04 00:00:00.000000000 Z
11
+ date: 2014-09-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -106,6 +106,7 @@ files:
106
106
  - lib/activeadmin/select2/version.rb
107
107
  - lib/formtastic/inputs/select2_input.rb
108
108
  - lib/formtastic/inputs/select2_multiple_input.rb
109
+ - lib/formtastic/inputs/select2_tags_input.rb
109
110
  homepage: https://github.com/mfairburn/activeadmin-select2#readme
110
111
  licenses:
111
112
  - MIT