calendar_date_select 1.15 → 1.16
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -0
- data/History.txt +29 -0
- data/Manifest.txt +1 -1
- data/{Readme.txt → README.txt} +2 -0
- data/Rakefile +18 -13
- data/VERSION +1 -0
- data/calendar_date_select.gemspec +96 -0
- data/js_test/functional/.tmp_cds_test.html +306 -0
- data/js_test/functional/cds_test.html +31 -0
- data/js_test/functional/format_iso_date_test.html +52 -0
- data/lib/calendar_date_select/calendar_date_select.rb +10 -4
- data/lib/calendar_date_select/form_helpers.rb +16 -4
- data/public/javascripts/calendar_date_select/calendar_date_select.js +9 -4
- data/public/javascripts/calendar_date_select/format_american.js +2 -1
- data/public/javascripts/calendar_date_select/format_danish.js +31 -0
- data/public/javascripts/calendar_date_select/format_iso_date.js +19 -36
- 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/es.js +11 -0
- data/public/javascripts/calendar_date_select/locale/fr.js +2 -1
- 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 +2 -1
- data/public/javascripts/calendar_date_select/locale/sl.js +11 -0
- data/public/stylesheets/calendar_date_select/green.css +142 -0
- data/spec/calendar_date_select/form_helpers_spec.rb +23 -0
- data/spec/calendar_date_select/includes_helper_spec.rb +46 -0
- data/spec/spec_helper.rb +1 -1
- metadata +52 -39
data/.gitignore
ADDED
data/History.txt
CHANGED
@@ -1,3 +1,32 @@
|
|
1
|
+
== Version 1.16
|
2
|
+
|
3
|
+
* Ability to specify a default time/date if no time/date is selected in the target form element. (Shih-gian Lee)
|
4
|
+
|
5
|
+
== Version 1.15.2
|
6
|
+
|
7
|
+
* Fix for set date (day must go last) (ujifgc)
|
8
|
+
* added logic to wrap image in span tag when there is error fields. (Shih-gian Lee)
|
9
|
+
* Initial commit of default time implementation. (Shih-gian Lee)
|
10
|
+
* default time implementation in form_helpers.rb. (Shih-gian Lee)
|
11
|
+
* Fix calendar_date_select helper for searchlogic compatibility (Andrea Frigido)
|
12
|
+
* Added Arabic language translations (Abdul-Jabbar Shalabi)
|
13
|
+
* rename instance variable. avoid conflict with name (Cyril Mougel)
|
14
|
+
* add translation in french (Cyril Mougel)
|
15
|
+
* Adding Slovenian sl-sl locale. (Miha Rebernik)
|
16
|
+
* Added danish format (Jacob Kjeldahl)
|
17
|
+
* translations for NL (Gert van der Spoel)
|
18
|
+
* new color scheme 'green' (Gert van der Spoel)
|
19
|
+
* Fixed missing translation in polish locales (Witold Rugowski)
|
20
|
+
* Added a italian locale (Andrea Frigido)
|
21
|
+
* fix time handling (Robert Brown)
|
22
|
+
* Added a spanish locale on public/javascripts/calendar_date_select/locale/es.js (kikito)
|
23
|
+
* Added description for iso date format (Lars E. Hoeg)
|
24
|
+
* Added Danish (da) translation (Lars E. Hoeg)
|
25
|
+
* Fixes issue with nil dates and trying to call type on them (Matt Haley)
|
26
|
+
|
27
|
+
== Version 1.15.1
|
28
|
+
* Bugfix: iso_date fixes (Robert Brown)
|
29
|
+
|
1
30
|
== Version 1.15
|
2
31
|
* Bugfix: don't include the :image option in the input field
|
3
32
|
|
data/Manifest.txt
CHANGED
@@ -34,7 +34,7 @@ public/stylesheets/calendar_date_select/plain.css
|
|
34
34
|
public/stylesheets/calendar_date_select/red.css
|
35
35
|
public/stylesheets/calendar_date_select/silver.css
|
36
36
|
Rakefile
|
37
|
-
|
37
|
+
README.txt
|
38
38
|
spec/
|
39
39
|
spec/calendar_date_select
|
40
40
|
spec/calendar_date_select/calendar_date_select_spec.rb
|
data/{Readme.txt → README.txt}
RENAMED
data/Rakefile
CHANGED
@@ -1,26 +1,31 @@
|
|
1
1
|
# -*- ruby -*-
|
2
2
|
|
3
|
-
require 'rubygems'
|
4
|
-
require 'hoe'
|
5
3
|
|
6
|
-
|
7
|
-
require
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gemspec|
|
7
|
+
gemspec.name = "calendar_date_select"
|
8
|
+
gemspec.version = File.read("VERSION").strip
|
9
|
+
gemspec.summary = "Calendar date picker for rails"
|
10
|
+
gemspec.description = "Calendar date picker for rails"
|
11
|
+
gemspec.email = ""
|
12
|
+
gemspec.homepage = "http://github.com/timcharper/calendar_date_select"
|
13
|
+
gemspec.authors = ["Shih-gian Lee", "Enrique Garcia Cota (kikito)", "Tim Charper", "Lars E. Hoeg"]
|
14
|
+
end
|
15
|
+
rescue LoadError
|
16
|
+
puts "Jeweler not available. Install it with: sudo gem install jeweler"
|
13
17
|
end
|
14
18
|
|
15
|
-
desc "Set the current gem version in the code
|
19
|
+
desc "Set the current gem version in the code according to the VERSION file"
|
16
20
|
task :set_version do
|
21
|
+
VERSION=File.read("VERSION").strip
|
17
22
|
["lib/calendar_date_select/calendar_date_select.rb", "public/javascripts/calendar_date_select/calendar_date_select.js"].each do |file|
|
18
23
|
abs_file = File.dirname(__FILE__) + "/" + file
|
19
|
-
src = File.read(abs_file)
|
24
|
+
src = File.read(abs_file)
|
20
25
|
src = src.map do |line|
|
21
26
|
case line
|
22
|
-
when /^ *VERSION/ then " VERSION = '#{
|
23
|
-
when /^\/\/ CalendarDateSelect version / then "// CalendarDateSelect version #{
|
27
|
+
when /^ *VERSION/ then " VERSION = '#{VERSION}'\n"
|
28
|
+
when /^\/\/ CalendarDateSelect version / then "// CalendarDateSelect version #{VERSION} - a prototype based date picker\n"
|
24
29
|
else
|
25
30
|
line
|
26
31
|
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.16
|
@@ -0,0 +1,96 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{calendar_date_select}
|
8
|
+
s.version = "1.16"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Shih-gian Lee", "Enrique Garcia Cota (kikito)", "Tim Charper", "Lars E. Hoeg"]
|
12
|
+
s.date = %q{2010-03-29}
|
13
|
+
s.description = %q{Calendar date picker for rails}
|
14
|
+
s.email = %q{}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"README.txt"
|
17
|
+
]
|
18
|
+
s.files = [
|
19
|
+
".gitignore",
|
20
|
+
"History.txt",
|
21
|
+
"MIT-LICENSE",
|
22
|
+
"Manifest.txt",
|
23
|
+
"README.txt",
|
24
|
+
"Rakefile",
|
25
|
+
"VERSION",
|
26
|
+
"calendar_date_select.gemspec",
|
27
|
+
"init.rb",
|
28
|
+
"js_test/functional/.tmp_cds_test.html",
|
29
|
+
"js_test/functional/cds_test.html",
|
30
|
+
"js_test/functional/format_iso_date_test.html",
|
31
|
+
"js_test/prototype.js",
|
32
|
+
"js_test/test.css",
|
33
|
+
"js_test/unit/cds_helper_methods.html",
|
34
|
+
"js_test/unittest.js",
|
35
|
+
"lib/calendar_date_select.rb",
|
36
|
+
"lib/calendar_date_select/calendar_date_select.rb",
|
37
|
+
"lib/calendar_date_select/form_helpers.rb",
|
38
|
+
"lib/calendar_date_select/includes_helper.rb",
|
39
|
+
"public/blank_iframe.html",
|
40
|
+
"public/images/calendar_date_select/calendar.gif",
|
41
|
+
"public/javascripts/calendar_date_select/calendar_date_select.js",
|
42
|
+
"public/javascripts/calendar_date_select/format_american.js",
|
43
|
+
"public/javascripts/calendar_date_select/format_danish.js",
|
44
|
+
"public/javascripts/calendar_date_select/format_db.js",
|
45
|
+
"public/javascripts/calendar_date_select/format_euro_24hr.js",
|
46
|
+
"public/javascripts/calendar_date_select/format_euro_24hr_ymd.js",
|
47
|
+
"public/javascripts/calendar_date_select/format_finnish.js",
|
48
|
+
"public/javascripts/calendar_date_select/format_hyphen_ampm.js",
|
49
|
+
"public/javascripts/calendar_date_select/format_iso_date.js",
|
50
|
+
"public/javascripts/calendar_date_select/format_italian.js",
|
51
|
+
"public/javascripts/calendar_date_select/locale/ar.js",
|
52
|
+
"public/javascripts/calendar_date_select/locale/da.js",
|
53
|
+
"public/javascripts/calendar_date_select/locale/de.js",
|
54
|
+
"public/javascripts/calendar_date_select/locale/es.js",
|
55
|
+
"public/javascripts/calendar_date_select/locale/fi.js",
|
56
|
+
"public/javascripts/calendar_date_select/locale/fr.js",
|
57
|
+
"public/javascripts/calendar_date_select/locale/it.js",
|
58
|
+
"public/javascripts/calendar_date_select/locale/nl.js",
|
59
|
+
"public/javascripts/calendar_date_select/locale/pl.js",
|
60
|
+
"public/javascripts/calendar_date_select/locale/pt.js",
|
61
|
+
"public/javascripts/calendar_date_select/locale/ru.js",
|
62
|
+
"public/javascripts/calendar_date_select/locale/sl.js",
|
63
|
+
"public/stylesheets/calendar_date_select/blue.css",
|
64
|
+
"public/stylesheets/calendar_date_select/default.css",
|
65
|
+
"public/stylesheets/calendar_date_select/green.css",
|
66
|
+
"public/stylesheets/calendar_date_select/plain.css",
|
67
|
+
"public/stylesheets/calendar_date_select/red.css",
|
68
|
+
"public/stylesheets/calendar_date_select/silver.css",
|
69
|
+
"spec/calendar_date_select/calendar_date_select_spec.rb",
|
70
|
+
"spec/calendar_date_select/form_helpers_spec.rb",
|
71
|
+
"spec/calendar_date_select/includes_helper_spec.rb",
|
72
|
+
"spec/spec_helper.rb"
|
73
|
+
]
|
74
|
+
s.homepage = %q{http://github.com/timcharper/calendar_date_select}
|
75
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
76
|
+
s.require_paths = ["lib"]
|
77
|
+
s.rubygems_version = %q{1.3.6}
|
78
|
+
s.summary = %q{Calendar date picker for rails}
|
79
|
+
s.test_files = [
|
80
|
+
"spec/calendar_date_select/calendar_date_select_spec.rb",
|
81
|
+
"spec/calendar_date_select/form_helpers_spec.rb",
|
82
|
+
"spec/calendar_date_select/includes_helper_spec.rb",
|
83
|
+
"spec/spec_helper.rb"
|
84
|
+
]
|
85
|
+
|
86
|
+
if s.respond_to? :specification_version then
|
87
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
88
|
+
s.specification_version = 3
|
89
|
+
|
90
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
91
|
+
else
|
92
|
+
end
|
93
|
+
else
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
@@ -0,0 +1,306 @@
|
|
1
|
+
|
2
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
3
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
4
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
5
|
+
<head>
|
6
|
+
<title>Calendar Date Select Test Cases</title>
|
7
|
+
<script src="../prototype.js" type="text/javascript"></script>
|
8
|
+
<script src="../unittest.js" type="text/javascript"></script>
|
9
|
+
<!-- other JavaScript includes -->
|
10
|
+
<script src="../../public/javascripts/calendar_date_select/calendar_date_select.js" type="text/javascript"></script>
|
11
|
+
|
12
|
+
<link rel="stylesheet" href="../../public/stylesheets/calendar_date_select/red.css" type="text/css" />
|
13
|
+
<link rel="stylesheet" href="../test.css" type="text/css" />
|
14
|
+
</head>
|
15
|
+
<body>
|
16
|
+
|
17
|
+
<!-- Log output -->
|
18
|
+
<div id="testlog"> </div>
|
19
|
+
|
20
|
+
<!-- here go any elements you do the testing on -->
|
21
|
+
<div id="cds_test_div">
|
22
|
+
<input type="text" id="cds_test" />
|
23
|
+
</div>
|
24
|
+
|
25
|
+
<!-- Tests -->
|
26
|
+
<script type="text/javascript" language="javascript">
|
27
|
+
// <![CDATA[
|
28
|
+
new Test.Unit.Runner({
|
29
|
+
setup: function() { with(this){
|
30
|
+
$("cds_test").value="";
|
31
|
+
$("cds_test").disabled = false;
|
32
|
+
$("cds_test").readOnly = false;
|
33
|
+
}},
|
34
|
+
teardown: function() { with(this){
|
35
|
+
if (typeof(cds)!="undefined")
|
36
|
+
assert(cds.closed,"all tests should close their calendar control");
|
37
|
+
}},
|
38
|
+
testMixedTime_feedDateWithAndWithoutTime_shouldSetAccordingly: function() { with(this) {
|
39
|
+
$A(["January 2, 2007 5:00 pm", "January 2, 2007 0:00 pm"]).each(function(d) {
|
40
|
+
$("cds_test").value=d;
|
41
|
+
cds = new CalendarDateSelect($("cds_test"), {time: "mixed"});
|
42
|
+
assertEqual(true, cds.use_time);
|
43
|
+
cds.close();
|
44
|
+
})
|
45
|
+
|
46
|
+
$("cds_test").value="January 2, 2007";
|
47
|
+
cds = new CalendarDateSelect($("cds_test"), {time: "mixed"});
|
48
|
+
assertEqual(false, cds.use_time);
|
49
|
+
cds.close();
|
50
|
+
}},
|
51
|
+
testTodayNowButton_mixedMode_shouldSetUseTimeAccordingly: function() { with(this){
|
52
|
+
cds = new CalendarDateSelect($("cds_test"), {time: "mixed"});
|
53
|
+
today_now = $$(".cds_buttons a[href=#]");
|
54
|
+
today_now[0].onclick();
|
55
|
+
assertEqual(false, cds.use_time, "when clicking today link");
|
56
|
+
|
57
|
+
today_now[1].onclick();
|
58
|
+
assertEqual(true, cds.use_time, "should have been true when clicking now link");
|
59
|
+
cds.close();
|
60
|
+
}},
|
61
|
+
test__selectMar_23_2008__shouldSelectCorrectDate: function() { with(this){
|
62
|
+
$("cds_test").value = "Mar 1, 2008"
|
63
|
+
cds = new CalendarDateSelect($("cds_test"), {time: "true"});
|
64
|
+
cds.updateSelectedDate({month: 2 /*+1*/, day: 23, year: 2008})
|
65
|
+
|
66
|
+
assertEqual("23", $$('td.selected div').first().innerHTML);
|
67
|
+
cds.close();
|
68
|
+
}},
|
69
|
+
test_updateSelectedDate: function() { with(this){
|
70
|
+
$("cds_test").value = "January 1, 2007"
|
71
|
+
cds = new CalendarDateSelect($("cds_test"), {time: "mixed"});
|
72
|
+
|
73
|
+
cds.use_time=true;
|
74
|
+
cds.updateSelectedDate({hour: ""})
|
75
|
+
assertEqual(false, cds.use_time, "when setting hour to ''");
|
76
|
+
|
77
|
+
cds.use_time=true;
|
78
|
+
cds.updateSelectedDate({minute: ""})
|
79
|
+
assertEqual(false, cds.use_time, "when setting minute to ''");
|
80
|
+
|
81
|
+
cds.use_time=false;
|
82
|
+
cds.updateSelectedDate({hour: 0})
|
83
|
+
assertEqual(true, cds.use_time, "when setting hour to 0");
|
84
|
+
|
85
|
+
cds.use_time=false;
|
86
|
+
cds.updateSelectedDate({minute: 0})
|
87
|
+
assertEqual(true, cds.use_time, "when setting minute to 0");
|
88
|
+
|
89
|
+
cds.close();
|
90
|
+
}},
|
91
|
+
test_navYear: function() { with(this){
|
92
|
+
$("cds_test").value = "January 1, 2007";
|
93
|
+
cds = new CalendarDateSelect($("cds_test"), {time: "mixed"});
|
94
|
+
cds.navYear(1870);
|
95
|
+
assertEqual(2007, cds.selected_date.getFullYear());
|
96
|
+
assertEqual(1870, cds.date.getFullYear());
|
97
|
+
cds.close();
|
98
|
+
}},
|
99
|
+
test_navMonth: function() { with(this){
|
100
|
+
$("cds_test").value = "January 1, 2007";
|
101
|
+
cds = new CalendarDateSelect($("cds_test"), {time: "mixed"});
|
102
|
+
cds.navMonth(5);
|
103
|
+
assertEqual(0, cds.selected_date.getMonth());
|
104
|
+
assertEqual(5, cds.date.getMonth())
|
105
|
+
cds.close();
|
106
|
+
}},
|
107
|
+
test_callBacks: function() { with(this){
|
108
|
+
$("cds_test").up().build("div", {id: "global"});
|
109
|
+
cds = new CalendarDateSelect($("cds_test"), {time: "mixed",
|
110
|
+
before_show: function() { $("global").before_show_called = true},
|
111
|
+
after_show: function() { $("global").after_show_called = true},
|
112
|
+
before_close: function() { $("global").before_close_called = true},
|
113
|
+
after_close: function() { $("global").after_close_called = true},
|
114
|
+
after_navigate: function() { $("global").after_navigate_called = true},
|
115
|
+
onchange: function() { $("global").onchange_called = true},
|
116
|
+
});
|
117
|
+
cds.navMonth(1);
|
118
|
+
cds.navMonth(10);
|
119
|
+
cds.updateSelectedDate({month: 1, day: 3, year: 2007});
|
120
|
+
cds.close();
|
121
|
+
assert($('global').before_show_called, "before_show wasnt called");
|
122
|
+
assert($('global').after_show_called, "after_show wasnt called");
|
123
|
+
assert($('global').before_close_called, "before_close wasnt called");
|
124
|
+
assert($('global').after_close_called, "after_close wasnt called");
|
125
|
+
assert($('global').after_navigate_called, "after_navigate wasnt called");
|
126
|
+
assert($('global').onchange_called, "onchange wasnt called");
|
127
|
+
$("global").remove();
|
128
|
+
}},
|
129
|
+
test_disabledElement_cantUpdate: function() {with(this){
|
130
|
+
$("cds_test").value = "May 10, 2007";
|
131
|
+
$("cds_test").disabled = true;
|
132
|
+
cds = new CalendarDateSelect($("cds_test"));
|
133
|
+
|
134
|
+
runTest = function() {
|
135
|
+
cds.updateSelectedDate({day: 1, month:0, year: 2007});
|
136
|
+
assertEqual(10, cds.selected_date.getDate())
|
137
|
+
}
|
138
|
+
runTest();
|
139
|
+
$("cds_test").disabled = false;
|
140
|
+
$("cds_test").readOnly = true;
|
141
|
+
runTest();
|
142
|
+
|
143
|
+
$("cds_test").readOnly = false;
|
144
|
+
cds.close();
|
145
|
+
}},
|
146
|
+
test_readOnlyElement_forcePopup_shouldUpdate: function() {with(this){
|
147
|
+
$("cds_test").value = "May 10, 2007";
|
148
|
+
$("cds_test").readOnly = true;
|
149
|
+
cds = new CalendarDateSelect($("cds_test"), {popup: "force"});
|
150
|
+
|
151
|
+
cds.updateSelectedDate({day: 1, month:0, year: 2007});
|
152
|
+
assertEqual(1, cds.selected_date.getDate())
|
153
|
+
|
154
|
+
$("cds_test").readOnly = false;
|
155
|
+
cds.close();
|
156
|
+
}},
|
157
|
+
test_timePassed_notUsingTime_shouldIgnore: function() {with(this) {
|
158
|
+
$("cds_test").value = "May 10, 2007 5:00 pm";
|
159
|
+
cds = new CalendarDateSelect($("cds_test"), {time:false});
|
160
|
+
assert(cds.options.get("close_on_click"), "should set close_on_click to true when not using time")
|
161
|
+
assertEqual(false, cds.use_time, "When parsing time");
|
162
|
+
cds.today();
|
163
|
+
assert(cds.closed, "should close when clicking today");
|
164
|
+
assert(!cds.use_time, "Should not use time when calling today");
|
165
|
+
|
166
|
+
cds = new CalendarDateSelect($("cds_test"), {time:false});
|
167
|
+
cds.updateSelectedDate({hours: 5, minutes:30}) // this will close the control
|
168
|
+
assertEqual(false, cds.use_time, "When setting hour/minute");
|
169
|
+
assert(cds.closed);
|
170
|
+
}},
|
171
|
+
test_setUseTime_true_notUsingTime_shouldIgnore: function() {with(this) {
|
172
|
+
$("cds_test").value = "May 10, 2007 5:00 pm";
|
173
|
+
cds = new CalendarDateSelect($("cds_test"), {time:false});
|
174
|
+
assertEqual(false, cds.use_time, "When parsing time");
|
175
|
+
cds.setUseTime(true); // this will close the control
|
176
|
+
assert(! cds.use_time, "After calling setUseTime(true)");
|
177
|
+
cds.close();
|
178
|
+
}},
|
179
|
+
test_setMinute_notOnInterval_usesFloor: function() {with(this){
|
180
|
+
$("cds_test").value = "May 10, 2007 5:25 pm";
|
181
|
+
cds = new CalendarDateSelect($("cds_test"), {time:true});
|
182
|
+
cds.updateSelectedDate({hour: 1, minute: 4});
|
183
|
+
assertEqual(0, cds.selected_date.getMinutes());
|
184
|
+
assertEqual(1, cds.selected_date.getHours());
|
185
|
+
|
186
|
+
cds.close();
|
187
|
+
}},
|
188
|
+
// this checks for a safari 2 bug where safari parses "" as a date back in 1969
|
189
|
+
test_parseDate_blankInput_interpretsAsNotSelected: function() {with(this){
|
190
|
+
$("cds_test").value = " ";
|
191
|
+
cds = new CalendarDateSelect($("cds_test"), {time:true});
|
192
|
+
assertEqual(new Date().getFullYear(), cds.selected_date.getFullYear());
|
193
|
+
assertEqual(new Date().getFullYear(), cds.date.getFullYear());
|
194
|
+
assert(! cds.selection_made)
|
195
|
+
cds.close();
|
196
|
+
}},
|
197
|
+
test_parseDate_timeTrue_noTimePassed_useTimeSetToTrueAnyway: function() {with(this){
|
198
|
+
$("cds_test").value = "December 1, 2007 ";
|
199
|
+
cds = new CalendarDateSelect($("cds_test"), {time:true});
|
200
|
+
assert(cds.use_time)
|
201
|
+
cds.close();
|
202
|
+
}},
|
203
|
+
test_passDivElement__shouldUseChildInputForTargetElement: function() {with(this){
|
204
|
+
cds = new CalendarDateSelect($("cds_test_div"), {time:true});
|
205
|
+
assertEqual("INPUT", cds.target_element.nodeName)
|
206
|
+
cds.close();
|
207
|
+
}},
|
208
|
+
test__flexibleYearRange__datePassedWayBackWhen__shouldInitYearSelectAroundDate: function() {with(this){
|
209
|
+
$("cds_test").value = "July 4, 1776";
|
210
|
+
cds = new CalendarDateSelect($("cds_test_div"), {time:true});
|
211
|
+
assert(cds.flexibleYearRange(), " should have had a flexibleYearRange");
|
212
|
+
assert(cds.year_select.setValue(1776), "Should have allowed me to select 1776");
|
213
|
+
cds.close();
|
214
|
+
}},
|
215
|
+
test__nonflexibleYearRange__dateRangeAtEnds__shouldntAllowNavigationPassedBoundary: function() {with(this){
|
216
|
+
$("cds_test").value = "January 1, 2007";
|
217
|
+
cds = new CalendarDateSelect($("cds_test_div"), {time:true, year_range: [2007, 2007]});
|
218
|
+
|
219
|
+
assert(! cds.navYear(2006), "should not allow year navigation outside of boundary");
|
220
|
+
assert(! cds.navYear(2008), "should not allow year navigation outside of boundary");
|
221
|
+
assert(! cds.navMonth(-1), "shouldnt allow me to go beyond boundary");
|
222
|
+
assert(! cds.navMonth(13), "shouldnt allow me to go beyond boundary");
|
223
|
+
assert(cds.navMonth(1), "should allow me to be in boundary");
|
224
|
+
assert(cds.navYear(2007), "should allow me to be in boundary");
|
225
|
+
cds.close();
|
226
|
+
}},
|
227
|
+
test__nonflexibleYearRange__shouldPopulateRange: function() {with(this){
|
228
|
+
$("cds_test").value = "January 1, 2007";
|
229
|
+
cds = new CalendarDateSelect($("cds_test_div"), {time:true, year_range: [2007, 2007]});
|
230
|
+
assert(cds.year_select.setValue(2007), "should allow me to select 2007");
|
231
|
+
cds.close();
|
232
|
+
}},
|
233
|
+
test__nonflexibleYearRange__initializedWithDateOutsideOfRange__shouldShowNavDateAsClosestToOutsideYear: function() {with(this){
|
234
|
+
$("cds_test").value = "January 1, 1900";
|
235
|
+
cds = new CalendarDateSelect($("cds_test_div"), {time:true, year_range: [1997, 2007]});
|
236
|
+
assertEqual(1997, cds.date.getFullYear(), "When going lesser than year_range");
|
237
|
+
cds.close();
|
238
|
+
|
239
|
+
$("cds_test").value = "January 1, 2010";
|
240
|
+
cds = new CalendarDateSelect($("cds_test_div"), {time:true, year_range: [1997, 2007]});
|
241
|
+
assertEqual(2007, cds.date.getFullYear(), "When going greater than year_range");
|
242
|
+
|
243
|
+
cds.close();
|
244
|
+
}},
|
245
|
+
test__nonflexibleYearRange__initializedWithDateInsideOfRange__shouldShowNavDateAsYear: function() {with(this){
|
246
|
+
$("cds_test").value = "January 1, 2005";
|
247
|
+
cds = new CalendarDateSelect($("cds_test_div"), {year_range: [1997, 2007]});
|
248
|
+
assertEqual(2005, cds.date.getFullYear(), "When going lesser than year_range");
|
249
|
+
cds.close();
|
250
|
+
}},
|
251
|
+
test__flexibleYearRange__goToBoundary__shouldRefreshRange: function() {with(this){
|
252
|
+
$("cds_test").value = "January 1, 2007";
|
253
|
+
cds = new CalendarDateSelect($("cds_test_div"), {year_range: 10});
|
254
|
+
cds.navYear(1997);
|
255
|
+
assert(cds.year_select.setValue(1987), "should have refreshed with 1997 as the center");
|
256
|
+
cds.navYear(2017);
|
257
|
+
assert(cds.year_select.setValue(2027), "should have refreshed with 2027 as the center");
|
258
|
+
cds.close();
|
259
|
+
}},
|
260
|
+
test__should_show_iframe_only_in_ie: function() {with(this){
|
261
|
+
cds = new CalendarDateSelect($("cds_test_div"));
|
262
|
+
|
263
|
+
if (navigator.appName=="Microsoft Internet Explorer")
|
264
|
+
assertEqual(1, $$('iframe.ie6_blocker').length)
|
265
|
+
else
|
266
|
+
assertEqual(0, $$('iframe.ie6_blocker').length)
|
267
|
+
|
268
|
+
cds.close();
|
269
|
+
}},
|
270
|
+
test__should_populate_minute_box_according_to_minute_interval: function() {with(this){
|
271
|
+
cds = new CalendarDateSelect($("cds_test_div"), {time: true, minute_interval: 10});
|
272
|
+
assert(cds.minute_select.setValue(0), "should allow me to select 0 minutes" );
|
273
|
+
assert(!cds.minute_select.setValue(5), "should NOT allow me to select 5 minutes");
|
274
|
+
assert(cds.minute_select.setValue(10), "should allow me to select 10 minutes" );
|
275
|
+
cds.close();
|
276
|
+
}},
|
277
|
+
test__shouldnt_leak_variables: function() {with (this) {
|
278
|
+
var vars = $w("padded2 compare_date str minute hour value e above e_dim e_top e_left matched e_bottom e_height c_pos c_left c_top c_height left_px top_px top_div header_div body_div buttons_div footer_div bottom_div days_tbody row_number cell_index weekday that pre_days use_time m y hover_date x d o")
|
279
|
+
vars.each(function(v) {eval(v + " = -100");});
|
280
|
+
|
281
|
+
cds = new CalendarDateSelect($("cds_test_div"), {time: true});
|
282
|
+
cds.navMonth(1);
|
283
|
+
cds.navYear(2);
|
284
|
+
cds.dayHover($$('.cds_body td').first());
|
285
|
+
cds.updateSelectedDate({day:1, month:1, year:2007});
|
286
|
+
cds.close();
|
287
|
+
|
288
|
+
vars.each(function(v) {
|
289
|
+
assert(-100 == eval(v), "Variable " + v + " was leaked");
|
290
|
+
});
|
291
|
+
}},
|
292
|
+
test__valid_date__shouldnt_allow_selection_of_invalid_dates_and_should_apply_css: function() {with (this) {
|
293
|
+
$('cds_test').value = "December 11, 2007";
|
294
|
+
cds = new CalendarDateSelect($("cds_test_div"), {valid_date_check: function(date) { date < new Date("December 13, 2007")}});
|
295
|
+
cds.updateSelectedDate({day:13, month:12-1, year:2007});
|
296
|
+
cds.close();
|
297
|
+
|
298
|
+
vars.each(function(v) {
|
299
|
+
assert(-100 == eval(v), "Variable " + v + " was leaked");
|
300
|
+
});
|
301
|
+
}}
|
302
|
+
});
|
303
|
+
// ]]>
|
304
|
+
</script>
|
305
|
+
</body>
|
306
|
+
</html>
|