{"id":29340,"date":"2013-06-26T11:33:09","date_gmt":"2013-06-26T15:33:09","guid":{"rendered":"http:\/\/www.templatemonster.com\/help\/?p=29340"},"modified":"2013-06-26T11:33:09","modified_gmt":"2013-06-26T15:33:09","slug":"js-animated-how-to-work-with-fullcalendar-plugin","status":"publish","type":"post","link":"https:\/\/www.templatemonster.com\/help\/js-animated-how-to-work-with-fullcalendar-plugin.html","title":{"rendered":"JS Animated. How to work with FullCalendar plugin"},"content":{"rendered":"<p>This tutorial is  going to show you how to work with a FullCalendar plugin included to some JS  Animated templates.<\/p>\r\n\r\n<a href=\"http:\/\/www.youtube.com\/watch?v=xSonrbsoXD8?width=1280&amp;height=720\" rel=\"prettyPhoto\">JS Animated. How to work with FullCalendar plugin<\/a>\r\n\r\n <p>FullCalendar is  a <a href=\"http:\/\/jquery.com\/\" rel=\"nofollow\">jQuery<\/a> plugin that  provides a full-sized, drag &#038; drop calendar. It uses AJAX to fetch events on-the-fly for each month and is easily configured. <\/p>\r\n<h3>Basic Usage<\/h3>\r\n<p>  If your template  comes with such a calendar, it means the plugin is already embedded with right JavaScript and CSS files, including the FullCalendar stylesheet, as well as the FullCalendar and <a href=\"http:\/\/jquery.com\/\" rel=\"nofollow\">jQuery<\/a> JS files, in the <strong>&lt;head&gt;<\/strong> section of your page:\r\n\r\n<pre class=\"brush:html\">\r\n&lt;link rel=&quot;stylesheet&quot; href=&quot;css\/fullcalendar.css&quot; \/&gt;<br>\r\n&lt;script src=&quot;js\/jquery-1.7.1.min.js&quot;&gt;&lt;\/script&gt;<br>\r\n&lt;script src=&quot;js\/fullcalendar.min.js&quot;&gt;&lt;\/script&gt;<br>\r\n<\/pre>\r\n\r\n<p>Beside the  dependencies, your web page should also have the JavaScript code that  initializes the calendar. This code should be executed after the page  has initialized with\u00a0 the help of  <strong>jQuery&#8217;s $(document).ready<\/strong> function enclosed into a <strong>&lt;script&gt;<\/strong> tag in the  head of your page:<\/p>\r\n\r\n<pre class=\"brush:js\">\r\n&lt;script type='text\/javascript'&gt;<br>\r\n$(document).ready(function() { <br>\r\nvar date = new Date();<br>\r\nvar d = date.getDate();<br>\r\nvar m = date.getMonth();<br>\r\nvar y = date.getFullYear();<br>\r\n&lt;\/script&gt;\r\n<\/pre>\r\n<p>where:<\/p>\r\n<ol>\r\n  <li>The <strong>new Date()<\/strong> method creates a new Date  with the current date and time<\/li>\r\n  <li> The <strong>getDate()<\/strong> method returns the day of the  month (from 1 to 31) for the specified date<\/li>\r\n  <li> The <strong>getMonth()<\/strong> method returns the month (from 0 to 11) for the  specified date, according to local time (January is 0, February is 1, and so  on)<\/li>\r\n  <li> The <strong>getFullYear()<\/strong> method returns the year (four digits) of the  specified date. (e.g.: 2013).<\/li>\r\n<\/ol>\r\n<p>  The other part  of the code looks like:<\/p>\r\n\r\n<pre class=\"brush:js\">\r\n\t\t$('#calendar').fullCalendar({\r\n\t\t\teditable: true,\r\n\t\t\tweekMode: 'liquid',\r\n\t\t\turl:'#',\r\n\r\n<\/pre>\r\n<ol>\r\n  <li><strong>editable \u00a0&#8211; <\/strong>Determines whether the events on the calendar can be  modified<\/li>\r\n  <li><strong>weekMode<\/strong> &#8211;  Determines the number of weeks  displayed in a month view. Also determines each week&#8217;s height. Its available  options: <\/li>\r\n<ul>\r\n  <li><strong>&#8216;fixed&#8217;<\/strong>&#8211; The calendar will always be 6 weeks tall. The  height will always be the same, as determined by <a href=\"http:\/\/arshaw.com\/fullcalendar\/docs\/display\/height\/\" rel=\"nofollow\">height<\/a>, <a href=\"http:\/\/arshaw.com\/fullcalendar\/docs\/display\/contentHeight\/\" rel=\"nofollow\">contentHeight<\/a>, or <a href=\"http:\/\/arshaw.com\/fullcalendar\/docs\/display\/aspectRatio\/\" rel=\"nofollow\">aspectRatio<\/a>.<\/li>\r\n  <li><strong>&#8216;liquid&#8217; &#8211; <\/strong>The calendar will have either 4, 5, or 6 weeks,  depending on the month. The height of the weeks will stretch to fill the  available height, as determined by <a href=\"http:\/\/arshaw.com\/fullcalendar\/docs\/display\/height\/\">height<\/a>, <a href=\"http:\/\/arshaw.com\/fullcalendar\/docs\/display\/contentHeight\/\" rel=\"nofollow\">contentHeight<\/a>, or <a href=\"http:\/\/arshaw.com\/fullcalendar\/docs\/display\/aspectRatio\/\" rel=\"nofollow\">aspectRatio<\/a>.<\/li>\r\n  <li><strong>&#8216;variable&#8217;<\/strong>&#8211; The calendar will have either 4, 5, or 6  weeks, depending on the month. Each week will have the same constant height,  meaning the calendar\u2019s height will change month-to-month.<\/li>\r\n<\/ul>\r\n<li><strong>url:&#8217;#&#8217;,<\/strong> &#8211; FullCalendar  can display events from a public <a href=\"http:\/\/calendar.google.com\/\" rel=\"nofollow\">Google Calendar<\/a>. It can serve as a backend that manages and  persistently stores event data (a feature that FullCalendar currently lacks).\r\n<\/ol>\r\n<p>For more info on  the general display see <a href=\"http:\/\/arshaw.com\/fullcalendar\/docs\/display\/\" rel=\"nofollow\">http:\/\/arshaw.com\/fullcalendar\/docs\/display\/<\/a>\r\n  <\/p>\r\n<p>Next comes the event source object. An   &quot;event  source&quot; is anything that provides FullCalendar with data about events. Since  version 1.5, Event Objects can have &quot;options&quot; associated with them: \r\n<\/p>\r\n\r\n<pre class=\"brush:js\">\r\n\r\nevents: [\r\n\t\t\t\t{\r\n\t\t\t\t\ttitle: 'Praent vestibulum',\r\n\t\t\t\t\tstart: new Date(y, m, 1, 9, 00),\r\n\t\t\t\t\tend: new Date(y, m, 1, 10, 00),\r\n\t\t\t\t\tallDay: false\r\n\t\t\t\t},\r\n\t\t\t\t{\r\n\t\t\t\t\ttitle: 'Vestibulum iaculis lacinia',\r\n\t\t\t\t\tstart: new Date(y, m, 2, 16, 00),\r\n\t\t\t\t\tallDay: false\r\n\t\t\t\t},\r\n\t\t\t\t{\r\n\t\t\t\t\ttitle: 'Integer rutrum ante eu lacus',\r\n\t\t\t\t\tstart: new Date(y, m, 4, 16, 00),\r\n\t\t\t\t\tallDay: false\r\n\t\t\t\t},\r\n\t\t\t\t{\r\n\t\t\t\t\ttitle: 'Aliquam erat volpat. Duis ac turpis',\r\n\t\t\t\t\tstart: new Date(y, m, 9, 16, 00),\r\n\t\t\t\t\tallDay: false\r\n\t\t\t\t},\r\n\t\t\t\t{\r\n\t\t\t\t\ttitle: 'Donec in velit vel ipsum',\r\n\t\t\t\t\tstart: new Date(y, m, 10, 16, 00),\r\n\t\t\t\t\tallDay: false\r\n\t\t\t\t},\r\n\t\t\t\t{\r\n\t\t\t\t\ttitle: 'Praent vestibulum',\r\n\t\t\t\t\tstart: new Date(y, m, 13, 9, 00),\r\n\t\t\t\t\tallDay: false\r\n\t\t\t\t},\r\n\t\t\t\t{\r\n\t\t\t\t\ttitle: 'Vestibulum iaculis lacinia',\r\n\t\t\t\t\tstart: new Date(y, m, 15, 16, 00),\r\n\t\t\t\t\tallDay: false\r\n\t\t\t\t},\r\n\t\t\t\t{\r\n\t\t\t\t\ttitle: 'Integer rutrum ante eu lacus',\r\n\t\t\t\t\tstart: new Date(y, m, 17, 16, 00),\r\n\t\t\t\t\tallDay: false\r\n\t\t\t\t},\r\n\t\t\t\t{\r\n\t\t\t\t\ttitle: 'nteger rutrum ante eu lacusi',\r\n\t\t\t\t\tstart: new Date(y, m, 18, 16, 00),\r\n\t\t\t\t\tallDay: false\r\n\t\t\t\t},\r\n\t\t\t\t{\r\n\t\t\t\t\ttitle: 'Integer rutrum ante eu lacus',\r\n\t\t\t\t\tstart: new Date(y, m, 19, 16, 00),\r\n\t\t\t\t\tallDay: false\r\n\t\t\t\t},\r\n\t\t\t\t{\r\n\t\t\t\t\ttitle: 'Integer rutrum ante eu lacus',\r\n\t\t\t\t\tstart: new Date(y, m, 23, 16, 00),\r\n\t\t\t\t\tallDay: false\r\n\t\t\t\t},\r\n\t\t\t\t{\r\n\t\t\t\t\ttitle: 'nteger rutrum ante eu lacus',\r\n\t\t\t\t\tstart: new Date(y, m, 24, 16, 00),\r\n\t\t\t\t\tallDay: false\r\n\t\t\t\t},\r\n\t\t\t\t{\r\n\t\t\t\t\ttitle: 'Integer rutrum ante eu lacus',\r\n\t\t\t\t\tstart: new Date(y, m, 27, 16, 00),\r\n\t\t\t\t\tallDay: false\r\n\t\t\t\t},\r\n\t\t\t\t{\r\n\t\t\t\t\ttitle: 'Integer rutrum ante eu lacus',\r\n\t\t\t\t\tstart: new Date(y, m, 28, 16, 00),\r\n\t\t\t\t\tallDay: false\r\n\t\t\t\t},\r\n\t\t\t\t{\r\n\t\t\t\t\ttitle: 'Vestibulum iaculis lacinia',\r\n\t\t\t\t\tstart: new Date(y, m, 29, 16, 00),\r\n\t\t\t\t\tallDay: false\r\n\t\t\t\t},\r\n\t\t\t\t{\r\n\t\t\t\t\ttitle: 'Praent vestibulum',\r\n\t\t\t\t\tstart: new Date(y, m, 30, 9, 00),\r\n\t\t\t\t\tallDay: false\r\n\t\t\t\t}\r\n\t\t\t]\r\n\t\t});\r\n\t\t\r\n\t});\r\n    &lt;\/script&gt;\r\n<\/pre>\r\n\r\n<p>In order to  display new events, you can edit the existing standard JavaScript objects that  FullCalendar uses to store information about a calendar event. You can  copy\u00a0 them to add more events. Below is  an example of the part in your code that needs to be edited or copied:<\/p>\r\n\r\n<pre class=\"brush:js\">\r\n\r\n\t\t\t\t{\r\n\t\t\t\t\ttitle: 'Praent vestibulum',\r\n\t\t\t\t\tstart: new Date(y, m, 1, 9, 00),\r\n\t\t\t\t\tend: new Date(y, m, 1, 10, 00),\r\n\t\t\t\t\tallDay: false\r\n\t\t\t\t},\r\n                \r\n<\/pre>                \r\n\r\n<p>Let\u2019s take a closer look at the  properties:<\/p>\r\n<ol>\r\n  <li>\u00a0<strong>title<\/strong> (String. <em>Required)\u00a0 &#8211;<\/em> The text  on an event&#8217;s element. E.g. can be changed to \r\n  &#8216;A new event\u2019,<\/li>\r\n  <li> <strong>start (<\/strong>Date. <em>Required<\/em>) &#8211; The date\/time an event begins. For instance,  if you are going to add a new event dated 05.23 (current year) that starts at  4.30 p.m., the line should be changed to: \r\n    start: new  Date(y, m, 23, 16, 30);<\/li>\r\n  <li><strong>allDay (true<\/strong> or <strong>false<\/strong>. Optional) &#8211; Whether an  event occurs at a specific time-of-day. This property affects whether an  event&#8217;s time is shown. \r\n  When specifying Event  Objects for events or eventSources,  omitting this property will make it inherit from <a href=\"http:\/\/arshaw.com\/fullcalendar\/docs\/event_data\/allDayDefault\/\" rel=\"nofollow\">allDayDefault<\/a>, which is normally true.<\/li>\r\n  <li><strong>end (<\/strong>Date. Optional) &#8211; The date\/time an event ends.<\/li>\r\n<\/ol>\r\n<ul>\r\n  <li><strong>If an event is all-day<\/strong>&#8230; the end date is inclusive. This means an event  with start Nov 10 and end Nov 12 will span 3 days  on the calendar.<\/li>\r\n  <li><strong>If an event is NOT all-day<\/strong>&#8230; the end date is exclusive. This is only a  gotcha when your end has time 00:00.  It means your event ends on midnight, and it will not span through the next  day.<\/li>\r\n<\/ul>\r\n<p>For other events  that you can use see <a href=\"http:\/\/arshaw.com\/fullcalendar\/docs\/event_data\/Event_Object\/\" rel=\"nofollow\">http:\/\/arshaw.com\/fullcalendar\/docs\/event_data\/Event_Object\/<\/a> <\/p>\r\n<p>  The code relies  on there being an element with an id of &quot;calendar&quot; in the body of  your page. The calendar will be placed inside this div:<\/p>\r\n\r\n<pre class=\"brush:html\">\r\n<div id=\"calendar\"><\/div>\r\n<\/pre>\r\n\r\n<p>This all allows  you to see a month-based calendar with some random events on it.<\/p>\r\n<h3>Options<\/h3>\r\n<p>Most of FullCalendar&#8217;s documentation describes options that affect the look  or behavior of the calendar. Options are usually set when the calendar is  initialized, like this:<\/p>\r\n\r\n<pre class=\"brush:js\">\r\n$('#calendar').fullCalendar({\r\nweekends: false \/\/ will hide Saturdays and Sundays\r\n});\r\n<\/pre>\r\n\r\n<h3>Callbacks<\/h3>\r\n<p>Callbacks are sort of like  options, but they are functions that get called whenever  something special happens. In the following example, an alert box will appear  whenever the user clicks on a day:<\/p>\r\n\r\n<pre class=\"brush:js\">\r\n$('#calendar').fullCalendar({\r\n\r\n\u00a0\u00a0\u00a0 dayClick: function() { \r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 alert('a day has been clicked!');\r\n\r\n\u00a0\u00a0\u00a0 }\r\n\r\n});\r\n<\/pre>\r\n\r\n<p>For more information on the FullCalendar plugin you can visit  <a href=\"http:\/\/arshaw.com\/fullcalendar\/\" target=\"_blank\" rel=\"nofollow\">http:\/\/arshaw.com\/fullcalendar\/<\/a>. Here you can download the latest releases of  the plugin as well as get support from the developers.<\/p>\r\n\r\n<p>Feel free to check the detailed video tutorial below:<\/p>\r\n\r\n<a href=\"http:\/\/www.youtube.com\/watch?v=xSonrbsoXD8?width=1280&amp;height=720\" rel=\"prettyPhoto\">JS Animated. How to work with FullCalendar plugin<\/a>","protected":false},"excerpt":{"rendered":"<p>This tutorial is  going to show you how to work with a FullCalendar plugin included to some JS Animated templates.<\/p>\n","protected":false},"author":30,"featured_media":29346,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[1016],"tags":[1515,1514,813,793,768,1264],"_links":{"self":[{"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/posts\/29340"}],"collection":[{"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/users\/30"}],"replies":[{"embeddable":true,"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/comments?post=29340"}],"version-history":[{"count":0,"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/posts\/29340\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/media\/29346"}],"wp:attachment":[{"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/media?parent=29340"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/categories?post=29340"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/tags?post=29340"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}