//created on sep 14 2012 var calendarAPI = function(){ c = this; this.event_create_div = $("#event_create"); this.event_quick_view_div = $("#event_quick_view"); this.initialize = function(){ $(window).load(function(){ c.loadMonthView(); bindHandlers(); }) var bindHandlers = function(){ $(".event").live("click",function(){ c.displayEvent(); }) $("#create_event_btn").click(function(){ c.newEvent($(this)); $(this).toggleClass("active"); return false; }) $('.mode_switch').click(function(){ var target = $(this).text(); switch(target){ case 'month': c.loadMonthView(); break; case 'week': c.loadWeekView(); break; case 'day': c.loadDayView(); break; case 'agenda': c.loadAgendaView(); break; } }); } } this.loadMonthView = function(){ $('#view_holder').load("cals/month_view", function() { $('.current_day_title').text('September 2012'); if($('#calendar_month').length > 0){ var $c_table = $('#calendar_month'); var sum_h = 0; var context_h = $('#main-sidebar').outerHeight(); $('#main-wrap > *').not('#orbit_calendar, .modal').each(function(){ sum_h += $(this).outerHeight(); }); $c_table // .height(context_h-sum_h-64) .find('.month_row') .not('.month_row.header') .height((context_h-sum_h-92) / 6); $(window).resize(function(){ $c_table .find('.month_row') .not('.month_row.header') .height(($('#main-sidebar').outerHeight()-sum_h-92) / 6); }); } }) } this.loadWeekView = function(){ $('#view_holder').load("cals/week_view", function() { $('.current_day_title').text('September 2 - 8, 2012'); }) } this.loadDayView = function(){ $('#view_holder').load("cals/day_view", function() { $('.current_day_title').text('September 2, 2012'); }) } this.loadAgendaView = function(){ $('#view_holder').load("cals/week_view", function() { $('.current_day_title').text('September 2, 2012'); }) } this.newEvent = function(dom){ var bindHandlers = function(){ c.event_create_div.find("button.btn-close").click(function(){ c.event_create_div.hide().empty(); dom.removeClass("active"); }) c.event_create_div.find("input[for=all_day][type=checkbox]").click(function(){ if($(this).is(":checked")) c.event_create_div.find("#non_all_day").hide() else c.event_create_div.find("#non_all_day").show() }) } if(!dom.hasClass("active")){ c.event_create_div.load(dom.attr("href"),function(){ c.event_create_div.show(); bindHandlers(); }) }else{ c.event_create_div.hide().empty(); } } this.newCalendars = function(){ if($('.color-picker').length > 0){ $('.color-picker').miniColors(); // just in category view } } this.displayEvent = function(){ c.event_quick_view_div.show() } c.initialize(); }