/** * jquery.calendario.js v1.0.0 * http://www.codrops.com * * Licensed under the MIT license. * http://www.opensource.org/licenses/mit-license.php * * Copyright 2012, Codrops * http://www.codrops.com */ ;( function( $, window, undefined ) { 'use strict'; $.Calendario = function( options, element ) { this.$el = $( element ); this._init( options ); }; // the options $.Calendario.defaults = { /* you can also pass: month : initialize calendar with this month (1-12). Default is today. year : initialize calendar with this year. Default is today. caldata : initial data/content for the calendar. caldata format: { 'MM-DD-YYYY' : 'HTML Content', 'MM-DD-YYYY' : 'HTML Content', 'MM-DD-YYYY' : 'HTML Content' ... } */ weeks : [ 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday' ], weekabbrs : [ 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat' ], months : [ 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December' ], monthabbrs : [ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' ], // choose between values in options.weeks or options.weekabbrs displayWeekAbbr : false, // choose between values in options.months or options.monthabbrs displayMonthAbbr : false, // left most day in the calendar // 0 - Sunday, 1 - Monday, ... , 6 - Saturday startIn : 1, onDayClick : function( $el, $content, dateProperties ) { return false; } }; $.Calendario.prototype = { _init : function( options ) { // options this.options = $.extend( true, {}, $.Calendario.defaults, options ); this.today = new Date(); this.month = ( isNaN( this.options.month ) || this.options.month == null) ? this.today.getMonth() : this.options.month - 1; this.year = ( isNaN( this.options.year ) || this.options.year == null) ? this.today.getFullYear() : this.options.year; this.caldata = this.options.caldata || {}; this._generateTemplate(); this._initEvents(); }, _initEvents : function() { var self = this; this.$el.on( 'click.calendario', 'div.fc-row > div', function() { var $cell = $( this ), idx = $cell.index(), $content = $cell.children( 'div' ), dateProp = { day : $cell.children( 'span.fc-date' ).text(), month : self.month + 1, monthname : self.options.displayMonthAbbr ? self.options.monthabbrs[ self.month ] : self.options.months[ self.month ], year : self.year, weekday : idx + self.options.startIn, weekdayname : self.options.weeks[ idx + self.options.startIn ] }; if( dateProp.day ) { self.options.onDayClick( $cell, $content, dateProp ); } } ); }, // Calendar logic based on http://jszen.blogspot.pt/2007/03/how-to-build-simple-calendar-with.html _generateTemplate : function( callback ) { var head = this._getHead(), body = this._getBody(), rowClass; switch( this.rowTotal ) { case 4 : rowClass = 'fc-four-rows'; break; case 5 : rowClass = 'fc-five-rows'; break; case 6 : rowClass = 'fc-six-rows'; break; } this.$cal = $( '