auto_select2 0.3.1 → 0.3.2
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.
Potentially problematic release.
This version of auto_select2 might be problematic. Click here for more details.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f6ec2faf3d1f40f1243e6a566865958b0f59a20f
|
4
|
+
data.tar.gz: 2a230eb36e1c113f54730c7916b7a1631753126e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f236f8dc081fc3dca44db0467e34b25d48417edcecbf63211f16582904ebd1f699cacbdcac4e4e6c873d2cf01b5cfe9585b007901b513c0b2210bb5d11c16804
|
7
|
+
data.tar.gz: 11eed5a4bf969b153749dc6687ce8ce2d20d44f9f0a3e67513fd0ffbdebafbc45685cf75404c837595ec61acf362bf35cb59b069db7a647dcdbe9990eb4a6ce4
|
data/README.md
CHANGED
@@ -103,7 +103,7 @@ following to your `app/assets/javascripts/application.js`:
|
|
103
103
|
### Select2 options
|
104
104
|
|
105
105
|
If you want to specify any parameters for [select2 constructor](http://ivaynberg.github.io/select2/)
|
106
|
-
you can pass it as hash into data-attribute `
|
106
|
+
you can pass it as hash into data-attribute `s2-options`. This parameter handle most options
|
107
107
|
but you can't pass through js-functions.
|
108
108
|
|
109
109
|
### Static select2 usage
|
@@ -116,7 +116,7 @@ For initialize static select2 you must set `auto-static-select2` css-class for s
|
|
116
116
|
|
117
117
|
For initialize ajax select 2 you must set `auto-ajax-select2` css-class for hidden-input element.
|
118
118
|
Then you have two ways. Easy way for simple selection: specify `default_class_name`, `default_text_column` and
|
119
|
-
`default_id_column` as params for `:href` within data-attribute `
|
119
|
+
`default_id_column` as params for `:href` within data-attribute `s2-options` (look at the end of this section).
|
120
120
|
Other way for custom selection: create `SearchAdapter`. This adapter has following requirements:
|
121
121
|
|
122
122
|
* class must be inherited from `AutoSelect2::Select2SearchAdapter::Base`
|
@@ -153,7 +153,7 @@ element with 42 variants. Function `search_default` return part of it in `items`
|
|
153
153
|
More about this function you can find in [example project](https://github.com/Loriowar/auto-select2_tag_example),
|
154
154
|
in example below and in source code.
|
155
155
|
|
156
|
-
Finally hidden-input must has `:href` parameter in data-attribute `
|
156
|
+
Finally hidden-input must has `:href` parameter in data-attribute `s2-options`. This
|
157
157
|
parameter specify url for ajax load select options. You can use helper
|
158
158
|
|
159
159
|
select2_autocompletes_path(class_name: :my_class_name)
|
@@ -198,7 +198,7 @@ near the `search_default` in `SearchAdapter`. Requirement for non-default search
|
|
198
198
|
* it must has same behavior as search_default
|
199
199
|
* name of methods must start with `search_`
|
200
200
|
|
201
|
-
For use custom searcher specify it into `:href` within data-attribute `
|
201
|
+
For use custom searcher specify it into `:href` within data-attribute `s2-options`:
|
202
202
|
|
203
203
|
select2_autocompletes_path(class_name: MyClassName, search_method: :unusual_case)
|
204
204
|
|
@@ -207,13 +207,13 @@ select options depend from another field on page. For this purpose you can speci
|
|
207
207
|
|
208
208
|
additional_ajax_data: {selector: 'input.css-class'}
|
209
209
|
|
210
|
-
inside data-attribute `
|
210
|
+
inside data-attribute `s2-options`. In this case in options of `SearchAdapter` appear
|
211
211
|
additional values. It construct from name and value of html-elements. Example:
|
212
212
|
|
213
213
|
= hidden_field_tag 'token', 'VUBJKB23UIVI1UU1VOBVI@', class: 'add-to-select2'
|
214
214
|
= hidden_field_tag 'select2element', '',
|
215
215
|
class: 'auto-ajax-select2',
|
216
|
-
data: {
|
216
|
+
data: {s2-options: { href: select2_autocompletes_path(class_name: :adapter_name,
|
217
217
|
search_method: :unusual_case),
|
218
218
|
additional_ajax_data: {selector: '.add-to-select2'}}}
|
219
219
|
|
@@ -229,11 +229,11 @@ icons for different select variants.
|
|
229
229
|
This feature require absolutely same things as ajax select2. Additionally you must
|
230
230
|
add `multiple` css-class for input element, doesn't forget about
|
231
231
|
`multi_ajax_select2_value_parser.js` script and pass `multiple: true` into
|
232
|
-
data-attribute `
|
232
|
+
data-attribute `s2-options`.
|
233
233
|
|
234
234
|
### Different multi ajax select2
|
235
235
|
|
236
|
-
Honestly speaking you can just pass `multiple: true` into data-attribute `
|
236
|
+
Honestly speaking you can just pass `multiple: true` into data-attribute `s2-options` and
|
237
237
|
ajax-select2 become multiple. But in this case selected options from select2 become as
|
238
238
|
comma separated string. As opposed to it `multi_ajax_select2_value_parser.js` make array
|
239
239
|
of multiple ids. This is more comfortable for use in controller.
|
data/lib/auto_select2/version.rb
CHANGED
@@ -0,0 +1,28 @@
|
|
1
|
+
jQuery ($) ->
|
2
|
+
window.initAutoDataSelect2 = ->
|
3
|
+
$('input.auto-data-select2').not('.select2-offscreen').each ->
|
4
|
+
$input = $(this)
|
5
|
+
customFormatSelection = $input.data('s2-format-selection')
|
6
|
+
customFormatResult = $input.data('s2-format-result')
|
7
|
+
if customFormatSelection isnt `undefined` && (window[customFormatSelection] isnt `undefined`)
|
8
|
+
formatSelectionFunc = window[customFormatSelection]
|
9
|
+
if (customFormatResult isnt `undefined`) && (window[customFormatResult] isnt `undefined`)
|
10
|
+
formatResultFunc = window[customFormatResult]
|
11
|
+
$input.select2({
|
12
|
+
data: $input.data('s2-data')
|
13
|
+
formatSelection: formatSelectionFunc
|
14
|
+
formatResult: formatResultFunc
|
15
|
+
})
|
16
|
+
return
|
17
|
+
return
|
18
|
+
|
19
|
+
|
20
|
+
$body = $('body')
|
21
|
+
$body.on 'ajaxSuccess', ->
|
22
|
+
initAutoDataSelect2()
|
23
|
+
return
|
24
|
+
|
25
|
+
$body.on 'cocoon:after-insert', ->
|
26
|
+
initAutoDataSelect2()
|
27
|
+
return
|
28
|
+
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.3.
|
4
|
+
version: 0.3.2
|
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: 2015-
|
12
|
+
date: 2015-02-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: railties
|
@@ -124,6 +124,7 @@ files:
|
|
124
124
|
- lib/auto_select2/select2_search_adapter/default.rb
|
125
125
|
- lib/auto_select2/version.rb
|
126
126
|
- vendor/assets/javascripts/auto_select2/ajax_select2.js.coffee
|
127
|
+
- vendor/assets/javascripts/auto_select2/data_select2.js.coffee
|
127
128
|
- vendor/assets/javascripts/auto_select2/multi_ajax_select2_value_parser.js.coffee
|
128
129
|
- vendor/assets/javascripts/auto_select2/static_select2.js.coffee
|
129
130
|
homepage: https://github.com/Loriowar/auto_select2
|