~kosova/+junk/tuxfamily-twiki

« back to all changes in this revision

Viewing changes to foswiki/data/System/JSCalendarContrib.txt

  • Committer: James Michael DuPont
  • Date: 2009-07-18 19:58:49 UTC
  • Revision ID: jamesmikedupont@gmail.com-20090718195849-vgbmaht2ys791uo2
added foswiki

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
---+!! %TOPIC%
 
2
<img src="%ATTACHURL%/screenshot.gif" style="float:right"/>
 
3
 
 
4
%SHORTDESCRIPTION%
 
5
 
 
6
<!--
 
7
 
 
8
   PLEASE DO NOT EDIT THIS TOPIC
 
9
 
 
10
   It is automatically generated from the subversion repository, and any changes
 
11
   you make will simply be overwritten the next time a release is generated.
 
12
 
 
13
   Instead, you could check your fix in, raise a bug in the Bugs web, or mail thge author.
 
14
-->
 
15
 
 
16
%TOC%
 
17
 
 
18
---++ Summary of Contents
 
19
This module packages the [[http://dynarch.com/mishoo/calendar.epl][Mishoo JSCalendar]] Javascript in a form suitable for use with Foswiki.
 
20
 
 
21
---++ Detailed Documentation
 
22
 
 
23
Read [[%ATTACHURL%/doc/html/reference.html][the Mishoo documentation]] or
 
24
[[%ATTACHURL%][visit the demo page]] for detailed information on using the
 
25
calendar widget.
 
26
 
 
27
This package also includes a small Perl module to make using the calendar
 
28
easier from Foswiki plugins. This module includes the functions:
 
29
 
 
30
 
 
31
---+++ Foswiki::Contrib::JSCalendarContrib::renderDateForEdit($name, $value, $format [, \%cssClass]) -> $html
 
32
 
 
33
This is the simplest way to use calendars from a plugin.
 
34
   * =$name= is the name of the CGI parameter for the calendar
 
35
     (it should be unique),
 
36
   * =$value= is the current value of the parameter (may be undef)
 
37
   * =$format= is the format to use (optional; the default is set
 
38
     in =configure=). The HTML returned will display a date field
 
39
     and a drop-down calendar.
 
40
   * =\%options= is an optional hash containing base options for
 
41
     the textfield.
 
42
Example:
 
43
<verbatim>
 
44
use Foswiki::Contrib::JSCalendarContrib;
 
45
...
 
46
my $fromDate = Foswiki::Contrib::JSCalendarContrib::renderDateForEdit(
 
47
   'from', '1 April 1999');
 
48
my $toDate = Foswiki::Contrib::JSCalendarContrib::renderDateForEdit(
 
49
   'to', undef, '%Y');
 
50
</verbatim>
 
51
 
 
52
 
 
53
---+++ Foswiki::Contrib::JSCalendarContrib::addHEAD($setup)
 
54
 
 
55
This function will automatically add the headers for the calendar to the page
 
56
being rendered. It's intended for use when you want more control over the
 
57
formatting of your calendars than =renderDateForEdit= affords. =$setup= is
 
58
the name of
 
59
the calendar setup module; it can either be omitted, in which case the method
 
60
described in the Mishoo documentation can be used to create calendars, or it
 
61
can be ='foswiki'=, in which case a Javascript helper function called
 
62
'showCalendar' is added that simplifies using calendars to set a value in a
 
63
text field. For example, say we wanted to display the date with the calendar
 
64
icon _before_ the text field, using the format =%Y %b %e=
 
65
<verbatim>
 
66
# Add styles and javascript for the calendar
 
67
use Foswiki::Contrib::JSCalendarContrib;
 
68
...
 
69
 
 
70
sub commonTagsHandler {
 
71
  ....
 
72
  # Enable 'showCalendar'
 
73
  Foswiki::Contrib::JSCalendarContrib::addHEAD( 'foswiki' );
 
74
 
 
75
  my $cal = CGI::image_button(
 
76
      -name => 'img_datefield',
 
77
      -onclick =>
 
78
       "return showCalendar('id_datefield','%Y %b %e')",
 
79
      -src=> Foswiki::Func::getPubUrlPath() . '/' .
 
80
             $Foswiki::cfg{SystemWebName} .
 
81
             '/JSCalendarContrib/img.gif',
 
82
      -alt => 'Calendar',
 
83
      -align => 'middle' )
 
84
    . CGI::textfield(
 
85
      { name => 'date', id => "id_datefield" });
 
86
  ....
 
87
}
 
88
</verbatim>
 
89
The first parameter to =showCalendar= is the id of the textfield, and the second parameter is the date format. Default format is '%e %B %Y'.
 
90
 
 
91
All available date specifiers:
 
92
<verbatim>
 
93
%a - abbreviated weekday name 
 
94
%A - full weekday name 
 
95
%b - abbreviated month name 
 
96
%B - full month name 
 
97
%C - century number 
 
98
%d - the day of the month ( 00 .. 31 ) 
 
99
%e - the day of the month ( 0 .. 31 ) 
 
100
%H - hour ( 00 .. 23 ) 
 
101
%I - hour ( 01 .. 12 ) 
 
102
%j - day of the year ( 000 .. 366 ) 
 
103
%k - hour ( 0 .. 23 ) 
 
104
%l - hour ( 1 .. 12 ) 
 
105
%m - month ( 01 .. 12 ) 
 
106
%M - minute ( 00 .. 59 ) 
 
107
%n - a newline character 
 
108
%p - "PM" or "AM"
 
109
%P - "pm" or "am"
 
110
%S - second ( 00 .. 59 ) 
 
111
%s - number of seconds since Epoch (since Jan 01 1970 00:00:00 UTC) 
 
112
%t - a tab character 
 
113
%U, %W, %V - the week number
 
114
   The week 01 is the week that has the Thursday in the current year,
 
115
   which is equivalent to the week that contains the fourth day of January. 
 
116
   Weeks start on Monday.
 
117
%u - the day of the week ( 1 .. 7, 1 = MON ) 
 
118
%w - the day of the week ( 0 .. 6, 0 = SUN ) 
 
119
%y - year without the century ( 00 .. 99 ) 
 
120
%Y - year including the century ( ex. 1979 ) 
 
121
%% - a literal % character 
 
122
</verbatim>
 
123
 
 
124
=addHEAD= can be called from =commonTagsHandler= for adding the header to all pages, or from =beforeEditHandler= just for edit pages etc.
 
125
 
 
126
An alternative to =commonTagsHandler= is =postRenderingHandler= which is more efficient since it is called less often.
 
127
 
 
128
 
 
129
 
 
130
---+++ Using the Calendar in user forms
 
131
You can also use the calendar directly in your own hand-built forms, without
 
132
having to write any code. Just add this inline in the topic text:
 
133
<verbatim>
 
134
%INCLUDE{"%SYSTEMWEB%/JSCalendarContribInline"}%
 
135
</verbatim>
 
136
Then, to display a calendar icon next to a text input field:
 
137
<verbatim>
 
138
<input type="text" id="cal_val_here" />
 
139
<input type="image" src="%PUBURL%/%SYSTEMWEB%/JSCalendarContrib/img.gif" onclick="javascript: return showCalendar('cal_val_here','%e %B %Y')" />
 
140
</verbatim>
 
141
If the contrib is installed, you will see such a field here:
 
142
%INCLUDE{"%SYSTEMWEB%/JSCalendarContribInline"}%
 
143
<input type="text" id="cal_val_here" />
 
144
<input type="image" src="%PUBURL%/%SYSTEMWEB%/JSCalendarContrib/img.gif" onclick="javascript: return showCalendar('cal_val_here','%e %B %Y')" />
 
145
 
 
146
<!--
 
147
   * Set SHORTDESCRIPTION = [[http://dynarch.com/mishoo/calendar.epl][Mishoo JSCalendar]], packaged for use by plugins, skins and add-ons.
 
148
-->
 
149
 
 
150
---+++ Installation Instructions
 
151
You do not need to install anything in the browser to use this extension. The following instructions are for the administrator who installs the extension on the server.
 
152
 
 
153
Open configure, and open the "Extensions" section. Use "Find More Extensions" to get a list of available extensions. Select "Install".
 
154
 
 
155
If you have any problems, or if the extension isn't available in =configure=, then you can still install manually from the command-line. See http://foswiki.org/Support/ManuallyInstallingExtensions for more help.
 
156
 
 
157
   * An administrator can customize the appearance of the calendar by setting the following in =<nop>LocalSite.cfg=
 
158
     | *Setting* | *Default* |
 
159
     | =$Foswiki::cfg{JSCalendarContrib}{style}= | ='blue'= |
 
160
     | =$Foswiki::cfg{JSCalendarContrib}{lang}= | ='en'= |
 
161
     | =$Foswiki::cfg{JSCalendarContrib}{format}= | ='%e %b %Y'= |
 
162
 
 
163
---+++ Contrib Info
 
164
 
 
165
Another great Foswiki extension from the <a style="text-decoration:none" href="http://wikiring.com"><img src="%ATTACHURLPATH%/wikiringlogo20x20.png" alt="" /> *WikiRing* </a> - working together to improve your wiki experience!
 
166
 
 
167
|  Author: | Foswiki:Main/CrawfordCurrie http://c-dot.co.uk |
 
168
|  Copyright &copy;: | See [[%ATTACHURL%/doc/html/reference.html][the Mishoo documentation]] |
 
169
|  License: | GPL ([[http://www.gnu.org/copyleft/gpl.html][GNU General Public License]]) |
 
170
|  Version: | 3417 (2009-04-12) |
 
171
| Change History: | |
 
172
|  16 Dec 2008 | Foswiki version |
 
173
|  10 Sep 2008 | Bugs:Item5991 Applied patch to fix rendering on IE7 .|
 
174
|  06 Sep 2007 | Bugs:Item4030 Added doc for using the calendar in user forms |
 
175
|  13603 | Bugs:Item2982 cleaned up the interface to the contrib, re-added a date rendering function with a more generic interface |
 
176
|  11594 | Allow format to be configured. |
 
177
|  11415 | Add a =renderFormFieldForEditHandler= so other plugins can forward to this handler to add the date field to the DataForms. (TWiki:Main.ThomasWeigert) |
 
178
|  10247 | Bugs:Item2054 put the calendar at z-index 2000, way above pattern skin divs. |
 
179
|  6634 | Bugs:Item453  removed EditTablePlugins private copy of the Mishoo JS calendar, and made sure it works with JSCalendarContrib. Improved the documentation of the JSCalendar while I was there. |
 
180
|  6626 | Bugs:Item468  updated docs for Dakar release |
 
181
|  5048 | Cairo readiness |
 
182
|  5039 | Split from !SharedCode |
 
183
|  27 Dec 2005 | updated to calendar version 1.0; set style for Safari to win2k-1|
 
184
|  14 Aug 2004 | Separated out from !SharedCode module |
 
185
|  Dependencies: | None |
 
186
|  Home: | http://foswiki.org/Extensions/%TOPIC% |
 
187
|  Support: | http://foswiki.org/Support/%TOPIC% |
 
188
 
 
189
---
 
190
*Related Topics:* %USERSWEB%.SitePreferences
 
191
 
 
192
%META:FILEATTACHMENT{name="screenshot.gif" attr="h" comment="" version="1"}%
 
193
%META:FILEATTACHMENT{name="wikiringlogo20x20.png" attr="h" comment="" version="1"}%