]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - themes/blog/jscalendar/bugtest-hidden-selects.html
Update jscalendar to 1.0
[SourceForge/phpwiki.git] / themes / blog / jscalendar / bugtest-hidden-selects.html
1 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ro" lang="ro">\r
2 \r
3 <head>\r
4 <title>Bug</title>\r
5 <link rel="stylesheet" type="text/css" media="all" href="calendar-win2k-1.css" title="win2k-1" />\r
6 \r
7 <!-- import the calendar script -->\r
8 <script type="text/javascript" src="calendar.js"></script>\r
9 \r
10 <!-- import the language module -->\r
11 <script type="text/javascript" src="lang/calendar-en.js"></script>\r
12 \r
13 <!-- helper script that uses the calendar -->\r
14 <script type="text/javascript">\r
15 // This function gets called when the end-user clicks on some date.\r
16 function selected(cal, date) {\r
17   cal.sel.value = date; // just update the date in the input field.\r
18   if (cal.sel.id == "sel1" || cal.sel.id == "sel3")\r
19     // if we add this call we close the calendar on single-click.\r
20     // just to exemplify both cases, we are using this only for the 1st\r
21     // and the 3rd field, while 2nd and 4th will still require double-click.\r
22     cal.callCloseHandler();\r
23 }\r
24 \r
25 // And this gets called when the end-user clicks on the _selected_ date,\r
26 // or clicks on the "Close" button.  It just hides the calendar without\r
27 // destroying it.\r
28 function closeHandler(cal) {\r
29   cal.hide();                        // hide the calendar\r
30 }\r
31 \r
32 // This function shows the calendar under the element having the given id.\r
33 // It takes care of catching "mousedown" signals on document and hiding the\r
34 // calendar if the click was outside.\r
35 function showCalendar(id, format) {\r
36   var el = document.getElementById(id);\r
37   if (calendar != null) {\r
38     // we already have some calendar created\r
39     calendar.hide();                 // so we hide it first.\r
40   } else {\r
41     // first-time call, create the calendar.\r
42     var cal = new Calendar(false, null, selected, closeHandler);\r
43     // uncomment the following line to hide the week numbers\r
44     // cal.weekNumbers = false;\r
45     calendar = cal;                  // remember it in the global var\r
46     cal.setRange(1900, 2070);        // min/max year allowed.\r
47     cal.create();\r
48   }\r
49   calendar.setDateFormat(format);    // set the specified date format\r
50   calendar.parseDate(el.value);      // try to parse the text in field\r
51   calendar.sel = el;                 // inform it what input field we use\r
52   calendar.showAtElement(el);        // show the calendar below it\r
53 \r
54   return false;\r
55 }\r
56 \r
57 var MINUTE = 60 * 1000;\r
58 var HOUR = 60 * MINUTE;\r
59 var DAY = 24 * HOUR;\r
60 var WEEK = 7 * DAY;\r
61 \r
62 // If this handler returns true then the "date" given as\r
63 // parameter will be disabled.  In this example we enable\r
64 // only days within a range of 10 days from the current\r
65 // date.\r
66 // You can use the functions date.getFullYear() -- returns the year\r
67 // as 4 digit number, date.getMonth() -- returns the month as 0..11,\r
68 // and date.getDate() -- returns the date of the month as 1..31, to\r
69 // make heavy calculations here.  However, beware that this function\r
70 // should be very fast, as it is called for each day in a month when\r
71 // the calendar is (re)constructed.\r
72 function isDisabled(date) {\r
73   var today = new Date();\r
74   return (Math.abs(date.getTime() - today.getTime()) / DAY) > 10;\r
75 }\r
76 </script>\r
77 </head>\r
78 \r
79 <body>\r
80 <form>\r
81 <b>Date:</b>\r
82 <br>\r
83 <input type="text" name="date1" id="sel1" size="30">\r
84 <input type="button" value="..." onclick="return showCalendar('sel1', 'y-m-d');">\r
85 <p>\r
86 <br>\r
87 <br><b>Visible &lt;select&gt;, hides and unhides as expected</b>\r
88 <br>\r
89 <select name="foo" multiple>\r
90 <option value="1">can use the functions date.getFullYear() -- returns</option>\r
91 <option value="2">4 digit number, date.getMonth() -- returns the month</option>\r
92 <option value="3">heavy calculations here.  However, beware that this</option>\r
93 </select>\r
94 \r
95 <p>\r
96 <br><b>Hidden &lt;select&gt;, it should stay hidden (but doesn't)</b>\r
97 <br>\r
98 <select name="foo2" multiple style="visibility: hidden">\r
99 <option value="1">this should</option>\r
100 <option value="2">remain hidden right?</option>\r
101 </select>\r
102 \r
103 <p>\r
104 <br><b>Hidden textbox below, it stays hidden as expected</b>\r
105 <br>\r
106 <input type="text" name="foo3" value="this stays hidden just fine" style="visibility: hidden">\r
107 </form>\r
108 </body></html>\r