/* = jquery.eventCalendar.js version: 0.68 date: 17-07-2015 author: Jaime Fernandez (@vissit) company: Paradigma Tecnologico (@paradigmate) url: http://www.vissit.com/projects/eventCalendar/ */ ;!function(e){function t(t,a){var l=e.extend({},e.fn.eventCalendar.defaults,a),o={wrap:"",directionLeftMove:"300",eventsJson:{}};t.each(function(){o.wrap=e(this),o.wrap.addClass("eventCalendar-wrap").append("

"+l.locales.txt_loading+"
"),l.eventsScrollable&&o.wrap.find(".eventCalendar-list-content").addClass("scrollable"),d(o),e(window).resize(function(){d(o)}),n("current",o,l),r(o,l,l.eventsLimit,!1,!1,!1,!1),s(o,l),o.wrap.on("click",".eventCalendar-day a",function(t){t.preventDefault();var a=o.wrap.attr("data-current-year"),n=o.wrap.attr("data-current-month"),s=e(this).parent().attr("rel");r(o,l,!1,a,n,s,"day")}),o.wrap.on("click",".eventCalendar-monthTitle",function(e){e.preventDefault();var t=o.wrap.attr("data-current-year"),a=o.wrap.attr("data-current-month");r(o,l,l.eventsLimit,t,a,!1,"month")})}),o.wrap.find(".eventCalendar-list").on("click",".eventCalendar-eventTitle",function(t){if(!l.showDescription){t.preventDefault();var a=e(this).parent().find(".eventCalendar-eventDesc");if(!a.find("a").size()){var n=e(this).attr("href"),r=e(this).attr("target");a.append(''+l.locales.txt_GoToEventUrl+"")}a.is(":visible")?a.slideUp():(l.onlyOneDescription&&o.wrap.find(".eventCalendar-eventDesc").slideUp(),a.slideDown())}})}function a(e,t){return"string"==typeof e.date?e.date.toLowerCase()>t.date.toLowerCase()?1:-1:e.date>t.date?1:-1}function n(t,a,n){var l=e("
"),s=e("
"),o=e("
"),d=e(""+n.locales.txt_prev+""+n.locales.txt_next+"");if($eventsCalendarDaysList=e(""),date=new Date,a.wrap.find(".eventCalendar-slider").length?a.wrap.find(".eventCalendar-slider").append(s):(a.wrap.prepend(l),l.append(s)),a.wrap.find(".eventCalendar-monthWrap.eventCalendar-currentMonth").removeClass("eventCalendar-currentMonth").addClass("eventCalendar-oldMonth"),s.addClass("eventCalendar-currentMonth").append(o,$eventsCalendarDaysList),"current"===t)day=date.getDate(),l.append(d);else{date=new Date(a.wrap.attr("data-current-year"),a.wrap.attr("data-current-month"),1,0,0,0),day=0,moveOfMonth=1,"prev"===t&&(moveOfMonth=-1),date.setMonth(date.getMonth()+moveOfMonth);var i=new Date;date.getMonth()===i.getMonth()&&(day=i.getDate())}var v=date.getFullYear(),c=(new Date).getFullYear(),p=date.getMonth(),f=p+1;"current"!=t&&r(a,n,n.eventsLimit,v,p,!1,t),a.wrap.attr("data-current-month",p).attr("data-current-year",v),moment.locale(n.locales.locale);var h=moment(v+" "+f,"YYYY MM").format("MMMM YYYY");o.find(".eventCalendar-monthTitle").html(h);var C,m=32-new Date(v,p,32).getDate(),u=[];if(n.showDayAsWeeks){if($eventsCalendarDaysList.addClass("eventCalendar-showAsWeek"),n.showDayNameInCalendar)for($eventsCalendarDaysList.addClass("eventCalendar-showDayNames"),C=0,n.startWeekOnMonday&&(C=1);7>C;C++)u.push('
  • '+moment()._locale._weekdaysShort[C]+"
  • "),6===C&&n.startWeekOnMonday&&u.push('
  • '+moment()._locale._weekdaysShort[0]+"
  • ");dt=new Date(v,p,1);var w=dt.getDay();for(n.startWeekOnMonday&&(w=dt.getDay()-1),0>w&&(w=6),C=w;C>0;C--)u.push('
  • ')}for(dayCount=1;m>=dayCount;dayCount++){var y="";day>0&&dayCount===day&&v===c&&(y="today"),u.push('
  • '+dayCount+"
  • ")}$eventsCalendarDaysList.append(u.join("")),l.css("height",s.height()+"px")}function r(t,a,n,r,s,d,i){n=n||0,r=r||"",d=d||"",s="undefined"!=typeof s?s:"",t.wrap.find(".eventCalendar-loading").fadeIn(),a.jsonData?(a.cacheJson=!0,t.eventsJson=a.jsonData,l(t,a,t.eventsJson,n,r,s,d,i)):a.cacheJson&&i?l(t,a,t.eventsJson,n,r,s,d,i):e.getJSON(a.eventsjson+"?limit="+n+"&year="+r+"&month="+s+"&day="+d,function(e){t.eventsJson=e,l(t,a,t.eventsJson,n,r,s,d,i)}).error(function(){o("error getting json: ",t.wrap)}),d>""&&(t.wrap.find(".eventCalendar-current").removeClass("eventCalendar-current"),t.wrap.find("#dayList_"+d).addClass("eventCalendar-current"))}function l(t,n,r,l,s,o,i,v){if(directionLeftMove="-="+t.directionLeftMove,eventContentHeight="auto",subtitle=t.wrap.find(".eventCalendar-list-wrap .eventCalendar-subtitle"),v){var c,p=parseInt(o)+1;moment.locale(n.locales.locale),""!==i?(c=moment(s+" "+p+" "+i,"YYYY MM DD").format("LL"),subtitle.html(n.locales.txt_SpecificEvents_prev+c+" "+n.locales.txt_SpecificEvents_after)):(c=moment(s+" "+p,"YYYY MM").format("MMMM"),subtitle.html(n.locales.txt_SpecificEvents_prev+c+" "+n.locales.txt_SpecificEvents_after)),"eventCalendar-prev"===v?directionLeftMove="+="+t.directionLeftMove:("day"===v||"month"===v)&&(directionLeftMove="+=0",eventContentHeight=0)}else subtitle.html(n.locales.txt_NextEvents),eventContentHeight="auto",directionLeftMove="-=0";t.wrap.find(".eventCalendar-list").animate({opacity:n.moveOpacity,left:directionLeftMove,height:eventContentHeight},n.moveSpeed,function(){t.wrap.find(".eventCalendar-list").css({left:0,height:"auto"}).hide();var d=[];if(r=e(r).sort(a),r.length){var v="";n.showDescription||(v="eventCalendar-hidden");var c="_self";n.openEventInNewWindow&&(c="_target");var p=0;e.each(r,function(e,a){var r,f,h,C,m,u,w,y,g,D;if("human"==n.jsonDateFormat?(r=a.date.split(" "),f=r[0].split("-"),h=r[1].split(":"),C=f[0],m=parseInt(f[1])-1,u=parseInt(f[2]),w=parseInt(m)+1,y=h[0],g=h[1],D=h[2],f=new Date(C,m,u,y,g,D)):(f=new Date(parseInt(a.date)),C=f.getFullYear(),m=f.getMonth(),u=f.getDate(),w=m+1,y=f.getHours(),g=f.getMinutes()),parseInt(g)<=9&&(g="0"+parseInt(g)),(0===l||l>p)&&!(o!==!1&&o!=m||""!==i&&i!=u||""!==s&&s!=C))if(o===!1&&f'+a.title+"":''+a.title+"",d.push('
  • "+M+'

    '+a.description+"

  • "),p++}C==t.wrap.attr("data-current-year")&&m==t.wrap.attr("data-current-month")&&t.wrap.find(".eventCalendar-currentMonth .eventCalendar-daysList #dayList_"+parseInt(u)).addClass("eventCalendar-dayWithEvents")})}d.length||d.push('
  • '+n.locales.txt_noEvents+"

  • "),t.wrap.find(".eventCalendar-loading").hide(),t.wrap.find(".eventCalendar-list").html(d.join("")),t.wrap.find(".eventCalendar-list").animate({opacity:1,height:"toggle"},n.moveSpeed)}),d(t)}function s(t,a){t.wrap.find(".eventCalendar-arrow").click(function(r){r.preventDefault();var l;e(this).hasClass("eventCalendar-next")?(n("next",t,a),l="-="+t.directionLeftMove):(n("prev",t,a),l="+="+t.directionLeftMove),t.wrap.find(".eventCalendar-monthWrap.eventCalendar-oldMonth").animate({opacity:a.moveOpacity,left:l},a.moveSpeed,function(){t.wrap.find(".eventCalendar-monthWrap.eventCalendar-oldMonth").remove()})})}function o(e,t){t.find(".eventCalendar-list-wrap").html(""+e+"")}function d(e){e.directionLeftMove=e.wrap.width(),e.wrap.find(".eventCalendar-monthWrap").width(e.wrap.width()+"px"),e.wrap.find(".eventCalendar-list-wrap").width(e.wrap.width()+"px")}e.fn.eventCalendar=function(a){var n=this;a.locales&&"string"==typeof a.locales?e.getJSON(a.locales,function(r){a.locales=e.extend({},e.fn.eventCalendar.defaults.locales,r),moment.locale(r.locale,a.locales.moment),moment.locale(r.locale),t(n,a)}).error(function(){o("error getting locale json",e(this))}):(a.locales&&a.locales.locale&&(a.locales=e.extend({},e.fn.eventCalendar.defaults.locales,a.locales),moment.locale(a.locales.locale,a.locales.moment),moment.locale(a.locales.locale)),t(n,a))},e.fn.eventCalendar.defaults={eventsjson:"js/events.json",eventsLimit:4,locales:{locale:"en",txt_noEvents:"There are no events in this period",txt_SpecificEvents_prev:"",txt_SpecificEvents_after:"events:",txt_next:"next",txt_prev:"prev",txt_NextEvents:"Next events:",txt_GoToEventUrl:"See the event",txt_loading:"loading..."},showDayAsWeeks:!0,startWeekOnMonday:!0,showDayNameInCalendar:!0,showDescription:!1,onlyOneDescription:!0,openEventInNewWindow:!1,eventsScrollable:!1,dateFormat:"D/MM/YYYY",jsonDateFormat:"timestamp",moveSpeed:500,moveOpacity:.15,jsonData:"",cacheJson:!0}}(jQuery);