combo_auto_box 0.0.50 → 0.0.51

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: 8f9debb2b2c340530de953873e3d271f632eaaa1
4
- data.tar.gz: 3d9312a88383e3d1c73cdf44e5eb476da784cc0f
3
+ metadata.gz: 50b086b14581ee4c93d851bdbdf89e40c85d9c1a
4
+ data.tar.gz: ca36601bbb3fd52bddb73fc0dd3a94cbf09b4439
5
5
  SHA512:
6
- metadata.gz: 70281602dc926d1b835452ed29919a6587c4c5a1355ab4d7c6fcf17b50d8550115f5be301178afa09f21e011f625eab03d84fd50f0f29459925da9ec570927cd
7
- data.tar.gz: 36d8741a23cd3800425aa23a270fe07da567522ca6b60c38bf116e34f9377c858d727d0b3094f175724cf39d267a931eee1c50d6eea357423eecb017fcd21d0b
6
+ metadata.gz: 51ceec1b461fad898b25405823d54cf9124e1bf05cd809e8a8e7905d80f91941b49a63e880b47c339d07ce70a37cc8198279104e0839ffd4dc9312e68114560b
7
+ data.tar.gz: ea89c157c85f09f0b29c48e48853367db8d6d1914374692e52d4f332fbfde2e27b92e07b85edd24f821f86a731ccd3ad330b2dd0ddfb6ddea2b3de59b365b7a9
@@ -1,3 +1,3 @@
1
1
  module ComboAutoBox
2
- VERSION = '0.0.50'
2
+ VERSION = '0.0.51'
3
3
  end
@@ -35,6 +35,7 @@ var ComboAutoBox = {
35
35
 
36
36
  $('#' + inputId).autocomplete( "close" );
37
37
  if ((options.source_not_found) && (!options.not_found_accepted)) {
38
+ dataNotFound($('#' + inputId).val());
38
39
  selectData('', '');
39
40
  } else {
40
41
  for (var i = 0; i < emails.length; i++) {
@@ -58,6 +59,7 @@ var ComboAutoBox = {
58
59
  removeLastSearchableItemForRansack();
59
60
  }
60
61
  } else if ((e.keyCode == 9) && (inputVal != '') && (options.source_not_found) && (options.type == 'simple')) {
62
+ dataNotFound($('#' + inputId).val());
61
63
  $('#' + inputId).autocomplete( "close");
62
64
  if (!options.not_found_accepted) {
63
65
  $('#' + inputId).val('');
@@ -65,6 +67,7 @@ var ComboAutoBox = {
65
67
  selectData($('#' + inputId).val(), $('#' + inputId).val());
66
68
  return true;
67
69
  } else if ((e.keyCode == 9) && (inputVal != '') && (options.source_not_found) && (options.type == 'multiple')) {
70
+ dataNotFound($('#' + inputId).val());
68
71
  $('#' + inputId).autocomplete( "close");
69
72
  var inputVal = $('#' + inputId).val().replace(/\t$/, '');
70
73
  if (options.not_found_accepted) {
@@ -93,6 +96,7 @@ var ComboAutoBox = {
93
96
  if (((e.which === 32) || (e.which === 44) || (e.which === 59)) && (options.type == 'multiple') && (options.email) && ($('#' + inputId).val().match(/[^@\s]+@([^@\s]+\.)+[^@\s]+/))) {
94
97
  $('#' + inputId).autocomplete( "close" );
95
98
  if ((options.source_not_found) && (!options.not_found_accepted)) {
99
+ dataNotFound($('#' + inputId).val());
96
100
  $('#' + inputId).val('');
97
101
  } else {
98
102
  addMultipleItem(inputId, $('#' + inputId).val(), $('#' + inputId).val());
@@ -108,6 +112,7 @@ var ComboAutoBox = {
108
112
  $('#' + inputId).autocomplete( "close" );
109
113
  selectData($('#' + inputId).val(), $('#' + inputId).val());
110
114
  } else if ((options.source_not_found) && (options.type == 'simple')) {
115
+ dataNotFound($('#' + inputId).val());
111
116
  $('#' + inputId).autocomplete( "close");
112
117
  if (!options.not_found_accepted) {
113
118
  $('#' + inputId).val('');
@@ -116,6 +121,7 @@ var ComboAutoBox = {
116
121
  } else if (options.type == 'multiple') {
117
122
  $('#' + inputId).autocomplete( "close" );
118
123
  if ((options.source_not_found) && (!options.not_found_accepted)) {
124
+ dataNotFound($('#' + inputId).val());
119
125
  $('#' + inputId).val('');
120
126
  } else {
121
127
  addMultipleItem(inputId, $('#' + inputId).val(), $('#' + inputId).val());
@@ -141,39 +147,46 @@ var ComboAutoBox = {
141
147
  });
142
148
 
143
149
  $('#' + inputId).autocomplete({
144
- source: setAutoCompleteSource(inputId),
145
- select: function(event, ui) {
146
- if ((options.source_not_found) && (options.type == 'simple')) {
150
+ source: setAutoCompleteSource(inputId),
151
+ select: function(event, ui) {
152
+ if ((options.source_not_found) && (options.type == 'simple')) {
153
+ dataNotFound($('#' + inputId).val());
147
154
  if (!options.not_found_accepted) {
148
155
  $('#' + inputId).val('');
149
156
  }
150
- selectData($('#' + inputId).val(), $('#' + inputId).val());
157
+ selectData($('#' + inputId).val(), $('#' + inputId).val());
151
158
  return false;
152
- } if ((options.source_not_found) && (options.type == 'multiple')) {
153
- var inputVal = $('#' + inputId).val();
154
- $('#' + inputId).val('');
155
- if (options.not_found_accepted) {
156
- addMultipleItem(inputId, inputVal, inputVal);
159
+ }
160
+
161
+ if ((options.source_not_found) && (options.type == 'multiple')) {
162
+ var inputVal = $('#' + inputId).val();
163
+
164
+ dataNotFound(inputVal);
165
+
166
+ $('#' + inputId).val('');
167
+ if (options.not_found_accepted) {
168
+ addMultipleItem(inputId, inputVal, inputVal);
157
169
  } else {
158
170
  inputVal = '';
159
171
  }
160
- selectData(inputVal, inputVal);
161
- return false;
162
- } else if (options.type == 'simple') {
163
- return selectData(ui.item.id, ui.item.label);
164
- } else if (options.type == 'full') {
165
- return selectData($('#' + inputId).val(), $('#' + inputId).val());
166
- } else if (options.type == 'multiple') {
167
- $('#' + inputId).val('');
168
- addMultipleItem(inputId, ui.item.id, ui.item.label);
169
- selectData(ui.item.id, ui.item.label);
170
- return false;
171
- } else if (options.type == 'searchable') {
172
- $('#' + inputId).val('');
173
- addSearchableItemForRansack(inputId, ui.item.id, ui.item.label);
174
- selectData(ui.item.id, ui.item.label);
175
- return false;
176
- }
172
+
173
+ selectData(inputVal, inputVal);
174
+ return false;
175
+ } else if (options.type == 'simple') {
176
+ return selectData(ui.item.id, ui.item.label);
177
+ } else if (options.type == 'full') {
178
+ return selectData($('#' + inputId).val(), $('#' + inputId).val());
179
+ } else if (options.type == 'multiple') {
180
+ $('#' + inputId).val('');
181
+ addMultipleItem(inputId, ui.item.id, ui.item.label);
182
+ selectData(ui.item.id, ui.item.label);
183
+ return false;
184
+ } else if (options.type == 'searchable') {
185
+ $('#' + inputId).val('');
186
+ addSearchableItemForRansack(inputId, ui.item.id, ui.item.label);
187
+ selectData(ui.item.id, ui.item.label);
188
+ return false;
189
+ }
177
190
  },
178
191
  search: function(event, ui) {
179
192
  if (options.type == 'searchable') {
@@ -911,6 +924,13 @@ var ComboAutoBox = {
911
924
  }
912
925
  };
913
926
 
927
+ // on data not found
928
+ var dataNotFound = function (selectedLabel) {
929
+ if (options.notFound != null) {
930
+ options.notFound(selectedLabel);
931
+ }
932
+ };
933
+
914
934
  // valid language or set 'en' as default
915
935
  var validLanguage = function () {
916
936
  var langs = ['math', 'en', 'pt-br', 'pt', 'es', 'fr', 'it'];
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: combo_auto_box
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.50
4
+ version: 0.0.51
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adilson Chacon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-30 00:00:00.000000000 Z
11
+ date: 2018-05-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec