tagsinput-rails 1.3.3.3 → 1.3.5.1

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: 934b74a2338644a3263aef30a45a6624ea877ded
4
- data.tar.gz: 6a23df1ff89d3c8af1b7f286de25ae5bedd42fc9
3
+ metadata.gz: 487a4e1b2474973c07b7d316546917d9f9abf622
4
+ data.tar.gz: 851843e94d25ebaea3132a71b95def4d2973c4eb
5
5
  SHA512:
6
- metadata.gz: 821b7f6a7be37617b5af3cfd1ebb9d2100e548de73ea055800c9859e592ca2087acbb740f0c7582442b483c0179556db6369b2d5ba6192045851f8d91f8302ae
7
- data.tar.gz: 8d59c9c40cc47398184d91dc8afb29d50dab028a2faa2deaa3d989896507cc07eb205a663b400af12e3506b9c8bbd1489035ef20145d9e5ce6b0c3b48e166776
6
+ metadata.gz: f595b25c1300a3f92c0a5212f20326aaff1ee96a46973b7d4a0f15143aeeeeb6a40275b93e02e878a16b33ebd0a5cd6ef21e16748bb6f4dd5fbbdc976d4094bd
7
+ data.tar.gz: 827e7cef8c8ea333910d21251f0bc1eb753292ba3f6493b010767bc4313e2d7ce86be0f17fdebeb0749aac9221621b4bf83892247b922117559df5dd9cf6ba59
data/README.md CHANGED
@@ -4,6 +4,10 @@ tagsinput-rails wraps the [jQuery-Tags-Input](http://xoxco.com/projects/code/tag
4
4
  use with the asset pipeline provided by rails 3.1. The gem includes the development (non-minified)
5
5
  source for ease of exploration. The asset pipeline will minify in production.
6
6
 
7
+ [![Gem Version](https://badge.fury.io/rb/tagsinput-rails.svg)](http://badge.fury.io/rb/tagsinput-rails)
8
+ [![Dependency Status](https://gemnasium.com/greshny/tagsinput-rails.svg)](https://gemnasium.com/greshny/tagsinput-rails)
9
+
10
+
7
11
  ## Installation
8
12
 
9
13
  Add this line to your application's Gemfile:
@@ -1,5 +1,5 @@
1
1
  module Tagsinput
2
2
  module Rails
3
- VERSION = '1.3.3.3'
3
+ VERSION = '1.3.5.1'
4
4
  end
5
5
  end
@@ -167,12 +167,12 @@
167
167
  return (jQuery.inArray(val, tagslist) >= 0); //true when tag exists, false when not
168
168
  };
169
169
 
170
- // clear all existing tags and import new ones from a string
171
- $.fn.importTags = function(str) {
172
- id = $(this).attr('id');
173
- $('#'+id+'_tagsinput .tag').remove();
174
- $.fn.tagsInput.importTags(this,str);
175
- }
170
+ // clear all existing tags and import new ones from a string
171
+ $.fn.importTags = function(str) {
172
+ var id = $(this).attr('id');
173
+ $('#'+id+'_tagsinput .tag').remove();
174
+ $.fn.tagsInput.importTags(this,str);
175
+ }
176
176
 
177
177
  $.fn.tagsInput = function(options) {
178
178
  var settings = jQuery.extend({
@@ -182,9 +182,9 @@
182
182
  width:'300px',
183
183
  height:'100px',
184
184
  autocomplete: {selectFirst: false },
185
- 'hide':true,
186
- 'delimiter':',',
187
- 'unique':true,
185
+ hide:true,
186
+ delimiter: ',',
187
+ unique:true,
188
188
  removeWithBackspace:true,
189
189
  placeholderColor:'#666666',
190
190
  autosize: true,
@@ -192,13 +192,23 @@
192
192
  inputPadding: 6*2
193
193
  },options);
194
194
 
195
+ var uniqueIdCounter = 0;
196
+
195
197
  this.each(function() {
198
+ // If we have already initialized the field, do not do it again
199
+ if (typeof $(this).attr('data-tagsinput-init') !== 'undefined') {
200
+ return;
201
+ }
202
+
203
+ // Mark the field as having been initialized
204
+ $(this).attr('data-tagsinput-init', true);
205
+
196
206
  if (settings.hide) {
197
207
  $(this).hide();
198
208
  }
199
209
  var id = $(this).attr('id');
200
210
  if (!id || delimiter[$(this).attr('id')]) {
201
- id = $(this).attr('id', 'tags' + new Date().getTime()).attr('id');
211
+ id = $(this).attr('id', 'tags' + new Date().getTime() + (uniqueIdCounter++)).attr('id');
202
212
  }
203
213
 
204
214
  var data = jQuery.extend({
@@ -230,7 +240,7 @@
230
240
 
231
241
  $(data.holder).css('width',settings.width);
232
242
  $(data.holder).css('min-height',settings.height);
233
- $(data.holder).css('height','100%');
243
+ $(data.holder).css('height',settings.height);
234
244
 
235
245
  if ($(data.real_input).val()!='') {
236
246
  $.fn.tagsInput.importTags($(data.real_input),$(data.real_input).val());
@@ -289,9 +299,9 @@
289
299
  });
290
300
 
291
301
  }
292
- // if user types a comma, create a new tag
302
+ // if user types a default delimiter like comma,semicolon and then create a new tag
293
303
  $(data.fake_input).bind('keypress',data,function(event) {
294
- if (event.which==event.data.delimiter.charCodeAt(0) || event.which==13 ) {
304
+ if (_checkDelimiter(event)) {
295
305
  event.preventDefault();
296
306
  if( (event.data.minChars <= $(event.data.fake_input).val().length) && (!event.data.maxChars || (event.data.maxChars >= $(event.data.fake_input).val().length)) )
297
307
  $(event.data.real_input).addTag($(event.data.fake_input).val(),{focus:true,unique:(settings.unique)});
@@ -351,4 +361,30 @@
351
361
  }
352
362
  };
353
363
 
364
+ /**
365
+ * check delimiter Array
366
+ * @param event
367
+ * @returns {boolean}
368
+ * @private
369
+ */
370
+ var _checkDelimiter = function(event){
371
+ var found = false;
372
+ if (event.which == 13) {
373
+ return true;
374
+ }
375
+
376
+ if (typeof event.data.delimiter === 'string') {
377
+ if (event.which == event.data.delimiter.charCodeAt(0)) {
378
+ found = true;
379
+ }
380
+ } else {
381
+ $.each(event.data.delimiter, function(index, delimiter) {
382
+ if (event.which == delimiter.charCodeAt(0)) {
383
+ found = true;
384
+ }
385
+ });
386
+ }
387
+
388
+ return found;
389
+ }
354
390
  })(jQuery);
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tagsinput-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.3.3
4
+ version: 1.3.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roman Greshny
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-27 00:00:00.000000000 Z
11
+ date: 2016-06-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -87,7 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
87
87
  version: '0'
88
88
  requirements: []
89
89
  rubyforge_project:
90
- rubygems_version: 2.2.2
90
+ rubygems_version: 2.5.1
91
91
  signing_key:
92
92
  specification_version: 4
93
93
  summary: The jQuery-Tags-Input jQuery plugin ready to play with the Rails Asset Pipeline