jquids 0.2.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.
@@ -0,0 +1,2 @@
1
+ *.gem
2
+ *.swp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format nested
@@ -0,0 +1,20 @@
1
+ Copyright (C) 2011 by Tim Harper and Nicholas LaMuro
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
19
+ THE SOFTWARE.
20
+
@@ -0,0 +1,213 @@
1
+ Jquids
2
+ ======
3
+
4
+ This is a rewrite of Tim Harper's "Calendar Date Select" gem
5
+ (https://github.com/timcharper/calendar_date_select) using the jQuery UI date
6
+ picker. This project is still in development and still far from working.
7
+
8
+ The projects intent is to simulate the ease of use of the original while:
9
+
10
+ - Updating the code to work with Rails 3
11
+ - Using the hosted jQuery UI infastructure to avoid local dependencies
12
+
13
+
14
+ Jquids stands for *JQ*uery *UI* *D*ate *S*elect
15
+
16
+
17
+ Usage
18
+ -----
19
+
20
+ Add the following some where in your page (preferablly in the head of your
21
+ layout file):
22
+
23
+ <%= jquids_includes %>
24
+
25
+ Change a field to so it uses the `jquids_tag`:
26
+
27
+ <%= jquids_tag "some_date" %>
28
+
29
+ and you should be good to go!
30
+
31
+
32
+ Customization
33
+ -------------
34
+
35
+ CalendarDateSelect allow for the use of many different formats and css styles,
36
+ and Jquids was made to allow for that same kind of flexibility, with
37
+ out all of the weight of an full library of javascript and css files in your
38
+ public folder.
39
+
40
+
41
+ ### jQeury Version
42
+
43
+ To specify a different version of jQuery, just include :jQuery => "X.X.X" to
44
+ your 'jquids_includes' method:
45
+
46
+ <%= jquids_includes :jQuery => "1.6.0" %>
47
+
48
+ A list of supported versions numbers can be found at the bottom of the page.
49
+
50
+ Because it is entirely possible that you are already using jQuery in your
51
+ application, the option is given to you to not include jQuery using
52
+ Jquids. To do that, just add :jQuery => :none to your
53
+ 'jquids_includes' method:
54
+
55
+ <%= jquids_includes :jQuery => :none %>
56
+
57
+ and now jQuery will not be included into your plugin.
58
+
59
+
60
+ ### jQuery UI Version
61
+
62
+ Just like you can specify a specific version of jQuery, you can also specify a
63
+ version of jQuery UI that you would prefer to use:
64
+
65
+ <%= jquids_includes :jQueryUI => "1.8.0" %>
66
+
67
+ A list of supported version numbers can be found at the bottom of the page.
68
+
69
+ You are also able tell the Jquids not to load jQuery UI in the same way
70
+ that you did with jQuery:
71
+
72
+ <%= jquids_includes :jQueryUI => :none %>
73
+
74
+ You may also use `nil` or `false`.
75
+
76
+
77
+ ### Custom Style
78
+
79
+ To change the style, just add `:style => :new_style` to the
80
+ `jquids_includes` declaration:
81
+
82
+ <%= jquids_includes :style => :vader %>
83
+
84
+ And the new style will be applied. All styles come from the Google CDN
85
+ (http://code.google.com/apis/libraries/devguide.html), so they are not hosted
86
+ in your application. If you wish to theme roll your own style
87
+ (http://jqueryui.com/themeroller/), just set `:style` to `:none`, `nil`, or
88
+ `false`, and include your style sheet in your project.
89
+
90
+ All styles that are available via the Google CDN for jQueryUI can be found
91
+ below.
92
+
93
+
94
+ ### Custom Format
95
+
96
+ To set the format the same way that was done with CalendarDateSelect, just set
97
+ the Jquids format variable using the `format=` function somewhere in
98
+ your code:
99
+
100
+ <% Jquids.format= :american %>
101
+
102
+ or you can set it in `jquids_includes` method by setting the
103
+ `:format` variable in the options hash:
104
+
105
+ <%= jquids_includes :format => :american %>
106
+
107
+ All the formats used mimic what was used in the original CalendarDateSelect
108
+ gem. The formats available are listed below.
109
+
110
+
111
+ ### Customizing the jQuery UI Datepicker
112
+
113
+ The jQuery datepicker has many options that you can implement through
114
+ Jquids via the `:datepicker_options` hash. To add an option to a
115
+ single datepicker element, simply add the hash as an argument to
116
+ `jquids_tag` call:
117
+
118
+ <%= jquids_tag "some_date", nil, :datepicker_options => {:showButtonPanel => true} %>
119
+
120
+ and now the datepicker will use the jQueryUI's button panel at the bottom of
121
+ the datepicker for that instance. But if you have multiple instances that all
122
+ should have the `showButtonPanel` equal to true, add the `:datepicker_options`
123
+ to the `jquids_includes`:
124
+
125
+ <%= jquids_includes :datepicker_options => {:showButtonPanel => true} %>
126
+
127
+ and the change will be applied to all instances of the datepicker. You can
128
+ overide that change by setting the setting to false on the desired
129
+ `jquids_tag` instances.
130
+
131
+ A full list of all of the jQueryUI functions can be found here:
132
+ http://jqueryui.com/demos/datepicker/#options
133
+
134
+
135
+ jQuery Versions
136
+ ---------------
137
+ "1.2.3, 1.2.6, 1.3.0, 1.3.1, 1.3.2, 1.4.0, 1.4.1, 1.4.2, 1.4.3, 1.4.4, 1.5.0,
138
+ 1.5.1, 1.5.2, 1.6.0, 1.6.1"
139
+
140
+
141
+ jQuery UI Versions
142
+ ------------------
143
+ "1.5.2, 1.5.3, 1.6.0, 1.7.0, 1.7.1, 1.7.2, 1.7.3, 1.8.0, 1.8.1, 1.8.2, 1.8.4,
144
+ 1.8.5, 1.8.6, 1.8.7, 1.8.8, 1.8.9, 1.8.10, 1.8.11, 1.8.12, 1.8.13"
145
+
146
+
147
+ Styles
148
+ ------
149
+
150
+ The default style is `:base`. The following can be implemented via the
151
+ `jquids_includes` function:
152
+
153
+ * `:base`
154
+ * `:black_tie`
155
+ * `:blitzer`
156
+ * `:cupertino`
157
+ * `:dark_hive`
158
+ * `:dot_luv`
159
+ * `:eggplant`
160
+ * `:excite_bike`
161
+ * `:flick`
162
+ * `:hot_sneaks`
163
+ * `:humanity`
164
+ * `:le_frog`
165
+ * `:mint_choc`
166
+ * `:overcast`
167
+ * `:pepper_grinder`
168
+ * `:redmond`
169
+ * `:smoothness`
170
+ * `:south_street`
171
+ * `:start`
172
+ * `:sunny`
173
+ * `:swanky_purse`
174
+ * `:trontastic`
175
+ * `:ui_darkness`
176
+ * `:ui_lightness`
177
+ * `:vader`
178
+
179
+
180
+ Formats
181
+ -------
182
+
183
+ The default format is `:natural`. Other formats include:
184
+
185
+ * `:natural` = "%B %d, %Y"
186
+ * `:hyphen_ampm` = "%Y-%m-%d"
187
+ * `:iso_date` = "%Y-%m-%d"
188
+ * `:finnish` = "%d.%m.%Y"
189
+ * `:danish` = "%d/%m/%Y"
190
+ * `:american` = "%m/%d/%Y"
191
+ * `:euro_24hr` = "%d %B %Y"
192
+ * `:euro_24hr_ymd` = "%Y.%m.%d"
193
+ * `:italian` = "%d/%m/%Y"
194
+ * `:db` = "%Y-%m-%d"
195
+
196
+ The only two formats currently with time
197
+ in am-pm is `:natural`, `:hyphen_ampm`, and `:american`.
198
+
199
+
200
+ TODO
201
+ ----
202
+
203
+ - Allow for setting the format via the `jquids_includes` method and
204
+ the ability to set it on a case by case basis (implemented, but has a bug)
205
+ - Map the option settings for CalendarDateSelect to Jquids
206
+ - Get callbacks working
207
+ - Get it to work in rails 2 and 3 (with tests)
208
+ - Integrate with formtastic
209
+
210
+
211
+ Contribute/Suggestions
212
+ ----------------------
213
+ Suggestions and contributions to the project are welcome.
@@ -0,0 +1,44 @@
1
+ require "rubygems"
2
+ #require "rspec/core/rake_task"
3
+ require "rspec/core/rake_task" if Gem.source_index.find_name('rspec').map {|x| x.version}.first.version.to_i >= 2
4
+ require "spec/rake/spectask" if Gem.source_index.find_name('rspec').map {|x| x.version}.first.version.to_i < 2
5
+
6
+ desc 'Default: run spec.'
7
+ task :default => :spec
8
+
9
+ if Gem.source_index.find_name('rspec').map {|x| x.version}.first.version.to_i >= 2
10
+ desc "Run specs"
11
+ RSpec::Core::RakeTask.new do |t|
12
+ t.pattern = "./spec/**/*_spec.rb" # not needed, it' a default.
13
+ # Put spec opts in a file named .rspec in root
14
+ end
15
+ elsif Gem.source_index.find_name('rspec').map {|x| x.version}.first.version.to_i < 2
16
+ desc "Run specs"
17
+ Spec::Rake::SpecTask.new do |t|
18
+ t.spec_files = "./spec/**/*_spec.rb"
19
+ # Put spec opts in a file named spec.opts in your spec folder
20
+ end
21
+ end
22
+
23
+ gemspec = eval(File.read(Dir["*.gemspec"].first))
24
+
25
+ desc "Validate the gemspec"
26
+ task :gemspec do
27
+ puts "Validating the gem..."
28
+ gemspec.validate
29
+ end
30
+
31
+ desc "Build gem locally"
32
+ task :build => :gemspec do
33
+ puts "Building the gem..."
34
+ system "gem build #{gemspec.name}.gemspec"
35
+ FileUtils.mkdir_p "pkg"
36
+ FileUtils.mv "#{gemspec.name}-#{gemspec.version}.gem", "pkg"
37
+ end
38
+
39
+ desc "Install gem locally"
40
+ task :install => :build do
41
+ puts "Installing..."
42
+ system "gem install pkg/#{gemspec.name}-#{gemspec.version}"
43
+ end
44
+
data/init.rb ADDED
@@ -0,0 +1 @@
1
+ require File.dirname(__FILE__) + "/lib/jquids.rb"
@@ -0,0 +1,17 @@
1
+ $:.push File.expand_path("../lib", __FILE__)
2
+ require "jquids/constants/version"
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = "jquids"
6
+ s.version = Jquids::VERSION
7
+ s.platform = Gem::Platform::RUBY
8
+ s.summary = "Integrating the jQueryUI date picker for Rails"
9
+ s.description = "Integrating the jQueryUI date picker for Rails"
10
+ s.authors = "Nick LaMuro"
11
+ s.email = "nicklamuro@gmail.com"
12
+ s.homepage = "https://github.com/NickLaMuro/jquids"
13
+
14
+ s.files = `git ls-files`.split("\n")
15
+ s.test_files = `git ls-files -- {spec}/*`.split("\n")
16
+ s.require_paths = ["lib"]
17
+ end
@@ -0,0 +1,9 @@
1
+ require "jquids/jquids.rb"
2
+ require "jquids/includes_helper.rb"
3
+ require "jquids/form_helpers.rb"
4
+ require "jquids/errors/not_a_known_format.rb"
5
+ require "jquids/errors/not_a_known_style.rb"
6
+
7
+ ActionView::Helpers::FormHelper.send(:include, Jquids::FormHelpers)
8
+ ActionView::Base.send(:include, Jquids::FormHelpers)
9
+ ActionView::Base.send(:include, Jquids::IncludesHelper)
@@ -0,0 +1,74 @@
1
+ module Jquids
2
+ FORMATS = {
3
+ :natural => {
4
+ :date => "%B %d, %Y",
5
+ :time => " %I:%M %p",
6
+ :js_date => "MM dd, yy",
7
+ :tr_js_time => "hh:mm TT",
8
+ :ampm => true
9
+ },
10
+ :hyphen_ampm => {
11
+ :date => "%Y-%m-%d",
12
+ :time => " %I:%M %p",
13
+ :js_date => "yy-mm-dd",
14
+ :tr_js_time => "hh:mm TT",
15
+ :ampm => true
16
+ },
17
+ :iso_date => {
18
+ :date => "%Y-%m-%d",
19
+ :time => " %H:%M",
20
+ :js_date => "yy-mm-dd",
21
+ :tr_js_time => "hh:mm",
22
+ :ampm => false
23
+ },
24
+ :finnish => {
25
+ :date => "%d.%m.%Y",
26
+ :time => " %H:%M",
27
+ :js_date => "dd.mm.yy",
28
+ :tr_js_time => "hh:mm",
29
+ :ampm => false
30
+ },
31
+ :danish => {
32
+ :date => "%d/%m/%Y",
33
+ :time => " %H:%M",
34
+ :js_date => "dd/mm/yy",
35
+ :tr_js_time => "hh:mm",
36
+ :ampm => false
37
+ },
38
+ :american => {
39
+ :date => "%m/%d/%Y",
40
+ :time => " %I:%M %p",
41
+ :js_date => "mm/dd/yy",
42
+ :tr_js_time => "hh:mm TT",
43
+ :ampm => true
44
+ },
45
+ :euro_24hr => {
46
+ :date => "%d %B %Y",
47
+ :time => " %H:%M",
48
+ :js_date => "dd MM yy",
49
+ :tr_js_time => "hh:mm",
50
+ :ampm => false
51
+ },
52
+ :euro_24hr_ymd => {
53
+ :date => "%Y.%m.%d",
54
+ :time => " %H:%M",
55
+ :js_date => "yy.mm.dd",
56
+ :tr_js_time => "hh:mm",
57
+ :ampm => false
58
+ },
59
+ :italian => {
60
+ :date => "%d/%m/%Y",
61
+ :time => " %H:%M",
62
+ :js_date => "dd/mm/yy",
63
+ :tr_js_time => "hh:mm",
64
+ :ampm => false
65
+ },
66
+ :db => {
67
+ :date => "%Y-%m-%d",
68
+ :time => " %H:%M",
69
+ :js_date => "yy-mm-dd",
70
+ :tr_js_time => "hh:mm",
71
+ :ampm => false
72
+ }
73
+ }
74
+ end
@@ -0,0 +1,3 @@
1
+ module Jquids
2
+ JQVersions = %w{1.2.3 1.2.6 1.3.0 1.3.1 1.3.2 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.5.0 1.5.1 1.5.2 1.6.0 1.6.1}
3
+ end
@@ -0,0 +1,29 @@
1
+ module Jquids
2
+ STYLES = {
3
+ :base => "base",
4
+ :black_tie => "black-tie",
5
+ :blitzer => "blitzer",
6
+ :cupertino => "cupertino",
7
+ :dark_hive => "dark-hive",
8
+ :dot_luv => "dot-luv",
9
+ :eggplant => "eggplant",
10
+ :excite_bike => "excite-bike",
11
+ :flick => "flick",
12
+ :hot_sneaks => "hot-sneaks",
13
+ :humanity => "humanity",
14
+ :le_frog => "le-frog",
15
+ :mint_choc => "mint-choc",
16
+ :overcast => "overcast",
17
+ :pepper_grinder => "pepper-grinder",
18
+ :redmond => "redmond",
19
+ :smoothness => "smoothness",
20
+ :south_street => "south-street",
21
+ :start => "start",
22
+ :sunny => "sunny",
23
+ :swanky_purse => "swanky-purse",
24
+ :trontastic => "trontastic",
25
+ :ui_darkness => "ui-darkness",
26
+ :ui_lightness => "ui-lightness",
27
+ :vader => "vader"
28
+ }
29
+ end
@@ -0,0 +1,3 @@
1
+ module Jquids
2
+ TimepickerTags = %w{v0.8 v0.9 v0.9.1 v0.9.2 v0.9.3 v0.9.4 v0.9.5}
3
+ end
@@ -0,0 +1,3 @@
1
+ module Jquids
2
+ UIVersions = %w{1.5.2 1.5.3 1.6.0 1.7.0 1.7.1 1.7.2 1.7.3 1.8.0 1.8.1 1.8.2 1.8.4 1.8.5 1.8.6 1.8.7 1.8.8 1.8.9 1.8.10 1.8.11 1.8.12 1.8.13}
3
+ end
@@ -0,0 +1,3 @@
1
+ module Jquids
2
+ VERSION = "0.2.1"
3
+ end
@@ -0,0 +1,8 @@
1
+ class Jquids::NotAKnownFormat < StandardError
2
+
3
+ # Not sure how to define a default message, but currently that is not needed
4
+ #def self.message
5
+ #"Jquids: Unrecognized format specification"
6
+ #end
7
+
8
+ end