select2_rails 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +5 -0
- data/Gemfile +4 -0
- data/README.md +76 -0
- data/Rakefile +9 -0
- data/lib/select2_rails/engine.rb +6 -0
- data/lib/select2_rails/source_file.rb +47 -0
- data/lib/select2_rails/version.rb +5 -0
- data/lib/select2_rails.rb +7 -0
- data/select2_rails.gemspec +22 -0
- data/vendor/assets/javascripts/select2.full.js +6219 -0
- data/vendor/assets/javascripts/select2.js +5508 -0
- data/vendor/assets/javascripts/select2_locale_az.js +3 -0
- data/vendor/assets/javascripts/select2_locale_bg.js +3 -0
- data/vendor/assets/javascripts/select2_locale_ca.js +3 -0
- data/vendor/assets/javascripts/select2_locale_cs.js +3 -0
- data/vendor/assets/javascripts/select2_locale_da.js +3 -0
- data/vendor/assets/javascripts/select2_locale_de.js +3 -0
- data/vendor/assets/javascripts/select2_locale_en.js +3 -0
- data/vendor/assets/javascripts/select2_locale_es.js +3 -0
- data/vendor/assets/javascripts/select2_locale_et.js +3 -0
- data/vendor/assets/javascripts/select2_locale_eu.js +3 -0
- data/vendor/assets/javascripts/select2_locale_fa.js +3 -0
- data/vendor/assets/javascripts/select2_locale_fi.js +3 -0
- data/vendor/assets/javascripts/select2_locale_fr.js +3 -0
- data/vendor/assets/javascripts/select2_locale_gl.js +3 -0
- data/vendor/assets/javascripts/select2_locale_he.js +3 -0
- data/vendor/assets/javascripts/select2_locale_hi.js +3 -0
- data/vendor/assets/javascripts/select2_locale_hr.js +3 -0
- data/vendor/assets/javascripts/select2_locale_hu.js +3 -0
- data/vendor/assets/javascripts/select2_locale_id.js +3 -0
- data/vendor/assets/javascripts/select2_locale_is.js +3 -0
- data/vendor/assets/javascripts/select2_locale_it.js +3 -0
- data/vendor/assets/javascripts/select2_locale_ko.js +3 -0
- data/vendor/assets/javascripts/select2_locale_lt.js +3 -0
- data/vendor/assets/javascripts/select2_locale_lv.js +3 -0
- data/vendor/assets/javascripts/select2_locale_mk.js +3 -0
- data/vendor/assets/javascripts/select2_locale_nb.js +3 -0
- data/vendor/assets/javascripts/select2_locale_nl.js +3 -0
- data/vendor/assets/javascripts/select2_locale_pl.js +3 -0
- data/vendor/assets/javascripts/select2_locale_pt-BR.js +3 -0
- data/vendor/assets/javascripts/select2_locale_pt.js +3 -0
- data/vendor/assets/javascripts/select2_locale_ro.js +3 -0
- data/vendor/assets/javascripts/select2_locale_ru.js +3 -0
- data/vendor/assets/javascripts/select2_locale_sk.js +3 -0
- data/vendor/assets/javascripts/select2_locale_sr.js +3 -0
- data/vendor/assets/javascripts/select2_locale_sv.js +3 -0
- data/vendor/assets/javascripts/select2_locale_th.js +3 -0
- data/vendor/assets/javascripts/select2_locale_tr.js +3 -0
- data/vendor/assets/javascripts/select2_locale_uk.js +3 -0
- data/vendor/assets/javascripts/select2_locale_vi.js +3 -0
- data/vendor/assets/javascripts/select2_locale_zh-CN.js +3 -0
- data/vendor/assets/javascripts/select2_locale_zh-TW.js +3 -0
- data/vendor/assets/stylesheets/select2-bootstrap.css +598 -0
- data/vendor/assets/stylesheets/select2.css +479 -0
- metadata +156 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 635b259bd970d56d8e363ba7e08ca9bc09d6f985
|
4
|
+
data.tar.gz: 26fb18b01bdb78c33b8a59e5e906314ab8677fc1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a71362f256f6c40489a5644d13593f2f0e617d0809c9e13c23ddd0b823c752a1a429cb7c8c4240b85539ad56d5c07fad6fe4a487328fc8d0124d88526113ec8b
|
7
|
+
data.tar.gz: 711b6c084a7475a9a61cca2fe5fbf73b6aa1b4cca73f947cfece1086f932ca49804e1c5a26855ea9d2e935ba74a9d42695e1d8ebcb8f756f5b54c77140f87673
|
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
#Select2 for Rails asset pipeline
|
2
|
+
|
3
|
+
[Select2](https://github.com/select2/select2) is a jQuery based replacement for select boxes. It supports searching, remote data sets, and infinite scrolling of results.
|
4
|
+
|
5
|
+
This repo is a continuation of the dead [select2-rails](https://github.com/argerim/select2-rails) project.
|
6
|
+
|
7
|
+
The `select2_rails` gem integrates the `Select2` jQuery plugin with the Rails asset pipeline.
|
8
|
+
|
9
|
+
[](http://badge.fury.io/rb/select2-rails)
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
### Install select2_rails gem
|
14
|
+
|
15
|
+
Add `select2_rails` to your Gemfile and run `bundle install`:
|
16
|
+
|
17
|
+
gem "select2_rails"
|
18
|
+
|
19
|
+
### Include select2_rails javascript assets
|
20
|
+
|
21
|
+
Add the following to your `app/assets/javascripts/application.js`:
|
22
|
+
|
23
|
+
//= require select2
|
24
|
+
|
25
|
+
alternatively, for the [full build](http://select2.github.io#builds):
|
26
|
+
|
27
|
+
//= require select2.full
|
28
|
+
|
29
|
+
### Include select2_rails stylesheet assets
|
30
|
+
|
31
|
+
Add to your `app/assets/stylesheets/application.css`:
|
32
|
+
|
33
|
+
*= require select2
|
34
|
+
|
35
|
+
If you are using Twitter Boostrap you need to also require the bootstrap theme CSS in addition to the above require.
|
36
|
+
|
37
|
+
*= require select2-bootstrap
|
38
|
+
|
39
|
+
To apply the theme, tell Select2 to do so by passing `bootstrap` to the [`theme`](https://select2.github.io/examples.html#themes) option when initializing Select2:
|
40
|
+
|
41
|
+
$( "#dropdown" ).select2({
|
42
|
+
theme: "bootstrap"
|
43
|
+
});
|
44
|
+
|
45
|
+
## Internationalization (i18n)
|
46
|
+
|
47
|
+
The `select2_rails` now supports multiple languages.
|
48
|
+
|
49
|
+
Add the following to your `app/assets/javascripts/application.js`:
|
50
|
+
|
51
|
+
//= require select2_locale_"any possible language"
|
52
|
+
|
53
|
+
Possible languages:
|
54
|
+
|
55
|
+
az, bg, ca, cs, da, de, en, es, et, eu, fi, fr, gl, hi, hr, hu, id, is, it, lt, lv, mk, nb, nl, pl, pt-BR, pt, ro, ru, sk, sr, sv, th, tr, uk, vi, zh-CN, zh-TW
|
56
|
+
|
57
|
+
## Fix
|
58
|
+
### IE8 Invalid Character
|
59
|
+
IE8 doesn't support some unescaped Unicode character and need to quote keys in object literals
|
60
|
+
You need some configurations for [Uglifier](https://github.com/lautis/uglifier) to do the work.
|
61
|
+
Add to your `config/environments/production.rb`
|
62
|
+
|
63
|
+
require 'uglifier'
|
64
|
+
config.assets.js_compressor = Uglifier.new(output: {ascii_only: true, quote_keys: true})
|
65
|
+
|
66
|
+
## Contributions
|
67
|
+
|
68
|
+
If you want to contribute, please:
|
69
|
+
|
70
|
+
* Fork the project.
|
71
|
+
* Make your feature addition or bug fix.
|
72
|
+
* Send me a pull request on Github.
|
73
|
+
|
74
|
+
## License
|
75
|
+
|
76
|
+
selec2_rails is released under the [MIT License](http://www.opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'json'
|
3
|
+
require 'httpclient'
|
4
|
+
|
5
|
+
class SourceFile < Thor
|
6
|
+
include Thor::Actions
|
7
|
+
|
8
|
+
desc "fetch source files", "fetch source files from GitHub"
|
9
|
+
def fetch
|
10
|
+
filtered_tags = fetch_tags
|
11
|
+
tag = select("Which tag do you want to fetch?", filtered_tags)
|
12
|
+
self.destination_root = "vendor/assets"
|
13
|
+
remote = "https://github.com/select2/select2"
|
14
|
+
|
15
|
+
get "#{remote}/raw/#{tag}/dist/css/select2.css", "stylesheets/select2.css"
|
16
|
+
get "#{remote}/raw/#{tag}/dist/js/select2.js", "javascripts/select2.js"
|
17
|
+
get "#{remote}/raw/#{tag}/dist/js/select2.full.js", "javascripts/select2.full.js"
|
18
|
+
|
19
|
+
languages.each do |lang|
|
20
|
+
get "#{remote}/raw/#{tag}/dist/js/i18n/#{lang}.js", "javascripts/select2_locale_#{lang}.js"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def fetch_tags
|
27
|
+
http = HTTPClient.new
|
28
|
+
response = JSON.parse(http.get("https://api.github.com/repos/select2/select2/tags").body)
|
29
|
+
response.map{|tag| tag["name"]}.sort
|
30
|
+
end
|
31
|
+
|
32
|
+
def languages
|
33
|
+
[ "az", "bg", "ca", "cs", "da", "de", "en", "es", "et", "eu", "fa", "fi", "fr", "gl", "he", "hi", "hr", "hu",
|
34
|
+
"id", "is", "it", "ko", "lt", "lv", "mk", "nb", "nl", "pl", "pt-BR", "pt", "ro", "ru", "sk", "sr",
|
35
|
+
"sv", "th", "tr", "uk", "vi", "zh-CN", "zh-TW"
|
36
|
+
].sort
|
37
|
+
end
|
38
|
+
|
39
|
+
def select msg, elements
|
40
|
+
elements.each_with_index do |element, index|
|
41
|
+
say(block_given? ? yield(element, index + 1) : ("#{index + 1}. #{element.to_s}"))
|
42
|
+
end
|
43
|
+
result = ask(msg).to_i
|
44
|
+
elements[result - 1]
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path("../lib/select2_rails/version", __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "select2_rails"
|
6
|
+
s.version = Select2::Rails::VERSION
|
7
|
+
s.authors = ["Valery Mayatsky"]
|
8
|
+
s.email = ["valerymayatsky@gmail.com"]
|
9
|
+
s.homepage = "https://github.com/arugin/select2_rails"
|
10
|
+
s.summary = %q{Integrate Select2 javascript library with Rails asset pipeline}
|
11
|
+
s.description = %q{Select2 is a jQuery based replacement for select boxes. It supports searching, remote data sets, and infinite scrolling of results. This gem integrates Select2 with Rails asset pipeline for easy of use.}
|
12
|
+
s.license = 'MIT'
|
13
|
+
s.files = `git ls-files`.split("\n")
|
14
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
15
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
16
|
+
s.require_paths = ["lib"]
|
17
|
+
|
18
|
+
s.add_dependency "thor", "~> 0.14"
|
19
|
+
s.add_development_dependency "bundler", "~> 1.0"
|
20
|
+
s.add_development_dependency "rails", ">= 3.0"
|
21
|
+
s.add_development_dependency "httpclient", "~> 2.2"
|
22
|
+
end
|