tristandunn-calendar_date_select 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -0
- data/History.txt +240 -0
- data/MIT-LICENSE +20 -0
- data/Manifest.txt +42 -0
- data/README.txt +18 -0
- data/Rakefile +35 -0
- data/VERSION +1 -0
- data/calendar_date_select.gemspec +96 -0
- data/init.rb +1 -0
- data/js_test/functional/.tmp_cds_test.html +306 -0
- data/js_test/functional/cds_test.html +349 -0
- data/js_test/functional/format_iso_date_test.html +52 -0
- data/js_test/prototype.js +4184 -0
- data/js_test/test.css +40 -0
- data/js_test/unit/cds_helper_methods.html +46 -0
- data/js_test/unittest.js +564 -0
- data/lib/calendar_date_select/calendar_date_select.rb +121 -0
- data/lib/calendar_date_select/form_helpers.rb +229 -0
- data/lib/calendar_date_select/includes_helper.rb +29 -0
- data/lib/calendar_date_select.rb +33 -0
- data/public/blank_iframe.html +2 -0
- data/public/images/calendar_date_select/calendar.gif +0 -0
- data/public/javascripts/calendar_date_select/calendar_date_select.js +443 -0
- data/public/javascripts/calendar_date_select/format_american.js +35 -0
- data/public/javascripts/calendar_date_select/format_danish.js +31 -0
- data/public/javascripts/calendar_date_select/format_db.js +27 -0
- data/public/javascripts/calendar_date_select/format_euro_24hr.js +7 -0
- data/public/javascripts/calendar_date_select/format_euro_24hr_ymd.js +7 -0
- data/public/javascripts/calendar_date_select/format_finnish.js +32 -0
- data/public/javascripts/calendar_date_select/format_hyphen_ampm.js +37 -0
- data/public/javascripts/calendar_date_select/format_iso_date.js +29 -0
- data/public/javascripts/calendar_date_select/format_italian.js +24 -0
- data/public/javascripts/calendar_date_select/locale/ar.js +10 -0
- data/public/javascripts/calendar_date_select/locale/da.js +11 -0
- data/public/javascripts/calendar_date_select/locale/de.js +11 -0
- data/public/javascripts/calendar_date_select/locale/es.js +11 -0
- data/public/javascripts/calendar_date_select/locale/fi.js +10 -0
- data/public/javascripts/calendar_date_select/locale/fr.js +11 -0
- data/public/javascripts/calendar_date_select/locale/it.js +9 -0
- data/public/javascripts/calendar_date_select/locale/nl.js +11 -0
- data/public/javascripts/calendar_date_select/locale/pl.js +11 -0
- data/public/javascripts/calendar_date_select/locale/pt.js +11 -0
- data/public/javascripts/calendar_date_select/locale/ru.js +10 -0
- data/public/javascripts/calendar_date_select/locale/sl.js +11 -0
- data/public/stylesheets/calendar_date_select/blue.css +130 -0
- data/public/stylesheets/calendar_date_select/default.css +135 -0
- data/public/stylesheets/calendar_date_select/green.css +142 -0
- data/public/stylesheets/calendar_date_select/plain.css +128 -0
- data/public/stylesheets/calendar_date_select/red.css +135 -0
- data/public/stylesheets/calendar_date_select/silver.css +133 -0
- data/spec/calendar_date_select/calendar_date_select_spec.rb +14 -0
- data/spec/calendar_date_select/form_helpers_spec.rb +203 -0
- data/spec/calendar_date_select/includes_helper_spec.rb +46 -0
- data/spec/spec_helper.rb +26 -0
- metadata +113 -0
@@ -0,0 +1,135 @@
|
|
1
|
+
.calendar_date_select {
|
2
|
+
color:white;
|
3
|
+
border:#777 1px solid;
|
4
|
+
display:block;
|
5
|
+
width:195px;
|
6
|
+
z-index: 1000;
|
7
|
+
}
|
8
|
+
/* this is a fun ie6 hack to get drop downs to stay behind the popup window. This should always be just underneath .calendar_date_select */
|
9
|
+
iframe.ie6_blocker {
|
10
|
+
position: absolute;
|
11
|
+
z-index: 999;
|
12
|
+
}
|
13
|
+
|
14
|
+
.calendar_date_select thead th {
|
15
|
+
font-weight:bold;
|
16
|
+
background-color: #E7E8E8;
|
17
|
+
border-bottom:2px solid black;
|
18
|
+
color: black !important;
|
19
|
+
}
|
20
|
+
|
21
|
+
.calendar_date_select .cds_buttons {
|
22
|
+
text-align:center;
|
23
|
+
padding:5px 0px;
|
24
|
+
background-color: #5f0000;
|
25
|
+
}
|
26
|
+
|
27
|
+
.calendar_date_select .cds_footer {
|
28
|
+
background-color: black;
|
29
|
+
padding:3px;
|
30
|
+
text-align:center;
|
31
|
+
}
|
32
|
+
|
33
|
+
.calendar_date_select table {
|
34
|
+
margin: 0px;
|
35
|
+
padding: 0px;
|
36
|
+
}
|
37
|
+
|
38
|
+
|
39
|
+
.calendar_date_select .cds_header {
|
40
|
+
background-color: #ccc;
|
41
|
+
border-bottom: 2px solid #aaa;
|
42
|
+
text-align:center;
|
43
|
+
}
|
44
|
+
|
45
|
+
.calendar_date_select .cds_header span {
|
46
|
+
font-size:15px;
|
47
|
+
color: black;
|
48
|
+
font-weight: bold;
|
49
|
+
}
|
50
|
+
|
51
|
+
.calendar_date_select select { font-size:11px;}
|
52
|
+
|
53
|
+
.calendar_date_select .cds_header a:hover {
|
54
|
+
color: white;
|
55
|
+
}
|
56
|
+
.calendar_date_select .cds_header a {
|
57
|
+
width:22px;
|
58
|
+
height:20px;
|
59
|
+
text-decoration: none;
|
60
|
+
font-size:14px;
|
61
|
+
color:black !important;
|
62
|
+
}
|
63
|
+
|
64
|
+
.calendar_date_select .cds_header a.prev {
|
65
|
+
float:left;
|
66
|
+
}
|
67
|
+
.calendar_date_select .cds_header a.next {
|
68
|
+
float:right;
|
69
|
+
}
|
70
|
+
|
71
|
+
.calendar_date_select .cds_header a.close {
|
72
|
+
float:right;
|
73
|
+
display:none;
|
74
|
+
}
|
75
|
+
|
76
|
+
.calendar_date_select .cds_header select.month {
|
77
|
+
width:90px;
|
78
|
+
}
|
79
|
+
|
80
|
+
.calendar_date_select .cds_header select.year {
|
81
|
+
width:61px;
|
82
|
+
}
|
83
|
+
|
84
|
+
.calendar_date_select .cds_buttons a {
|
85
|
+
color: white;
|
86
|
+
font-size: 9px;
|
87
|
+
}
|
88
|
+
|
89
|
+
|
90
|
+
.calendar_date_select td {
|
91
|
+
background-color: #660000;
|
92
|
+
font-size:12px;
|
93
|
+
width: 24px;
|
94
|
+
height: 21px;
|
95
|
+
text-align:center;
|
96
|
+
vertical-align: middle;
|
97
|
+
}
|
98
|
+
.calendar_date_select td.weekend {
|
99
|
+
background-color: #5a0000;
|
100
|
+
}
|
101
|
+
|
102
|
+
.calendar_date_select td div {
|
103
|
+
color:#fff;
|
104
|
+
}
|
105
|
+
.calendar_date_select td div.other {
|
106
|
+
color: #93554C;
|
107
|
+
}
|
108
|
+
.calendar_date_select td.selected div {
|
109
|
+
color:black;
|
110
|
+
}
|
111
|
+
|
112
|
+
|
113
|
+
.calendar_date_select tbody td {
|
114
|
+
border-bottom: 1px solid #550000;
|
115
|
+
}
|
116
|
+
.calendar_date_select tbody td.selected {
|
117
|
+
background-color:white;
|
118
|
+
color:black;
|
119
|
+
}
|
120
|
+
|
121
|
+
.calendar_date_select tbody td:hover {
|
122
|
+
background-color:#ccc;
|
123
|
+
}
|
124
|
+
|
125
|
+
.calendar_date_select tbody td.today {
|
126
|
+
border: 1px dashed red;
|
127
|
+
}
|
128
|
+
|
129
|
+
.calendar_date_select td.disabled div {
|
130
|
+
color: #440000;
|
131
|
+
}
|
132
|
+
|
133
|
+
.fieldWithErrors .calendar_date_select {
|
134
|
+
border: 2px solid red;
|
135
|
+
}
|
@@ -0,0 +1,133 @@
|
|
1
|
+
.calendar_date_select {
|
2
|
+
color:white;
|
3
|
+
border:#777 1px solid;
|
4
|
+
display:block;
|
5
|
+
width:195px;
|
6
|
+
z-index: 1000;
|
7
|
+
}
|
8
|
+
/* this is a fun ie6 hack to get drop downs to stay behind the popup window. This should always be just underneath .calendar_date_select */
|
9
|
+
iframe.ie6_blocker {
|
10
|
+
position: absolute;
|
11
|
+
z-index: 999;
|
12
|
+
}
|
13
|
+
|
14
|
+
.calendar_date_select thead th {
|
15
|
+
font-weight:bold;
|
16
|
+
background-color: #000;
|
17
|
+
border-top:1px solid #777;
|
18
|
+
border-bottom:2px solid #333;
|
19
|
+
color: white !important;
|
20
|
+
}
|
21
|
+
|
22
|
+
.calendar_date_select .cds_buttons {
|
23
|
+
text-align:center;
|
24
|
+
padding:5px 0px;
|
25
|
+
background-color: #555;
|
26
|
+
}
|
27
|
+
|
28
|
+
.calendar_date_select .cds_footer {
|
29
|
+
background-color: black;
|
30
|
+
padding:3px;
|
31
|
+
font-size:12px;
|
32
|
+
text-align:center;
|
33
|
+
}
|
34
|
+
|
35
|
+
.calendar_date_select table {
|
36
|
+
margin: 0px;
|
37
|
+
padding: 0px;
|
38
|
+
}
|
39
|
+
|
40
|
+
|
41
|
+
.calendar_date_select .cds_header {
|
42
|
+
background-color: #ccc;
|
43
|
+
border-bottom: 2px solid #aaa;
|
44
|
+
text-align:center;
|
45
|
+
}
|
46
|
+
|
47
|
+
.calendar_date_select .cds_header span {
|
48
|
+
font-size:15px;
|
49
|
+
color: black;
|
50
|
+
font-weight: bold;
|
51
|
+
}
|
52
|
+
|
53
|
+
.calendar_date_select select { font-size:11px;}
|
54
|
+
|
55
|
+
.calendar_date_select .cds_header a:hover {
|
56
|
+
color: white;
|
57
|
+
}
|
58
|
+
.calendar_date_select .cds_header a {
|
59
|
+
width:22px;
|
60
|
+
height:20px;
|
61
|
+
text-decoration: none;
|
62
|
+
font-size:14px;
|
63
|
+
color:black !important;
|
64
|
+
}
|
65
|
+
|
66
|
+
.calendar_date_select .cds_header a.prev {
|
67
|
+
float:left;
|
68
|
+
}
|
69
|
+
.calendar_date_select .cds_header a.next {
|
70
|
+
float:right;
|
71
|
+
}
|
72
|
+
.calendar_date_select .cds_header a.close {
|
73
|
+
float:right;
|
74
|
+
display:none;
|
75
|
+
}
|
76
|
+
|
77
|
+
.calendar_date_select .cds_header select.month {
|
78
|
+
width:90px;
|
79
|
+
}
|
80
|
+
|
81
|
+
.calendar_date_select .cds_header select.year {
|
82
|
+
width:61px;
|
83
|
+
}
|
84
|
+
|
85
|
+
.calendar_date_select .cds_buttons a {
|
86
|
+
color: white;
|
87
|
+
font-size: 9px;
|
88
|
+
}
|
89
|
+
.calendar_date_select td {
|
90
|
+
font-size:12px;
|
91
|
+
width: 24px;
|
92
|
+
height: 21px;
|
93
|
+
text-align:center;
|
94
|
+
vertical-align: middle;
|
95
|
+
background-color: #666666;
|
96
|
+
}
|
97
|
+
.calendar_date_select td.weekend {
|
98
|
+
background-color: #606060;
|
99
|
+
}
|
100
|
+
|
101
|
+
.calendar_date_select td div {
|
102
|
+
color: #fff;
|
103
|
+
}
|
104
|
+
.calendar_date_select td div.other {
|
105
|
+
color: #888;
|
106
|
+
}
|
107
|
+
.calendar_date_select td.selected div {
|
108
|
+
color:black;
|
109
|
+
}
|
110
|
+
|
111
|
+
.calendar_date_select tbody td {
|
112
|
+
border-bottom: 1px solid #555;
|
113
|
+
}
|
114
|
+
.calendar_date_select td.selected {
|
115
|
+
background-color:white;
|
116
|
+
}
|
117
|
+
|
118
|
+
.calendar_date_select td:hover {
|
119
|
+
background-color:#ccc;
|
120
|
+
}
|
121
|
+
|
122
|
+
.calendar_date_select td.today {
|
123
|
+
border: 1px dashed #999;
|
124
|
+
}
|
125
|
+
|
126
|
+
.calendar_date_select td.disabled div {
|
127
|
+
color: #454545;
|
128
|
+
}
|
129
|
+
|
130
|
+
|
131
|
+
.fieldWithErrors .calendar_date_select {
|
132
|
+
border: 2px solid red;
|
133
|
+
}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe CalendarDateSelect do
|
4
|
+
it "should detect presence of time in a string" do
|
5
|
+
CalendarDateSelect.has_time?("January 7, 2007").should == false
|
6
|
+
CalendarDateSelect.has_time?("January 7, 2007 5:50pm").should == true
|
7
|
+
CalendarDateSelect.has_time?("January 7, 2007 5:50 pm").should == true
|
8
|
+
CalendarDateSelect.has_time?("January 7, 2007 16:30 pm").should == true
|
9
|
+
|
10
|
+
CalendarDateSelect.has_time?(Date.parse("January 7, 2007 3:00 pm")).should == false
|
11
|
+
CalendarDateSelect.has_time?(Time.parse("January 7, 2007 3:00 pm")).should == true
|
12
|
+
CalendarDateSelect.has_time?(DateTime.parse("January 7, 2007 3:00 pm")).should == true
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,203 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe CalendarDateSelect::FormHelpers do
|
4
|
+
include ActionView::Helpers::FormHelper
|
5
|
+
include ActionView::Helpers::JavaScriptHelper
|
6
|
+
include ActionView::Helpers::AssetTagHelper
|
7
|
+
include ActionView::Helpers::TagHelper
|
8
|
+
include ActionView::Helpers::FormTagHelper
|
9
|
+
|
10
|
+
include CalendarDateSelect::FormHelpers
|
11
|
+
|
12
|
+
before(:each) do
|
13
|
+
@controller = ActionController::Base.new
|
14
|
+
@request = OpenStruct.new
|
15
|
+
@controller.request = @request
|
16
|
+
|
17
|
+
@model = OpenStruct.new
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "mixed mode" do
|
21
|
+
it "should not output a time when the value is a Date" do
|
22
|
+
@model.start_datetime = Date.parse("January 2, 2007")
|
23
|
+
output = calendar_date_select(:model, :start_datetime, :time => "mixed")
|
24
|
+
output.should_not match(/12:00 AM/)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should output a time when the value is a Time" do
|
28
|
+
@model.start_datetime = Time.parse("January 2, 2007 12:00 AM")
|
29
|
+
output = calendar_date_select(:model, :start_datetime, :time => "mixed")
|
30
|
+
output.should match(/12:00 AM/)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should render a time when time is passed as 'true'" do
|
35
|
+
@model.start_datetime = Date.parse("January 2, 2007")
|
36
|
+
output = calendar_date_select(:model, :start_datetime, :time => "true")
|
37
|
+
output.should match(/12:00 AM/)
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should time_false__model_returns_time__should_render_without_time" do
|
41
|
+
@model.start_datetime = Time.parse("January 2, 2007 12:00 AM")
|
42
|
+
output = calendar_date_select(:model, :start_datetime)
|
43
|
+
output.should_not match(/12:00 AM/)
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should _nil_model__shouldnt_populate_value" do
|
47
|
+
@model = nil
|
48
|
+
output = calendar_date_select(:model, :start_datetime)
|
49
|
+
|
50
|
+
output.should_not match(/value/)
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should _vdc__should_auto_format_function" do
|
54
|
+
@model.start_datetime = Time.parse("January 2, 2007 12:00 AM")
|
55
|
+
output = calendar_date_select(:model,
|
56
|
+
:start_datetime,
|
57
|
+
:valid_date_check => "date < new Date()"
|
58
|
+
)
|
59
|
+
output.should include("valid_date_check:function(date) { return(date < new Date()) }")
|
60
|
+
|
61
|
+
output = calendar_date_select(:model,
|
62
|
+
:start_datetime,
|
63
|
+
:valid_date_check => "return(date < new Date())"
|
64
|
+
)
|
65
|
+
output.should include("valid_date_check:function(date) { return(date < new Date()) }")
|
66
|
+
output = calendar_date_select(:model,
|
67
|
+
:start_datetime,
|
68
|
+
:valid_date_check => "function(p) { return(date < new Date()) }"
|
69
|
+
)
|
70
|
+
output.should include("valid_date_check:function(p) { return(date < new Date()) }")
|
71
|
+
end
|
72
|
+
|
73
|
+
it "should raise an error if the valid_date_check function is missing a return statement" do
|
74
|
+
message = ":valid_date_check function is missing a 'return' statement. Try something like: :valid_date_check => 'if (date > new(Date)) return true; else return false;'"
|
75
|
+
lambda {
|
76
|
+
output = calendar_date_select(:model,
|
77
|
+
:start_datetime,
|
78
|
+
:valid_date_check => "date = 5; date < new Date());"
|
79
|
+
)
|
80
|
+
}.should raise_error(ArgumentError, message)
|
81
|
+
|
82
|
+
lambda {
|
83
|
+
output = calendar_date_select(:model,
|
84
|
+
:start_datetime,
|
85
|
+
:valid_date_check => "function(p) { date = 5; date < new Date()); }"
|
86
|
+
)
|
87
|
+
}.should raise_error(ArgumentError, message)
|
88
|
+
end
|
89
|
+
|
90
|
+
it "should _hdc__should_auto_format_function" do
|
91
|
+
@model.start_datetime = Time.parse("January 2, 2007 12:00 AM")
|
92
|
+
output = calendar_date_select(:model,
|
93
|
+
:start_datetime,
|
94
|
+
:highlighted_date_check => "date < new Date()"
|
95
|
+
)
|
96
|
+
output.should include("highlighted_date_check:function(date) { return(date < new Date()) }")
|
97
|
+
|
98
|
+
output = calendar_date_select(:model,
|
99
|
+
:start_datetime,
|
100
|
+
:highlighted_date_check => "return(date < new Date())"
|
101
|
+
)
|
102
|
+
output.should include("highlighted_date_check:function(date) { return(date < new Date()) }")
|
103
|
+
output = calendar_date_select(:model,
|
104
|
+
:start_datetime,
|
105
|
+
:highlighted_date_check => "function(p) { return(date < new Date()) }"
|
106
|
+
)
|
107
|
+
output.should include("highlighted_date_check:function(p) { return(date < new Date()) }")
|
108
|
+
end
|
109
|
+
|
110
|
+
it "should raise an error if the highlighted_date_check function is missing a return statement" do
|
111
|
+
message = ":highlighted_date_check function is missing a 'return' statement. Try something like: :highlighted_date_check => 'if (date > new(Date)) return true; else return false;'"
|
112
|
+
lambda {
|
113
|
+
output = calendar_date_select(:model,
|
114
|
+
:start_datetime,
|
115
|
+
:highlighted_date_check => "date = 5; date < new Date());"
|
116
|
+
)
|
117
|
+
}.should raise_error(ArgumentError, message)
|
118
|
+
|
119
|
+
lambda {
|
120
|
+
output = calendar_date_select(:model,
|
121
|
+
:start_datetime,
|
122
|
+
:highlighted_date_check => "function(p) { date = 5; date < new Date()); }"
|
123
|
+
)
|
124
|
+
}.should raise_error(ArgumentError, message)
|
125
|
+
end
|
126
|
+
|
127
|
+
it "should render the year_range argument correctly" do
|
128
|
+
output = calendar_date_select(:model, :start_datetime)
|
129
|
+
output.should include("year_range:10")
|
130
|
+
output = calendar_date_select(:model, :start_datetime, :year_range => 2000..2010)
|
131
|
+
output.should include("year_range:[2000, 2010]")
|
132
|
+
output = calendar_date_select(:model, :start_datetime, :year_range => (15.years.ago..5.years.ago))
|
133
|
+
output.should include("year_range:[#{15.years.ago.year}, #{5.years.ago.year}]")
|
134
|
+
end
|
135
|
+
|
136
|
+
it "should disregard the :object parameter when nil" do
|
137
|
+
@model.start_datetime = Time.parse("January 2, 2007 12:00 AM")
|
138
|
+
output = calendar_date_select(:model, :start_datetime, :time => true, :object => nil)
|
139
|
+
output.should include(CalendarDateSelect.format_date(@model.start_datetime))
|
140
|
+
end
|
141
|
+
|
142
|
+
it "should regard :object parameter" do
|
143
|
+
@model.start_datetime = Time.parse("January 2, 2007 12:00 AM")
|
144
|
+
output = calendar_date_select(:lame_o, :start_datetime, :time => true, :object => @model)
|
145
|
+
output.should include(CalendarDateSelect.format_date(@model.start_datetime))
|
146
|
+
end
|
147
|
+
|
148
|
+
it "should respect parameters provided in default_options" do
|
149
|
+
new_options = CalendarDateSelect.default_options.merge(:popup => "force")
|
150
|
+
CalendarDateSelect.stub!(:default_options).and_return(new_options)
|
151
|
+
calendar_date_select_tag(:name, "").should include("popup:'force'")
|
152
|
+
end
|
153
|
+
|
154
|
+
it "should respect the :image option" do
|
155
|
+
output = calendar_date_select_tag(:name, "Some String", :image => "boogy.png")
|
156
|
+
output.should include("boogy.png")
|
157
|
+
end
|
158
|
+
|
159
|
+
it "should not pass the :image option as a javascript option" do
|
160
|
+
output = calendar_date_select_tag(:name, "Some String", :image => "boogy.png")
|
161
|
+
output.should_not include("image:")
|
162
|
+
end
|
163
|
+
|
164
|
+
it "should use the CSS class calendar_date_select_tag for popup selector icon" do
|
165
|
+
output = calendar_date_select_tag(:name, "Some String", :image => "boogy.png")
|
166
|
+
output.should include("calendar_date_select_popup_icon")
|
167
|
+
end
|
168
|
+
|
169
|
+
describe "calendar_date_select_tag" do
|
170
|
+
before(:each) do
|
171
|
+
@time = Time.parse("January 2, 2007 12:01:23 AM")
|
172
|
+
end
|
173
|
+
|
174
|
+
it "should use the string verbatim when provided" do
|
175
|
+
output = calendar_date_select_tag(:name, "Some String")
|
176
|
+
|
177
|
+
output.should include("Some String")
|
178
|
+
end
|
179
|
+
|
180
|
+
it "should not render the time when time is false (or nil)" do
|
181
|
+
output = calendar_date_select_tag(:name, @time, :time => false)
|
182
|
+
|
183
|
+
output.should_not match(/12:01 AM/)
|
184
|
+
output.should include(CalendarDateSelect.format_date(@time.to_date))
|
185
|
+
end
|
186
|
+
|
187
|
+
it "should render the time when :time => true" do
|
188
|
+
output = calendar_date_select_tag(:name, @time, :time => true)
|
189
|
+
|
190
|
+
output.should include(CalendarDateSelect.format_date(@time))
|
191
|
+
end
|
192
|
+
|
193
|
+
it "should render the time when :time => 'mixed'" do
|
194
|
+
output = calendar_date_select_tag(:name, @time, :time => 'mixed')
|
195
|
+
output.should include(CalendarDateSelect.format_date(@time))
|
196
|
+
end
|
197
|
+
|
198
|
+
it "not include the image option in the result input tag" do
|
199
|
+
output = calendar_date_select_tag(:name, @time, :time => 'mixed')
|
200
|
+
output.should_not include("image=")
|
201
|
+
end
|
202
|
+
end
|
203
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe CalendarDateSelect::IncludesHelper do
|
4
|
+
include ActionView::Helpers::TagHelper
|
5
|
+
include ActionView::Helpers::AssetTagHelper
|
6
|
+
include CalendarDateSelect::IncludesHelper
|
7
|
+
|
8
|
+
describe "calendar_date_select_includes" do
|
9
|
+
it "should include the specified locale" do
|
10
|
+
calendar_date_select_includes(:locale => "fr").should include("calendar_date_select/locale/fr.js")
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should include the specified style" do
|
14
|
+
calendar_date_select_includes(:style => "blue").should include("calendar_date_select/blue.css")
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should complain if you provide an illegitimate argument" do
|
18
|
+
lambda { calendar_date_select_includes(:language => "fr") }.should raise_error(ArgumentError)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "calendar_date_select_javascripts" do
|
23
|
+
it "should return an array of javascripts" do
|
24
|
+
calendar_date_select_javascripts.should == ["calendar_date_select/calendar_date_select"]
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should return the :javascript_include of the specified format, if the specified format expects it" do
|
28
|
+
CalendarDateSelect.stub!(:format).and_return(CalendarDateSelect::FORMATS[:hyphen_ampm])
|
29
|
+
calendar_date_select_javascripts.should == ["calendar_date_select/calendar_date_select", "calendar_date_select/format_hyphen_ampm"]
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should blow up if an illegitimate argument is passed" do
|
33
|
+
lambda { calendar_date_select_javascripts(:language => "fr") }.should raise_error(ArgumentError)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe "calendar_date_select_stylesheets" do
|
38
|
+
it "should return an array of stylesheet" do
|
39
|
+
calendar_date_select_javascripts.should == ["calendar_date_select/calendar_date_select"]
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should blow up if an illegitimate argument is passed" do
|
43
|
+
lambda { calendar_date_select_stylesheets(:css_version => "blue") }.should raise_error(ArgumentError)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
|
3
|
+
require 'spec'
|
4
|
+
|
5
|
+
gem 'activesupport', ">= 2.2.0"
|
6
|
+
gem 'actionpack', ">= 2.2.0"
|
7
|
+
|
8
|
+
require 'active_support'
|
9
|
+
require 'action_pack'
|
10
|
+
require 'action_controller'
|
11
|
+
require 'action_view'
|
12
|
+
|
13
|
+
require 'ostruct'
|
14
|
+
|
15
|
+
ActionView::Helpers::InstanceTag.class_eval do
|
16
|
+
class << self; alias new_with_backwards_compatibility new; end
|
17
|
+
end
|
18
|
+
|
19
|
+
$: << (File.dirname(__FILE__) + "/../lib")
|
20
|
+
require "calendar_date_select"
|
21
|
+
|
22
|
+
class String
|
23
|
+
def to_regexp
|
24
|
+
is_a?(Regexp) ? self : Regexp.new(Regexp.escape(self.to_s))
|
25
|
+
end
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: tristandunn-calendar_date_select
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Enrique Garcia Cota (kikito)
|
8
|
+
- Tim Charper
|
9
|
+
- Lars E. Hoeg
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
|
14
|
+
date: 2010-01-06 00:00:00 -05:00
|
15
|
+
default_executable:
|
16
|
+
dependencies: []
|
17
|
+
|
18
|
+
description: calendar_date_select fork; includes highlighting
|
19
|
+
email: egarcia@splendeo.es
|
20
|
+
executables: []
|
21
|
+
|
22
|
+
extensions: []
|
23
|
+
|
24
|
+
extra_rdoc_files:
|
25
|
+
- README.txt
|
26
|
+
files:
|
27
|
+
- .gitignore
|
28
|
+
- History.txt
|
29
|
+
- MIT-LICENSE
|
30
|
+
- Manifest.txt
|
31
|
+
- README.txt
|
32
|
+
- Rakefile
|
33
|
+
- VERSION
|
34
|
+
- calendar_date_select.gemspec
|
35
|
+
- init.rb
|
36
|
+
- js_test/functional/.tmp_cds_test.html
|
37
|
+
- js_test/functional/cds_test.html
|
38
|
+
- js_test/functional/format_iso_date_test.html
|
39
|
+
- js_test/prototype.js
|
40
|
+
- js_test/test.css
|
41
|
+
- js_test/unit/cds_helper_methods.html
|
42
|
+
- js_test/unittest.js
|
43
|
+
- lib/calendar_date_select.rb
|
44
|
+
- lib/calendar_date_select/calendar_date_select.rb
|
45
|
+
- lib/calendar_date_select/form_helpers.rb
|
46
|
+
- lib/calendar_date_select/includes_helper.rb
|
47
|
+
- public/blank_iframe.html
|
48
|
+
- public/images/calendar_date_select/calendar.gif
|
49
|
+
- public/javascripts/calendar_date_select/calendar_date_select.js
|
50
|
+
- public/javascripts/calendar_date_select/format_american.js
|
51
|
+
- public/javascripts/calendar_date_select/format_danish.js
|
52
|
+
- public/javascripts/calendar_date_select/format_db.js
|
53
|
+
- public/javascripts/calendar_date_select/format_euro_24hr.js
|
54
|
+
- public/javascripts/calendar_date_select/format_euro_24hr_ymd.js
|
55
|
+
- public/javascripts/calendar_date_select/format_finnish.js
|
56
|
+
- public/javascripts/calendar_date_select/format_hyphen_ampm.js
|
57
|
+
- public/javascripts/calendar_date_select/format_iso_date.js
|
58
|
+
- public/javascripts/calendar_date_select/format_italian.js
|
59
|
+
- public/javascripts/calendar_date_select/locale/ar.js
|
60
|
+
- public/javascripts/calendar_date_select/locale/da.js
|
61
|
+
- public/javascripts/calendar_date_select/locale/de.js
|
62
|
+
- public/javascripts/calendar_date_select/locale/es.js
|
63
|
+
- public/javascripts/calendar_date_select/locale/fi.js
|
64
|
+
- public/javascripts/calendar_date_select/locale/fr.js
|
65
|
+
- public/javascripts/calendar_date_select/locale/it.js
|
66
|
+
- public/javascripts/calendar_date_select/locale/nl.js
|
67
|
+
- public/javascripts/calendar_date_select/locale/pl.js
|
68
|
+
- public/javascripts/calendar_date_select/locale/pt.js
|
69
|
+
- public/javascripts/calendar_date_select/locale/ru.js
|
70
|
+
- public/javascripts/calendar_date_select/locale/sl.js
|
71
|
+
- public/stylesheets/calendar_date_select/blue.css
|
72
|
+
- public/stylesheets/calendar_date_select/default.css
|
73
|
+
- public/stylesheets/calendar_date_select/green.css
|
74
|
+
- public/stylesheets/calendar_date_select/plain.css
|
75
|
+
- public/stylesheets/calendar_date_select/red.css
|
76
|
+
- public/stylesheets/calendar_date_select/silver.css
|
77
|
+
- spec/calendar_date_select/calendar_date_select_spec.rb
|
78
|
+
- spec/calendar_date_select/form_helpers_spec.rb
|
79
|
+
- spec/calendar_date_select/includes_helper_spec.rb
|
80
|
+
- spec/spec_helper.rb
|
81
|
+
has_rdoc: true
|
82
|
+
homepage: http://github.com/kikito/calendar_date_select
|
83
|
+
licenses: []
|
84
|
+
|
85
|
+
post_install_message:
|
86
|
+
rdoc_options:
|
87
|
+
- --charset=UTF-8
|
88
|
+
require_paths:
|
89
|
+
- lib
|
90
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: "0"
|
95
|
+
version:
|
96
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: "0"
|
101
|
+
version:
|
102
|
+
requirements: []
|
103
|
+
|
104
|
+
rubyforge_project:
|
105
|
+
rubygems_version: 1.3.5
|
106
|
+
signing_key:
|
107
|
+
specification_version: 3
|
108
|
+
summary: calendar_date_select fork; includes highlighting
|
109
|
+
test_files:
|
110
|
+
- spec/calendar_date_select/calendar_date_select_spec.rb
|
111
|
+
- spec/calendar_date_select/form_helpers_spec.rb
|
112
|
+
- spec/calendar_date_select/includes_helper_spec.rb
|
113
|
+
- spec/spec_helper.rb
|