calendar_date_select 1.14 → 1.15
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.
- data/History.txt +3 -0
- data/Rakefile +2 -2
- data/lib/calendar_date_select/calendar_date_select.rb +1 -1
- data/lib/calendar_date_select/form_helpers.rb +8 -6
- data/public/javascripts/calendar_date_select/calendar_date_select.js +1 -1
- data/spec/calendar_date_select/form_helpers_spec.rb +15 -10
- metadata +2 -2
data/History.txt
CHANGED
data/Rakefile
CHANGED
@@ -8,11 +8,11 @@ require "activesupport"
|
|
8
8
|
require './lib/calendar_date_select.rb'
|
9
9
|
|
10
10
|
Hoe.new('calendar_date_select', CalendarDateSelect::VERSION) do |p|
|
11
|
-
p.rubyforge_name = '
|
11
|
+
p.rubyforge_name = 'cds'
|
12
12
|
p.developer('Tim Harper', 'tim c harper at gmail dot com')
|
13
13
|
end
|
14
14
|
|
15
|
-
|
15
|
+
desc "Set the current gem version in the code (VERSION=version)"
|
16
16
|
task :set_version do
|
17
17
|
["lib/calendar_date_select/calendar_date_select.rb", "public/javascripts/calendar_date_select/calendar_date_select.js"].each do |file|
|
18
18
|
abs_file = File.dirname(__FILE__) + "/" + file
|
@@ -96,7 +96,7 @@ module CalendarDateSelect::FormHelpers
|
|
96
96
|
#
|
97
97
|
# <%= calendar_date_select_tag "event_demo", "", :after_navigate => "alert('The current selected month is ' + this.calendar_date_select.selected_date.getMonth());" ,
|
98
98
|
def calendar_date_select_tag( name, value = nil, options = {})
|
99
|
-
options, javascript_options = calendar_date_select_process_options(options)
|
99
|
+
image, options, javascript_options = calendar_date_select_process_options(options)
|
100
100
|
value = CalendarDateSelect.format_time(value, javascript_options)
|
101
101
|
|
102
102
|
javascript_options.delete(:format)
|
@@ -106,7 +106,7 @@ module CalendarDateSelect::FormHelpers
|
|
106
106
|
hidden_field_tag(name, value, options) :
|
107
107
|
text_field_tag(name, value, options)
|
108
108
|
|
109
|
-
calendar_date_select_output(tag, options, javascript_options)
|
109
|
+
calendar_date_select_output(tag, image, options, javascript_options)
|
110
110
|
end
|
111
111
|
|
112
112
|
# Similar to the difference between +text_field_tag+ and +text_field+, this method behaves like +text_field+
|
@@ -126,7 +126,7 @@ module CalendarDateSelect::FormHelpers
|
|
126
126
|
use_time = false if Date===(obj.respond_to?(method) && obj.send(method))
|
127
127
|
end
|
128
128
|
|
129
|
-
options, javascript_options = calendar_date_select_process_options(options)
|
129
|
+
image, options, javascript_options = calendar_date_select_process_options(options)
|
130
130
|
|
131
131
|
options[:value] ||=
|
132
132
|
if(obj.respond_to?(method) && obj.send(method).respond_to?(:strftime))
|
@@ -142,6 +142,7 @@ module CalendarDateSelect::FormHelpers
|
|
142
142
|
tag = ActionView::Helpers::InstanceTag.new_with_backwards_compatibility(object, method, self, options.delete(:object))
|
143
143
|
calendar_date_select_output(
|
144
144
|
tag.to_input_field_tag( (javascript_options[:hidden] || javascript_options[:embedded]) ? "hidden" : "text", options),
|
145
|
+
image,
|
145
146
|
options,
|
146
147
|
javascript_options
|
147
148
|
)
|
@@ -151,6 +152,7 @@ module CalendarDateSelect::FormHelpers
|
|
151
152
|
# extracts any options passed into calendar date select, appropriating them to either the Javascript call or the html tag.
|
152
153
|
def calendar_date_select_process_options(options)
|
153
154
|
options, javascript_options = CalendarDateSelect.default_options.merge(options), {}
|
155
|
+
image = options.delete(:image)
|
154
156
|
callbacks = [:before_show, :before_close, :after_show, :after_close, :after_navigate]
|
155
157
|
for key in [:time, :valid_date_check, :embedded, :buttons, :clear_button, :format, :year_range, :month_year, :popup, :hidden, :minute_interval] + callbacks
|
156
158
|
javascript_options[key] = options.delete(key) if options.has_key?(key)
|
@@ -184,10 +186,10 @@ module CalendarDateSelect::FormHelpers
|
|
184
186
|
end
|
185
187
|
|
186
188
|
javascript_options[:year_range] = format_year_range(javascript_options[:year_range] || 10)
|
187
|
-
[options, javascript_options]
|
189
|
+
[image, options, javascript_options]
|
188
190
|
end
|
189
191
|
|
190
|
-
def calendar_date_select_output(input, options = {}, javascript_options = {})
|
192
|
+
def calendar_date_select_output(input, image, options = {}, javascript_options = {})
|
191
193
|
out = input
|
192
194
|
if javascript_options[:embedded]
|
193
195
|
uniq_id = "cds_placeholder_#{(rand*100000).to_i}"
|
@@ -196,7 +198,7 @@ module CalendarDateSelect::FormHelpers
|
|
196
198
|
out << javascript_tag("new CalendarDateSelect( $('#{uniq_id}').previous(), #{options_for_javascript(javascript_options)} ); ")
|
197
199
|
else
|
198
200
|
out << " "
|
199
|
-
out << image_tag(
|
201
|
+
out << image_tag(image,
|
200
202
|
:onclick => "new CalendarDateSelect( $(this).previous(), #{options_for_javascript(javascript_options)} );",
|
201
203
|
:style => 'border:0px; cursor:pointer;',
|
202
204
|
:class=>'calendar_date_select_popup_icon')
|
@@ -1,4 +1,4 @@
|
|
1
|
-
// CalendarDateSelect version 1.
|
1
|
+
// CalendarDateSelect version 1.15 - a prototype based date picker
|
2
2
|
// Questions, comments, bugs? - see the project page: http://code.google.com/p/calendardateselect
|
3
3
|
if (typeof Prototype == 'undefined') alert("CalendarDateSelect Error: Prototype could not be found. Please make sure that your application's layout includes prototype.js (.g. <%= javascript_include_tag :defaults %>) *before* it includes calendar_date_select.js (.g. <%= calendar_date_select_includes %>).");
|
4
4
|
if (Prototype.Version < "1.6") alert("Prototype 1.6.0 is required. If using earlier version of prototype, please use calendar_date_select version 1.8.3");
|
@@ -130,6 +130,10 @@ describe CalendarDateSelect::FormHelpers do
|
|
130
130
|
end
|
131
131
|
|
132
132
|
describe "calendar_date_select_tag" do
|
133
|
+
before(:each) do
|
134
|
+
@time = Time.parse("January 2, 2007 12:01:23 AM")
|
135
|
+
end
|
136
|
+
|
133
137
|
it "should use the string verbatim when provided" do
|
134
138
|
output = calendar_date_select_tag(:name, "Some String")
|
135
139
|
|
@@ -137,25 +141,26 @@ describe CalendarDateSelect::FormHelpers do
|
|
137
141
|
end
|
138
142
|
|
139
143
|
it "should not render the time when time is false (or nil)" do
|
140
|
-
|
141
|
-
output = calendar_date_select_tag(:name, time, :time => false)
|
144
|
+
output = calendar_date_select_tag(:name, @time, :time => false)
|
142
145
|
|
143
146
|
output.should_not match(/12:01 AM/)
|
144
|
-
output.should include(CalendarDateSelect.format_date(time.to_date))
|
147
|
+
output.should include(CalendarDateSelect.format_date(@time.to_date))
|
145
148
|
end
|
146
149
|
|
147
150
|
it "should render the time when :time => true" do
|
148
|
-
|
149
|
-
output = calendar_date_select_tag(:name, time, :time => true)
|
151
|
+
output = calendar_date_select_tag(:name, @time, :time => true)
|
150
152
|
|
151
|
-
output.should include(CalendarDateSelect.format_date(time))
|
153
|
+
output.should include(CalendarDateSelect.format_date(@time))
|
152
154
|
end
|
153
155
|
|
154
156
|
it "should render the time when :time => 'mixed'" do
|
155
|
-
|
156
|
-
output
|
157
|
-
|
158
|
-
|
157
|
+
output = calendar_date_select_tag(:name, @time, :time => 'mixed')
|
158
|
+
output.should include(CalendarDateSelect.format_date(@time))
|
159
|
+
end
|
160
|
+
|
161
|
+
it "not include the image option in the result input tag" do
|
162
|
+
output = calendar_date_select_tag(:name, @time, :time => 'mixed')
|
163
|
+
output.should_not include("image=")
|
159
164
|
end
|
160
165
|
end
|
161
166
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: calendar_date_select
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: "1.
|
4
|
+
version: "1.15"
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Harper
|
@@ -98,7 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
98
98
|
version:
|
99
99
|
requirements: []
|
100
100
|
|
101
|
-
rubyforge_project:
|
101
|
+
rubyforge_project: cds
|
102
102
|
rubygems_version: 1.3.1
|
103
103
|
signing_key:
|
104
104
|
specification_version: 2
|