combo_auto_box 0.0.27 → 0.0.28
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.
@@ -31,13 +31,24 @@ var ComboAutoBox = {
|
|
31
31
|
} else if (options.type == 'searchable') {
|
32
32
|
removeLastSearchableItemForRansack();
|
33
33
|
}
|
34
|
-
} else if ((e.keyCode == 9) && (
|
34
|
+
} else if ((e.keyCode == 9) && (inputVal != '') && (options.source_not_found) && (options.type == 'simple')) {
|
35
35
|
$('#' + inputId).autocomplete( "close");
|
36
36
|
if (!options.not_found_accepted) {
|
37
37
|
$('#' + inputId).val('');
|
38
38
|
}
|
39
39
|
selectData($('#' + inputId).val(), $('#' + inputId).val());
|
40
40
|
return true;
|
41
|
+
} else if ((e.keyCode == 9) && (inputVal != '') && (options.source_not_found) && (options.type == 'multiple')) {
|
42
|
+
$('#' + inputId).autocomplete( "close");
|
43
|
+
var inputVal = $('#' + inputId).val().replace(/\t$/, '');
|
44
|
+
if (options.not_found_accepted) {
|
45
|
+
addMultipleItem(inputId, inputVal, inputVal);
|
46
|
+
} else {
|
47
|
+
inputVal = '';
|
48
|
+
}
|
49
|
+
selectData(inputVal, inputVal);
|
50
|
+
$('#' + inputId).val('');
|
51
|
+
return true;
|
41
52
|
}
|
42
53
|
|
43
54
|
});
|
@@ -47,7 +58,7 @@ var ComboAutoBox = {
|
|
47
58
|
if (options.type == 'full') {
|
48
59
|
$('#' + inputId).autocomplete( "close" );
|
49
60
|
selectData($('#' + inputId).val(), $('#' + inputId).val());
|
50
|
-
} else if ((options.type == 'simple')
|
61
|
+
} else if ((options.source_not_found) && (options.type == 'simple')) {
|
51
62
|
$('#' + inputId).autocomplete( "close");
|
52
63
|
if (!options.not_found_accepted) {
|
53
64
|
$('#' + inputId).val('');
|
@@ -55,7 +66,11 @@ var ComboAutoBox = {
|
|
55
66
|
selectData($('#' + inputId).val(), $('#' + inputId).val());
|
56
67
|
} else if (options.type == 'multiple') {
|
57
68
|
$('#' + inputId).autocomplete( "close" );
|
58
|
-
|
69
|
+
if ((options.source_not_found) && (!options.not_found_accepted)) {
|
70
|
+
$('#' + inputId).val('');
|
71
|
+
} else {
|
72
|
+
addMultipleItem(inputId, $('#' + inputId).val(), $('#' + inputId).val());
|
73
|
+
}
|
59
74
|
selectData($('#' + inputId).val(), $('#' + inputId).val());
|
60
75
|
$('#' + inputId).val('');
|
61
76
|
} else if (options.type == 'searchable') {
|
@@ -79,12 +94,22 @@ var ComboAutoBox = {
|
|
79
94
|
$('#' + inputId).autocomplete({
|
80
95
|
source: setAutoCompleteSource(inputId),
|
81
96
|
select: function(event, ui) {
|
82
|
-
if ((options.type == 'simple')
|
97
|
+
if ((options.source_not_found) && (options.type == 'simple')) {
|
83
98
|
if (!options.not_found_accepted) {
|
84
99
|
$('#' + inputId).val('');
|
85
100
|
}
|
86
101
|
selectData($('#' + inputId).val(), $('#' + inputId).val());
|
87
102
|
return false;
|
103
|
+
} if ((options.source_not_found) && (options.type == 'multiple')) {
|
104
|
+
var inputVal = $('#' + inputId).val();
|
105
|
+
$('#' + inputId).val('');
|
106
|
+
if (options.not_found_accepted) {
|
107
|
+
addMultipleItem(inputId, inputVal, inputVal);
|
108
|
+
} else {
|
109
|
+
inputVal = '';
|
110
|
+
}
|
111
|
+
selectData(inputVal, inputVal);
|
112
|
+
return false;
|
88
113
|
} else if (options.type == 'simple') {
|
89
114
|
return selectData(ui.item.id, ui.item.label);
|
90
115
|
} else if (options.type == 'full') {
|
@@ -128,7 +153,7 @@ var ComboAutoBox = {
|
|
128
153
|
var term = 'term=' + $('#' + inputId).val();
|
129
154
|
var params = (options.data == null) ? term : options.data + '&' + term;
|
130
155
|
$.getJSON(options.source + '?' + params, function(data) {
|
131
|
-
if ((options.type == 'simple')
|
156
|
+
if ((data.length == 0) && ((options.type == 'simple') || (options.type == 'multiple'))) {
|
132
157
|
return response(sourceForNotFound(inputId));
|
133
158
|
} else {
|
134
159
|
options.source_not_found = false;
|
@@ -140,13 +165,13 @@ var ComboAutoBox = {
|
|
140
165
|
} else {
|
141
166
|
var selectedSource = new Array();
|
142
167
|
$.each(options.source, function( index, value ){
|
143
|
-
var pattern = new RegExp($('#' + inputId).val(),'i');
|
168
|
+
var pattern = new RegExp($('#' + inputId).val(), 'i');
|
144
169
|
if (value.label.match(pattern)) {
|
145
170
|
selectedSource.push(value);
|
146
171
|
}
|
147
172
|
});
|
148
173
|
|
149
|
-
if ((options.type == 'simple')
|
174
|
+
if ((selectedSource.length == 0) && ((options.type == 'simple') || (options.type == 'multiple'))) {
|
150
175
|
return response(sourceForNotFound(inputId));
|
151
176
|
} else {
|
152
177
|
options.source_not_found = false;
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: combo_auto_box
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.28
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-05-
|
12
|
+
date: 2014-05-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|