data/TWiki/JSCalendarContrib.txt
author Colas Nahaboo <colas@nahaboo.net>
Mon, 11 Aug 2008 20:33:37 +0200
changeset 2 7bc60a767fa4
parent 1 e2915a7cbdfa
permissions -rw-r--r--
TWiki-4.2.2 Release
     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 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 
   127 
   128 ---+++ Using the Calendar in user forms
   129 You can also use the calendar directly in your own hand-built forms, without
   130 having to write any code. Just add this inline in the topic text:
   131 <verbatim>
   132 %INCLUDE{"%SYSTEMWEB%/JSCalendarContribInline"}%
   133 </verbatim>
   134 Then, to display a calendar icon next to a text input field:
   135 <verbatim>
   136 <input type="text" id="cal_val_here" />
   137 <input type="image" src="%PUBURL%/%SYSTEMWEB%/JSCalendarContrib/img.gif" onclick="javascript: return showCalendar('cal_val_here','%e %B %Y')" />
   138 </verbatim>
   139 If the contrib is installed, you will see such a field here:
   140 %INCLUDE{"%SYSTEMWEB%/JSCalendarContribInline"}%
   141 <input type="text" id="cal_val_here" />
   142 <input type="image" src="%PUBURL%/%SYSTEMWEB%/JSCalendarContrib/img.gif" onclick="javascript: return showCalendar('cal_val_here','%e %B %Y')" />
   143 
   144 <!--
   145    * Set SHORTDESCRIPTION = [[http://dynarch.com/mishoo/calendar.epl][Mishoo JSCalendar]], packaged for use by plugins, skins and add-ons.
   146 -->
   147 
   148 ---+++ Installation Instructions
   149 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.
   150 
   151 Like many other TWiki extensions, this module is shipped with a fully
   152 automatic installer script written using the Build<nop>Contrib.
   153    * If you have TWiki 4.2 or later, you can install from the =configure= interface (Go to Plugins->Find More Extensions)
   154       * See the [[http://twiki.org/cgi-bin/view/Plugins/BuildContribInstallationSupplement][installation supplement]] on TWiki.org for more information.
   155    * If you have any problems, then you can still install manually from the command-line:
   156       1 Download one of the =.zip= or =.tgz= archives
   157       1 Unpack the archive in the root directory of your TWiki installation.
   158       1 Run the installer script ( =perl &lt;module&gt;_installer= )
   159       1 Run =configure= and enable the module, if it is a plugin.
   160       1 Repeat for any missing dependencies.
   161    * If you are *still* having problems, then instead of running the installer script:
   162       1 Make sure that the file permissions allow the webserver user to access all files.
   163       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)
   164       1 Manually edit !LocalSite.cfg to set any configuration variables.
   165 
   166 %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>"}%
   167 
   168 	* An administrator can customize the appearance of the calendar by setting the following in =<nop>LocalSite.cfg=
   169      | *Setting* | *Default* |
   170      | =$TWiki::cfg{JSCalendarContrib}{style}= | ='blue'= |
   171      | =$TWiki::cfg{JSCalendarContrib}{lang}= | ='en'= |
   172      | =$TWiki::cfg{JSCalendarContrib}{format}= | ='%e %b %Y'= |
   173 
   174 ---+++ Contrib Info
   175 
   176 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!
   177 
   178 |  Author: | TWiki:Main/CrawfordCurrie http://c-dot.co.uk |
   179 |  Version: | 03 Aug 2008 |
   180 |  Copyright &copy;: | See [[%ATTACHURL%/doc/html/reference.html][the Mishoo documentation]] |
   181 |  License: | GPL ([[http://www.gnu.org/copyleft/gpl.html][GNU General Public License]]) |
   182 |  Dependencies: | None |
   183 |  Change History: | |
   184 |  03 Aug 2008 | TWiki 4.2.1 release version incl new calendar icon |
   185 |  6 Sep 2007 | Bugs:Item4030 Added doc for using the calendar in user forms |
   186 |  13603 | Bugs:Item2982 cleaned up the interface to the contrib, re-added a date rendering function with a more generic interface |
   187 |  11594 | Allow format to be configured. |
   188 |  11415 | Add a =renderFormFieldForEditHandler= so other plugins can forward to this handler to add the date field to the TWikiForms. (TWiki:Main.ThomasWeigert) |
   189 |  10247 | Bugs:Item2054 put the calendar at z-index 2000, way above pattern skin divs. |
   190 |  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. |
   191 |  6626 | Bugs:Item468  updated docs for Dakar release |
   192 |  5048 | Cairo readiness |
   193 |  5039 | Split from SharedCode |
   194 |  27 Dec 2005 | updated to calendar version 1.0; set style for Safari to win2k-1|
   195 |  14 Aug 2004 | Separated out from SharedCode module |
   196 |  Home: | http://TWiki.org/cgi-bin/view/Plugins/%TOPIC% |
   197 |  Feedback: | http://TWiki.org/cgi-bin/view/Plugins/%TOPIC%Dev |
   198 |  Appraisal: | http://TWiki.org/cgi-bin/view/Plugins/%TOPIC%Appraisal |
   199 
   200 __Related Topics:__ %SYSTEMWEB%.TWikiPreferences
   201 
   202 %META:FILEATTACHMENT{name="screenshot.gif" attr="h" comment="" version="1"}%
   203 %META:FILEATTACHMENT{name="wikiringlogo20x20.png" attr="h" comment="" version="1"}%