rails-jquery-tokeninput 0.2.3 → 0.2.4

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
  !binary "U0hBMQ==":
3
- metadata.gz: a3bcd9bfc4bc7929b9a87dfdd7e49d3c33e0084e
4
- data.tar.gz: 70d255d467b289caf9491266693bf1b1239c1183
3
+ metadata.gz: 11c59b6682b7ce709c4a6a7998e8eb730cf0439a
4
+ data.tar.gz: fc4992bff17cf83dab322d113ee2358fbc1f2756
5
5
  SHA512:
6
- metadata.gz: bfe6e84930642e94027be845f757e88e291424e7db10eaa9fef13a4a9001ceda638966b2c026cd28ec31f4d803e094e77d8eb5939e0f7b447c04e3a725754c18
7
- data.tar.gz: 6256ad90fd42912bf007a0527d497ad83a5acc5ada3c137934392acafa622873176362e40f510457a3d93bc5808ef481bd0ecc680e6c420b281da6e9066a5ff2
6
+ metadata.gz: a12f0be7d001714a49fd660d9aef5d11853ef722b1432372aea52c81cd4fe67cb2bf708530240999f12efb94b2cfdd203fe0a07fba5ee064d4ff8adb6274f2a0
7
+ data.tar.gz: 3164972f37173f5dddf259d39fa5794c75a8cf3908ab23b8574e827add64cb8d3a57ce95be77e94ca53756fa8ac5ea156fd1d87ecda994ececcf1d784821e899
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ .ruby-version
2
+ Gemfile.lock
3
+ spec/dummy/log/test.log
4
+ spec/dummy/tmp/
@@ -2,36 +2,42 @@
2
2
  //= require jquery.tokeninput
3
3
 
4
4
  $(function() {
5
+ var DEFAULTS = {
6
+ options: { tokenValue: 'id' },
7
+ source: []
8
+ };
9
+
5
10
  $.each($('input[data-tokeninput]'), function(index, input) {
6
11
  var inputName = $(input).attr('name');
7
- var options = $(input).data('tokeninput').options || {};
12
+ var source = $(input).data('tokeninput').collection || DEFAULTS.source;
13
+ var options = $(input).data('tokeninput').options || DEFAULTS.options;
8
14
 
9
- var add_input = function(value) {
10
- var inputItemName = inputName + '[]';
15
+ var addInput = function(value) {
16
+ var inputItemName = inputName + '[]';
11
17
  $('<input name="' + inputItemName + '" type="text" style="display: none;" value="' + value + '">').insertAfter(input);
12
18
  }
13
19
 
14
- var add_item = function(item) {
15
- var inputItemValue = item[$(input).data('tokeninput').options.tokenValue || 'id'];
16
- add_input(inputItemValue);
20
+ var addItem = function(item) {
21
+ var inputItemValue = item[options.tokenValue];
22
+ addInput(inputItemValue);
17
23
  }
18
24
 
19
- $(input).attr('name', '');
20
-
21
- options.onAdd = add_item;
22
-
23
- options.onDelete = function(item) {
24
- var inputItemValue = item[$(input).data('tokeninput').options.tokenValue || 'id'];
25
+ var deleteItem = function(item) {
26
+ var inputItemValue = item[options.tokenValue];
25
27
  $('input[value="' + inputItemValue + '"]').remove();
26
- add_input('');
28
+ addInput('');
27
29
  };
28
30
 
31
+ options.onAdd = addItem;
32
+ options.onDelete = deleteItem;
33
+
29
34
  if(options.prePopulate) {
30
35
  $.each(options.prePopulate, function(index, itemToPrePopulate) {
31
- add_item(itemToPrePopulate)
36
+ addItem(itemToPrePopulate)
32
37
  });
33
38
  }
34
39
 
35
- $(input).tokenInput($(input).data('tokeninput').collection, options);
40
+ $(input).attr('name', '');
41
+ $(input).tokenInput(source, options);
36
42
  });
37
43
  });
@@ -1,7 +1,7 @@
1
1
  module Rails
2
2
  module Jquery
3
3
  module Tokeninput
4
- VERSION = '0.2.3'
4
+ VERSION = '0.2.4'
5
5
  end
6
6
  end
7
7
  end
@@ -18,12 +18,13 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ['lib']
20
20
 
21
- spec.add_dependency 'jquery-rails'
21
+ spec.add_dependency 'jquery-rails', '~> 2'
22
22
 
23
- spec.add_development_dependency 'activemodel'
23
+ spec.add_development_dependency 'activemodel', '~> 4.1.9'
24
+ spec.add_development_dependency 'actionpack', '~> 4.1.9'
24
25
  spec.add_development_dependency 'sprockets-rails'
25
-
26
26
  spec.add_development_dependency 'rspec-rails'
27
27
  spec.add_development_dependency 'capybara'
28
28
  spec.add_development_dependency 'poltergeist'
29
+ spec.add_development_dependency 'pry-byebug'
29
30
  end
@@ -1,3 +1,5 @@
1
+ require 'active_model'
2
+
1
3
  class World
2
4
  include ActiveModel::Conversion
3
5
  extend ActiveModel::Naming
@@ -10,3 +10,4 @@
10
10
  # Make sure your secret_key_base is kept private
11
11
  # if you're sharing your code publicly.
12
12
  Dummy::Application.config.secret_key_base = '72b84484d1fdd5faa3ff6b09182a13b26010880c681bd3f6c575f61cdca53640d08c344fd97cb2e058ff713264ce780439d6fa3bd0ada716309de98520efbccd'
13
+ Dummy::Application.config.secret_token = '72b84484d1fdd5faa3ff6b09182a13b26010880c681bd3f6c575f61cdca53640d08c344fd97cb2e058ff713264ce780439d6fa3bd0ada716309de98520efbccd'
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
  require 'features/pages/world_page'
3
3
 
4
- feature 'Tokeninput:' do
4
+ feature 'Tokeninput' do
5
5
  let(:world_page) { WorldPage.new(root_path) }
6
6
  let(:country) { Country.first }
7
7
 
@@ -22,8 +22,4 @@ feature 'Tokeninput:' do
22
22
 
23
23
  expect(world_page.response['countries']).to match_array([country[:iso_code]])
24
24
  end
25
-
26
- scenario 'adding and removing tokens', js: true do
27
- pending 'will come soon'
28
- end
29
25
  end
data/spec/spec_helper.rb CHANGED
@@ -6,5 +6,6 @@ require 'rspec/rails'
6
6
  require 'capybara/rspec'
7
7
  require 'capybara/rails'
8
8
  require 'capybara/poltergeist'
9
+ require 'pry-byebug'
9
10
 
10
11
  Capybara.javascript_driver = :poltergeist
metadata CHANGED
@@ -1,43 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-jquery-tokeninput
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evgeny Li
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-25 00:00:00.000000000 Z
11
+ date: 2015-02-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jquery-rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ! '>='
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '2'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ! '>='
24
+ - - ~>
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: '2'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activemodel
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ! '>='
31
+ - - ~>
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: 4.1.9
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ! '>='
38
+ - - ~>
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: 4.1.9
41
+ - !ruby/object:Gem::Dependency
42
+ name: actionpack
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: 4.1.9
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 4.1.9
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: sprockets-rails
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -94,6 +108,20 @@ dependencies:
94
108
  - - ! '>='
95
109
  - !ruby/object:Gem::Version
96
110
  version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: pry-byebug
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ! '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
97
125
  description: rails-jquery-tokeninput project integrates Tokeninput jQuery plugin which
98
126
  allows your users to select multiple items from a predefined list, using autocompletion
99
127
  as they type to find each item
@@ -103,6 +131,7 @@ executables: []
103
131
  extensions: []
104
132
  extra_rdoc_files: []
105
133
  files:
134
+ - .gitignore
106
135
  - .rspec
107
136
  - .travis.yml
108
137
  - Gemfile