Frontier Calendar is a full month jQuery plugin. It was designed to look like Google Calendar.
Screenshot 1
All form fields are required.
Free to use. You're welcome. I claim no responsibility if it explodes in a cloud of doom.
MIT License: http://en.wikipedia.org/wiki/MIT_License
Seth Lenzi
slenzi@gmail.com
**Important** Please read below regarding modified jQuery Core library for drag-and-drop in IE.
JQuery Core
js/jquery-core/jquery-1.4.2-ie-fix.min.js if you want drag-and-drop to work correctly in IE. Otherwise use regular jQuery Core library.
Read README-IE-FIX.TXT file in jquery-frontier-cal-x.x/js/jquery-core/ folder if you are interested in what was modified.
http://jquery.com/
JQuery UI
http://jqueryui.com
jshashtable
http://www.timdown.co.uk/jshashtable/
http://code.google.com/p/jshashtable/
Step 1: Install modified jQuery Core. This plugin should have come with a slightly modified version of the jQuery Core library in the js/jquery-core/ folder. The file name is jquery-1.4.2-ie-fix.js for the uncompressed version and jquery-1.4.2-ie-fix.min.js for the compressed version. A slight modification was need to get drag-and-drop to work correctly in Internet Explorer. If you don't care about IE than you can use an unmodified copy of jQuery Core library. If you are interested in what was modified in the core library read the README-IE-FIX.TXT file in jquery-frontier-cal-x.x/js/jquery-core/ folder. When a new version of jQuery Core is released you can make the same small modification. Only one line!
WebContent/ |__js/ | |__jquery-core/ | |__jquery-1.4.2-ie-fix.min.js | |__index.html
Step 2: If you don't already have the jQuery UI library you should download it from jQuery's UI web site. This consists of a javascript file and a CSS file. Add both files to your HTML document root. Javascript files should go in a folder named "js" or "javascript" and CSS files should go in a folder names "css". Note: jQuery UI with the smoothness theme is already included with this example in the css/ folder.
WebContent/ |__js/ | |__jquery-core/ | | |__jquery-1.4.2-ie-fix.min.js | | | |__jquery-ui/ | |__smoothness/ | |__jquery-ui-1.8.1.custom.min.js |__css/ | |__jquery-ui/ | |__smoothness/ | |__jquery-ui-1.8.1.custom.css |__index.html
Step 3: Add the Frontier Calendar Javascript file and Frontier Calendar CSS file to your HTML document root.
WebContent/ |__js/ | |__jquery-core/ | | |__jquery-1.4.2-ie-fix.min.js | | | |__jquery-ui/ | | |__smoothness/ | | |__jquery-ui-1.8.1.custom.min.js | | | |__frontierCalendar/ | |__jquery-frontier-cal-1.3.2.min.js | |__css/ | |__jquery-ui/ | | |__smoothness/ | | |__jquery-ui-1.8.1.custom.css | | | |__frontierCalendar/ | |__jquery-frontier-cal-1.3.2.css | |__index.html
Step 4: Add the required jshashtable-2.1.js library inlcude in the example /js/lib/ folder.
http://code.google.com/p/jshashtable/
Note: This library must be inlcuded before the Frontier Calendar javascript file!
WebContent/ |__js/ | |__jquery-core/ | | |__jquery-1.4.2-ie-fix.min.js | | | |__jquery-ui/ | | |__smoothness/ | | |__jquery-ui-1.8.1.custom.min.js | | | |__frontierCalendar/ | | |__jquery-frontier-cal-1.3.2.min.js | | | |__lib/ | |__jshashtable-2.1.js | |__css/ | |__jquery-ui/ | | |__smoothness/ | | |__jquery-ui-1.8.1.custom.css | | | |__frontierCalendar/ | |__jquery-frontier-cal-1.3.2.css | |__index.html
Step 5: Inlcude all libraries on your html page. (Note: The colorpicker javascript file and css file are not required. This is used in the example.)
Initialize the calendar with the current year and month using the date parameter. Provide callback functions for click events using the dayClickCallback and agendaClickCallback parameters, and drop events (drag-and-drop) via the agendaDropCallback option. dayClickCallback will be fired when users click on a day cell and agendaClickCallback will be fired when users click on an agenda item. agendaDropCallback will be fired when agenda items are dragged and then dropped into a day cell (if drag-and-drop is enabled.)
After initialization retrieve a reference to the plugin using .data("plugin"). The jfcalplugin object is the interface to the calendar and will be used later to interact with the calendar (add/edit/delete agenda items, etc.)
| Parameter | Type | Description |
|---|---|---|
| date | javascript Date object | A Date object with the year and month you want the calendar initialized to. Remember that with javascript Dates the months start at 0 (Januaray=0) |
| dayClickCallback | function | A function that is triggered when a day cell is clicked. This is where you can create your customized add event form. |
| agendaClickCallback | function | A function that is triggered when an agenda item is clicked. This is where you can create your customized delete/edit agenda item form. |
| agendaDropCallback | function | A function that is called when an agenda item is dropped into a day cell. Here is where you could for example perform an AJAX call to update your database. |
| dragAndDropEnabled | boolean | True to enable drag-and-drop, false to disable. |
By default the calendar is 100% wide and the height is calculated by aspect ratio. The day cells will be roughly the same height as they are wide (minus the height of the week headers that show the day numbers.) There are a couple ways you can control the size of the calendar.
Option 1: CSS File
In the CSS file you can change the width attribute of the .JFrontierCal element. You may use precentage widths and pixel widths.
Option 2: Aspect ratio
By default the aspect ratio is 1. This makes the day cells roughly the same height as they are wide. Using the API you can change this value.
For example, you can set the aspect ratio to 0.5 to make the day cells half as tall as they are wide resulting in a calendar that is much
wider than it is tall. The aspect ratio value must be less that or equal to 1, and greater than 0. A value of 0.75 makes the day cells 3/4th
as tall as they are wide, and a value of 0.25 makes the day cells 1/4th tall as they are wide.
To change the aspect ratio use the jfcalplugin.setAspectRatio() method.
| Parameter | Type | Description |
|---|---|---|
| calId | String | The ID of the calendar div element. |
| ratio | Float | A value less than or equal to 1 and greater than 0. |
Drag-and-drop works in Chrome, Firefox, Safari, and Opera. If you want IE than you have to use the inlcuded modified jQuery Core file (jquery-1.4.2-ie-fix.min.js). Please read the txt file at query-frontier-cal-x.x/js/jquery-core/README-IE-FIX.TXT for more information.
Drag-and-drop is enabled by default. To turn it off pass false for the dragAndDropEnabled when you initialize the calendar.
There are a few callback functions, agendaDragStartCallback & agendaDragStopCallback, that are fired when dragging starts and stops on agenda items. These callbacks are defined in the calendar initialization method.
When an agenda item is dragged but NOT dropped into another day cell it will revert back to it's start position. When it reverts the applyAgendaTooltip(divElm,agendaItem) will be called again. When dragging starts you can destroy any tooltip you applied, when reverted it will be applied again.
| Parameter | Type | Description |
|---|---|---|
| eventObj | jQuery event object | The event object for the drag event. |
| divElm | jQuery object | The div element for the agenda item. |
| agendaItem | javascript object |
The agenda item data
|
| Parameter | Type | Description |
|---|---|---|
| eventObj | jQuery event object | The event object for the drag event. |
| divElm | jQuery object | The div element for the agenda item. |
| agendaItem | javascript object |
The agenda item data
|
Frontier calendar provides a hook that allows you to add tooltips to agenda items. You can use any tooltip library you want. Ideally the tooltip library you use should have a destroy or hide method. The tooltip library used in the example is qtip, http://craigsworks.com/projects/qtip/
The hook is the callback function applyAgendaTooltipCallback defined during calendar initialization. This method is fired under the following conditions.
This method could be fired multiple times if the agenda item wraps around to another week. For example if the agenda item starts on Friday and ends on Tuesday there will be two div elements for the agenda item. One div element that spans from Friday to Saturday, and another div element in the next week that spans from Sunday to Tuesday. The tooltip will be applied to all div elements that make up the agenda item.
| Parameter | Type | Description |
|---|---|---|
| divElm | jQuery object | The div element for the agenda item. |
| agendaItem | javascript object |
The agenda item data
|
There are many instances in which you may need to get the current year and month that calendar is displaying. Use the jfcalplugin.getCurrentDate() method to get a javascript Date object.
| Parameter | Type | Description |
|---|---|---|
| calId | String | The ID of the calendar div element. |
| Returns: A javascript Date object with the year and month that the calendar is currently set to. | ||
To retrieve agenda items from the calendar use jfcalplugin.getAgendaItemById() or jfcalplugin.getAgendaItemByDataAttr() or jfcalplugin.getAllAgendaItems()
Agenda Item Object Specification:
| Parameter | Type | Description |
|---|---|---|
| calId | String | The ID of the calendar div element. |
| agendaId | integer | The internal agenda ID. You can get this ID from event object on click events. |
| Returns: A single agenda item object. | ||
| Parameter | Type | Description |
|---|---|---|
| calId | String | The ID of the calendar div element. |
| attrName | String |
The name of the attribute in the agenda data object. When you add an agenda item to the calendar one of the
parameters is an object with key value pairs. This allows you to store any data you want in the agenda item.
|
| attrValue | string/number | The attribute value in the data object. |
| Return: An array of agenda item objects. All agenda items that have the matching attribute value. If there is only one than the array will be of length 1. | ||
| Parameter | Type | Description |
|---|---|---|
| calId | String | The ID of the calendar div element. |
| Return: An array of agenda item objects. | ||
To add an agenda item to the calendar use the jfcalplugin.addAgendaItem() method.
| Parameter | Type | Description |
|---|---|---|
| calId | String | The ID of the calendar div element. |
| title | String | The title of the agenda item. This is displayed on the agenda div element. |
| startDate | Date | Date & time the agenda event starts. |
| endDate | Date | Date & time the agenda event ends. |
| allDay | boolean | True if an all day event (do not show start time on agenda div element), false otherwise. False by default. |
| data | Object |
Any optional data you want to store in the agenda item. An object with a series of key value pairs.
e.g. {var1: "some data", var2: "more data", var3: "etc..."} Pass null if you don't want to store any data. |
| displayProp | Object |
Optional display properties for the agenda item, or null.
|
To delete an agenda item use either jfcalplugin.deleteAgendaItemById(), or jfcalplugin.deleteAgendaItemByDataAttr(), or jfcalplugin.deleteAllAgendaItems() methods.
| Parameter | Type | Description |
|---|---|---|
| calId | String | The ID of the calendar div element. |
| agendaId | integer | The internal agenda ID. You can get this ID from event object on click events. |
| Parameter | Type | Description |
|---|---|---|
| calId | String | The ID of the calendar div element. |
| attrName | String |
The name of the attribute in the agenda data object. When you add an agenda item to the calendar one of the
parameters is an object with key value pairs. This allows you to store any data you want in the agenda item.
|
| attrValue | string/number | The attribute value in the data object. |
| Parameter | Type | Description |
|---|---|---|
| calId | String | The ID of the calendar div element. |
Documentation coming soon!
For now you simply pull the agenda item from the calendar, update it, delete the existing entry and then re-add it. I will have a nice update method later.
Frontier calendar has some basic iCal support. You can import iCal VEVENT data from an iCal file using the jfcalplugin.loadICalSource(calId,iCalUrl,responseDataType) method.
Please note that I don't know every much about iCal... The above method just parses out the VEVENT data and builds agenda items.
| Parameter | Type | Description |
|---|---|---|
| calId | String | The ID of the calendar div element. |
| iCalUrl | String |
Path to the iCal file. This can be a local path on disk or a URL. This resource will be requested using a jQuery AJAX call. Please note: This will not work on Chrome for local files. See http://code.google.com/p/chromium/issues/detail?id=40787 |
| responseDataType | string |
Data type of the response data, something like "text/html" or "application/octet-stream", etc... |
If another element on your page changes size, causing the calendar div element to move, you may notice that the agenda items are not properly aligned. For example, if you have an element above the calendar that grows in height than the celendar div element will be pushed down further on the page. Since the agenda items are absolutely positioned over the calendar day cells they will not move, and they will not be properly aligned over the calendar.
|
Before: Agenda items are posititoned correctly.
|
After: element above calendar cause calendar div to shift down. Absolute positioned agenda items do not shift down with the calendar. Looks bad! :(
|
Solution 1: Call the reRenderAgendaItems(calId) function to re-render the agenda items after the calendar moves.
Solution 2: Make sure there is nothing on your page that will cause the calendar div element to move! :)
June 23nd, 2010 - Version 1.3.1
June 22nd, 2010 - Version 1.3
June 17th, 2010 - Version 1.2:
June 14th, 2010 - Version 1.1:
June 9th, 2010 - Version 1.0: Initial release.