index.html 13KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <!-- $Id: index.html,v 1.15 2005/03/05 14:38:10 mishoo Exp $ -->
  5. <head>
  6. <meta http-equiv="content-type" content="text/xml; charset=utf-8" />
  7. <title>The Coolest DHTML Calendar - Online Demo</title>
  8. <link rel="stylesheet" type="text/css" media="all" href="skins/aqua/theme.css" title="Aqua" />
  9. <link rel="alternate stylesheet" type="text/css" media="all" href="calendar-blue.css" title="winter" />
  10. <link rel="alternate stylesheet" type="text/css" media="all" href="calendar-blue2.css" title="blue" />
  11. <link rel="alternate stylesheet" type="text/css" media="all" href="calendar-brown.css" title="summer" />
  12. <link rel="alternate stylesheet" type="text/css" media="all" href="calendar-green.css" title="green" />
  13. <link rel="alternate stylesheet" type="text/css" media="all" href="calendar-win2k-1.css" title="win2k-1" />
  14. <link rel="alternate stylesheet" type="text/css" media="all" href="calendar-win2k-2.css" title="win2k-2" />
  15. <link rel="alternate stylesheet" type="text/css" media="all" href="calendar-win2k-cold-1.css" title="win2k-cold-1" />
  16. <link rel="alternate stylesheet" type="text/css" media="all" href="calendar-win2k-cold-2.css" title="win2k-cold-2" />
  17. <link rel="alternate stylesheet" type="text/css" media="all" href="calendar-system.css" title="system" />
  18. <!-- import the calendar script -->
  19. <script type="text/javascript" src="calendar.js"></script>
  20. <!-- import the language module -->
  21. <script type="text/javascript" src="lang/calendar-en.js"></script>
  22. <!-- other languages might be available in the lang directory; please check
  23. your distribution archive. -->
  24. <!-- helper script that uses the calendar -->
  25. <script type="text/javascript">
  26. var oldLink = null;
  27. // code to change the active stylesheet
  28. function setActiveStyleSheet(link, title) {
  29. var i, a, main;
  30. for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
  31. if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
  32. a.disabled = true;
  33. if(a.getAttribute("title") == title) a.disabled = false;
  34. }
  35. }
  36. if (oldLink) oldLink.style.fontWeight = 'normal';
  37. oldLink = link;
  38. link.style.fontWeight = 'bold';
  39. return false;
  40. }
  41. // This function gets called when the end-user clicks on some date.
  42. function selected(cal, date) {
  43. cal.sel.value = date; // just update the date in the input field.
  44. if (cal.dateClicked && (cal.sel.id == "sel1" || cal.sel.id == "sel3"))
  45. // if we add this call we close the calendar on single-click.
  46. // just to exemplify both cases, we are using this only for the 1st
  47. // and the 3rd field, while 2nd and 4th will still require double-click.
  48. cal.callCloseHandler();
  49. }
  50. // And this gets called when the end-user clicks on the _selected_ date,
  51. // or clicks on the "Close" button. It just hides the calendar without
  52. // destroying it.
  53. function closeHandler(cal) {
  54. cal.hide(); // hide the calendar
  55. // cal.destroy();
  56. _dynarch_popupCalendar = null;
  57. }
  58. // This function shows the calendar under the element having the given id.
  59. // It takes care of catching "mousedown" signals on document and hiding the
  60. // calendar if the click was outside.
  61. function showCalendar(id, format, showsTime, showsOtherMonths) {
  62. var el = document.getElementById(id);
  63. if (_dynarch_popupCalendar != null) {
  64. // we already have some calendar created
  65. _dynarch_popupCalendar.hide(); // so we hide it first.
  66. } else {
  67. // first-time call, create the calendar.
  68. var cal = new Calendar(1, null, selected, closeHandler);
  69. // uncomment the following line to hide the week numbers
  70. // cal.weekNumbers = false;
  71. if (typeof showsTime == "string") {
  72. cal.showsTime = true;
  73. cal.time24 = (showsTime == "24");
  74. }
  75. if (showsOtherMonths) {
  76. cal.showsOtherMonths = true;
  77. }
  78. _dynarch_popupCalendar = cal; // remember it in the global var
  79. cal.setRange(1900, 2070); // min/max year allowed.
  80. cal.create();
  81. }
  82. _dynarch_popupCalendar.setDateFormat(format); // set the specified date format
  83. _dynarch_popupCalendar.parseDate(el.value); // try to parse the text in field
  84. _dynarch_popupCalendar.sel = el; // inform it what input field we use
  85. // the reference element that we pass to showAtElement is the button that
  86. // triggers the calendar. In this example we align the calendar bottom-right
  87. // to the button.
  88. _dynarch_popupCalendar.showAtElement(el.nextSibling, "Br"); // show the calendar
  89. return false;
  90. }
  91. var MINUTE = 60 * 1000;
  92. var HOUR = 60 * MINUTE;
  93. var DAY = 24 * HOUR;
  94. var WEEK = 7 * DAY;
  95. // If this handler returns true then the "date" given as
  96. // parameter will be disabled. In this example we enable
  97. // only days within a range of 10 days from the current
  98. // date.
  99. // You can use the functions date.getFullYear() -- returns the year
  100. // as 4 digit number, date.getMonth() -- returns the month as 0..11,
  101. // and date.getDate() -- returns the date of the month as 1..31, to
  102. // make heavy calculations here. However, beware that this function
  103. // should be very fast, as it is called for each day in a month when
  104. // the calendar is (re)constructed.
  105. function isDisabled(date) {
  106. var today = new Date();
  107. return (Math.abs(date.getTime() - today.getTime()) / DAY) > 10;
  108. }
  109. function flatSelected(cal, date) {
  110. var el = document.getElementById("preview");
  111. el.innerHTML = date;
  112. }
  113. function showFlatCalendar() {
  114. var parent = document.getElementById("display");
  115. // construct a calendar giving only the "selected" handler.
  116. var cal = new Calendar(0, null, flatSelected);
  117. // hide week numbers
  118. cal.weekNumbers = false;
  119. // We want some dates to be disabled; see function isDisabled above
  120. cal.setDisabledHandler(isDisabled);
  121. cal.setDateFormat("%A, %B %e");
  122. // this call must be the last as it might use data initialized above; if
  123. // we specify a parent, as opposite to the "showCalendar" function above,
  124. // then we create a flat calendar -- not popup. Hidden, though, but...
  125. cal.create(parent);
  126. // ... we can show it here.
  127. cal.show();
  128. }
  129. </script>
  130. <style type="text/css">
  131. .ex { font-weight: bold; background: #fed; color: #080 }
  132. .help { color: #080; font-style: italic; }
  133. body { background: #fea; font: 10pt tahoma,verdana,sans-serif; }
  134. table { font: 13px verdana,tahoma,sans-serif; }
  135. a { color: #00f; }
  136. a:visited { color: #00f; }
  137. a:hover { color: #f00; background: #fefaf0; }
  138. a:active { color: #08f; }
  139. .key { border: 1px solid #000; background: #fff; color: #008;
  140. padding: 0px 5px; cursor: default; font-size: 80%; }
  141. </style>
  142. </head>
  143. <body onload="showFlatCalendar()">
  144. <h2><a href="http://www.dynarch.com/projects/calendar/"
  145. title="Visit the project website">jscalendar</a>-1.0
  146. "It is happening again"</h2>
  147. <p>
  148. <div style="float: right; border: 1px solid #b87; padding: 2px; font-size: 90%; background: #ffb;">
  149. Theme:<br />
  150. <a href="#" id="defaultTheme" onclick="return setActiveStyleSheet(this, 'Aqua');">Aqua</a>
  151. |
  152. <a href="#" onclick="return setActiveStyleSheet(this, 'winter');">winter</a>
  153. |
  154. <a href="#" onclick="return setActiveStyleSheet(this, 'blue');">blue</a>
  155. |
  156. <a href="#" onclick="return setActiveStyleSheet(this, 'summer');">summer</a>
  157. |
  158. <a href="#" onclick="return setActiveStyleSheet(this, 'green');">green</a>
  159. <br />
  160. <a href="#" onclick="return setActiveStyleSheet(this, 'win2k-1');">win2k-1</a>
  161. |
  162. <a href="#" onclick="return setActiveStyleSheet(this, 'win2k-2');">win2k-2</a>
  163. |
  164. <a href="#" onclick="return setActiveStyleSheet(this, 'win2k-cold-1');">win2k-cold-1</a>
  165. |
  166. <a href="#" onclick="return setActiveStyleSheet(this, 'win2k-cold-2');">win2k-cold-2</a>
  167. <br />
  168. <a href="#" onclick="return setActiveStyleSheet(this, 'system');">system</a>
  169. <script type="text/javascript">
  170. setActiveStyleSheet(document.getElementById("defaultTheme"), "Aqua");
  171. </script>
  172. </div>
  173. <a href="release-notes.html">Release notes</a>.
  174. <br />
  175. Set it up in minutes:
  176. <a href="simple-1.html">popup calendar</a>,
  177. <a href="simple-2.html">flat calendar</a>.
  178. Other samples:
  179. <a href="simple-3.html">special days</a>,
  180. <a href="dayinfo.html">day info</a>,
  181. <a href="multiple-dates.html">multiple dates selection</a>
  182. <br />
  183. Documentation:
  184. <a href="doc/html/reference.html">HTML</a>,
  185. <a href="doc/reference.pdf">PDF</a>.
  186. <br />
  187. </p>
  188. <div style="padding-left:20px; font-size: 90%; font-style: italic;">
  189. </div>
  190. <table style="width: 100%">
  191. <tr valign="top">
  192. <td style="background: #ffa; padding: 5px; border: 1px solid #995;">
  193. <form action="#">
  194. <div style="background: #995; color: #ffa; font-weight: bold; padding: 2px;">
  195. Popup examples
  196. </div>
  197. <br />
  198. <b>Date #1:</b> <input type="text" name="date1" id="sel1" size="30"
  199. ><input type="reset" value=" ... "
  200. onclick="return showCalendar('sel1', '%Y-%m-%d [%W] %H:%M', '24', true);"> %Y-%m-%d [%W] %H:%M -- single
  201. click<br />
  202. <b>Date #2:</b> <input type="text" name="date2" id="sel2" size="30"
  203. ><input type="reset" value=" ... "
  204. onclick="return showCalendar('sel2', '%a, %b %e, %Y [%I:%M %p]', '12');"> %a, %b %e, %Y [%I:%M %p]
  205. -- double click
  206. <br /><br />
  207. <!--
  208. if you remove this comment and leave the following HTML code
  209. you will see a horrible effect, in all supported browsers (IE and Mozilla).
  210. -->
  211. <SELECT multiple size="4" name="component-select">
  212. <OPTION selected value="Component_1_a">Component_1</OPTION>
  213. <OPTION selected value="Component_1_b">Component_2</OPTION>
  214. <OPTION>Component_3</OPTION>
  215. <OPTION>Component_4</OPTION>
  216. <OPTION>Component_5</OPTION>
  217. <OPTION>Component_6</OPTION>
  218. <OPTION>Component_7</OPTION>
  219. </SELECT>
  220. this select should hide when the calendar is above it.
  221. <br /><br />
  222. <b>Date #3:</b> <input type="text" name="date3" id="sel3" size="30"
  223. ><input type="reset" value=" ... "
  224. onclick="return showCalendar('sel3', '%d/%m/%Y');"> %d/%m/%Y
  225. -- single click
  226. <br />
  227. <b>Date #4:</b> <input type="text" name="date4" id="sel4" size="30"
  228. ><input type="reset" value=" ... "
  229. onclick="return showCalendar('sel4', '%A, %B %e, %Y');"> %A, %B %e, %Y --
  230. double click
  231. </form>
  232. <p>This is release <b>1.0</b>. Works on MSIE/Win 5.0 or better (really),
  233. Opera 7+, Mozilla, Firefox, Netscape 6.x, 7.0 and all other Gecko-s,
  234. Konqueror and Safari.</p>
  235. <h4>Keyboard navigation</h4>
  236. <p>Starting with version 0.9.2, you can also use the keyboard to select
  237. dates (only for popup calendars; does <em>not</em> work with Opera
  238. 7 or Konqueror/Safari). The following keys are available:</p>
  239. <ul>
  240. <li><span class="key">&larr;</span> , <span class="key">&rarr;</span> ,
  241. <span class="key">&uarr;</span> , <span class="key">&darr;</span> -- select date</li>
  242. <li><span class="key">CTRL</span> + <span class="key">&larr;</span> ,
  243. <span class="key">&rarr;</span> -- select month</li>
  244. <li><span class="key">CTRL</span> + <span class="key">&uarr;</span> ,
  245. <span class="key">&darr;</span> -- select year</li>
  246. <li><span class="key">SPACE</span> -- go to <em>today</em> date</li>
  247. <li><span class="key">ENTER</span> -- accept the currently selected date</li>
  248. <li><span class="key">ESC</span> -- cancel selection</li>
  249. </ul>
  250. </td>
  251. <td style="padding: 5px; margin: 5px; border: 1px solid #984; background: #ed9; width: 19em;">
  252. <div style="background: #984; color: #fea; font-weight: bold; padding: 2px; text-align: center">
  253. Flat calendar
  254. </div>
  255. <p style="width: 12em"><small>A non-popup version will appear below as soon
  256. as the page is loaded. Note that it doesn't show the week number.</small></p>
  257. <!-- the calendar will be inserted here -->
  258. <div id="display" style="float: right; clear: both;"></div>
  259. <div id="preview" style="font-size: 80%; text-align: center; padding: 2px">&nbsp;</div>
  260. <p style="clear: both;"><small>
  261. The example above uses the <code>setDisabledHandler()</code> member function
  262. to setup a handler that would only enable days withing a range of 10 days,
  263. forward or backward, from the current date.
  264. </small></p>
  265. </div>
  266. </td>
  267. </tr>
  268. </table>
  269. <hr /><address>
  270. &copy; <a href="http://www.dynarch.com/">dynarch.com</a> 2002-2005 <br />
  271. Author: <a href="http://www.bazon.net/mishoo/">Mihai
  272. Bazon</a><br /> Distributed under the <a
  273. href="http://www.gnu.org/licenses/lgpl.html">GNU LGPL</a>.</address>
  274. <p style="font-size: smaller">If you use this script on a public page we
  275. would love it if you would <a href="http://www.dynarch.com/contact.html">let us
  276. know</a>.</p>
  277. </body></html>