data/TWiki/JSCalendarContrib.txt
author Colas Nahaboo <colas@nahaboo.net>
Sat, 26 Jan 2008 15:50:53 +0100
changeset 0 414e01d06fd5
child 1 e2915a7cbdfa
permissions -rw-r--r--
RELEASE 4.2.0 freetown
colas@0
     1
---+!! %TOPIC%
colas@0
     2
<img src="%ATTACHURL%/screenshot.gif" style="float:right"/>
colas@0
     3
colas@0
     4
%SHORTDESCRIPTION%
colas@0
     5
colas@0
     6
<!--
colas@0
     7
colas@0
     8
   PLEASE DO NOT EDIT THIS TOPIC
colas@0
     9
colas@0
    10
   It is automatically generated from the subversion repository, and any changes
colas@0
    11
   you make will simply be overwritten the next time a release is generated.
colas@0
    12
colas@0
    13
   Instead, you could check your fix in, raise a bug in the Bugs web, or mail thge author.
colas@0
    14
-->
colas@0
    15
colas@0
    16
%TOC%
colas@0
    17
colas@0
    18
---++ Summary of Contents
colas@0
    19
This module packages the [[http://dynarch.com/mishoo/calendar.epl][Mishoo JSCalendar]] Javascript in a form suitable for use with TWiki.
colas@0
    20
colas@0
    21
---++ Detailed Documentation
colas@0
    22
colas@0
    23
Read [[%ATTACHURL%/doc/html/reference.html][the Mishoo documentation]] or
colas@0
    24
[[%ATTACHURL%][visit the demo page]] for detailed information on using the
colas@0
    25
calendar widget.
colas@0
    26
colas@0
    27
This package also includes a small Perl module to make using the calendar
colas@0
    28
easier from TWiki plugins. This module includes the functions:
colas@0
    29
colas@0
    30
colas@0
    31
---+++ TWiki::Contrib::JSCalendarContrib::renderDateForEdit($name, $value, $format [, \%cssClass]) -> $html
colas@0
    32
colas@0
    33
This is the simplest way to use calendars from a plugin.
colas@0
    34
   * =$name= is the name of the CGI parameter for the calendar
colas@0
    35
     (it should be unique),
colas@0
    36
   * =$value= is the current value of the parameter (may be undef)
colas@0
    37
   * =$format= is the format to use (optional; the default is set
colas@0
    38
     in =configure=). The HTML returned will display a date field
colas@0
    39
     and a drop-down calendar.
colas@0
    40
   * =\%options= is an optional hash containing base options for
colas@0
    41
     the textfield.
colas@0
    42
Example:
colas@0
    43
<verbatim>
colas@0
    44
use TWiki::Contrib::JSCalendarContrib;
colas@0
    45
...
colas@0
    46
my $fromDate = TWiki::Contrib::JSCalendarContrib::renderDateForEdit(
colas@0
    47
   'from', '1 April 1999');
colas@0
    48
my $toDate = TWiki::Contrib::JSCalendarContrib::renderDateForEdit(
colas@0
    49
   'to', undef, '%Y');
colas@0
    50
</verbatim>
colas@0
    51
colas@0
    52
colas@0
    53
---+++ TWiki::Contrib::JSCalendarContrib::addHEAD($setup)
colas@0
    54
colas@0
    55
This function will automatically add the headers for the calendar to the page
colas@0
    56
being rendered. It's intended for use when you want more control over the
colas@0
    57
formatting of your calendars than =renderDateForEdit= affords. =$setup= is
colas@0
    58
the name of
colas@0
    59
the calendar setup module; it can either be omitted, in which case the method
colas@0
    60
described in the Mishoo documentation can be used to create calendars, or it
colas@0
    61
can be ='twiki'=, in which case a Javascript helper function called
colas@0
    62
'showCalendar' is added that simplifies using calendars to set a value in a
colas@0
    63
text field. For example, say we wanted to display the date with the calendar
colas@0
    64
icon _before_ the text field, using the format =%Y %b %e=
colas@0
    65
<verbatim>
colas@0
    66
# Add styles and javascript for the calendar
colas@0
    67
use TWiki::Contrib::JSCalendarContrib;
colas@0
    68
...
colas@0
    69
colas@0
    70
sub commonTagsHandler {
colas@0
    71
  ....
colas@0
    72
  # Enable 'showCalendar'
colas@0
    73
  TWiki::Contrib::JSCalendarContrib::addHEAD( 'twiki' );
colas@0
    74
colas@0
    75
  my $cal = CGI::image_button(
colas@0
    76
      -name => 'img_datefield',
colas@0
    77
      -onclick =>
colas@0
    78
       "return showCalendar('id_datefield','%Y %b %e')",
colas@0
    79
      -src=> TWiki::Func::getPubUrlPath() . '/' .
colas@0
    80
             TWiki::Func::getTwikiWebname() .
colas@0
    81
             '/JSCalendarContrib/img.gif',
colas@0
    82
      -alt => 'Calendar',
colas@0
    83
      -align => 'middle' )
colas@0
    84
    . CGI::textfield(
colas@0
    85
      { name => 'date', id => "id_datefield" });
colas@0
    86
  ....
colas@0
    87
}
colas@0
    88
</verbatim>
colas@0
    89
The first parameter to =showCalendar= is the id of the textfield, and the second parameter is the . See the Mishoo documentation for details of the '$e %B %Y' parameter.
colas@0
    90
colas@0
    91
=addHEAD= can be called from =commonTagsHandler= for adding the header to all pages, or from =beforeEditHandler= just for edit pages etc.
colas@0
    92
colas@0
    93
colas@0
    94
colas@0
    95
---+++ Using the Calendar in user forms
colas@0
    96
You can also use the calendar directly in your own hand-built forms, without
colas@0
    97
having to write any code. Just add this inline in the topic text:
colas@0
    98
<verbatim>
colas@0
    99
%INCLUDE{"%SYSTEMWEB%/JSCalendarContribInline"}%
colas@0
   100
</verbatim>
colas@0
   101
Then, to display a calendar icon next to a text input field:
colas@0
   102
<verbatim>
colas@0
   103
<input type="text" id="cal_val_here" />
colas@0
   104
<input type="image" src="%PUBURL%/%SYSTEMWEB%/JSCalendarContrib/img.gif" onclick="javascript: return showCalendar('cal_val_here','%e %B %Y')" />
colas@0
   105
</verbatim>
colas@0
   106
If the contrib is installed, you will see such a field here:
colas@0
   107
%INCLUDE{"%SYSTEMWEB%/JSCalendarContribInline"}%
colas@0
   108
<input type="text" id="cal_val_here" />
colas@0
   109
<input type="image" src="%PUBURL%/%SYSTEMWEB%/JSCalendarContrib/img.gif" onclick="javascript: return showCalendar('cal_val_here','%e %B %Y')" />
colas@0
   110
colas@0
   111
<!--
colas@0
   112
   * Set SHORTDESCRIPTION = [[http://dynarch.com/mishoo/calendar.epl][Mishoo JSCalendar]], packaged for use by plugins, skins and add-ons.
colas@0
   113
-->
colas@0
   114
colas@0
   115
---+++ Installation Instructions
colas@0
   116
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 where TWiki is running.
colas@0
   117
colas@0
   118
Like many other TWiki extensions, this module is shipped with a fully
colas@0
   119
automatic installer script written using the Build<nop>Contrib.
colas@0
   120
   * If you have TWiki 4.2 or later, you can install from the =configure= interface (Go to Plugins->Find More Extensions)
colas@0
   121
      * See the [[http://twiki.org/cgi-bin/view/Plugins/BuildContribInstallationSupplement][installation supplement]] on TWiki.org for more information.
colas@0
   122
   * If you have any problems, then you can still install manually from the command-line:
colas@0
   123
      1 Download one of the =.zip= or =.tgz= archives
colas@0
   124
      1 Unpack the archive in the root directory of your TWiki installation.
colas@0
   125
      1 Run the installer script ( =perl &lt;module&gt;_installer= )
colas@0
   126
      1 Run =configure= and enable the module, if it is a plugin.
colas@0
   127
      1 Repeat for any missing dependencies.
colas@0
   128
   * If you are *still* having problems, then instead of running the installer script:
colas@0
   129
      1 Make sure that the file permissions allow the webserver user to access all files.
colas@0
   130
      1 Check in any installed files that have existing =,v= files in your existing install (take care *not* to lock the files when you check in)
colas@0
   131
      1 Manually edit !LocalSite.cfg to set any configuration variables.
colas@0
   132
colas@0
   133
%IF{"defined 'SYSTEMWEB'" else="<div class='twikiAlert'>%X% WARNING: SYSTEMWEB is not defined in this TWiki. Please add these definitions to your %MAINWEB%.TWikiPreferences, if they are not already there:<br><pre>   * <nop>Set SYSTEMWEB = %<nop>TWIKIWEB%<br>   * <nop>Set USERSWEB = %<nop>MAINWEB%</pre></div>"}%
colas@0
   134
colas@0
   135
	* An administrator can customize the appearance of the calendar by setting the following in =<nop>LocalSite.cfg=
colas@0
   136
     | *Setting* | *Default* |
colas@0
   137
     | =$TWiki::cfg{JSCalendarContrib}{style}= | ='blue'= |
colas@0
   138
     | =$TWiki::cfg{JSCalendarContrib}{lang}= | ='en'= |
colas@0
   139
     | =$TWiki::cfg{JSCalendarContrib}{format}= | ='%e %b %Y'= |
colas@0
   140
colas@0
   141
---+++ Contrib Info
colas@0
   142
colas@0
   143
Another great TWiki 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!
colas@0
   144
colas@0
   145
|  Author: | TWiki:Main/CrawfordCurrie http://c-dot.co.uk |
colas@0
   146
|  Version: | 16236 (22 Jan 2008) of the Mishoo calendar |
colas@0
   147
|  Copyright &copy;: | See [[%ATTACHURL%/doc/html/reference.html][the Mishoo documentation]] |
colas@0
   148
|  License: | GPL ([[http://www.gnu.org/copyleft/gpl.html][GNU General Public License]]) |
colas@0
   149
|  Dependencies: | None |
colas@0
   150
| Change History: | |
colas@0
   151
|  6 Sep 2007 | Bugs:Item4030 Added doc for using the calendar in user forms |
colas@0
   152
|  13603 | Bugs:Item2982 cleaned up the interface to the contrib, re-added a date rendering function with a more generic interface |
colas@0
   153
|  11594 | Allow format to be configured. |
colas@0
   154
|  11415 | Add a =renderFormFieldForEditHandler= so other plugins can forward to this handler to add the date field to the TWikiForms. (TWiki:Main.ThomasWeigert) |
colas@0
   155
|  10247 | Bugs:Item2054 put the calendar at z-index 2000, way above pattern skin divs. |
colas@0
   156
|  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. |
colas@0
   157
|  6626 | Bugs:Item468  updated docs for Dakar release |
colas@0
   158
|  5048 | Cairo readiness |
colas@0
   159
|  5039 | Split from SharedCode |
colas@0
   160
|  27 Dec 2005 | updated to calendar version 1.0; set style for Safari to win2k-1|
colas@0
   161
|  14 Aug 2004 | Separated out from SharedCode module |
colas@0
   162
|  Home: | http://TWiki.org/cgi-bin/view/Plugins/%TOPIC% |
colas@0
   163
|  Feedback: | http://TWiki.org/cgi-bin/view/Plugins/%TOPIC%Dev |
colas@0
   164
|  Appraisal: | http://TWiki.org/cgi-bin/view/Plugins/%TOPIC%Appraisal |
colas@0
   165
colas@0
   166
__Related Topics:__ %SYSTEMWEB%.TWikiPreferences
colas@0
   167
colas@0
   168
%META:FILEATTACHMENT{name="screenshot.gif" attr="h" comment="" version="1"}%
colas@0
   169
%META:FILEATTACHMENT{name="wikiringlogo20x20.png" attr="h" comment="" version="1"}%