jquery_textcomplete 0.1.8 → 0.1.9

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
- SHA1:
3
- metadata.gz: 09941941f5d42754ad0b5945d434e350aaa6ba13
4
- data.tar.gz: 84370c46d1c25f88eab5ba9c4190c2581d75d1ff
2
+ SHA256:
3
+ metadata.gz: cbfd8a164a1bdf2cbe143d4f1009b2025b96a360bf0d8d00545eed84c7dfbe2a
4
+ data.tar.gz: f50c64af8b2959bc1bdf096bbc14b6ad869a1415c52bc7539ef8fdd64b6f6ee9
5
5
  SHA512:
6
- metadata.gz: aeb22004a89c09f7f13eccb4e2d5c29df9875a4894905f7f5a4675b7175ef78080f517a8e5a4bcb0c6f0e2f2737dcaba30c30368c7374e83014ff3d6126dc8b1
7
- data.tar.gz: ac9409f36c3f883ff9e8dad56eba393b79b462350464c24ed76ef9ffc4d9fbd76c63a3690b1f4a5ee0b30dc5411f9b523c677bb335a02c698c6cf453fb211c70
6
+ metadata.gz: c3b55d23d6ee124e9439e5dc57be8d166752e2ad11af6a1daa96b8eb54ce371e9c40ffbc23c26b7dc90d4e63b8ee7c8ff40f2bc199b0d72814c425593b2f5427
7
+ data.tar.gz: 9d033d3e03d06ac3cc9d4391f7b6947a78a46fe0327bee071be6898317022e7aceb64975c8758fcc463843c58085eda9e91c0028a1ee869e511f0b95dbac4b87
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # JqueryTextcomplete
2
2
 
3
- JqueryTextcomplete can be used for autocompleting search fields, tags in textareas, and other textfield inputs! Compatible with Ruby on Rails applications, can be used in conjunction with acts-as-taggable-on gem for autocomplete tagging, requires Jquery.
3
+ JqueryTextcomplete can be used for autocompleting search fields, tags in textareas, and other textfield inputs! Compatible with Ruby on Rails applications, can be used in conjunction with [searchkick](https://github.com/ankane/searchkick) gem for returning autocomplete results and with [acts-as-taggable-on](https://github.com/mbleigh/acts-as-taggable-on) gem for autocomplete tagging. Requires Jquery.
4
4
 
5
5
  ## Installation
6
6
 
@@ -20,13 +20,68 @@ Or install it yourself as:
20
20
 
21
21
  ## Usage
22
22
 
23
- Include in your application.js file:
23
+ Include in your `application.js` file:
24
24
 
25
25
  //= require jquery.textcomplete
26
26
 
27
- Include in your application.scss file:
27
+ Include in your `application.scss` file:
28
+
29
+ *= require jquery.textcomplete
30
+
31
+ Example usage:
32
+
33
+ In views:
34
+
35
+ <script type="text/javascript">
36
+ addTextCompleteForHashtagsAndUsertags($('.textcomplete'));
37
+ </script>
38
+
39
+ In `application.js`:
40
+
41
+ function addTextCompleteForHashtagsAndUsertags($textarea) {
42
+ $textarea.textcomplete([
43
+ {
44
+ // Usertag strategy
45
+ match: /(\s|^)@([^\s]+)$/,
46
+ search: function (term, callback) {
47
+ $.getJSON('/users/autocomplete_usertag', { query: term })
48
+ .done(function (resp) { callback(resp); })
49
+ .fail(function () { callback([]); });
50
+ },
51
+ replace: function (value) {
52
+ return '$1' + value + ' ';
53
+ }
54
+ },
55
+ {
56
+ // Hashtag strategy
57
+ match: /(\s|^)#(\w+)$/,
58
+ search: function (term, callback) {
59
+ $.getJSON('/posts/autocomplete_hashtag', { query: term })
60
+ .done(function (resp) { callback(resp); })
61
+ .fail(function () { callback([]); });
62
+ },
63
+ replace: function (value) {
64
+ return '$1' + value + ' ';
65
+ }
66
+ }
67
+ ]);
68
+ }
69
+
70
+ In `users_controller.rb`:
71
+
72
+ def autocomplete_usertag
73
+ render json: User.search(params[:query], {
74
+ fields: ["name"],
75
+ limit: 10,
76
+ load: false,
77
+ misspellings: {below: 2}
78
+ }).map{|user| user.name.downcase.prepend('@').split(' ').join('.')}
79
+ end
80
+
81
+ In `routes.rb`:
82
+
83
+ get 'autocomplete_usertag' => 'users#autocomplete_usertag', on: :collection
28
84
 
29
- //= require jquery.textcomplete
30
85
 
31
86
  For more options and style customization, please, see [jQuery Textcomplete documentation](https://github.com/yuku-t/jquery-textcomplete).
32
87
 
@@ -10,8 +10,8 @@ Gem::Specification.new do |spec|
10
10
  spec.authors = ["Sebastian Peterlin"]
11
11
  spec.email = ["speterlin@gmail.com"]
12
12
 
13
- spec.summary = %q{JqueryTextcomplete can be used for autocompleting search fields, tags in textareas, and other textfield inputs!}
14
- spec.description = %q{JqueryTextcomplete can be used for autocompleting search fields, tags in textareas, and other textfield inputs! Compatible with Ruby on Rails applications, can be used in conjunction with acts-as-taggable-on gem for autocomplete tagging, requires Jquery.}
13
+ spec.summary = %q{JqueryTextcomplete is a Ruby on Rails gem enabling text autocomplete in search fields, tags in textareas, and other textfield inputs!}
14
+ spec.description = %q{JqueryTextcomplete can be used for autocompleting search fields, tags in textareas, and other textfield inputs! Compatible with Ruby on Rails applications, can be used in conjunction with searchkick gem for returning autocomplete results and with acts-as-taggable-on gem for autocomplete tagging. Requires Jquery.}
15
15
  spec.homepage = "http://github.com/speterlin/jquery_textcomplete"
16
16
  spec.license = "MIT"
17
17
 
@@ -31,8 +31,11 @@ Gem::Specification.new do |spec|
31
31
  spec.add_development_dependency "bundler", "~> 1.12"
32
32
  spec.add_development_dependency "rake", "~> 10.0"
33
33
  spec.add_development_dependency "rspec", "~> 3.0"
34
- # to be able to use sass, not sure if I need sass gem, maybe replace rails with railties
34
+
35
35
  spec.add_dependency "rails", "~> 5.0"
36
+ # to be able to use sass, not sure if I need sass gem, maybe replace rails with railties
36
37
  spec.add_dependency "sass", "~> 3.0"
37
38
  spec.add_dependency "sass-rails", "~> 5.0"
39
+ # maybe add spec.add_dependency 'jquery-rails' and spec.add_dependency 'jquery-ui-rails'
40
+
38
41
  end
@@ -1,3 +1,3 @@
1
1
  module JqueryTextcomplete
2
- VERSION = "0.1.8"
2
+ VERSION = "0.1.9"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jquery_textcomplete
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sebastian Peterlin
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-04-23 00:00:00.000000000 Z
11
+ date: 2018-05-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -96,8 +96,8 @@ dependencies:
96
96
  version: '5.0'
97
97
  description: JqueryTextcomplete can be used for autocompleting search fields, tags
98
98
  in textareas, and other textfield inputs! Compatible with Ruby on Rails applications,
99
- can be used in conjunction with acts-as-taggable-on gem for autocomplete tagging,
100
- requires Jquery.
99
+ can be used in conjunction with searchkick gem for returning autocomplete results
100
+ and with acts-as-taggable-on gem for autocomplete tagging. Requires Jquery.
101
101
  email:
102
102
  - speterlin@gmail.com
103
103
  executables: []
@@ -140,9 +140,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
140
140
  version: '0'
141
141
  requirements: []
142
142
  rubyforge_project:
143
- rubygems_version: 2.5.1
143
+ rubygems_version: 2.7.6
144
144
  signing_key:
145
145
  specification_version: 4
146
- summary: JqueryTextcomplete can be used for autocompleting search fields, tags in
147
- textareas, and other textfield inputs!
146
+ summary: JqueryTextcomplete is a Ruby on Rails gem enabling text autocomplete in search
147
+ fields, tags in textareas, and other textfield inputs!
148
148
  test_files: []