auto_select2 0.5.7 → 0.6.0
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c9be173978dccafe657015583af373a3d36cb6da
|
4
|
+
data.tar.gz: 54adb5c5be02c5d419d0f32365279b6b098f15c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc044938595f0fac64a5ac4a17673348ee9cf9f529a82e2fa48dfa7840e3edacda6cab865e0badf867239161d5d432067ef27b4feee7580306e112a1e5670d7e
|
7
|
+
data.tar.gz: 969312ba3e3bc74263e2394a564e261a5290523c6df7673e1a6fc7043697f3d17cc28e4e54e247f8886ef5c3a700448e19b3764cf4ddd32e0ef5462563d48d87
|
data/lib/auto_select2/version.rb
CHANGED
@@ -35,6 +35,22 @@ jQuery ($) ->
|
|
35
35
|
result = '<span class="'+classes.join(' ')+'">'+item.text+'</span>'
|
36
36
|
result
|
37
37
|
|
38
|
+
window.paramsCollection = ($input)->
|
39
|
+
additionalUserData = $input.data('s2-options')
|
40
|
+
paramsCollection = {}
|
41
|
+
if additionalUserData isnt `undefined`
|
42
|
+
additionalAjaxData = additionalUserData['additional_ajax_data']
|
43
|
+
if additionalAjaxData isnt `undefined`
|
44
|
+
if typeof window[additionalAjaxData['function']] == "function"
|
45
|
+
functionCollection = window[additionalAjaxData['function']]($input, term)
|
46
|
+
$(additionalAjaxData['selector']).each (index, el) ->
|
47
|
+
$el = $(el)
|
48
|
+
paramsCollection[$el.attr('name')] = $el.val()
|
49
|
+
return
|
50
|
+
$.extend(paramsCollection, additionalAjaxData['params'], functionCollection)
|
51
|
+
delete paramsCollection[$input.attr('name')]
|
52
|
+
paramsCollection
|
53
|
+
|
38
54
|
window.initAutoAjaxSelect2 = ->
|
39
55
|
# @todo: need to refactor this hell
|
40
56
|
$inputs = $('input.auto-ajax-select2')
|
@@ -66,21 +82,7 @@ jQuery ($) ->
|
|
66
82
|
dataType: 'json',
|
67
83
|
data: (term, page) ->
|
68
84
|
ajaxData = { term: term, page: page }
|
69
|
-
|
70
|
-
paramsCollection = {}
|
71
|
-
if additionalUserData isnt `undefined`
|
72
|
-
additionalAjaxData = additionalUserData['additional_ajax_data']
|
73
|
-
if additionalAjaxData isnt `undefined`
|
74
|
-
if typeof window[additionalAjaxData['function']] == "function"
|
75
|
-
functionCollection = window[additionalAjaxData['function']]($input, term)
|
76
|
-
$(additionalAjaxData['selector']).each (index, el) ->
|
77
|
-
$el = $(el)
|
78
|
-
paramsCollection[$el.attr('name')] = $el.val()
|
79
|
-
return
|
80
|
-
$.extend(paramsCollection, additionalAjaxData['params'], functionCollection)
|
81
|
-
delete paramsCollection[$input.attr('name')]
|
82
|
-
|
83
|
-
return $.extend({}, paramsCollection, ajaxData)
|
85
|
+
return $.extend({}, paramsCollection($input), ajaxData)
|
84
86
|
,
|
85
87
|
results: (data, page) ->
|
86
88
|
more = (page * limit) < data.total
|
@@ -94,14 +96,14 @@ jQuery ($) ->
|
|
94
96
|
initSelectionClassName = $element.data('init-selection-class-name')
|
95
97
|
if (id != '')
|
96
98
|
if initText != undefined
|
97
|
-
params = {
|
99
|
+
params = {id: id, text: initText}
|
98
100
|
if initClassName != undefined
|
99
101
|
params.class_name = initClassName
|
100
102
|
params.selection_class_name = initSelectionClassName
|
101
103
|
callback(params)
|
102
104
|
else
|
103
105
|
$.ajax(path, {
|
104
|
-
data: { init: true, item_ids: id
|
106
|
+
data: $.extend({}, paramsCollection($element), {init: true, item_ids: id}),
|
105
107
|
dataType: "json"
|
106
108
|
}).done((data) ->
|
107
109
|
if(data != null)
|
@@ -123,6 +125,7 @@ jQuery ($) ->
|
|
123
125
|
|
124
126
|
return
|
125
127
|
return
|
128
|
+
|
126
129
|
initAutoAjaxSelect2()
|
127
130
|
|
128
131
|
$document = $(document)
|
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.
|
4
|
+
version: 0.6.0
|
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: 2017-
|
12
|
+
date: 2017-05-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: railties
|