[ Mini Kiebo ]
Server: Windows NT DESKTOP-5B8S0D4 6.2 build 9200 (Windows 8 Professional Edition) i586
Path:
D:
/
xampp182
/
htdocs
/
simpeg
/
zapatec
/
zpcal
/
zpcal
/
jsdocs
/
[
Home
]
File: overview-summary-calendar-setup.js.html
<!doctype html public "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd"> <html> <head> <title> Zapatec Calendar Overview </title> <link rel ="stylesheet" type="text/css" href="stylesheet.css" title="Style"> <script> function asd() { parent.document.title="calendar-setup.js Overview"; } </script> </head> <body bgcolor="white" onload="asd();"> <!-- ========== START OF NAVBAR ========== --> <a name="navbar_top"><!-- --></a> <table border="0" width="100%" cellpadding="1" cellspacing="0"> <tr> <td colspan=2 bgcolor="#EEEEFF" class="NavBarCell1"> <a name="navbar_top_firstrow"><!-- --></a> <table border="0" cellpadding="0" cellspacing="3"> <tr align="center" valign="top"> <td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="overview-summary.html"><font class="NavBarFont1"><b>Overview</b></font></a> </td> <td bgcolor="#FFFFFF" class="NavBarCell1Rev"> <font class="NavBarFont1Rev"><b>File</b></font> </td> <td bgcolor="#FFFFFF" class="NavBarCell1"> <font class="NavBarFont1">Class</font> </td> <td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a> </td> <td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a> </td> <td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a> </td> </tr> </table> </td> <td bgcolor="#EEEEFF" align="right" valign="top"> <em> <b>Zapatec Calendar</b></em> </td> </tr> <tr> <td bgcolor="white" class="NavBarCell2"><font size="-2"> PREV NEXT</font></td> <td bgcolor="white" class="NavBarCell2"><font size="-2"> <a href="index.html" target="_top"><b>FRAMES</b></a> <a href="overview-summary.html" target="_top"><b>NO FRAMES</b></a> <script> <!-- if(window==top) { document.writeln('<A HREF="allclasses-noframe.html" TARGET=""><B>All Classes</B></A>'); } //--> </script> <noscript> <a href="allclasses-noframe.html" target=""><b>All Classes</b></a> </noscript> </font></td> </tr> </table> <!-- =========== END OF NAVBAR =========== --> <hr> <center> <h2>calendar-setup.js</h2> </center> <h4>Summary</h4> <p> No overview generated for 'calendar-setup.js'<BR/><BR/> </p> <hr> <!-- ========== METHOD SUMMARY =========== --> <!-- ========== END METHOD SUMMARY =========== --> <pre class="sourceview"><span class="comment">/* * $Id: calendar-setup.js 7059 2007-05-03 14:28:07Z slip $ * The Zapatec DHTML Calendar * * Copyright (c) 2004-2006 by Zapatec, Inc. * http://www.zapatec.com * 1700 MLK Way, Berkeley, California, * 94709, U.S.A. * All rights reserved. * * Original version written by Mihai Bazon, * http://www.bazon.net/mishoo/calendar.epl * * This file defines helper functions for setting up the calendar. They are * intended to help non-programmers get a working calendar on their site * quickly. This script should not be seen as part of the calendar. It just * shows you what one can do with the calendar, while in the same time * providing a quick and simple method for setting it up. If you need * exhaustive customization of the calendar creation process feel free to * modify this code to suit your needs (this is recommended and much better * than modifying calendar.js itself). */</span> <span class="comment">// $Id: calendar-setup.js 7059 2007-05-03 14:28:07Z slip $</span> <span class="comment">//test for the right path</span> Zapatec.Setup = <span class="reserved">function</span> () {}; Zapatec.Setup.test = true; <span class="comment">/** * This function "patches" an input field (or other element) to use a calendar * widget for date selection. * * Note that you can use the Zapatec DHTML Calendar Wizard and generate the code * and modify the results. * The "params" is a single object that can have the following properties: * * \code * prop. name | description * ------------------------------------------------------------------------------------------------- * inputField | the ID of an input field to store the date * displayArea | the ID of a DIV or other element to show the date * button | ID of a button or other element that will trigger the calendar * eventName | event that will trigger the calendar, without the "on" prefix (default: "click") * closeEventName| event that will close the calendar (i.e. one can use "focus" for eventName and "blur" for closeEventName) * ifFormat | date format that will be stored in the input field * daFormat | the date format that will be used to display the date in displayArea * singleClick | (true/false) wether the calendar is in single click mode or not (default: true) * firstDay | numeric: 0 to 6. "0" means display Sunday first, "1" means display Monday first, etc. * align | alignment (default: "Br"); if you don't know what's this see the calendar documentation * range | array with 2 elements. Default: [1900.0, 2999.12] -- the range of years available * weekNumbers | (true/false) if it's true (default) the calendar will display week numbers * flat | null or element ID; if not null the calendar will be a flat calendar having the parent with the given ID * flatCallback | function that receives a JS Date object and returns an URL to point the browser to (for flat calendar) * disableFunc | function that receives a JS Date object and should return true if that date has to be disabled in the calendar * onSelect | function that gets called when a date is selected. You don't _have_ to supply this (the default is generally okay) * onClose | function that gets called when the calendar is closed. [default] * onUpdate | function that gets called after the date is updated in the input field. Receives a reference to the calendar. * date | the date that the calendar will be initially displayed to * showsTime | default: false; if true the calendar will include a time selector * timeFormat | the time format; can be "12" or "24", default is "12" * electric | if true (default) then given fields/date areas are updated for each move; otherwise they're updated only on close * sortOrder | ("asc"(ending)/"desc"(ending)/"none"). If "asc" (default), order of the multiple dates (when multiple dates is on) will be sorted in ascending order. Otherwise, it will be sorted in descending order. "none" means no sorting is needed. * step | configures the step of the years in drop-down boxes; default: 2 * position | configures the calendar absolute position; default: null * cache | if "true" (but default: "false") it will reuse the same calendar object, where possible * showOthers | if "true" (but default: "false") it will show days from other months too * saveDate | if set (default unset) will save a cookie for this duration. * numberMonths | Have the calendar display multiple months * controlMonth | When displaying multiple months, this will be the control month. Default 1. * vertical | When displaying multiple months, months can progress in a vertical or horizontal way. Horizontal is the default. * monthsInRow | When displaying multiple months how many months in a horizontal row. Works both in vertical and horizontal mode. Default numberMonths * fdowClick | Allow click on Days of Week 1st day * titleHtml | Html you can put in title of calendar * noHelp | Disables "?" button in your calendar * noCloseButton | Disables "X" button in your calendar * disableYearNav| Disables year navigation buttons * * \endcode * * None of them is required, they all have default values. However, if you * pass none of "inputField", "displayArea" or "button" you'll get a warning * saying "nothing to setup". */</span> Zapatec.Calendar.setup = <span class="reserved">function</span> (params) { paramsList = [<span class="literal">"id"</span>]; <span class="reserved">function</span> param_default(pname, def) { <span class="reserved">if</span> (typeof params[pname] == <span class="literal">"undefined"</span>) { params[pname] = def; } paramsList.push(pname); }; params.id = Zapatec.Utils.generateID(<span class="literal">"calendar"</span>); param_default(<span class="literal">"inputField"</span>, null); param_default(<span class="literal">"displayArea"</span>, null); param_default(<span class="literal">"button"</span>, null); param_default(<span class="literal">"eventName"</span>, <span class="literal">"click"</span>); param_default(<span class="literal">"closeEventName"</span>, null); param_default(<span class="literal">"ifFormat"</span>, <span class="literal">"%Y/%m/%d"</span>); param_default(<span class="literal">"daFormat"</span>, <span class="literal">"%Y/%m/%d"</span>); param_default(<span class="literal">"singleClick"</span>, true); param_default(<span class="literal">"disableFunc"</span>, null); param_default(<span class="literal">"dateStatusFunc"</span>, params[<span class="literal">"disableFunc"</span>]); <span class="comment">// takes precedence if both are defined</span> param_default(<span class="literal">"dateText"</span>, null); param_default(<span class="literal">"firstDay"</span>, null); param_default(<span class="literal">"align"</span>, <span class="literal">"Br"</span>); param_default(<span class="literal">"range"</span>, [1900, 2999]); param_default(<span class="literal">"weekNumbers"</span>, true); param_default(<span class="literal">"flat"</span>, null); param_default(<span class="literal">"flatCallback"</span>, null); param_default(<span class="literal">"onSelect"</span>, null); param_default(<span class="literal">"onClose"</span>, null); param_default(<span class="literal">"onUpdate"</span>, null); param_default(<span class="literal">"date"</span>, null); param_default(<span class="literal">"showsTime"</span>, false); param_default(<span class="literal">"sortOrder"</span>, <span class="literal">"asc"</span>); param_default(<span class="literal">"timeFormat"</span>, <span class="literal">"24"</span>); param_default(<span class="literal">"timeInterval"</span>, null); param_default(<span class="literal">"electric"</span>, true); param_default(<span class="literal">"step"</span>, 2); param_default(<span class="literal">"position"</span>, null); param_default(<span class="literal">"cache"</span>, false); param_default(<span class="literal">"showOthers"</span>, false); param_default(<span class="literal">"multiple"</span>, null); param_default(<span class="literal">"saveDate"</span>, null); param_default(<span class="literal">"fdowClick"</span>, false); param_default(<span class="literal">"titleHtml"</span>, null); param_default(<span class="literal">"noHelp"</span>, false); param_default(<span class="literal">"noCloseButton"</span>, false); param_default(<span class="literal">"disableYearNav"</span>, false); param_default(<span class="literal">"disableFdowChange"</span>, false); <span class="reserved">if</span> (params.weekNumbers) { params.disableFdowChange = true; params.firstDay = 1; } param_default(<span class="literal">"disableDrag"</span>, false); param_default(<span class="literal">"numberMonths"</span>, 1); <span class="reserved">if</span> ((params.numberMonths > 12) || (params.numberMonths < 1)) { params.numberMonths = 1; } <span class="reserved">if</span> (params.numberMonths > 1) { params.showOthers = false; } params.numberMonths = parseInt(params.numberMonths, 10); param_default(<span class="literal">"controlMonth"</span>, 1); <span class="reserved">if</span> ((params.controlMonth > params.numberMonths) || (params.controlMonth < 1)) { params.controlMonth = 1; } params.controlMonth = parseInt(params.controlMonth, 10); param_default(<span class="literal">"vertical"</span>, false); <span class="reserved">if</span> (params.monthsInRow > params.numberMonths) { params.monthsInRow = params.numberMonths; } param_default(<span class="literal">"monthsInRow"</span>, params.numberMonths); params.monthsInRow = parseInt(params.monthsInRow, 10); param_default(<span class="literal">"multiple"</span>, false); <span class="reserved">if</span> (params.multiple) { params.singleClick = false; } param_default(<span class="literal">"canType"</span>, false); var tmp = [<span class="literal">"inputField"</span>, <span class="literal">"displayArea"</span>, <span class="literal">"button"</span>]; <span class="reserved">for</span> (var i in tmp) { <span class="reserved">if</span> (typeof params[tmp[i]] == <span class="literal">"string"</span>) { params[tmp[i]] = document.getElementById(params[tmp[i]]); } } <span class="reserved">if</span> (!params.inputField) { params.canType = false; } <span class="reserved">else</span> { params.inputField.setAttribute(<span class="literal">"autocomplete"</span>, <span class="literal">"off"</span>); } <span class="reserved">if</span> (!(params.flat || params.multiple || params.inputField || params.displayArea || params.button)) { alert(<span class="literal">"Calendar.setup '"</span> + params.id + <span class="literal">"':\n Nothing to setup (no fields found). Please check your code"</span>); <span class="reserved">return</span> false; } <span class="reserved">if</span> (((params.timeInterval) && ((params.timeInterval !== Math.floor(params.timeInterval)) || ((60 % params.timeInterval !== 0) && (params.timeInterval % 60 !== 0)))) || (params.timeInterval > 360)) { alert(<span class="literal">"'"</span> + params.id + <span class="literal">"': timeInterval option can only have the following number of minutes:\n1, 2, 3, 4, 5, 6, 10, 15, 30, 60, 120, 180, 240, 300, 360 "</span>); params.timeInterval = null; } <span class="reserved">if</span> (params.date && !Date.parse(params.date)) { alert(<span class="literal">"'"</span> + params.id + <span class="literal">"' Start Date Invalid: "</span> + params.date + <span class="literal">".\nSee date option.\nDefaulting to today."</span>); params.date = null; } <span class="reserved">if</span> (params.saveDate) { <span class="comment">//If saveDate is on We're saving the date in a cookie</span> param_default(<span class="literal">"cookiePrefix"</span>, window.location.href + <span class="literal">"--"</span> + params.button.id); <span class="comment">//fetch the cookie</span> var cookieName = params.cookiePrefix; var newdate = Zapatec.Utils.getCookie(cookieName); <span class="reserved">if</span> (newdate != null) { <span class="comment">//if there's a cookie</span> <span class="comment">//set the value of the text field</span> document.getElementById(params.inputField.id).value = newdate; } } <span class="reserved">for</span>(var ii in params) { <span class="reserved">if</span> (typeof params.constructor.<span class="reserved">prototype</span>[ii] != <span class="literal">"undefined"</span>) { continue; } <span class="reserved">if</span> (Zapatec.Utils.arrIndexOf(paramsList, ii) == -1) { alert(<span class="literal">"Wrong config option: "</span> + ii); } } <span class="reserved">function</span> onSelect(cal) { var p = cal.params; var update = (cal.dateClicked || p.electric); <span class="reserved">if</span> (update && p.flat) { <span class="reserved">if</span> (typeof p.flatCallback == <span class="literal">"function"</span>) { <span class="reserved">if</span> (!p.multiple) <span class="comment">//User can call function submitFlatDates directly in Calendar object to handle the submission of multiple dates.</span> p.flatCallback(cal); } <span class="reserved">else</span> alert(<span class="literal">"'"</span> + cal.id + <span class="literal">"': No flatCallback given -- doing nothing."</span>); <span class="reserved">return</span> false; } <span class="reserved">if</span> (update && p.inputField) { p.inputField.value = cal.currentDate.print(p.ifFormat); <span class="reserved">if</span> (typeof p.inputField.onchange == <span class="literal">"function"</span>) p.inputField.onchange(); } <span class="reserved">if</span> (update && p.displayArea) p.displayArea.innerHTML = cal.currentDate.print(p.daFormat); <span class="reserved">if</span> (update && p.singleClick && cal.dateClicked) cal.callCloseHandler(); <span class="reserved">if</span> (update && typeof p.onUpdate == <span class="literal">"function"</span>) p.onUpdate(cal); <span class="reserved">if</span> (p.saveDate) { <span class="comment">//save date in cookie</span> <span class="comment">//unique name of the cookie is the name of the button + href</span> var cookieName = p.cookiePrefix; Zapatec.Utils.writeCookie(cookieName, p.inputField.value, null, <span class="literal">'/'</span>, p.saveDate); } }; <span class="reserved">if</span> (params.flat != null) { <span class="reserved">if</span> (typeof params.flat == <span class="literal">"string"</span>) params.flat = document.getElementById(params.flat); <span class="reserved">if</span> (!params.flat) { alert(<span class="literal">"Calendar.setup '"</span> + params.id + <span class="literal">"':\n Flat specified but can't find parent."</span>); <span class="reserved">return</span> false; } var cal = new Zapatec.Calendar(params.firstDay, params.date, params.onSelect || onSelect); cal.disableFdowClick = params.disableFdowChange; cal.showsOtherMonths = params.showOthers; cal.showsTime = params.showsTime; cal.time24 = (params.timeFormat == <span class="literal">"24"</span>); cal.timeInterval = params.timeInterval; cal.params = params; cal.weekNumbers = params.weekNumbers; cal.sortOrder = params.sortOrder.toLowerCase(); cal.setRange(params.range[0], params.range[1]); cal.setDateStatusHandler(params.dateStatusFunc); cal.getDateText = params.dateText; cal.numberMonths = params.numberMonths; cal.controlMonth = params.controlMonth; cal.vertical = params.vertical; cal.yearStep = params.step; cal.monthsInRow = params.monthsInRow; cal.helpButton = !params.noHelp; cal.closeButton = !params.noCloseButton; cal.yearNav = !params.disableYearNav; <span class="reserved">if</span> (params.ifFormat) { cal.setDateFormat(params.ifFormat); } <span class="reserved">if</span> (params.inputField && params.inputField.type == <span class="literal">"text"</span> && typeof params.inputField.value == <span class="literal">"string"</span>) { cal.parseDate(params.inputField.value); } <span class="reserved">if</span> (params.multiple) { cal.setMultipleDates(params.multiple); } cal.create(params.flat); cal.show(); <span class="reserved">return</span> cal; } var triggerEl = params.button || params.displayArea || params.inputField; <span class="reserved">if</span> (params.canType) { <span class="reserved">function</span> cancelBubble(ev) { ev = ev || window.event; <span class="reserved">if</span> (Zapatec.is_ie) { ev.cancelBubble = true; } <span class="reserved">else</span> { ev.stopPropagation(); } } Zapatec.Utils.addEvent(params.inputField, <span class="literal">"mousedown"</span>, cancelBubble); Zapatec.Utils.addEvent(params.inputField, <span class="literal">"keydown"</span>, cancelBubble); Zapatec.Utils.addEvent(params.inputField, <span class="literal">"keypress"</span>, cancelBubble); Zapatec.Utils.addEvent(params.inputField, <span class="literal">"keyup"</span>, <span class="reserved">function</span>(ev) { var format = params.inputField ? params.ifFormat : params.daFormat; var parsedDate = Date.parseDate(params.inputField.value, format); var cal = window.calendar; <span class="reserved">if</span> (cal && parsedDate && !cal.hidden) { cal.setDate(parsedDate); } }); } triggerEl[<span class="literal">"on"</span> + params.eventName] = <span class="reserved">function</span>() { var dateEl = params.inputField || params.displayArea; <span class="comment">//FIX for Enter key!</span> <span class="reserved">if</span> ((!params.canType || params.inputField != triggerEl) && triggerEl.blur) { triggerEl.blur(); } var dateFmt = params.inputField ? params.ifFormat : params.daFormat; var mustCreate = false; var cal = window.calendar; <span class="reserved">if</span> (params.canType && (params.inputField == triggerEl) && cal && !cal.hidden) { <span class="reserved">return</span>; } <span class="comment">// Exit if calendar is NOT hidden and user tries to create another calendar (Click or SpaceBar)</span> <span class="comment">// Rev 1.9 - this needs to be integrated, it broke the multiple month feature</span> <span class="comment">//if (cal && !cal.hidden) return false;</span> <span class="reserved">if</span> (!(cal && params.cache)) { window.calendar = cal = new Zapatec.Calendar(params.firstDay, params.date, params.onSelect || onSelect, params.onClose || <span class="reserved">function</span>(cal) { <span class="reserved">if</span> (params.cache) cal.hide(); <span class="reserved">else</span> cal.destroy(); }); cal.disableFdowClick = params.disableFdowChange; cal.showsTime = params.showsTime; cal.time24 = (params.timeFormat == <span class="literal">"24"</span>); cal.timeInterval = params.timeInterval; cal.weekNumbers = params.weekNumbers; cal.numberMonths = params.numberMonths; cal.controlMonth = params.controlMonth; cal.vertical = params.vertical; cal.monthsInRow = params.monthsInRow; cal.historyDateFormat = params.ifFormat || params.daFormat; cal.helpButton = !params.noHelp; cal.disableDrag = params.disableDrag; cal.closeButton = !params.noCloseButton; cal.yearNav = !params.disableYearNav; cal.sortOrder = params.sortOrder.toLowerCase(); mustCreate = true; } <span class="reserved">else</span> { <span class="reserved">if</span> (params.date) cal.setDate(params.date); cal.hide(); } <span class="reserved">if</span> (params.multiple) { cal.setMultipleDates(params.multiple); } cal.showsOtherMonths = params.showOthers; cal.yearStep = params.step; cal.setRange(params.range[0], params.range[1]); cal.params = params; cal.setDateStatusHandler(params.dateStatusFunc); cal.getDateText = params.dateText; cal.setDateFormat(dateFmt); <span class="reserved">if</span> (mustCreate) cal.create(); <span class="reserved">if</span> (dateEl) { var dateValue; <span class="comment">//figure out if the it's in value or innerHTML</span> <span class="reserved">if</span> (dateEl.value) { dateValue = dateEl.value; } <span class="reserved">else</span> { dateValue = dateEl.innerHTML; } <span class="reserved">if</span> (dateValue != <span class="literal">""</span>) { <span class="comment">//if there is a date to initialize from</span> var parsedDate = Date.parseDate(dateEl.value || dateEl.innerHTML, dateFmt); <span class="comment">//This check for when webmaster initializes the box with something like</span> <span class="comment">//"check in"</span> <span class="reserved">if</span> (parsedDate != null) { <span class="comment">//if it's parsable</span> cal.setDate(parsedDate); } } } <span class="reserved">if</span> (!params.position) cal.showAtElement(params.button || params.displayArea || params.inputField, params.align); <span class="reserved">else</span> cal.showAt(params.position[0], params.position[1]); <span class="reserved">return</span> false; }; <span class="reserved">if</span> (params.closeEventName) { triggerEl[<span class="literal">"on"</span> + params.closeEventName] = <span class="reserved">function</span>() { <span class="reserved">if</span> (window.calendar) window.calendar.callCloseHandler(); }; } <span class="reserved">return</span> cal; }; </pre> <hr> <!-- ========== START OF NAVBAR ========== --> <a name="navbar_top"><!-- --></a> <table border="0" width="100%" cellpadding="1" cellspacing="0"> <tr> <td colspan=2 bgcolor="#EEEEFF" class="NavBarCell1"> <a name="navbar_top_firstrow"><!-- --></a> <table border="0" cellpadding="0" cellspacing="3"> <tr align="center" valign="top"> <td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="overview-summary.html"><font class="NavBarFont1"><b>Overview</b></font></a> </td> <td bgcolor="#FFFFFF" class="NavBarCell1Rev"> <font class="NavBarFont1Rev"><b>File</b></font> </td> <td bgcolor="#FFFFFF" class="NavBarCell1"> <font class="NavBarFont1">Class</font> </td> <td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a> </td> <td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a> </td> <td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a> </td> </tr> </table> </td> <td bgcolor="#EEEEFF" align="right" valign="top"><em> <b>Zapatec Calendar</b></em> </td> </tr> <tr> <td bgcolor="white" class="NavBarCell2"><font size="-2"> PREV NEXT</font></td> <td bgcolor="white" class="NavBarCell2"><font size="-2"> <a href="index.html" target="_top"><b>FRAMES</b></a> <a href="overview-summary.html" target="_top"><b>NO FRAMES</b></a> <script> <!-- if(window==top) { document.writeln('<A HREF="allclasses-noframe.html" TARGET=""><B>All Classes</B></A>'); } //--> </script> <noscript> <a href="allclasses-noframe.html" target=""><b>All Classes</b></a> </noscript> </font></td> </tr> </table> <!-- =========== END OF NAVBAR =========== --> <hr> <font size="-1"> </font> <div class="jsdoc_ctime">Documentation generated by <a href="http://jsdoc.sourceforge.net/" target="_parent">JSDoc</a> on Thu Aug 16 12:18:51 2007</div> </body> </html>