chosen-dartsass 2.0.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 74453e7428c8c31a49dcb64c982a04ced84e92d3904b868fee992a5d278d99ea
4
+ data.tar.gz: f4fa18c0b7fd9367480a5d92095b3b90ad41ca5e6e36670d7df3a849d1c708f5
5
+ SHA512:
6
+ metadata.gz: 966a85bbfbe340d99dec26b5f5118d29cfb482d7a7e1a79089e22019c72c86ade46dc2060a230fdce7cb1c047da2a1cb0e95a806965372efe845fad0dfe6f1e6
7
+ data.tar.gz: 134a585898329e97cf8ced3e237e0643131586cbbc451d09ad33e532fca03bd177084606ac1b26ce95621d4d573042a6d79e5dc1c4c9c673e18996c6729a879b
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ Dockerfile
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'http://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in chosen-rails.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (C) 2011-2013 by Tse-Ching Ho
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,160 @@
1
+ # Chosen for rails asset pipeline
2
+
3
+ [Chosen](https://github.com/harvesthq/chosen) is a library for making long, unwieldy select boxes more user friendly.
4
+
5
+ The `chosen-dartsass` gem integrates the `Chosen` into Rails asset pipeline with the [propshaft](https://github.com/rails/propshaft), using [dartsass-rails](https://github.com/rails/dartsass-rails).
6
+
7
+ ## Usage
8
+
9
+ ### Install chosen-dartsass gem
10
+
11
+ Include `chosen-dartsass` in Gemfile
12
+
13
+ ```rb
14
+ gem 'jquery-rails'
15
+ gem 'chosen-dartsass'
16
+ ```
17
+
18
+ Then run `bundle install`
19
+
20
+ ### About JQuery
21
+
22
+ You can get jquery via [jquery-rails](https://github.com/rails/jquery-rails).
23
+
24
+ Please consider [jquery-turbolinks](https://github.com/kossnocorp/jquery.turbolinks) if you have turbolinks issues for Rails 4 +.
25
+
26
+ ### Include chosen javascript assets
27
+
28
+ Add to your `app/assets/javascripts/application.js` if use with jQuery
29
+
30
+ ```coffee
31
+ //= require jquery
32
+ //= require chosen-jquery
33
+ ```
34
+
35
+ ### Include chosen stylesheet assets
36
+
37
+ Add to your `app/assets/stylesheets/application.css`
38
+
39
+ ```scss
40
+ *= require chosen
41
+ ```
42
+
43
+ ### Enable chosen javascript by specific css class
44
+
45
+ For rails 6, remember to add `javascript_include_tag` in `app/views/layouts/application.html.erb`, like
46
+
47
+ ```ruby
48
+ <%= javascript_include_tag 'application' %>
49
+ ```
50
+
51
+ Add to one javascript file, like `scaffold.js`
52
+
53
+ ```js
54
+ $(function() {
55
+ // enable chosen js
56
+ $('.chosen-select').chosen({
57
+ allow_single_deselect: true,
58
+ no_results_text: 'No results matched',
59
+ width: '200px'
60
+ });
61
+ });
62
+ ```
63
+
64
+ Notice: `width` option is required since `Chosen 0.9.15`.
65
+
66
+ And this file must be included in `application.js`
67
+
68
+ ```coffee
69
+ //= require chosen-jquery
70
+ //= require scaffold
71
+ ```
72
+
73
+ Also add the class to your form field
74
+
75
+ ```erb
76
+ <%= f.select :author,
77
+ User.all.map { |u| [u.name, u.id] },
78
+ { include_blank: true },
79
+ { class: 'chosen-select' }
80
+ %>
81
+ ```
82
+
83
+ If you use simple form as form builder
84
+
85
+ ```erb
86
+ <%= f.association :author,
87
+ collection: User.all,
88
+ include_blank: true,
89
+ input_html: { class: 'chosen-select' }
90
+ %>
91
+ ```
92
+
93
+ ### Deployment
94
+
95
+ Since version 0.13.0, non-digested assets of `chosen-dartsass` will simply be copied from digested assets.
96
+
97
+ ## RSpec helpers
98
+ `chosen-dartsass` provides RSpec feature helper methods that allow users to select or unselect options from both single and multiple chosen elements. Add the following to your `spec/rails_helper.rb` (or `spec/spec_helper.rb`):
99
+
100
+ ```ruby
101
+ require 'chosen-dartsass/rspec'
102
+ ```
103
+
104
+ This automatically configures RSpec by adding:
105
+
106
+ ```ruby
107
+ RSpec.configure do |config|
108
+ config.include Chosen::Rspec::FeatureHelpers, type: :feature
109
+ end
110
+ ```
111
+
112
+ Configuration includes two additional methods for all `type: :feature` specs:
113
+
114
+ ```ruby
115
+ chosen_select(value, options = {})
116
+ chosen_unselect(value, options = {})
117
+ ```
118
+
119
+ Both methods require `from: '...'` inside the `options` hash that is either a CSS selector or a field's label (requires the `for` attribute on the label!).
120
+
121
+ ### Example usage
122
+ To handle a single select:
123
+
124
+ ```ruby
125
+ chosen_select('Leo Tolstoy', from: 'Author')
126
+ chosen_unselect('Leo Tolstoy', from: '#author')
127
+ chosen_select('Fyodor Dostoyevsky', from: '#author')
128
+ ```
129
+
130
+ To handle a multiple select:
131
+
132
+ ```ruby
133
+ chosen_select('Leo Tolstoy', 'Fyodor Dostoyevsky', 'Anton Chekhov', from: 'Authors')
134
+ # or, by single value:
135
+ chosen_select('Leo Tolstoy', from: '#authors')
136
+
137
+ chosen_unselect('Fyodor Dostoyevsky', ' Anton Chekhov', from: 'Authors')
138
+ # or, by single value:
139
+ chosen_unselect('Leo Tolstoy', from: '#authors')
140
+ ```
141
+
142
+ ## Gem maintenance
143
+
144
+ Maintain `chosen-dartsass` gem with `Rake` commands.
145
+
146
+ Update origin chosen source files.
147
+
148
+ ```bash
149
+ rake update-chosen
150
+ ```
151
+
152
+ Publish gem.
153
+
154
+ ```bash
155
+ rake release
156
+ ```
157
+
158
+ ## License
159
+
160
+ use MIT license.
data/Rakefile ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env rake
2
+ require 'bundler/gem_tasks'
3
+ require File.expand_path('../lib/chosen-dartsass/source_file', __FILE__)
4
+
5
+ desc "Update with Harvest's Chosen Library"
6
+ task 'update-chosen', 'repository_url', 'branch' do |task, args|
7
+ remote = args['repository_url'] || 'https://github.com/harvesthq/chosen'
8
+ branch = args['branch'] || 'main'
9
+ files = SourceFile.new
10
+ #files.fetch remote, branch
11
+ #files.eject_javascript_class_from_closure
12
+ files.generate_js
13
+ files.cleanup
14
+ end
@@ -0,0 +1,26 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/chosen-dartsass/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ['Sergio Cambra']
6
+ gem.email = ['activescaffold@googlegroups.com']
7
+ gem.description = %q{Chosen is a javascript library of select box enhancer for jQuery and Protoype. This gem integrates Chosen with Rails asset pipeline using dartsass for easy of use, supporting propshaft.}
8
+ gem.summary = %q{Integrate Chosen javascript library with Rails asset pipeline}
9
+ gem.homepage = 'https://github.com/activescaffold/chosen-dartsass'
10
+
11
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
12
+ gem.files = `git ls-files`.split("\n")
13
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
14
+ gem.name = 'chosen-dartsass'
15
+ gem.require_paths = ['lib']
16
+ gem.version = Chosen::Dartsass::VERSION
17
+ gem.license = 'MIT'
18
+
19
+ gem.add_dependency 'railties', '>= 3.0'
20
+ gem.add_dependency 'dartsass-rails', '>= 0.5.0'
21
+
22
+ gem.add_development_dependency 'bundler', '>= 1.0'
23
+ gem.add_development_dependency 'rails', '>= 7.0'
24
+ gem.add_development_dependency 'thor', '>= 0.14'
25
+ gem.add_development_dependency 'coffee-rails', '>= 3.2'
26
+ end