var calendar1_presets = { show : "5", time: "0", showmaxlength : "15" }; var imavex = imavex || {}; imavex.globals = imavex.globals || {}, imavex.globals.iw_cw_calendars = imavex.globals.iw_cw_calendars || []; jQuery(function($) { var cal1 = $('#calendar1').calendario({ onDayClick: function ($el, $contentEl, dateProperties) { //if not showing text, then set the click functionalty for the day if(!calendar1_presets.show) { if ($contentEl.length > 0) { cfr_showEvents(1,$('#calendar1'), dateProperties); } } }, rendertype: "text", startIn: 0 }); imavex.globals.iw_cw_calendars.push(cal1); var starting_view = ""; if(jQuery(window).width() < 768) starting_view = "list"; if(starting_view == "list") cfr_updateMode( $('#calendar1') ); cfr_updateEvents(cal1, $('#calendar1')); /* Click on the List Button */ $('#calendar1-list').on('click', function(e) { var cur = cfr_updateMode( $('#calendar1') ); cfr_updateEvents(cal1, $('#calendar1'), true); }); //load an event from the url if (imavex.browser.hasHistoryApi()) { var url = window.location.href.toString(); if(url.match(/#/)) { var parts = url.split("#"); var eventid = parts[1]; //assert it's a 32 character id if(eventid.match(/\w{32}/)) cfr_openEvent(eventid); } } /* Click on the Previous Button */ $('#calendar1-prev').on('click', function(e) { e.preventDefault(); cal1.gotoPreviousMonth(function() { cfr_updateEvents(cal1, $('#calendar1')); cfr_updateMonthMenu(1, cal1.getMonth()); cfr_updateYearMenu(1, cal1.getYear()); cfr_updateMonthYear(cal1, $('#calendar1')); }); }); /* Click on the month menu Button */ $('#calendar1-month li').on('click', function(e) { e.preventDefault(); var mon = $("a", this).data("month"); var year = $('#calendar1-year li.active a').data("year"); cfr_updateMonthMenu(1, mon); //set new selected cal1.goto(mon - 1, year, function (e) { cfr_updateEvents(cal1, $('#calendar1')); cfr_updateMonthYear(cal1, $('#calendar1')); }); }); /* Click on the year menu */ $('#calendar1-year li').on('click', function(e) { e.preventDefault(); var year = $("a", this).data("year"); var mon = $('#calendar1-month li.active a').data("month"); cfr_updateYearMenu(1, year); //set new selected cal1.goto(mon - 1, year, function (e) { cfr_updateEvents(cal1, $('#calendar1')); cfr_updateMonthYear(cal1, $('#calendar1')); }); }); /* Click the next button */ $('#calendar1-next').on('click', function(e) { e.preventDefault(); cal1.gotoNextMonth(function() { cfr_updateEvents(cal1, $('#calendar1')); cfr_updateMonthMenu(1, cal1.getMonth()); cfr_updateYearMenu(1, cal1.getYear()); cfr_updateMonthYear(cal1, $('#calendar1')); }); }); /* Click on a different Event Type */ $('#calendar1-event-types li a').on('click', function(e) { e.preventDefault(); var val = $(this).data("event-type-id"); var title = $(this).html(); //clear the active on all lists item $('#calendar1-event-types li ').removeClass("active"); // activiate the current selected $(this).parent("li").addClass("active"); //set the event type id $('#calendar1').data("event-type", val); cal1.goto(cal1.getMonth() - 1, cal1.getYear(), function (e) { cfr_updateEvents(cal1, $('#calendar1'), true); jQuery("#calendar1-event-type-title").html( title + ' '); }); }); /* Click Today */ $('#calendar1-today').on('click', function(e) { e.preventDefault(); cal1.gotoNow(function() { cfr_updateEvents(cal1, $('#calendar1')); cfr_updateMonthMenu(1, cal1.getMonth()); cfr_updateYearMenu(1, cal1.getYear()); cfr_updateMonthYear(cal1, $('#calendar1')); }); }); $('#iw-cw-search-form-1').on('submit', function(e) { e.preventDefault(); var form = $(this), searchTerm = $('#iw-cw-search-input-1', form).val(), inst_num = form.data('instance'); cfr_loadSearchResults(inst_num, searchTerm); }); $(window).resize( function () { cal1.goto(cal1.getMonth() - 1, cal1.getYear(), function (e) { cfr_updateEvents(cal1, $('#calendar1')); }); if($(window).width() <= 768 && (!cfr_calendarMode["calendar1"] || cfr_calendarMode["calendar1"] == 0)) { var cur = cfr_updateMode( $('#calendar1') ); cfr_updateEvents(cal1, $('#calendar1'), true); } }); }); // vim: ft=javascript