calendar_date_select 1.11.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +216 -0
- data/MIT-LICENSE +20 -0
- data/Manifest.txt +39 -0
- data/Rakefile +31 -0
- data/Readme.txt +16 -0
- data/init.rb +1 -0
- data/js_test/functional/cds_test.html +334 -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.rb +19 -0
- data/lib/calendar_date_select/calendar_date_select.rb +223 -0
- data/lib/calendar_date_select/includes_helper.rb +38 -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 +442 -0
- data/public/javascripts/calendar_date_select/format_american.js +34 -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 +36 -0
- data/public/javascripts/calendar_date_select/format_iso_date.js +46 -0
- data/public/javascripts/calendar_date_select/format_italian.js +24 -0
- data/public/javascripts/calendar_date_select/locale/de.js +10 -0
- data/public/javascripts/calendar_date_select/locale/fi.js +10 -0
- data/public/javascripts/calendar_date_select/locale/fr.js +10 -0
- data/public/javascripts/calendar_date_select/locale/pl.js +10 -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/stylesheets/calendar_date_select/blue.css +130 -0
- data/public/stylesheets/calendar_date_select/default.css +135 -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/test/functional/calendar_date_select_test.rb +157 -0
- data/test/functional/helper_methods_test.rb +15 -0
- data/test/test_helper.rb +19 -0
- metadata +104 -0
data/History.txt
ADDED
@@ -0,0 +1,216 @@
|
|
1
|
+
== Version 1.11.1 ==
|
2
|
+
* properly wrap buttons if they are too big for the line
|
3
|
+
* more translations: german (Jonas), Added russian translation (DEkart)
|
4
|
+
* locale fixes:
|
5
|
+
* Fix: time doesn't work (using 12 hour instead of 24 hour) in Italian format.
|
6
|
+
* updated Portuguese translation with the "Clear" action (Daniel Luz)
|
7
|
+
* Portuguese was missing month of October
|
8
|
+
* Added a clear button (Hendy Tanata)
|
9
|
+
* Reverted a change that attempted to fix position in a scrollable div, but caused probles elsewhere
|
10
|
+
* Added :minute_interval to calendar_date_select_process_options, fixing http://code.google.com/p/calendardateselect/issues/detail?id=81
|
11
|
+
* Add helpers to give the list of javascripts and stylesheets (calendar_date_select_javascripts and calendar_date_select_stylesheets)
|
12
|
+
* Converted over to use Hoe (echoe was giving too many problems). Refactored the directory structure to make it more gem-ish.
|
13
|
+
|
14
|
+
== Version 1.11 ==
|
15
|
+
|
16
|
+
* Calendar Date Select now works as a ruby-gem (thanks, artmotion!)
|
17
|
+
* Applied fix outlined in Issue #83: http://code.google.com/p/calendardateselect/issues/detail?id=83 (Thanks David Bolton)
|
18
|
+
|
19
|
+
== Version 1.10.5 ==
|
20
|
+
Apr 7, 2008
|
21
|
+
* Javascript code refactoring! Less mess!
|
22
|
+
* Bugfix - range was including element 42, which is really the 43rd element, so there was an error happening when today happens exactly 43 days after the beginning date (caught this by chance, surprised it wasn't reported before)
|
23
|
+
|
24
|
+
== Version 1.10.4 ==
|
25
|
+
Mar 24, 2008
|
26
|
+
* patch applied to fix issue #92: nil object option causes CalendarDateSelect.calendar_date_select(object, method, options) to not use object. Thanks, sskirby!
|
27
|
+
|
28
|
+
== Version 1.10.3 ==
|
29
|
+
Mar 24. 2008
|
30
|
+
* Fixed active scaffold integration bug. Thanks tapajos!
|
31
|
+
|
32
|
+
== Version 1.10.2 ==
|
33
|
+
Mar 10. 2008
|
34
|
+
* bugfix: calendar_date_select_tag doesn't format Time and Date values (thanks for the patch, sskirby!)
|
35
|
+
|
36
|
+
== Version 1.10.1 ==
|
37
|
+
Mar 10, 2008
|
38
|
+
* updated to automatically install locale folder
|
39
|
+
* bugfix - cds "today" was showing up as Mar 9th 2008, when it was really Mar 10th 2008 - was caused by a wrinkle in time (Day light savings time)
|
40
|
+
* Prototype 1.6.0.1 compatibility issue (77) resolved - thanks mike.nicholaides for the patch!
|
41
|
+
* patch applied from mjroghelia to fix ie ssl iframe issue (84)
|
42
|
+
* xhtml error fixed - replaced with #160;
|
43
|
+
|
44
|
+
==Version 1.10 ==
|
45
|
+
Dec 3, 2007
|
46
|
+
* You can now pass in a parameter to tell CalendarDateSelect not to allow selection of certain dates. See the [http://www.restatesman.com/static/calendar?tab=other demo] for an example.
|
47
|
+
|
48
|
+
==Version 1.9.2==
|
49
|
+
Nov 26, 2007
|
50
|
+
* CalendarDateSelect was leaking javascript variables. (nothing was explicitly declared local, so javascript assumes global). Added test case and applied fix. This may help with some of the conflicts CalendarDateSelect has been causing with other scripts.
|
51
|
+
* Applied Ryan Wood's patch to fix the problem with using a form builder against objects like authorization[coverage_attributes][]. Thanks Ryan Wood!
|
52
|
+
* Wes Hays brought up the point of parseInt trying to auto-detect number formats. Wrote code to force interpretation of digits as base10, with test cases to prove it.
|
53
|
+
* Misleading test case failure in Safari fixed: Safari won't let a boolean value to a property that should have a function (understandably). Changed the test variable names to prevent such a conflict.
|
54
|
+
* Now uses css :hover, rather than manually setting/removing the hover class. If you are using a custom stylesheet, you'll need to change ".calendar_date_select tbody td.hover" to ".calendar_date_select tbody td:hover" (thanks, Alex Egg)
|
55
|
+
|
56
|
+
==Version 1.9.1==
|
57
|
+
Nov 15, 2007
|
58
|
+
* Removed dependency on deprecated features in 1.6.0. Thanks again, Richard Quadling!
|
59
|
+
* Bugfix - was showing wrong day selected when selecting Mar 23, 2008. (Day light savings time issue). Fixed with test case.
|
60
|
+
* Added CSS style to show red border around the embedded calendar_date_select div's with errors.
|
61
|
+
* Callbacks were broken with 1.9.0. Fixed, added test cases.
|
62
|
+
|
63
|
+
==Version 1.9.0==
|
64
|
+
Nov 13, 2007
|
65
|
+
* Prototype 1.6.0 compatibility update. Will now break with earlier versions of prototype (ie 1.5.1). Big thanks to Kevin Alexander and Richard Quadling
|
66
|
+
* Additional test coverage for improved stability going forward.
|
67
|
+
|
68
|
+
==Version 1.8.3==
|
69
|
+
Nov 12, 2007
|
70
|
+
|
71
|
+
* Improved close methods:
|
72
|
+
* Added "OK" button at the bottom
|
73
|
+
* Double clicking a day closes the calendar (not in IE, though... because IE is everyone's favorite browser to program for)
|
74
|
+
* Escape key closes calendar
|
75
|
+
* Added optional close button at the top, which is hidden by default. Don't use this unless you really need it, because it may disappear in the future.
|
76
|
+
* Don't focus a hidden element
|
77
|
+
* Navigate down to child input element if exists (in case a div tag is passed in). Resolves problems when input control is wrapped with a error div. Test cases
|
78
|
+
* Allow specific year ranges (pass in an array)
|
79
|
+
* restrict year navigation inside of a non-flexible range
|
80
|
+
* test case to check auto-repopulating of flexibleYearRanges.
|
81
|
+
* test case to check boundaries of nonFlexibleYearRanges.
|
82
|
+
* Ability to pass in :year_range => 5.years.ago..0.years.ago to calendar_date_select (ruby)
|
83
|
+
* Updated test cases
|
84
|
+
* Bugfix for duplicate days that were occuring across day-light-saving-time boundaries
|
85
|
+
* Added format_american.js (thanks, Wes Hays)
|
86
|
+
* Added format_italian.js (thanks, Bigonazzi)
|
87
|
+
* Added format_euro_24hr.js (thanks, James Silberbauer)
|
88
|
+
* Bugfix for Konqueror - Was showing blank white box for popup window - had to do with Iframe hack.
|
89
|
+
* Code-refactoring, clean up, breaking down methods, making the code easier to understand and extend.
|
90
|
+
* Added new stylesheet definition: .calendar_date_select .cds_header a.close { display: none}. Update your custom stylesheet with this new definition.
|
91
|
+
|
92
|
+
|
93
|
+
==Version 1.8.1==
|
94
|
+
September 27 2007
|
95
|
+
* 1.8.0 was rushed. There were a bunch of bugs that cropped up immediately. This deploy includes JavaScript unit testing using the scriptaculous unit test framework! ([http://www.restatesman.com/calendar_date_select/js_test/functional/cds_test.html click here to run the tests on the latest trunk version]). These unit tests are going to greatly improve the reliability of CalendarDateSelect releases.
|
96
|
+
|
97
|
+
==Version 1.8.0==
|
98
|
+
|
99
|
+
September 26 2007
|
100
|
+
* Bugfix - Safari 2 issue fixed (was interpreting "" as January 1, 1969)
|
101
|
+
* CSS overhaul - removed buttons and replaced with links. Cleaned up CSS. See CSSDiff_1_7_0__1_8_0 for a diff.
|
102
|
+
* :popup => :force (force the user to select a date)
|
103
|
+
* :time => "mixed" - You can now create a calendar control that allows a user to select "all day" or a specific time!
|
104
|
+
* :month_year => "label" - Replace the clunky dropdowns with a text.
|
105
|
+
* Some internal "gardening" on the code
|
106
|
+
|
107
|
+
==Version 1.7.1==
|
108
|
+
|
109
|
+
Aug 29 2007
|
110
|
+
|
111
|
+
* Rendering options weren't being passed to the input control (like :style, :class, etc.)
|
112
|
+
|
113
|
+
==Version 1.7.0==
|
114
|
+
|
115
|
+
Aug 24 2007
|
116
|
+
|
117
|
+
* update calendar date select to not rely on dom_id's anymore ( and no longer automatically changes the dom_id for your input fields )
|
118
|
+
|
119
|
+
* applied Steve Madsen's patch for not blanking out invalid dates.
|
120
|
+
|
121
|
+
==Version 1.6.1==
|
122
|
+
|
123
|
+
Aug 24 2007
|
124
|
+
|
125
|
+
* Serious javascript bug when using "hyphen_ampm" format fixed. (Was only working in Firefox browsers with firebug installed)
|
126
|
+
|
127
|
+
* Added a bunch of new callbacks: before_show, before_close, after_show, after_close, after_navigate. (see [http://www.restatesman.com/static/calendar?tab=callbacks here] for details)
|
128
|
+
|
129
|
+
|
130
|
+
==Version 1.6.0==
|
131
|
+
|
132
|
+
July 27 2007
|
133
|
+
|
134
|
+
* Now MUCH easier to change date formats! See ChangingDateFormat for details.
|
135
|
+
* Opera button labels fixed
|
136
|
+
* Calendar "flicker" fixed when displaying popup window.
|
137
|
+
* JS error 106 being thrown - fixed
|
138
|
+
* Bug fixes relating to calendar date select deciding whether to display above or below an element on a page
|
139
|
+
* XHTML compliance issue resolved - image had an invalid "id"
|
140
|
+
* Disabled/readonly elements can't be updated
|
141
|
+
* (note, if you wish to prevent user from inputting a date without the date picker, use the "embedded" option. See [http://restatesman.com/static/calendar/ demo] for example).
|
142
|
+
* Changes/cleanups submitted by Steve Madsen. If you see Steve, tell him what a great guy he is!
|
143
|
+
* Ability to change calendar image via CalendarDateSelect.image=
|
144
|
+
* cleaning up on how input tags are rendered
|
145
|
+
|
146
|
+
==Version 1.5.2==
|
147
|
+
|
148
|
+
July 12 2007
|
149
|
+
* onchange event handler now supported.
|
150
|
+
* detects to see if prototype is loaded. If not, shows error message
|
151
|
+
* ability to hide "buttons"
|
152
|
+
* date parsing broken out to static function Date.parseFormattedString() for anyone who wants date's to parse a different way from javascript
|
153
|
+
* you can no longer select 1:60 pm.
|
154
|
+
|
155
|
+
==Version 1.5.1==
|
156
|
+
|
157
|
+
June 21, 2007
|
158
|
+
|
159
|
+
* fixed following tickets:
|
160
|
+
* Selecting dates in April 2007 doesn't highlight day
|
161
|
+
* Selecting 29 February 2008 returns 1 March 2008
|
162
|
+
* options[:format] needs to be purged
|
163
|
+
|
164
|
+
==Version 1.5==
|
165
|
+
June 18, 2007
|
166
|
+
|
167
|
+
* New CSS stylesheet
|
168
|
+
|
169
|
+
* Fixed "white on white" css issue when selecting a day
|
170
|
+
|
171
|
+
* Clicking today now updates the input field
|
172
|
+
|
173
|
+
==Version 1.4==
|
174
|
+
June 16, 2007
|
175
|
+
|
176
|
+
* more bug fixes (selecting across daylight savings time causing js error. Sometimes clicking a day of the next month after selecting day 31 of the previous month was causing 2 months later to be selected)
|
177
|
+
|
178
|
+
* CSS improvements and refactoring
|
179
|
+
|
180
|
+
* form builder methods now automatically detect whether or not to use a Time field
|
181
|
+
|
182
|
+
* a bit more optimization
|
183
|
+
|
184
|
+
* refactored date formatter methods and others so they can be more easily overridden.
|
185
|
+
|
186
|
+
==Version 1.3==
|
187
|
+
June 8, 2007
|
188
|
+
|
189
|
+
* a few bug fixes
|
190
|
+
|
191
|
+
* Modified the helper methods to allow passing of virtually any JavaScript argument into the JavaScript control.
|
192
|
+
|
193
|
+
==Version 1.2==
|
194
|
+
June 4, 2007
|
195
|
+
|
196
|
+
* Big optimizations to the redrawing of the calendar. Now, previous/next buttons much more responsive.
|
197
|
+
|
198
|
+
* Improved feel of pop-up dialog - when somewhere else clicked on the screen other than the popup calendar, popup calendar will automatically close.
|
199
|
+
|
200
|
+
* If the popup window won't fit on the screen underneath the control, will automatically position to the top.
|
201
|
+
|
202
|
+
|
203
|
+
==Version 1.1==
|
204
|
+
June 2, 2007
|
205
|
+
|
206
|
+
* There was a very strange bug that crept in for Internet Explorer. Internet Explorer does not allow you to set the innerHTML property for "button" elements. Therefore, it was necessary to change "button" elements to "input" elements of type button.
|
207
|
+
|
208
|
+
* There was a change to the CSS file. Anything applying styles to "button" elements has been changed to "input.button". If you have a custom stylesheet, update accordingly.
|
209
|
+
|
210
|
+
==Version 1.0==
|
211
|
+
June 1, 2007
|
212
|
+
|
213
|
+
* Initial release!
|
214
|
+
|
215
|
+
|
216
|
+
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
All portions Copyright (c) 2007 Tim Harper
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Manifest.txt
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
History.txt
|
2
|
+
init.rb
|
3
|
+
js_test/functional/cds_test.html
|
4
|
+
js_test/prototype.js
|
5
|
+
js_test/test.css
|
6
|
+
js_test/unit/cds_helper_methods.html
|
7
|
+
js_test/unittest.js
|
8
|
+
lib/calendar_date_select/calendar_date_select.rb
|
9
|
+
lib/calendar_date_select/includes_helper.rb
|
10
|
+
lib/calendar_date_select.rb
|
11
|
+
Manifest.txt
|
12
|
+
MIT-LICENSE
|
13
|
+
public/blank_iframe.html
|
14
|
+
public/images/calendar_date_select/calendar.gif
|
15
|
+
public/javascripts/calendar_date_select/calendar_date_select.js
|
16
|
+
public/javascripts/calendar_date_select/format_american.js
|
17
|
+
public/javascripts/calendar_date_select/format_db.js
|
18
|
+
public/javascripts/calendar_date_select/format_euro_24hr.js
|
19
|
+
public/javascripts/calendar_date_select/format_euro_24hr_ymd.js
|
20
|
+
public/javascripts/calendar_date_select/format_finnish.js
|
21
|
+
public/javascripts/calendar_date_select/format_hyphen_ampm.js
|
22
|
+
public/javascripts/calendar_date_select/format_iso_date.js
|
23
|
+
public/javascripts/calendar_date_select/format_italian.js
|
24
|
+
public/javascripts/calendar_date_select/locale/de.js
|
25
|
+
public/javascripts/calendar_date_select/locale/fi.js
|
26
|
+
public/javascripts/calendar_date_select/locale/fr.js
|
27
|
+
public/javascripts/calendar_date_select/locale/pl.js
|
28
|
+
public/javascripts/calendar_date_select/locale/pt.js
|
29
|
+
public/javascripts/calendar_date_select/locale/ru.js
|
30
|
+
public/stylesheets/calendar_date_select/blue.css
|
31
|
+
public/stylesheets/calendar_date_select/default.css
|
32
|
+
public/stylesheets/calendar_date_select/plain.css
|
33
|
+
public/stylesheets/calendar_date_select/red.css
|
34
|
+
public/stylesheets/calendar_date_select/silver.css
|
35
|
+
Rakefile
|
36
|
+
Readme.txt
|
37
|
+
test/functional/calendar_date_select_test.rb
|
38
|
+
test/functional/helper_methods_test.rb
|
39
|
+
test/test_helper.rb
|
data/Rakefile
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'hoe'
|
5
|
+
|
6
|
+
$: << File.dirname(__FILE__) + "/lib/"
|
7
|
+
require "activesupport"
|
8
|
+
require './lib/calendar_date_select.rb'
|
9
|
+
|
10
|
+
Hoe.new('calendar_date_select', CalendarDateSelect::VERSION) do |p|
|
11
|
+
p.rubyforge_name = 'calendar_date_select'
|
12
|
+
p.developer('Tim Harper', 'tim c harper at gmail dot com')
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
task :set_version do
|
17
|
+
["lib/calendar_date_select/calendar_date_select.rb", "public/javascripts/calendar_date_select/calendar_date_select.js"].each do |file|
|
18
|
+
abs_file = File.dirname(__FILE__) + "/" + file
|
19
|
+
src = File.read(abs_file);
|
20
|
+
src = src.map do |line|
|
21
|
+
case line
|
22
|
+
when /^ *VERSION/ then " VERSION = '#{ENV['VERSION']}'\n"
|
23
|
+
when /^\/\/ CalendarDateSelect version / then "// CalendarDateSelect version #{ENV['VERSION']} - a prototype based date picker\n"
|
24
|
+
else
|
25
|
+
line
|
26
|
+
end
|
27
|
+
end.join
|
28
|
+
File.open(abs_file, "wb") { |f| f << src }
|
29
|
+
end
|
30
|
+
end
|
31
|
+
# vim: syntax=Ruby
|
data/Readme.txt
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
= CalendarDateSelect
|
2
|
+
|
3
|
+
http://code.google.com/p/calendardateselect/
|
4
|
+
|
5
|
+
== Examples
|
6
|
+
|
7
|
+
"See a demo here":http://electronicholas.com/calendar
|
8
|
+
|
9
|
+
== Submitting patches
|
10
|
+
|
11
|
+
Please take care to do the following:
|
12
|
+
|
13
|
+
* Clean up your patch (don't send a patch bomb with a hundred features in one)
|
14
|
+
* Write test cases!
|
15
|
+
* As a general rule of thumb, think of ways to make things more general purpose than specific.
|
16
|
+
|
data/init.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/lib/calendar_date_select.rb"
|
@@ -0,0 +1,334 @@
|
|
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") assert(cds.closed,"all tests should close their calendar control");
|
36
|
+
Date.first_day_of_week = 0;
|
37
|
+
Date.weekdays = $w("S M T W T F S")
|
38
|
+
}},
|
39
|
+
testMixedTime_feedDateWithAndWithoutTime_shouldSetAccordingly: function() { with(this) {
|
40
|
+
$A(["January 2, 2007 5:00 pm", "January 2, 2007 0:00 pm"]).each(function(d) {
|
41
|
+
$("cds_test").value=d;
|
42
|
+
cds = new CalendarDateSelect($("cds_test"), {time: "mixed"});
|
43
|
+
assertEqual(true, cds.use_time);
|
44
|
+
cds.close();
|
45
|
+
})
|
46
|
+
|
47
|
+
$("cds_test").value="January 2, 2007";
|
48
|
+
cds = new CalendarDateSelect($("cds_test"), {time: "mixed"});
|
49
|
+
assertEqual(false, cds.use_time);
|
50
|
+
cds.close();
|
51
|
+
}},
|
52
|
+
testTodayNowButton_mixedMode_shouldSetUseTimeAccordingly: function() { with(this){
|
53
|
+
cds = new CalendarDateSelect($("cds_test"), {time: "mixed"});
|
54
|
+
today_now = $$(".cds_buttons a[href=#]");
|
55
|
+
today_now[0].onclick();
|
56
|
+
assertEqual(false, cds.use_time, "when clicking today link");
|
57
|
+
|
58
|
+
today_now[1].onclick();
|
59
|
+
assertEqual(true, cds.use_time, "should have been true when clicking now link");
|
60
|
+
cds.close();
|
61
|
+
}},
|
62
|
+
test__selectMar_23_2008__shouldSelectCorrectDate: function() { with(this){
|
63
|
+
$("cds_test").value = "Mar 1, 2008"
|
64
|
+
cds = new CalendarDateSelect($("cds_test"), {time: "true"});
|
65
|
+
cds.updateSelectedDate({month: 2 /*+1*/, day: 23, year: 2008})
|
66
|
+
|
67
|
+
assertEqual("23", $$('td.selected div').first().innerHTML);
|
68
|
+
cds.close();
|
69
|
+
}},
|
70
|
+
test_updateSelectedDate: function() { with(this){
|
71
|
+
$("cds_test").value = "January 1, 2007"
|
72
|
+
cds = new CalendarDateSelect($("cds_test"), {time: "mixed"});
|
73
|
+
|
74
|
+
cds.use_time=true;
|
75
|
+
cds.updateSelectedDate({hour: ""})
|
76
|
+
assertEqual(false, cds.use_time, "when setting hour to ''");
|
77
|
+
|
78
|
+
cds.use_time=true;
|
79
|
+
cds.updateSelectedDate({minute: ""})
|
80
|
+
assertEqual(false, cds.use_time, "when setting minute to ''");
|
81
|
+
|
82
|
+
cds.use_time=false;
|
83
|
+
cds.updateSelectedDate({hour: 0})
|
84
|
+
assertEqual(true, cds.use_time, "when setting hour to 0");
|
85
|
+
|
86
|
+
cds.use_time=false;
|
87
|
+
cds.updateSelectedDate({minute: 0})
|
88
|
+
assertEqual(true, cds.use_time, "when setting minute to 0");
|
89
|
+
|
90
|
+
cds.close();
|
91
|
+
}},
|
92
|
+
test_navYear: function() { with(this){
|
93
|
+
$("cds_test").value = "January 1, 2007";
|
94
|
+
cds = new CalendarDateSelect($("cds_test"), {time: "mixed"});
|
95
|
+
cds.navYear(1870);
|
96
|
+
assertEqual(2007, cds.selected_date.getFullYear());
|
97
|
+
assertEqual(1870, cds.date.getFullYear());
|
98
|
+
cds.close();
|
99
|
+
}},
|
100
|
+
test_navMonth: function() { with(this){
|
101
|
+
$("cds_test").value = "January 1, 2007";
|
102
|
+
cds = new CalendarDateSelect($("cds_test"), {time: "mixed"});
|
103
|
+
cds.navMonth(5);
|
104
|
+
assertEqual(0, cds.selected_date.getMonth());
|
105
|
+
assertEqual(5, cds.date.getMonth())
|
106
|
+
cds.close();
|
107
|
+
}},
|
108
|
+
test_callBacks: function() { with(this){
|
109
|
+
$("cds_test").up().build("div", {id: "global"});
|
110
|
+
cds = new CalendarDateSelect($("cds_test"), {time: "mixed",
|
111
|
+
before_show: function() { $("global").before_show_called = true},
|
112
|
+
after_show: function() { $("global").after_show_called = true},
|
113
|
+
before_close: function() { $("global").before_close_called = true},
|
114
|
+
after_close: function() { $("global").after_close_called = true},
|
115
|
+
after_navigate: function() { $("global").after_navigate_called = true},
|
116
|
+
onchange: function() { $("global").onchange_called = true},
|
117
|
+
});
|
118
|
+
cds.navMonth(1);
|
119
|
+
cds.navMonth(10);
|
120
|
+
cds.updateSelectedDate({month: 1, day: 3, year: 2007});
|
121
|
+
cds.close();
|
122
|
+
assert($('global').before_show_called, "before_show wasnt called");
|
123
|
+
assert($('global').after_show_called, "after_show wasnt called");
|
124
|
+
assert($('global').before_close_called, "before_close wasnt called");
|
125
|
+
assert($('global').after_close_called, "after_close wasnt called");
|
126
|
+
assert($('global').after_navigate_called, "after_navigate wasnt called");
|
127
|
+
assert($('global').onchange_called, "onchange wasnt called");
|
128
|
+
$("global").remove();
|
129
|
+
}},
|
130
|
+
test_disabledElement_cantUpdate: function() {with(this){
|
131
|
+
$("cds_test").value = "May 10, 2007";
|
132
|
+
$("cds_test").disabled = true;
|
133
|
+
cds = new CalendarDateSelect($("cds_test"));
|
134
|
+
|
135
|
+
runTest = function() {
|
136
|
+
cds.updateSelectedDate({day: 1, month:0, year: 2007});
|
137
|
+
assertEqual(10, cds.selected_date.getDate())
|
138
|
+
}
|
139
|
+
runTest();
|
140
|
+
$("cds_test").disabled = false;
|
141
|
+
$("cds_test").readOnly = true;
|
142
|
+
runTest();
|
143
|
+
|
144
|
+
$("cds_test").readOnly = false;
|
145
|
+
cds.close();
|
146
|
+
}},
|
147
|
+
test_readOnlyElement_forcePopup_shouldUpdate: function() {with(this){
|
148
|
+
$("cds_test").value = "May 10, 2007";
|
149
|
+
$("cds_test").readOnly = true;
|
150
|
+
cds = new CalendarDateSelect($("cds_test"), {popup: "force"});
|
151
|
+
|
152
|
+
cds.updateSelectedDate({day: 1, month:0, year: 2007});
|
153
|
+
assertEqual(1, cds.selected_date.getDate())
|
154
|
+
|
155
|
+
$("cds_test").readOnly = false;
|
156
|
+
cds.close();
|
157
|
+
}},
|
158
|
+
test_timePassed_notUsingTime_shouldIgnore: function() {with(this) {
|
159
|
+
$("cds_test").value = "May 10, 2007 5:00 pm";
|
160
|
+
cds = new CalendarDateSelect($("cds_test"), {time:false});
|
161
|
+
assert(cds.closeOnClick(), "should set close_on_click to true when not using time")
|
162
|
+
assertEqual(false, cds.use_time, "When parsing time");
|
163
|
+
cds.today();
|
164
|
+
assert(cds.closed, "should close when clicking today");
|
165
|
+
assert(!cds.use_time, "Should not use time when calling today");
|
166
|
+
|
167
|
+
cds = new CalendarDateSelect($("cds_test"), {time:false});
|
168
|
+
cds.updateSelectedDate({hours: 5, minutes:30}) // this will close the control
|
169
|
+
assertEqual(false, cds.use_time, "When setting hour/minute");
|
170
|
+
assert(cds.closed);
|
171
|
+
}},
|
172
|
+
test_setUseTime_true_notUsingTime_shouldIgnore: function() {with(this) {
|
173
|
+
$("cds_test").value = "May 10, 2007 5:00 pm";
|
174
|
+
cds = new CalendarDateSelect($("cds_test"), {time:false});
|
175
|
+
assertEqual(false, cds.use_time, "When parsing time");
|
176
|
+
cds.setUseTime(true); // this will close the control
|
177
|
+
assert(! cds.use_time, "After calling setUseTime(true)");
|
178
|
+
cds.close();
|
179
|
+
}},
|
180
|
+
test_setMinute_notOnInterval_usesFloor: function() {with(this){
|
181
|
+
$("cds_test").value = "May 10, 2007 5:25 pm";
|
182
|
+
cds = new CalendarDateSelect($("cds_test"), {time:true});
|
183
|
+
cds.updateSelectedDate({hour: 1, minute: 4});
|
184
|
+
assertEqual(0, cds.selected_date.getMinutes());
|
185
|
+
assertEqual(1, cds.selected_date.getHours());
|
186
|
+
|
187
|
+
cds.close();
|
188
|
+
}},
|
189
|
+
// this checks for a safari 2 bug where safari parses "" as a date back in 1969
|
190
|
+
test_parseDate_blankInput_interpretsAsNotSelected: function() {with(this){
|
191
|
+
$("cds_test").value = " ";
|
192
|
+
cds = new CalendarDateSelect($("cds_test"), {time:true});
|
193
|
+
assertEqual(new Date().getFullYear(), cds.selected_date.getFullYear());
|
194
|
+
assertEqual(new Date().getFullYear(), cds.date.getFullYear());
|
195
|
+
assert(! cds.selection_made)
|
196
|
+
cds.close();
|
197
|
+
}},
|
198
|
+
test_parseDate_timeTrue_noTimePassed_useTimeSetToTrueAnyway: function() {with(this){
|
199
|
+
$("cds_test").value = "December 1, 2007 ";
|
200
|
+
cds = new CalendarDateSelect($("cds_test"), {time:true});
|
201
|
+
assert(cds.use_time)
|
202
|
+
cds.close();
|
203
|
+
}},
|
204
|
+
test_passDivElement__shouldUseChildInputForTargetElement: function() {with(this){
|
205
|
+
cds = new CalendarDateSelect($("cds_test_div"), {time:true});
|
206
|
+
assertEqual("INPUT", cds.target_element.nodeName)
|
207
|
+
cds.close();
|
208
|
+
}},
|
209
|
+
test__flexibleYearRange__datePassedWayBackWhen__shouldInitYearSelectAroundDate: function() {with(this){
|
210
|
+
$("cds_test").value = "July 4, 1776";
|
211
|
+
cds = new CalendarDateSelect($("cds_test_div"), {time:true});
|
212
|
+
assert(cds.flexibleYearRange(), " should have had a flexibleYearRange");
|
213
|
+
assert(cds.year_select.setValue(1776), "Should have allowed me to select 1776");
|
214
|
+
cds.close();
|
215
|
+
}},
|
216
|
+
test__nonflexibleYearRange__dateRangeAtEnds__shouldntAllowNavigationPassedBoundary: function() {with(this){
|
217
|
+
$("cds_test").value = "January 1, 2007";
|
218
|
+
cds = new CalendarDateSelect($("cds_test"), {time:true, year_range: [2007, 2007]});
|
219
|
+
|
220
|
+
assert(! cds.navYear(2006), "should not allow year navigation outside of boundary");
|
221
|
+
assert(! cds.navYear(2008), "should not allow year navigation outside of boundary");
|
222
|
+
assert(! cds.navMonth(-1), "shouldnt allow me to go beyond boundary");
|
223
|
+
assert(! cds.navMonth(13), "shouldnt allow me to go beyond boundary");
|
224
|
+
assert(cds.navMonth(1), "should allow me to be in boundary");
|
225
|
+
assert(cds.navYear(2007), "should allow me to be in boundary");
|
226
|
+
cds.close();
|
227
|
+
}},
|
228
|
+
test__nonflexibleYearRange__shouldPopulateRange: function() {with(this){
|
229
|
+
$("cds_test").value = "January 1, 2007";
|
230
|
+
cds = new CalendarDateSelect($("cds_test"), {time:true, year_range: [2007, 2007]});
|
231
|
+
assert(cds.year_select.setValue(2007), "should allow me to select 2007");
|
232
|
+
cds.close();
|
233
|
+
}},
|
234
|
+
test__nonflexibleYearRange__initializedWithDateOutsideOfRange__shouldShowNavDateAsClosestToOutsideYear: function() {with(this){
|
235
|
+
$("cds_test").value = "January 1, 1900";
|
236
|
+
cds = new CalendarDateSelect($("cds_test"), {time:true, year_range: [1997, 2007]});
|
237
|
+
assertEqual(1997, cds.date.getFullYear(), "When going lesser than year_range");
|
238
|
+
cds.close();
|
239
|
+
|
240
|
+
$("cds_test").value = "January 1, 2010";
|
241
|
+
cds = new CalendarDateSelect($("cds_test"), {time:true, year_range: [1997, 2007]});
|
242
|
+
assertEqual(2007, cds.date.getFullYear(), "When going greater than year_range");
|
243
|
+
|
244
|
+
cds.close();
|
245
|
+
}},
|
246
|
+
test__nonflexibleYearRange__initializedWithDateInsideOfRange__shouldShowNavDateAsYear: function() {with(this){
|
247
|
+
$("cds_test").value = "January 1, 2005";
|
248
|
+
cds = new CalendarDateSelect($("cds_test"), {year_range: [1997, 2007]});
|
249
|
+
assertEqual(2005, cds.date.getFullYear(), "When going lesser than year_range");
|
250
|
+
cds.close();
|
251
|
+
}},
|
252
|
+
test__flexibleYearRange__goToBoundary__shouldRefreshRange: function() {with(this){
|
253
|
+
$("cds_test").value = "January 1, 2007";
|
254
|
+
cds = new CalendarDateSelect($("cds_test"), {year_range: 10});
|
255
|
+
cds.navYear(1997);
|
256
|
+
assert(cds.year_select.setValue(1987), "should have refreshed with 1997 as the center");
|
257
|
+
cds.navYear(2017);
|
258
|
+
assert(cds.year_select.setValue(2027), "should have refreshed with 2027 as the center");
|
259
|
+
cds.close();
|
260
|
+
}},
|
261
|
+
test__should_show_iframe_only_in_ie: function() {with(this){
|
262
|
+
cds = new CalendarDateSelect($("cds_test"));
|
263
|
+
|
264
|
+
if (navigator.appName=="Microsoft Internet Explorer")
|
265
|
+
assertEqual(1, $$('iframe.ie6_blocker').length)
|
266
|
+
else
|
267
|
+
assertEqual(0, $$('iframe.ie6_blocker').length)
|
268
|
+
|
269
|
+
cds.close();
|
270
|
+
}},
|
271
|
+
test__should_populate_minute_box_according_to_minute_interval: function() {with(this){
|
272
|
+
cds = new CalendarDateSelect($("cds_test"), {time: true, minute_interval: 10});
|
273
|
+
assert(cds.minute_select.setValue(0), "should allow me to select 0 minutes" );
|
274
|
+
assert(!cds.minute_select.setValue(5), "should NOT allow me to select 5 minutes");
|
275
|
+
assert(cds.minute_select.setValue(10), "should allow me to select 10 minutes" );
|
276
|
+
cds.close();
|
277
|
+
}},
|
278
|
+
test__shouldnt_leak_variables: function() {with (this) {
|
279
|
+
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")
|
280
|
+
vars.each(function(v) {eval(v + " = -100");});
|
281
|
+
|
282
|
+
cds = new CalendarDateSelect($("cds_test"), {time: true});
|
283
|
+
cds.navMonth(1);
|
284
|
+
cds.navYear(2);
|
285
|
+
cds.dayHover($$('.cds_body td').first());
|
286
|
+
cds.updateSelectedDate({day:1, month:1, year:2007});
|
287
|
+
cds.close();
|
288
|
+
|
289
|
+
vars.each(function(v) {
|
290
|
+
assert(-100 == eval(v), "Variable " + v + " was leaked");
|
291
|
+
});
|
292
|
+
}},
|
293
|
+
test__valid_date__shouldnt_allow_selection_of_invalid_dates_and_should_apply_css: function() {with (this) {
|
294
|
+
$('cds_test').value = "December 11, 2007";
|
295
|
+
cds = new CalendarDateSelect($("cds_test"), {valid_date_check: function(date) { return date < new Date("December 13, 2007")}, time: "mixed"});
|
296
|
+
assertEqual("December 11, 2007", $F('cds_test'));
|
297
|
+
cds.updateSelectedDate({day:13, month:12-1, year:2007});
|
298
|
+
assertEqual("December 11, 2007", $F('cds_test'), "Date should not have been allowed to be selected");
|
299
|
+
cds.updateSelectedDate({day:10, month:12-1, year:2007});
|
300
|
+
assertEqual("December 10, 2007", $F('cds_test'), "Date should not have been allowed to be selected");
|
301
|
+
|
302
|
+
day_12_element = $$('.calendar_date_select td')[17];
|
303
|
+
day_13_element = $$('.calendar_date_select td')[18];
|
304
|
+
assertEqual(12, day_12_element.day); // make sure we have th right one
|
305
|
+
assertEqual(13, day_13_element.day); // make sure we have th right one
|
306
|
+
assert( ! day_12_element.hasClassName("disabled"), "Day 12 shouldnt be disabled");
|
307
|
+
assert(day_13_element.hasClassName("disabled"), "Day 13 should be disabled");
|
308
|
+
|
309
|
+
cds.close();
|
310
|
+
}},
|
311
|
+
test__valid_date_check_is_nil__should_show_all_cells_as_enabled: function() {with (this) {
|
312
|
+
$('cds_test').value = "December 11, 2007";
|
313
|
+
cds = new CalendarDateSelect($("cds_test"));
|
314
|
+
|
315
|
+
$$('.calendar_date_select td').each(function(e){
|
316
|
+
assert( ! e.hasClassName("disabled"));
|
317
|
+
});
|
318
|
+
|
319
|
+
cds.close();
|
320
|
+
}},
|
321
|
+
test__should_pull_up_dec_07_when_first_day_of_week_is_1: function() {with (this) {
|
322
|
+
Date.first_day_of_week = 1;
|
323
|
+
Date.weekdays = $w("M T W T F S S");
|
324
|
+
$('cds_test').value = "December 1, 2007";
|
325
|
+
cds = new CalendarDateSelect($("cds_test"));
|
326
|
+
|
327
|
+
assertEqual(1, $$(".calendar_date_select").length);
|
328
|
+
cds.close();
|
329
|
+
}}
|
330
|
+
});
|
331
|
+
// ]]>
|
332
|
+
</script>
|
333
|
+
</body>
|
334
|
+
</html>
|