---+!! %TOPIC%
<img src="%ATTACHURL%/screenshot.gif" style="float:right"/>

%SHORTDESCRIPTION%

<!--

   PLEASE DO NOT EDIT THIS TOPIC

   It is automatically generated from the subversion repository, and any changes
   you make will simply be overwritten the next time a release is generated.

   Instead, you could check your fix in, raise a bug in the Bugs web, or mail thge author.
-->

%TOC%

---++ Summary of Contents
This module packages the [[http://dynarch.com/mishoo/calendar.epl][Mishoo JSCalendar]] Javascript in a form suitable for use with TWiki.

---++ Detailed Documentation

Read [[%ATTACHURL%/doc/html/reference.html][the Mishoo documentation]] or
[[%ATTACHURL%][visit the demo page]] for detailed information on using the
calendar widget.

This package also includes a small Perl module to make using the calendar
easier from TWiki plugins. This module includes the functions:


---+++ TWiki::Contrib::JSCalendarContrib::renderDateForEdit($name, $value, $format) -> $html

This is the simplest way to use calendars from a plugin.
   * =$name= is the name of the CGI parameter for the calendar
     (it should be unique),
   * =$value= is the current value of the parameter (may be undef)
   * =$format= is the format to use (optional; the default is set
     in =configure=). The
HTML returned will display a date field and a drop-down calendar.
Example:
<verbatim>
use TWiki::Contrib::JSCalendarContrib;
...
my $fromDate = TWiki::Contrib::JSCalendarContrib::renderDateForEdit(
   'from', '1 April 1999');
my $toDate = TWiki::Contrib::JSCalendarContrib::renderDateForEdit(
   'to', undef, '%Y');
</verbatim>


---+++ TWiki::Contrib::JSCalendarContrib::addHEAD($setup)

This function will automatically add the headers for the calendar to the page
being rendered. It's intended for use when you want more control over the
formatting of your calendars than =renderDateForEdit= affords. =$setup= is
the name of
the calendar setup module; it can either be omitted, in which case the method
described in the Mishoo documentation can be used to create calendars, or it
can be ='twiki'=, in which case a Javascript helper function called
'showCalendar' is added that simplifies using calendars to set a value in a
text field. For example, say we wanted to display the date with the calendar
icon _before_ the text field, using the format =%Y %b %e=
<verbatim>
# Add styles and javascript for the calendar
use TWiki::Contrib::JSCalendarContrib;
...

sub commonTagsHandler {
  ....
  # Enable 'showCalendar'
  TWiki::Contrib::JSCalendarContrib::addHEAD( 'twiki' );

  my $cal = CGI::image_button(
      -name => 'img_datefield',
      -onclick =>
       "return showCalendar('id_datefield','%Y %b %e')",
      -src=> TWiki::Func::getPubUrlPath() . '/' .
             TWiki::Func::getTwikiWebname() .
             '/JSCalendarContrib/img.gif',
      -alt => 'Calendar',
      -align => 'MIDDLE' )
    . CGI::textfield(
      { name => 'date', id => "id_datefield" });
  ....
}
</verbatim>
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.

=addHEAD= can be called from =commonTagsHandler= for adding the header to all pages, or from =beforeEditHandler= just for edit pages etc.



---+++ Using the Calendar in user forms
You can also use the calendar directly in your own hand-built forms, without
having to write any code. Just add this inline in the topic text:
<verbatim>
%INCLUDE{"%SYSTEMWEB%/JSCalendarContribInline"}%
</verbatim>
Then, to display a calendar icon next to a text input field:
<verbatim>
<input type="text" id="cal_val_here" />
<input type="image" src="%PUBURL%/%SYSTEMWEB%/JSCalendarContrib/img.gif" onclick="javascript: return showCalendar('cal_val_here','%e %B %Y')" />
</verbatim>
If the contrib is installed, you will see such a field here:
%INCLUDE{"%SYSTEMWEB%/JSCalendarContribInline"}%
<input type="text" id="cal_val_here" />
<input type="image" src="%PUBURL%/%SYSTEMWEB%/JSCalendarContrib/img.gif" onclick="javascript: return showCalendar('cal_val_here','%e %B %Y')" />

<!--
   * Set SHORTDESCRIPTION = [[http://dynarch.com/mishoo/calendar.epl][Mishoo JSCalendar]], packaged for use by plugins, skins and add-ons.
-->

---+++ Installation Instructions
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.

Like many other TWiki extensions, this module is shipped with a fully automatic installer script written using the Build<nop>Contrib.
   * If you have TWiki 4.1 or later, you can install from the =configure= interface (Go to Plugins->Find More Extensions)
      * The webserver user has to have permission to write to all areas of your installation for this to work.
   * If you have a permanent connection to the internet, you are recommended to use the automatic installer script
      * Just download the =JSCalendarContrib_installer= perl script and run it.
   * *Notes:*
      * The installer script will:
         * Automatically resolve dependencies,
         * Copy files into the right places in your local install (even if you have renamed data directories),
         * check in new versions of any installed files that have existing RCS histories files in your existing install (such as topics).
         * If the $TWIKI_PACKAGES environment variable is set to point to a directory, the installer will try to get archives from there. Otherwise it will try to download from twiki.org or cpan.org, as appropriate.
         * (Developers only: the script will look for twikiplugins/JSCalendarContrib/JSCalendarContrib.tgz before downloading from TWiki.org)
      * If you don't have a permanent connection, you can still use the automatic installer, by downloading all required TWiki archives to a local directory.
         * Point the environment variable =$TWIKI_PACKAGES= to this directory, and the installer script will look there first for required TWiki packages.
            * =$TWIKI_PACKAGES= is actually a path; you can list several directories separated by :
         * If you are behind a firewall that blocks access to CPAN, you can pre-install the required !CPAN libraries, as described at http://twiki.org/cgi-bin/view/TWiki/HowToInstallCpanModules
   * If you don't want to use the installer script, or have problems on your platform (e.g. you don't have Perl 5.8), then you can still install manually:
      1 Download and unpack one of the =.zip= or =.tgz= archives to a temporary directory.
      1 Manually copy the contents across to the relevant places in your TWiki installation.
      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)
      1 Manually edit !LocalSite.cfg to set any configuration variables.
      1 Run =configure= and enable the module, if it is a plugin.
      1 Repeat from step 1 for any missing dependencies.

__Note__ if you are installing this extension in TWiki version < 4.2, please add these definitions to your Main<nop>.WebPreferences, if they are not already there:
   * <nop>Set SYSTEMWEB = %<nop>TWIKIWEB%
   * <nop>Set USERSWEB = %<nop>MAINWEB%


	* An administrator can customize the appearance of the calendar by setting the following in =<nop>LocalSite.cfg=
     | *Setting* | *Default* |
     | =$TWiki::cfg{JSCalendarContrib}{style}= | ='blue'= |
     | =$TWiki::cfg{JSCalendarContrib}{lang}= | ='en'= |
     | =$TWiki::cfg{JSCalendarContrib}{format}= | ='%e %b %Y'= |

---+++ Contrib Info

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!

|  Author: | TWiki:Main/CrawfordCurrie http://c-dot.co.uk |
|  Version: | 14794 (02 Oct 2007) of the Mishoo calendar |
|  Copyright &copy;: | See [[%ATTACHURL%/doc/html/reference.html][the Mishoo documentation]] |
|  License: | GPL ([[http://www.gnu.org/copyleft/gpl.html][GNU General Public License]]) |
|  Dependencies: | None |
| Change History: | |
|  6 Sep 2007 | Bugs:Item4030 Added doc for using the calendar in user forms |
|  13603 | Bugs:Item2982 cleaned up the interface to the contrib, re-added a date rendering function with a more generic interface |
|  11594 | Allow format to be configured. |
|  11415 | Add a =renderFormFieldForEditHandler= so other plugins can forward to this handler to add the date field to the TWikiForms. (TWiki:Main.ThomasWeigert) |
|  10247 | Bugs:Item2054 put the calendar at z-index 2000, way above pattern skin divs. |
|  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. |
|  6626 | Bugs:Item468  updated docs for Dakar release |
|  5048 | Cairo readiness |
|  5039 | Split from SharedCode |
|  27 Dec 2005 | updated to calendar version 1.0; set style for Safari to win2k-1|
|  14 Aug 2004 | Separated out from SharedCode module |
|  Home: | http://TWiki.org/cgi-bin/view/Plugins/%TOPIC% |
|  Feedback: | http://TWiki.org/cgi-bin/view/Plugins/%TOPIC%Dev |
|  Appraisal: | http://TWiki.org/cgi-bin/view/Plugins/%TOPIC%Appraisal |

__Related Topics:__ %SYSTEMWEB%.TWikiPreferences

%META:FILEATTACHMENT{name="screenshot.gif" attr="h" comment="" version="1"}%
%META:FILEATTACHMENT{name="wikiringlogo20x20.png" attr="h" comment="" version="1"}%
