data/TWiki/JSCalendarContrib.txt
changeset 0 414e01d06fd5
child 1 e2915a7cbdfa
equal deleted inserted replaced
-1:000000000000 0:414e01d06fd5
       
     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 TWiki.
       
    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 TWiki plugins. This module includes the functions:
       
    29 
       
    30 
       
    31 ---+++ TWiki::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 TWiki::Contrib::JSCalendarContrib;
       
    45 ...
       
    46 my $fromDate = TWiki::Contrib::JSCalendarContrib::renderDateForEdit(
       
    47    'from', '1 April 1999');
       
    48 my $toDate = TWiki::Contrib::JSCalendarContrib::renderDateForEdit(
       
    49    'to', undef, '%Y');
       
    50 </verbatim>
       
    51 
       
    52 
       
    53 ---+++ TWiki::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 ='twiki'=, 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 TWiki::Contrib::JSCalendarContrib;
       
    68 ...
       
    69 
       
    70 sub commonTagsHandler {
       
    71   ....
       
    72   # Enable 'showCalendar'
       
    73   TWiki::Contrib::JSCalendarContrib::addHEAD( 'twiki' );
       
    74 
       
    75   my $cal = CGI::image_button(
       
    76       -name => 'img_datefield',
       
    77       -onclick =>
       
    78        "return showCalendar('id_datefield','%Y %b %e')",
       
    79       -src=> TWiki::Func::getPubUrlPath() . '/' .
       
    80              TWiki::Func::getTwikiWebname() .
       
    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 . See the Mishoo documentation for details of the '$e %B %Y' parameter.
       
    90 
       
    91 =addHEAD= can be called from =commonTagsHandler= for adding the header to all pages, or from =beforeEditHandler= just for edit pages etc.
       
    92 
       
    93 
       
    94 
       
    95 ---+++ Using the Calendar in user forms
       
    96 You can also use the calendar directly in your own hand-built forms, without
       
    97 having to write any code. Just add this inline in the topic text:
       
    98 <verbatim>
       
    99 %INCLUDE{"%SYSTEMWEB%/JSCalendarContribInline"}%
       
   100 </verbatim>
       
   101 Then, to display a calendar icon next to a text input field:
       
   102 <verbatim>
       
   103 <input type="text" id="cal_val_here" />
       
   104 <input type="image" src="%PUBURL%/%SYSTEMWEB%/JSCalendarContrib/img.gif" onclick="javascript: return showCalendar('cal_val_here','%e %B %Y')" />
       
   105 </verbatim>
       
   106 If the contrib is installed, you will see such a field here:
       
   107 %INCLUDE{"%SYSTEMWEB%/JSCalendarContribInline"}%
       
   108 <input type="text" id="cal_val_here" />
       
   109 <input type="image" src="%PUBURL%/%SYSTEMWEB%/JSCalendarContrib/img.gif" onclick="javascript: return showCalendar('cal_val_here','%e %B %Y')" />
       
   110 
       
   111 <!--
       
   112    * Set SHORTDESCRIPTION = [[http://dynarch.com/mishoo/calendar.epl][Mishoo JSCalendar]], packaged for use by plugins, skins and add-ons.
       
   113 -->
       
   114 
       
   115 ---+++ Installation Instructions
       
   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.
       
   117 
       
   118 Like many other TWiki extensions, this module is shipped with a fully
       
   119 automatic installer script written using the Build<nop>Contrib.
       
   120    * If you have TWiki 4.2 or later, you can install from the =configure= interface (Go to Plugins->Find More Extensions)
       
   121       * See the [[http://twiki.org/cgi-bin/view/Plugins/BuildContribInstallationSupplement][installation supplement]] on TWiki.org for more information.
       
   122    * If you have any problems, then you can still install manually from the command-line:
       
   123       1 Download one of the =.zip= or =.tgz= archives
       
   124       1 Unpack the archive in the root directory of your TWiki installation.
       
   125       1 Run the installer script ( =perl &lt;module&gt;_installer= )
       
   126       1 Run =configure= and enable the module, if it is a plugin.
       
   127       1 Repeat for any missing dependencies.
       
   128    * If you are *still* having problems, then instead of running the installer script:
       
   129       1 Make sure that the file permissions allow the webserver user to access all files.
       
   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)
       
   131       1 Manually edit !LocalSite.cfg to set any configuration variables.
       
   132 
       
   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>"}%
       
   134 
       
   135 	* An administrator can customize the appearance of the calendar by setting the following in =<nop>LocalSite.cfg=
       
   136      | *Setting* | *Default* |
       
   137      | =$TWiki::cfg{JSCalendarContrib}{style}= | ='blue'= |
       
   138      | =$TWiki::cfg{JSCalendarContrib}{lang}= | ='en'= |
       
   139      | =$TWiki::cfg{JSCalendarContrib}{format}= | ='%e %b %Y'= |
       
   140 
       
   141 ---+++ Contrib Info
       
   142 
       
   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!
       
   144 
       
   145 |  Author: | TWiki:Main/CrawfordCurrie http://c-dot.co.uk |
       
   146 |  Version: | 16236 (22 Jan 2008) of the Mishoo calendar |
       
   147 |  Copyright &copy;: | See [[%ATTACHURL%/doc/html/reference.html][the Mishoo documentation]] |
       
   148 |  License: | GPL ([[http://www.gnu.org/copyleft/gpl.html][GNU General Public License]]) |
       
   149 |  Dependencies: | None |
       
   150 | Change History: | |
       
   151 |  6 Sep 2007 | Bugs:Item4030 Added doc for using the calendar in user forms |
       
   152 |  13603 | Bugs:Item2982 cleaned up the interface to the contrib, re-added a date rendering function with a more generic interface |
       
   153 |  11594 | Allow format to be configured. |
       
   154 |  11415 | Add a =renderFormFieldForEditHandler= so other plugins can forward to this handler to add the date field to the TWikiForms. (TWiki:Main.ThomasWeigert) |
       
   155 |  10247 | Bugs:Item2054 put the calendar at z-index 2000, way above pattern skin divs. |
       
   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. |
       
   157 |  6626 | Bugs:Item468  updated docs for Dakar release |
       
   158 |  5048 | Cairo readiness |
       
   159 |  5039 | Split from SharedCode |
       
   160 |  27 Dec 2005 | updated to calendar version 1.0; set style for Safari to win2k-1|
       
   161 |  14 Aug 2004 | Separated out from SharedCode module |
       
   162 |  Home: | http://TWiki.org/cgi-bin/view/Plugins/%TOPIC% |
       
   163 |  Feedback: | http://TWiki.org/cgi-bin/view/Plugins/%TOPIC%Dev |
       
   164 |  Appraisal: | http://TWiki.org/cgi-bin/view/Plugins/%TOPIC%Appraisal |
       
   165 
       
   166 __Related Topics:__ %SYSTEMWEB%.TWikiPreferences
       
   167 
       
   168 %META:FILEATTACHMENT{name="screenshot.gif" attr="h" comment="" version="1"}%
       
   169 %META:FILEATTACHMENT{name="wikiringlogo20x20.png" attr="h" comment="" version="1"}%