data_grid 0.0.1 → 0.0.2
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/.rspec +3 -0
- data/CHANGELOG +5 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/Rakefile +1 -0
- data/app/assets/images/data_grid/calendar_view_month.png +0 -0
- data/app/assets/images/data_grid/csv.gif +0 -0
- data/app/assets/images/data_grid/delete.png +0 -0
- data/app/assets/images/data_grid/edit.png +0 -0
- data/app/assets/images/data_grid/no.png +0 -0
- data/app/assets/images/data_grid/sort_down.gif +0 -0
- data/app/assets/images/data_grid/sort_up.gif +0 -0
- data/app/assets/images/data_grid/yes.png +0 -0
- data/app/assets/javascripts/data_grid/data_grid.js +24 -0
- data/app/assets/javascripts/data_grid/grid_calendar/calendar-setup.js +200 -0
- data/app/assets/javascripts/data_grid/grid_calendar/calendar-setup_stripped.js +21 -0
- data/app/assets/javascripts/data_grid/grid_calendar/calendar.js +1819 -0
- data/app/assets/javascripts/data_grid/grid_calendar/calendar_original.js +1845 -0
- data/app/assets/javascripts/data_grid/grid_calendar/calendar_patched.js +1819 -0
- data/app/assets/javascripts/data_grid/grid_calendar/calendar_stripped.js +14 -0
- data/app/assets/javascripts/data_grid/grid_calendar/img.gif +0 -0
- data/app/assets/javascripts/data_grid/grid_calendar/lang/calendar-af.js +39 -0
- data/app/assets/javascripts/data_grid/grid_calendar/lang/calendar-al.js +101 -0
- data/app/assets/javascripts/data_grid/grid_calendar/lang/calendar-bg.js +124 -0
- data/app/assets/javascripts/data_grid/grid_calendar/lang/calendar-big5-utf8.js +123 -0
- data/app/assets/javascripts/data_grid/grid_calendar/lang/calendar-big5.js +123 -0
- data/app/assets/javascripts/data_grid/grid_calendar/lang/calendar-br.js +108 -0
- data/app/assets/javascripts/data_grid/grid_calendar/lang/calendar-ca.js +123 -0
- data/app/assets/javascripts/data_grid/grid_calendar/lang/calendar-cs-utf8.js +65 -0
- data/app/assets/javascripts/data_grid/grid_calendar/lang/calendar-cs-win.js +65 -0
- data/app/assets/javascripts/data_grid/grid_calendar/lang/calendar-da.js +123 -0
- data/app/assets/javascripts/data_grid/grid_calendar/lang/calendar-de.js +124 -0
- data/app/assets/javascripts/data_grid/grid_calendar/lang/calendar-du.js +45 -0
- data/app/assets/javascripts/data_grid/grid_calendar/lang/calendar-el.js +89 -0
- data/app/assets/javascripts/data_grid/grid_calendar/lang/calendar-en.js +127 -0
- data/app/assets/javascripts/data_grid/grid_calendar/lang/calendar-es.js +129 -0
- data/app/assets/javascripts/data_grid/grid_calendar/lang/calendar-fi.js +98 -0
- data/app/assets/javascripts/data_grid/grid_calendar/lang/calendar-fr.js +125 -0
- data/app/assets/javascripts/data_grid/grid_calendar/lang/calendar-he-utf8.js +123 -0
- data/app/assets/javascripts/data_grid/grid_calendar/lang/calendar-hr-utf8.js +49 -0
- data/app/assets/javascripts/data_grid/grid_calendar/lang/calendar-hr.js +0 -0
- data/app/assets/javascripts/data_grid/grid_calendar/lang/calendar-hu.js +124 -0
- data/app/assets/javascripts/data_grid/grid_calendar/lang/calendar-it.js +124 -0
- data/app/assets/javascripts/data_grid/grid_calendar/lang/calendar-jp.js +45 -0
- data/app/assets/javascripts/data_grid/grid_calendar/lang/calendar-ko-utf8.js +120 -0
- data/app/assets/javascripts/data_grid/grid_calendar/lang/calendar-ko.js +120 -0
- data/app/assets/javascripts/data_grid/grid_calendar/lang/calendar-lt-utf8.js +114 -0
- data/app/assets/javascripts/data_grid/grid_calendar/lang/calendar-lt.js +114 -0
- data/app/assets/javascripts/data_grid/grid_calendar/lang/calendar-lv.js +123 -0
- data/app/assets/javascripts/data_grid/grid_calendar/lang/calendar-nl.js +73 -0
- data/app/assets/javascripts/data_grid/grid_calendar/lang/calendar-no.js +114 -0
- data/app/assets/javascripts/data_grid/grid_calendar/lang/calendar-pl-utf8.js +93 -0
- data/app/assets/javascripts/data_grid/grid_calendar/lang/calendar-pl.js +56 -0
- data/app/assets/javascripts/data_grid/grid_calendar/lang/calendar-pt.js +123 -0
- data/app/assets/javascripts/data_grid/grid_calendar/lang/calendar-ro.js +66 -0
- data/app/assets/javascripts/data_grid/grid_calendar/lang/calendar-ru.js +123 -0
- data/app/assets/javascripts/data_grid/grid_calendar/lang/calendar-ru_win_.js +123 -0
- data/app/assets/javascripts/data_grid/grid_calendar/lang/calendar-si.js +94 -0
- data/app/assets/javascripts/data_grid/grid_calendar/lang/calendar-sk.js +99 -0
- data/app/assets/javascripts/data_grid/grid_calendar/lang/calendar-sp.js +110 -0
- data/app/assets/javascripts/data_grid/grid_calendar/lang/calendar-sv.js +93 -0
- data/app/assets/javascripts/data_grid/grid_calendar/lang/calendar-tr.js +58 -0
- data/app/assets/javascripts/data_grid/grid_calendar/lang/calendar-zh.js +119 -0
- data/app/assets/javascripts/data_grid/grid_calendar/lang/cn_utf8.js +123 -0
- data/app/assets/javascripts/data_grid/grid_calendar/menuarrow.gif +0 -0
- data/app/assets/javascripts/data_grid/grid_calendar/menuarrow2.gif +0 -0
- data/app/assets/stylesheets/data_grid/data_grid.css +90 -0
- data/app/assets/stylesheets/data_grid/data_grid_3_0.css +90 -0
- data/app/assets/stylesheets/data_grid/grid_calendar/calendar-blue.css +233 -0
- data/app/assets/stylesheets/data_grid/grid_calendar/calendar-blue2.css +237 -0
- data/app/assets/stylesheets/data_grid/grid_calendar/calendar-brown.css +226 -0
- data/app/assets/stylesheets/data_grid/grid_calendar/calendar-green.css +230 -0
- data/app/assets/stylesheets/data_grid/grid_calendar/calendar-system.css +252 -0
- data/app/assets/stylesheets/data_grid/grid_calendar/calendar-tas.css +240 -0
- data/app/assets/stylesheets/data_grid/grid_calendar/calendar-win2k-1.css +272 -0
- data/app/assets/stylesheets/data_grid/grid_calendar/calendar-win2k-2.css +272 -0
- data/app/assets/stylesheets/data_grid/grid_calendar/calendar-win2k-cold-1.css +266 -0
- data/app/assets/stylesheets/data_grid/grid_calendar/calendar-win2k-cold-2.css +272 -0
- data/app/assets/stylesheets/data_grid/grid_calendar/img.gif +0 -0
- data/app/assets/stylesheets/data_grid/grid_calendar/menuarrow.gif +0 -0
- data/app/assets/stylesheets/data_grid/grid_calendar/menuarrow2.gif +0 -0
- data/app/assets/stylesheets/data_grid/grid_calendar/skins/aqua/active-bg.gif +0 -0
- data/app/assets/stylesheets/data_grid/grid_calendar/skins/aqua/dark-bg.gif +0 -0
- data/app/assets/stylesheets/data_grid/grid_calendar/skins/aqua/hover-bg.gif +0 -0
- data/app/assets/stylesheets/data_grid/grid_calendar/skins/aqua/menuarrow.gif +0 -0
- data/app/assets/stylesheets/data_grid/grid_calendar/skins/aqua/normal-bg.gif +0 -0
- data/app/assets/stylesheets/data_grid/grid_calendar/skins/aqua/rowhover-bg.gif +0 -0
- data/app/assets/stylesheets/data_grid/grid_calendar/skins/aqua/status-bg.gif +0 -0
- data/app/assets/stylesheets/data_grid/grid_calendar/skins/aqua/theme.css +236 -0
- data/app/assets/stylesheets/data_grid/grid_calendar/skins/aqua/title-bg.gif +0 -0
- data/app/assets/stylesheets/data_grid/grid_calendar/skins/aqua/today-bg.gif +0 -0
- data/app/views/data_grid/_data_grid.html.erb +101 -0
- data/config/locales/en.yml +10 -0
- data/data_grid.gemspec +27 -0
- data/lib/data_grid/column.rb +38 -0
- data/lib/data_grid/controller.rb +30 -0
- data/lib/data_grid/cookies_state_saver.rb +42 -0
- data/lib/data_grid/csv_exporter.rb +79 -0
- data/lib/data_grid/data_grid_logic.rb +175 -0
- data/lib/data_grid/data_source_array.rb +267 -0
- data/lib/data_grid/data_source_orm.rb +207 -0
- data/lib/data_grid/engine.rb +19 -0
- data/lib/data_grid/summaries.rb +34 -0
- data/lib/data_grid/version.rb +3 -0
- data/lib/data_grid/view_helpers.rb +271 -0
- data/lib/data_grid.rb +43 -0
- data/lib/generators/data_grid/copy_view_generator.rb +16 -0
- data/lib/generators/data_grid/install_generator.rb +29 -0
- data/lib/generators/templates/data_grid.rb +29 -0
- data/lib/generators/templates/stylesheets/data_grid/data_grid_3_0.css +90 -0
- data/spec/orm_spec.rb +57 -0
- data/spec/spec_helper.rb +15 -0
- data/spec/support/active_record.rb +17 -0
- metadata +118 -5
data/.rspec
ADDED
data/CHANGELOG
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright (c) 2013 Krzysztof Kempiński
|
|
2
|
+
|
|
3
|
+
MIT License
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require "bundler/gem_tasks"
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
function dataGridSetInnerHtml(id, ih) {
|
|
2
|
+
var e = document.getElementById(id);
|
|
3
|
+
e.innerHTML = ih;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
function dataGridSetValue(id, v) {
|
|
7
|
+
var e = document.getElementById(id);
|
|
8
|
+
e.value = v;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function handleCalendarClose(cal, dom_id, form_id) {
|
|
12
|
+
if (cal)
|
|
13
|
+
cal.hide();
|
|
14
|
+
|
|
15
|
+
var e = document.getElementById(dom_id);
|
|
16
|
+
var es = document.getElementsByName(dom_id);
|
|
17
|
+
for(var i=0;i<es.length;i++) {
|
|
18
|
+
es[i].value = e.value;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (form_id)
|
|
22
|
+
document.getElementById(form_id).submit();
|
|
23
|
+
}
|
|
24
|
+
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
/* Copyright Mihai Bazon, 2002, 2003 | http://dynarch.com/mishoo/
|
|
2
|
+
* ---------------------------------------------------------------------------
|
|
3
|
+
*
|
|
4
|
+
* The DHTML Calendar
|
|
5
|
+
*
|
|
6
|
+
* Details and latest version at:
|
|
7
|
+
* http://dynarch.com/mishoo/calendar.epl
|
|
8
|
+
*
|
|
9
|
+
* This script is distributed under the GNU Lesser General Public License.
|
|
10
|
+
* Read the entire license text here: http://www.gnu.org/licenses/lgpl.html
|
|
11
|
+
*
|
|
12
|
+
* This file defines helper functions for setting up the calendar. They are
|
|
13
|
+
* intended to help non-programmers get a working calendar on their site
|
|
14
|
+
* quickly. This script should not be seen as part of the calendar. It just
|
|
15
|
+
* shows you what one can do with the calendar, while in the same time
|
|
16
|
+
* providing a quick and simple method for setting it up. If you need
|
|
17
|
+
* exhaustive customization of the calendar creation process feel free to
|
|
18
|
+
* modify this code to suit your needs (this is recommended and much better
|
|
19
|
+
* than modifying calendar.js itself).
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
// $Id: calendar-setup.js,v 1.25 2005/03/07 09:51:33 mishoo Exp $
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* This function "patches" an input field (or other element) to use a calendar
|
|
26
|
+
* widget for date selection.
|
|
27
|
+
*
|
|
28
|
+
* The "params" is a single object that can have the following properties:
|
|
29
|
+
*
|
|
30
|
+
* prop. name | description
|
|
31
|
+
* -------------------------------------------------------------------------------------------------
|
|
32
|
+
* inputField | the ID of an input field to store the date
|
|
33
|
+
* displayArea | the ID of a DIV or other element to show the date
|
|
34
|
+
* button | ID of a button or other element that will trigger the calendar
|
|
35
|
+
* eventName | event that will trigger the calendar, without the "on" prefix (default: "click")
|
|
36
|
+
* ifFormat | date format that will be stored in the input field
|
|
37
|
+
* daFormat | the date format that will be used to display the date in displayArea
|
|
38
|
+
* singleClick | (true/false) wether the calendar is in single click mode or not (default: true)
|
|
39
|
+
* firstDay | numeric: 0 to 6. "0" means display Sunday first, "1" means display Monday first, etc.
|
|
40
|
+
* align | alignment (default: "Br"); if you don't know what's this see the calendar documentation
|
|
41
|
+
* range | array with 2 elements. Default: [1900, 2999] -- the range of years available
|
|
42
|
+
* weekNumbers | (true/false) if it's true (default) the calendar will display week numbers
|
|
43
|
+
* flat | null or element ID; if not null the calendar will be a flat calendar having the parent with the given ID
|
|
44
|
+
* flatCallback | function that receives a JS Date object and returns an URL to point the browser to (for flat calendar)
|
|
45
|
+
* disableFunc | function that receives a JS Date object and should return true if that date has to be disabled in the calendar
|
|
46
|
+
* onSelect | function that gets called when a date is selected. You don't _have_ to supply this (the default is generally okay)
|
|
47
|
+
* onClose | function that gets called when the calendar is closed. [default]
|
|
48
|
+
* onUpdate | function that gets called after the date is updated in the input field. Receives a reference to the calendar.
|
|
49
|
+
* date | the date that the calendar will be initially displayed to
|
|
50
|
+
* showsTime | default: false; if true the calendar will include a time selector
|
|
51
|
+
* timeFormat | the time format; can be "12" or "24", default is "12"
|
|
52
|
+
* electric | if true (default) then given fields/date areas are updated for each move; otherwise they're updated only on close
|
|
53
|
+
* step | configures the step of the years in drop-down boxes; default: 2
|
|
54
|
+
* position | configures the calendar absolute position; default: null
|
|
55
|
+
* cache | if "true" (but default: "false") it will reuse the same calendar object, where possible
|
|
56
|
+
* showOthers | if "true" (but default: "false") it will show days from other months too
|
|
57
|
+
*
|
|
58
|
+
* None of them is required, they all have default values. However, if you
|
|
59
|
+
* pass none of "inputField", "displayArea" or "button" you'll get a warning
|
|
60
|
+
* saying "nothing to setup".
|
|
61
|
+
*/
|
|
62
|
+
Calendar.setup = function (params) {
|
|
63
|
+
function param_default(pname, def) { if (typeof params[pname] == "undefined") { params[pname] = def; } };
|
|
64
|
+
|
|
65
|
+
param_default("inputField", null);
|
|
66
|
+
param_default("displayArea", null);
|
|
67
|
+
param_default("button", null);
|
|
68
|
+
param_default("eventName", "click");
|
|
69
|
+
param_default("ifFormat", "%Y/%m/%d");
|
|
70
|
+
param_default("daFormat", "%Y/%m/%d");
|
|
71
|
+
param_default("singleClick", true);
|
|
72
|
+
param_default("disableFunc", null);
|
|
73
|
+
param_default("dateStatusFunc", params["disableFunc"]); // takes precedence if both are defined
|
|
74
|
+
param_default("dateText", null);
|
|
75
|
+
param_default("firstDay", null);
|
|
76
|
+
param_default("align", "Br");
|
|
77
|
+
param_default("range", [1900, 2999]);
|
|
78
|
+
param_default("weekNumbers", true);
|
|
79
|
+
param_default("flat", null);
|
|
80
|
+
param_default("flatCallback", null);
|
|
81
|
+
param_default("onSelect", null);
|
|
82
|
+
param_default("onClose", null);
|
|
83
|
+
param_default("onUpdate", null);
|
|
84
|
+
param_default("date", null);
|
|
85
|
+
param_default("showsTime", false);
|
|
86
|
+
param_default("timeFormat", "24");
|
|
87
|
+
param_default("electric", true);
|
|
88
|
+
param_default("step", 2);
|
|
89
|
+
param_default("position", null);
|
|
90
|
+
param_default("cache", false);
|
|
91
|
+
param_default("showOthers", false);
|
|
92
|
+
param_default("multiple", null);
|
|
93
|
+
|
|
94
|
+
var tmp = ["inputField", "displayArea", "button"];
|
|
95
|
+
for (var i in tmp) {
|
|
96
|
+
if (typeof params[tmp[i]] == "string") {
|
|
97
|
+
params[tmp[i]] = document.getElementById(params[tmp[i]]);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
if (!(params.flat || params.multiple || params.inputField || params.displayArea || params.button)) {
|
|
101
|
+
alert("Calendar.setup:\n Nothing to setup (no fields found). Please check your code");
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function onSelect(cal) {
|
|
106
|
+
var p = cal.params;
|
|
107
|
+
var update = (cal.dateClicked || p.electric);
|
|
108
|
+
if (update && p.inputField) {
|
|
109
|
+
p.inputField.value = cal.date.print(p.ifFormat);
|
|
110
|
+
if (typeof p.inputField.onchange == "function")
|
|
111
|
+
p.inputField.onchange();
|
|
112
|
+
}
|
|
113
|
+
if (update && p.displayArea)
|
|
114
|
+
p.displayArea.innerHTML = cal.date.print(p.daFormat);
|
|
115
|
+
if (update && typeof p.onUpdate == "function")
|
|
116
|
+
p.onUpdate(cal);
|
|
117
|
+
if (update && p.flat) {
|
|
118
|
+
if (typeof p.flatCallback == "function")
|
|
119
|
+
p.flatCallback(cal);
|
|
120
|
+
}
|
|
121
|
+
if (update && p.singleClick && cal.dateClicked)
|
|
122
|
+
cal.callCloseHandler();
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
if (params.flat != null) {
|
|
126
|
+
if (typeof params.flat == "string")
|
|
127
|
+
params.flat = document.getElementById(params.flat);
|
|
128
|
+
if (!params.flat) {
|
|
129
|
+
alert("Calendar.setup:\n Flat specified but can't find parent.");
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
var cal = new Calendar(params.firstDay, params.date, params.onSelect || onSelect);
|
|
133
|
+
cal.showsOtherMonths = params.showOthers;
|
|
134
|
+
cal.showsTime = params.showsTime;
|
|
135
|
+
cal.time24 = (params.timeFormat == "24");
|
|
136
|
+
cal.params = params;
|
|
137
|
+
cal.weekNumbers = params.weekNumbers;
|
|
138
|
+
cal.setRange(params.range[0], params.range[1]);
|
|
139
|
+
cal.setDateStatusHandler(params.dateStatusFunc);
|
|
140
|
+
cal.getDateText = params.dateText;
|
|
141
|
+
if (params.ifFormat) {
|
|
142
|
+
cal.setDateFormat(params.ifFormat);
|
|
143
|
+
}
|
|
144
|
+
if (params.inputField && typeof params.inputField.value == "string") {
|
|
145
|
+
cal.parseDate(params.inputField.value);
|
|
146
|
+
}
|
|
147
|
+
cal.create(params.flat);
|
|
148
|
+
cal.show();
|
|
149
|
+
return false;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
var triggerEl = params.button || params.displayArea || params.inputField;
|
|
153
|
+
triggerEl["on" + params.eventName] = function() {
|
|
154
|
+
var dateEl = params.inputField || params.displayArea;
|
|
155
|
+
var dateFmt = params.inputField ? params.ifFormat : params.daFormat;
|
|
156
|
+
var mustCreate = false;
|
|
157
|
+
var cal = window.calendar;
|
|
158
|
+
if (dateEl)
|
|
159
|
+
params.date = Date.parseDate(dateEl.value || dateEl.innerHTML, dateFmt);
|
|
160
|
+
if (!(cal && params.cache)) {
|
|
161
|
+
window.calendar = cal = new Calendar(params.firstDay,
|
|
162
|
+
params.date,
|
|
163
|
+
params.onSelect || onSelect,
|
|
164
|
+
params.onClose || function(cal) { cal.hide(); });
|
|
165
|
+
cal.showsTime = params.showsTime;
|
|
166
|
+
cal.time24 = (params.timeFormat == "24");
|
|
167
|
+
cal.weekNumbers = params.weekNumbers;
|
|
168
|
+
mustCreate = true;
|
|
169
|
+
} else {
|
|
170
|
+
if (params.date)
|
|
171
|
+
cal.setDate(params.date);
|
|
172
|
+
cal.hide();
|
|
173
|
+
}
|
|
174
|
+
if (params.multiple) {
|
|
175
|
+
cal.multiple = {};
|
|
176
|
+
for (var i = params.multiple.length; --i >= 0;) {
|
|
177
|
+
var d = params.multiple[i];
|
|
178
|
+
var ds = d.print("%Y%m%d");
|
|
179
|
+
cal.multiple[ds] = d;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
cal.showsOtherMonths = params.showOthers;
|
|
183
|
+
cal.yearStep = params.step;
|
|
184
|
+
cal.setRange(params.range[0], params.range[1]);
|
|
185
|
+
cal.params = params;
|
|
186
|
+
cal.setDateStatusHandler(params.dateStatusFunc);
|
|
187
|
+
cal.getDateText = params.dateText;
|
|
188
|
+
cal.setDateFormat(dateFmt);
|
|
189
|
+
if (mustCreate)
|
|
190
|
+
cal.create();
|
|
191
|
+
cal.refresh();
|
|
192
|
+
if (!params.position)
|
|
193
|
+
cal.showAtElement(params.button || params.displayArea || params.inputField, params.align);
|
|
194
|
+
else
|
|
195
|
+
cal.showAt(params.position[0], params.position[1]);
|
|
196
|
+
return false;
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
return cal;
|
|
200
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/* Copyright Mihai Bazon, 2002, 2003 | http://dynarch.com/mishoo/
|
|
2
|
+
* ---------------------------------------------------------------------------
|
|
3
|
+
*
|
|
4
|
+
* The DHTML Calendar
|
|
5
|
+
*
|
|
6
|
+
* Details and latest version at:
|
|
7
|
+
* http://dynarch.com/mishoo/calendar.epl
|
|
8
|
+
*
|
|
9
|
+
* This script is distributed under the GNU Lesser General Public License.
|
|
10
|
+
* Read the entire license text here: http://www.gnu.org/licenses/lgpl.html
|
|
11
|
+
*
|
|
12
|
+
* This file defines helper functions for setting up the calendar. They are
|
|
13
|
+
* intended to help non-programmers get a working calendar on their site
|
|
14
|
+
* quickly. This script should not be seen as part of the calendar. It just
|
|
15
|
+
* shows you what one can do with the calendar, while in the same time
|
|
16
|
+
* providing a quick and simple method for setting it up. If you need
|
|
17
|
+
* exhaustive customization of the calendar creation process feel free to
|
|
18
|
+
* modify this code to suit your needs (this is recommended and much better
|
|
19
|
+
* than modifying calendar.js itself).
|
|
20
|
+
*/
|
|
21
|
+
Calendar.setup=function(params){function param_default(pname,def){if(typeof params[pname]=="undefined"){params[pname]=def;}};param_default("inputField",null);param_default("displayArea",null);param_default("button",null);param_default("eventName","click");param_default("ifFormat","%Y/%m/%d");param_default("daFormat","%Y/%m/%d");param_default("singleClick",true);param_default("disableFunc",null);param_default("dateStatusFunc",params["disableFunc"]);param_default("dateText",null);param_default("firstDay",null);param_default("align","Br");param_default("range",[1900,2999]);param_default("weekNumbers",true);param_default("flat",null);param_default("flatCallback",null);param_default("onSelect",null);param_default("onClose",null);param_default("onUpdate",null);param_default("date",null);param_default("showsTime",false);param_default("timeFormat","24");param_default("electric",true);param_default("step",2);param_default("position",null);param_default("cache",false);param_default("showOthers",false);param_default("multiple",null);var tmp=["inputField","displayArea","button"];for(var i in tmp){if(typeof params[tmp[i]]=="string"){params[tmp[i]]=document.getElementById(params[tmp[i]]);}}if(!(params.flat||params.multiple||params.inputField||params.displayArea||params.button)){alert("Calendar.setup:\n Nothing to setup (no fields found). Please check your code");return false;}function onSelect(cal){var p=cal.params;var update=(cal.dateClicked||p.electric);if(update&&p.inputField){p.inputField.value=cal.date.print(p.ifFormat);if(typeof p.inputField.onchange=="function")p.inputField.onchange();}if(update&&p.displayArea)p.displayArea.innerHTML=cal.date.print(p.daFormat);if(update&&typeof p.onUpdate=="function")p.onUpdate(cal);if(update&&p.flat){if(typeof p.flatCallback=="function")p.flatCallback(cal);}if(update&&p.singleClick&&cal.dateClicked)cal.callCloseHandler();};if(params.flat!=null){if(typeof params.flat=="string")params.flat=document.getElementById(params.flat);if(!params.flat){alert("Calendar.setup:\n Flat specified but can't find parent.");return false;}var cal=new Calendar(params.firstDay,params.date,params.onSelect||onSelect);cal.showsOtherMonths=params.showOthers;cal.showsTime=params.showsTime;cal.time24=(params.timeFormat=="24");cal.params=params;cal.weekNumbers=params.weekNumbers;cal.setRange(params.range[0],params.range[1]);cal.setDateStatusHandler(params.dateStatusFunc);cal.getDateText=params.dateText;if(params.ifFormat){cal.setDateFormat(params.ifFormat);}if(params.inputField&&typeof params.inputField.value=="string"){cal.parseDate(params.inputField.value);}cal.create(params.flat);cal.show();return false;}var triggerEl=params.button||params.displayArea||params.inputField;triggerEl["on"+params.eventName]=function(){var dateEl=params.inputField||params.displayArea;var dateFmt=params.inputField?params.ifFormat:params.daFormat;var mustCreate=false;var cal=window.calendar;if(dateEl)params.date=Date.parseDate(dateEl.value||dateEl.innerHTML,dateFmt);if(!(cal&¶ms.cache)){window.calendar=cal=new Calendar(params.firstDay,params.date,params.onSelect||onSelect,params.onClose||function(cal){cal.hide();});cal.showsTime=params.showsTime;cal.time24=(params.timeFormat=="24");cal.weekNumbers=params.weekNumbers;mustCreate=true;}else{if(params.date)cal.setDate(params.date);cal.hide();}if(params.multiple){cal.multiple={};for(var i=params.multiple.length;--i>=0;){var d=params.multiple[i];var ds=d.print("%Y%m%d");cal.multiple[ds]=d;}}cal.showsOtherMonths=params.showOthers;cal.yearStep=params.step;cal.setRange(params.range[0],params.range[1]);cal.params=params;cal.setDateStatusHandler(params.dateStatusFunc);cal.getDateText=params.dateText;cal.setDateFormat(dateFmt);if(mustCreate)cal.create();cal.refresh();if(!params.position)cal.showAtElement(params.button||params.displayArea||params.inputField,params.align);else cal.showAt(params.position[0],params.position[1]);return false;};return cal;};
|