Go to the source code of this file.
|
The Calendar object constructor. Call it, for example, like this:
// the following function is called when a date is clicked function selFunc(cal) { alert(cal.date); } // the following function is called when the calendar should be closed function closeFunc(cal) { cal.destroy(); } var cal = new Zapatec.Calendar(1, new Date(), selFunc, closeFunc); The above creates a new Calendar object. The Calendar isn't displayed instantly; using the "cal" variable, the programmer can now set certain configuration variables, hook his own event handlers and then display the calendar using Zapatec.Calendar.create().
Definition at line 43 of file calendar.js. |
|
For internal use only. This function is called from the constructor, only once, to initialize some internal arrays containing translation strings. It is also called from the calendar wizard in order to reconfigure the calendar with a language different than the initially selected one. Definition at line 123 of file calendar.js. |
|
Translate a string according to the currently loaded language table. The type variable can be null or missing, or can have one of the following values: "dn", "sdn", "mn", "smn".
Definition at line 165 of file calendar.js. |
|
"static", needed for event handlers.
Definition at line 186 of file calendar.js. |
|
preferences
Definition at line 189 of file calendar.js. |
|
Writes the preferences cookie.
Definition at line 201 of file calendar.js. |
|
Loads the preference cookie and merges saved prefs to Zapatec.Calendar.prefs.
Definition at line 210 of file calendar.js. |
|
For internal use only. Adds a set of events to make some element behave like a button.
Definition at line 227 of file calendar.js. |
|
For internal use only. This function undoes what Zapatec.Calendar._add_evs did, therefore unregisters the event handlers.
Definition at line 242 of file calendar.js. |
|
Given an HTML element, this function determines if it's part of the "months" combo box and if so it returns the element containing the month name.
Definition at line 258 of file calendar.js. |
|
Similar to findMonth() but for the history combo.
Definition at line 268 of file calendar.js. |
|
Similar to the above functions, but for the years combo.
Definition at line 278 of file calendar.js. |
|
This function displays the months combo box. It doesn't need any parameters because it uses the static _C variable which maintains a reference to the last calendar that was clicked in the page. Definition at line 292 of file calendar.js. |
|
Same as the above, this function displays the history combo box for the active calendar. Definition at line 337 of file calendar.js. |
|
Displays the years combo box for the active calendar. The "fwd" parameter tells it if it should display future (right) or past (left) years.
Definition at line 376 of file calendar.js. |
|
This is an event handler that gets called when the mouse button is released upon the document. The name (tableMouseUp) is because of historic reasons (in the initial calendar versions this event was triggered by the calendar table, but now it's the document who does it). This function does a number of things. It determines which is the element that was actually clicked. Note that the "mouseup" event usually means "something was clicked"; it's "mouseup" who fires the "onclick" event, not "mousedown" ;-). So, if the clicked element is a member of one of the combo boxes such as month, year or history, then the appropriate action is taken (switch month, year or go to history date). Also, the Zapatec.Calendar.cellClick() function is called, which further examines the target element and might do other things. Finally, this handler deregisters itself (it's automatically enabled at "mousedown" on document), stops the event propagation, sets the static _C variable to null (meaning "no calendar is currently in use").
Definition at line 447 of file calendar.js. |
|
Event handler that gets called when the end-user moves the mouse over the document. This function is pretty complicated too. It adds hover/active state class to elements that are highlighted and/or clicked. It determines whether one is trying to modify the time by "drag'n'drop" (the original interface implemented by the calendar). Finally, it determines if the mouse is over combo box items, also adding/removing hover states and setting some calendar variables with reference to the element involved.
Definition at line 527 of file calendar.js. |
|
This is a simple function that stops a "mousedown" related to the calendar's table element. This helps avoiding text selection in certain browsers (most notably, Safari, since Mozilla already has a better way).
Definition at line 682 of file calendar.js. |
|
Called when the mouse button is pressed upon a button. The name of this function is so for historical reasons; currently, this function is used for any type of buttons used in the calendar, not only "days". This function does quite some things. It checks if the clicked cell is the title bar or the status bar, in which case it starts the calendar dragging mechanism (cal._dragStart()). If the cell is a time part, then it registers Zapatec.Calendar.tableMouseOver() event handler on the document. If the cell is a "navigation" button (next/prev year or month, or today) then a timeout is created that will show the appropriate combo box if the button is not quickly depressed.
Definition at line 759 of file calendar.js. |
|
For IE5 we can't make unselectable elements, but we can void the selection immediately after the double click event :D. This function is a double click handler which does exactly that. Uses IE-specific functions.
Definition at line 812 of file calendar.js. |
|
This function gets called at "onmouseover" events that trigger on any kind of button, like dates, navigation buttons, etc. Basically, the function computes and caches the tooltip (if it's a date cell for instance) and displays it in the status bar. If the cell is not a navigation button, it will also add "rowhilite" class to the containing TR element.
Definition at line 828 of file calendar.js. |
|
Gets called when the mouse leaves a button. This function "undoes" what dayMouseOver did, that is, it removes the "rowhilite" class from the containing TR and restores the status bar display to read "Select date".
Definition at line 872 of file calendar.js. |
|
The generic "click" handler. This function handles actions on any kind of buttons that appear inside our calendar. It determines the button type by querying el.navtype. The following types of objects are supported:
Definition at line 927 of file calendar.js. |
|
This function creates the calendar HTML elements inside the given parent. If _par is null than it creates a popup calendar inside the BODY element. If _par is an element, be it BODY, then it creates a non-popup calendar (still hidden). The function looks rather complicated, but what it does is quite simple. The basic calendar elements will be created, that is, a containing DIV, a TABLE that contains a headers (titles, navigation bar and day names bars), a body containing up to 12 months, each has 6 rows with 7 or 8 cells (this depends on whether week numbers are on or off) and a footer containing the status bar. Appropriate event handlers are assigned to all buttons or to the titles and status bar (for drag'n'drop). This function also builds the time selector if the calendar is configured so, and it also creates the elements required for combo boxes (years, months, history). This function does not display day names or dates. This is done in Zapatec.Calendar.prototype._init(). Therefore, by separating these 2 actions we can make date switching happen much faster because the _init function will already have the elements in place (so we don't need to create them again and again). This was a major improvement which got in the calendar v0.9.1.
Definition at line 1256 of file calendar.js. |
|
This function handles keypress events that occur while a popup calendar is displayed. The implementation is quite complicated; this function calls cellClick in order to set the new date as if it was clicked.
Definition at line 1687 of file calendar.js. |
|
(RE)Initializes the calendar to the given date and firstDayOfWeek. This function perform the action of actually displaying the day names and dates in the calendar. But first, it checks if the passed date fits in the allowed range, configured by the "minYear", "maxYear", "minMonth" and "maxMonth" properties of the Calendar object. It takes care to highlight special days (calling the calendar.getDateStatus() function which can be overridden by external scripts) or to highlight any dates that might be selected (for instance when multiple dates is on, this function will call _initMultipleDates() to highlight selected dates accordingly). This function is highly optimized for speed, therefore the code in it is not trivial and what it does might not seem obvious. :-) So, WARNING, this is voodoo. If you want to properly understand the code you should analyze it line by line and try to execute it step by step; use the Venkman JS debugger.
Definition at line 1782 of file calendar.js. |
|
If "multiple dates" is selected (the calendar.multiple property) this function will highlight cells that display dates that are selected. It is only called from the _init() function.
Definition at line 2104 of file calendar.js. |
|
Given a Date object, this function will "toggle" it in the calendar; that is, it will select it if not already selected, or unselect it if was already selected. The array of dates is updated accordingly and the cell object will be added or removed the appropriate class name ("selected"). Of course, this only takes place if "multiple dates" is selected.
Definition at line 2126 of file calendar.js. |
|
Call this in order to install a function handler that returns a tooltip for the given date. For example:
function myHandler(date) { var str = date.print("%Y/%m/%d"); if (str == "1979/08/03") { return "Happy birthday Mishoo! :D"; } return str; } calendar.setDateToolTipHandler(myHandler); The tooltip handler is a "unary" function (receives one argument). The argument passed is a date object and the function should return the tooltip for that date.
Definition at line 2164 of file calendar.js. |
|
Moves the calendar to the specified date. If date is not passed, then the "today" date is assumed. This function does range checking and displays an error in the status bar if the new date is not allowed by the configured calendar range. Otherwise, it simply calls _init() with the new date.
Definition at line 2176 of file calendar.js. |
|
Displays a hint in the status bar
Definition at line 2195 of file calendar.js. |
|
Refreshes the calendar. Useful if the "disabledHandler" function is dynamic, meaning that the list of disabled date can change at runtime. Just call this function if you think that the list of disabled dates should change. This function simply calls _init() using the current firstDayOfWeek and the current calendar date. Definition at line 2208 of file calendar.js. |
|
"refresh()" isn't a good name for it: this function _destroys_ the calendar object and creates another one with the same parameters. This comes in handy for the calendar wizard where we need to reconstruct the calendar for virtually any property change.
Definition at line 2218 of file calendar.js. |
|
Configures the "firstDayOfWeek" parameter of the calendar.
Definition at line 2236 of file calendar.js. |
|
These functions allow one to install a handler that gets called for each date when a month is displayed in the calendar. Based on this handler's return value, that date can be disabled or highlighted using a class name returned by the handler. The handler has the following prototype:
function dateStatus(date, year, month, day); While all 4 parameters are passed, the handler can for instance use only the first one. The year, month and day can all be determined from the first parameter which is a Date object, but because many people will explicitely need the year, month or day, we pass them too to speed things up (since we already know them at the time the handler is called). Here is an example of a not-so-complex handler:
function my_DateStatus(date, year, month, day) { var str = date.print("%Y/%m/%d"); if (str >= '2000/01/01' && str <= '2000/12/31') { return true; // disable all dates in 2000 } if (str == "1979/08/03") { return "birthday"; } return false; } calendar.setDateStatusHandler(my_DateStatus); The above handler will disable all dates in 2000 (returns true) and highlight "1979/08/03" using the class "birthday". From this example we can notice that the handler can return a boolean value or a string value. The "boolean" return type is supported for backwards compatibility (function setDisabledHandler, which is deprecated by setDateStatusHandler). Here's what the return value means:
Note that user defined class names should have an associated CSS part somewhere in the document that specifies how the days will look like; otherwise, no difference will be visible. For instance, for highlighting "birthday" dates, one should also add:
.birthday { color: #f00; } somewhere in the CSS of the calling document. (the above will make them red). Disabled dates are not clickable; however, if one overrides the "disable" CSS class, or if the cell also gets an "other_string" class that contains settings that override the "disabled" class, those cells might not look "disabled" but still behave so. WARNING: this function gets called 28 to 31 times each time a month is displayed. This means that if you are doing crazy computations in order to determine the status of a day, things will slow down dramatically. You have been warned.
Definition at line 2324 of file calendar.js. |
|
Configures a range of allowed dates for the calendar. Currently, this function supports setting a range on a "month granularity". This means, using it you can't disable part of a month. Both parameters are numeric and can be float. The range is "inclusive". This function might seem somehow complicated, but it's designed in a way that keeps backwards compatibility with the calendar v0.9.6.
The above statements mean that the following two lines are equivalent:
calendar.setDate(1999, 2005); // or
calendar.setDate(1999.01, 2005.12);
Definition at line 2354 of file calendar.js. |
|
This function sets up the cal.multiple property initially when the flat or popup calendar is created. If there are dates to be displayed or added to the first time, this property will be filled with those dates at the beginning. multiple -- [Array] - stores the current dates for future use and appending of additional dates Definition at line 2371 of file calendar.js. |
|
Call the calendar's callback function, if defined. The passed argument is the date object. This is a public function meant to be invoked by the user so that s/he can have more controls on what to do with the dates selected. Definition at line 2387 of file calendar.js. |
|
This function updates the calendar history and saves the cookie. The history is a string containing date and time formatted as "%Y/%m/%d/%H/%M" (that is, all time parts separated by slashes, in a "most significant to least significant order"). Further, such formats are separated by commas, and the current calendar date is added the first, then the cookie saved.
Definition at line 2437 of file calendar.js. |
|
Calls the calendar's onClose handler, if present. Either way, this function calls updateHistory() in order to update the history cookie.
Definition at line 2458 of file calendar.js. |
|
Removes the calendar object from the DOM tree and destroys it.
Definition at line 2469 of file calendar.js. |
|
Moves the calendar element to a different section in the DOM tree (changes its parent). This might be useful for flat calendars.
Definition at line 2483 of file calendar.js. |
|
This gets called when the user presses a mouse button anywhere in the document, if the calendar is shown. If the click was outside the open calendar this function closes it and stops the event from propagating.
Definition at line 2497 of file calendar.js. |
|
Updates the calendar "WCH" (windowed controls hider). A WCH is an "invention" (read: "miserable hack") that works around one of the most common and old bug in Internet Explorer: the SELECT boxes or IFRAMES show on top of any other HTML element. This function makes sure that the WCH covers correctly the calendar element and another element if passed.
Definition at line 2519 of file calendar.js. |
|
Displays a hidden calendar. It walks quickly through the HTML elements and makes sure that they don't have "hover" or "active" class names that might be there from a previous time the same calendar was displayed. This function also calls updateWCH() and hideShowCovered() to workaround miserable IE bugs. If the calendar is a popup calendar and doesn't have the "noGrab" property set, this function also adds document event handlers to intercept key events or to close the calendar when one clicks outside it. Definition at line 2534 of file calendar.js. |
|
Hides the calendar. Also removes any "hilite" from the class of any TD element. Unregisters the document event handlers for key presses and mousedown.
Definition at line 2565 of file calendar.js. |
|
Shows the calendar at a given absolute position (beware that, depending on the calendar element style -- position property -- this might be relative to the parent's containing rectangle).
Definition at line 2585 of file calendar.js. |
|
This function displays the calendar near a given "anchor" element, according to some rules passed in opts. The opts argument is a string containing one or 2 letters. The first letter decides the vertical alignment, and the second letter decides the horizontal alignment relative to the anchor element. Following we will describe these options; in parens we will use simple descriptions like "top to bottom" which means that the top margin of the calendar is aligned with the bottom margin of the object. Vertical align:
Horizontal align (defaults to 'l' if no letter passed):
Definition at line 2620 of file calendar.js. |
|
Customizes the date format that will be reported to the onSelect handler. The format string is described in Date.prototype.print().
Definition at line 2665 of file calendar.js. |
|
Customizes the tooltip date format. See Zapatec.Calendar.prototype.setDateFormat() for a description of the str format.
Definition at line 2675 of file calendar.js. |
|
This function hides or shows "windowed controls" accordingly so that the calendar isn't obtured by any such control. Historically, this function was used for any browser. It simply walks through all SELECT, IFRAME and APPLET elements present in the DOM, checks if they intersect the calendar and hides them if so or makes them visible otherwise. This approacy has a number of problems, the most important being that if the end-user's code contains a SELECT which is already hidden and it must stay hidden, it will still be made visible when the calendar closes. The other obvious problem is that there's an ugly effect generated by elements that suddenly (dis)appear when you drag the calendar around the screen. Currently this function is only used on IE5.0/Windows, browser that leaves no room for a better workaround to this problem. For IE5.5+/Windows an workaround is possible, albeit amazingly ugly (WCH). For other browsers such crazy techniques are not anymore useful because the bugs related to windowed controls were fixed. Definition at line 2714 of file calendar.js. |
|
This function displays the week day names in the calendar header, according to the current "firstDayOfWeek". Definition at line 2776 of file calendar.js. |
|
Compare two dates in either ascending or descending order. To be used for the multiple dates feature. This function is passed as an argument to the sort routine which calls it to compare dates.
Definition at line 2822 of file calendar.js. |
|
For internal use only. Starts dragging the element. Definition at line 2839 of file calendar.js. |
|
This function compares only years, months and days of two date objects.
Definition at line 3165 of file calendar.js. |