auto_select2_tag 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7135570876f371fa423540127b4a28337230ef62
4
+ data.tar.gz: 08d56515f4cb65d64f3e38166768aeb7e6a1445f
5
+ SHA512:
6
+ metadata.gz: 7114555077caa79911e48da5448ba5f3dfc69506afb87378f8825ec7fddd4038cb38b40bbfe2ef0f1171fdb188c185e0cd02aa1a819f0ec0203ca50e686106db
7
+ data.tar.gz: c1e656be18e124c381ff027ce43e9638256ba3d3a272d7c46a73d34ff945e4194a233cdda6b5a2e1f34230da2bf55b84dbd3dd6ab84e0b20fd73a578cff960fe
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ .idea/*
7
+ Gemfile.lock
8
+ InstalledFiles
9
+ _yardoc
10
+ coverage
11
+ doc/
12
+ lib/bundler/man
13
+ pkg
14
+ rdoc
15
+ spec/reports
16
+ test/tmp
17
+ test/version_tmp
18
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in auto_select2_tag.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Ivan Zabrovskiy
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,69 @@
1
+ # AutoSelect2Tag
2
+
3
+ Provide tag-helper methods for create Select2 elements by the same way as any other view elements.
4
+
5
+ [![Gem Version](https://badge.fury.io/rb/auto_select2_tag.png)](http://badge.fury.io/rb/auto_select2_tag)
6
+
7
+ ## Installation
8
+
9
+ Firstly install [AutoSelect2](https://github.com/Loriowar/auto_select2#installation) with
10
+ dependency. Then add this line to your application's Gemfile:
11
+
12
+ gem 'auto_select2_tag'
13
+
14
+ And execute:
15
+
16
+ $ bundle
17
+
18
+ ## Usage
19
+
20
+ Gem provide only two helper methods for initialize select2 elements:
21
+
22
+ * select2_tag
23
+ * select2_ajax_tag
24
+
25
+ details about realization you can find on
26
+ [AutoSelect2](https://github.com/Loriowar/auto_select2#installation) page.
27
+
28
+ ### select2_tag
29
+
30
+ select2_tag(name, option_tags = nil, options = {})
31
+
32
+ Has same behavior as common
33
+ [select_tag](http://apidock.com/rails/ActionView/Helpers/FormTagHelper/select_tag). In addition
34
+ you can specify `:select2_options` in options. This parameter allow to set select2
35
+ [constructor options](http://ivaynberg.github.io/select2/).
36
+
37
+ #### Example of usage select2_tag
38
+
39
+ = select2_tag :select2_name,
40
+ my_options_for_select2(my_init_value),
41
+ placeholder: 'Fill me!',
42
+ include_blank: true,
43
+ select2_options: {width: 'auto'}
44
+
45
+ ### select2_ajax_tag
46
+
47
+ select2_ajax_tag(name, select2_searcher, value = nil, options = {})
48
+
49
+ All allowed options for this helper can be found on
50
+ [AutoSelect2](https://github.com/Loriowar/auto_select2#installation) page. look at example
51
+ below; this is an easy way to understand helper parameters.
52
+
53
+ #### Example of usage select2_ajax_tag
54
+
55
+ = select2_ajax_tag :my_select2_name,
56
+ :my_search_adapter_name,
57
+ my_init_value_id,
58
+ placeholder: 'Fill me now!',
59
+ search_method: :unusual_case,
60
+ class: 'my-select2-input',
61
+ select2_options: {additional_ajax_data: {selector: '.additional-elements'}}
62
+
63
+ ## Contributing
64
+
65
+ 1. Fork it ( http://github.com/Loriowar/auto_select2_tag/fork )
66
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
67
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
68
+ 4. Push to the branch (`git push origin my-new-feature`)
69
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'auto_select2_tag/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'auto_select2_tag'
8
+ spec.version = AutoSelect2Tag::VERSION
9
+ spec.authors = ["Dmitriy Lisichkin", "Ivan Zabrovskiy"]
10
+ spec.email = ["dima@sb42.ru", "lorowar@gmail.com"]
11
+ spec.summary = %q{Provide tag-helper methods for create Select2 elements by the same way as any other elements}
12
+ spec.description = spec.summary
13
+ spec.homepage = "https://github.com/Loriowar/auto_select2_tag"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "railties", ">= 3.1"
22
+ spec.add_dependency 'select2-rails'
23
+ spec.add_dependency 'coffee-rails'
24
+ spec.add_dependency 'auto_select2'
25
+
26
+ spec.add_development_dependency "bundler", "~> 1.5"
27
+ spec.add_development_dependency "rake"
28
+ spec.add_development_dependency "rails", "~> 3.2.12"
29
+ end
@@ -0,0 +1,37 @@
1
+ module AutoSelect2Tag
2
+ module Select2HelperTags
3
+
4
+ def select2_tag(name, option_tags = nil, options = {})
5
+ options[:class] = [options[:class], 'auto-static-select2'].compact.join(' ')
6
+ select2_options = options.delete(:select2_options)
7
+ if select2_options.present?
8
+ options[:data] = (options[:data] || {}).merge('s2options' => select2_options)
9
+ end
10
+ select_tag(name, option_tags, options)
11
+ end
12
+
13
+ def select2_ajax_tag(name, select2_searcher, value = nil, options={})
14
+ limit = options.delete(:limit)
15
+ original_classes = options.delete(:class)
16
+ original_data = options.delete(:data) || {}
17
+ select2_options = options.delete(:select2_options)
18
+ original_data.merge!('s2options' => select2_options) if select2_options.present?
19
+ search_method = options.delete(:search_method)
20
+ classes = ['auto-ajax-select2', original_classes].compact.join(' ')
21
+ controller_params = { class_name: select2_searcher }
22
+ if search_method.present?
23
+ controller_params.merge!({ search_method: search_method })
24
+ end
25
+ hidden_field_system_options = {
26
+ class: classes,
27
+ data: original_data.merge(
28
+ { href: select2_autocompletes_path(controller_params),
29
+ limit: limit.present? ? limit : 25 }
30
+ )
31
+ }
32
+ hidden_field_options = hidden_field_system_options.merge(options)
33
+ hidden_field_tag(name, value, hidden_field_options)
34
+ end
35
+
36
+ end
37
+ end
@@ -0,0 +1,5 @@
1
+ require 'auto_select2_tag/helpers/select2_helper_tags.rb'
2
+
3
+ module AutoSelect2Tag::Select2HelperTags; end
4
+
5
+ ActionView::Base.send :include, AutoSelect2Tag::Select2HelperTags
@@ -0,0 +1,3 @@
1
+ module AutoSelect2Tag
2
+ VERSION = '0.1.1'
3
+ end
@@ -0,0 +1,8 @@
1
+ require 'auto_select2_tag/version'
2
+ require 'auto_select2_tag/helpers'
3
+
4
+ module AutoSelect2Tag
5
+ class Engine < ::Rails::Engine
6
+ # Get rails to add app, lib, vendor to load path
7
+ end
8
+ end
metadata ADDED
@@ -0,0 +1,157 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: auto_select2_tag
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Dmitriy Lisichkin
8
+ - Ivan Zabrovskiy
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-11-26 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: railties
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - '>='
19
+ - !ruby/object:Gem::Version
20
+ version: '3.1'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - '>='
26
+ - !ruby/object:Gem::Version
27
+ version: '3.1'
28
+ - !ruby/object:Gem::Dependency
29
+ name: select2-rails
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - '>='
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - '>='
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: coffee-rails
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - '>='
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ type: :runtime
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - '>='
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: auto_select2
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ type: :runtime
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ - !ruby/object:Gem::Dependency
71
+ name: bundler
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ~>
75
+ - !ruby/object:Gem::Version
76
+ version: '1.5'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ~>
82
+ - !ruby/object:Gem::Version
83
+ version: '1.5'
84
+ - !ruby/object:Gem::Dependency
85
+ name: rake
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - '>='
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ type: :development
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - '>='
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ - !ruby/object:Gem::Dependency
99
+ name: rails
100
+ requirement: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ~>
103
+ - !ruby/object:Gem::Version
104
+ version: 3.2.12
105
+ type: :development
106
+ prerelease: false
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ~>
110
+ - !ruby/object:Gem::Version
111
+ version: 3.2.12
112
+ description: Provide tag-helper methods for create Select2 elements by the same way
113
+ as any other elements
114
+ email:
115
+ - dima@sb42.ru
116
+ - lorowar@gmail.com
117
+ executables: []
118
+ extensions: []
119
+ extra_rdoc_files: []
120
+ files:
121
+ - .gitignore
122
+ - Gemfile
123
+ - LICENSE.txt
124
+ - README.md
125
+ - Rakefile
126
+ - auto_select2_tag.gemspec
127
+ - lib/auto_select2_tag.rb
128
+ - lib/auto_select2_tag/helpers.rb
129
+ - lib/auto_select2_tag/helpers/select2_helper_tags.rb
130
+ - lib/auto_select2_tag/version.rb
131
+ homepage: https://github.com/Loriowar/auto_select2_tag
132
+ licenses:
133
+ - MIT
134
+ metadata: {}
135
+ post_install_message:
136
+ rdoc_options: []
137
+ require_paths:
138
+ - lib
139
+ required_ruby_version: !ruby/object:Gem::Requirement
140
+ requirements:
141
+ - - '>='
142
+ - !ruby/object:Gem::Version
143
+ version: '0'
144
+ required_rubygems_version: !ruby/object:Gem::Requirement
145
+ requirements:
146
+ - - '>='
147
+ - !ruby/object:Gem::Version
148
+ version: '0'
149
+ requirements: []
150
+ rubyforge_project:
151
+ rubygems_version: 2.0.2
152
+ signing_key:
153
+ specification_version: 4
154
+ summary: Provide tag-helper methods for create Select2 elements by the same way as
155
+ any other elements
156
+ test_files: []
157
+ has_rdoc: