2012-09-14 13:59:20 +00:00
|
|
|
//created on sep 14 2012
|
2012-09-14 07:20:01 +00:00
|
|
|
|
2012-09-14 13:59:20 +00:00
|
|
|
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;
|
|
|
|
}
|
2012-09-14 07:20:01 +00:00
|
|
|
});
|
2012-09-14 13:59:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
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();
|
|
|
|
});
|
2012-09-12 08:16:01 +00:00
|
|
|
|
2012-09-14 07:20:01 +00:00
|
|
|
$c_table
|
2012-09-14 13:59:20 +00:00
|
|
|
// .height(context_h-sum_h-64)
|
2012-09-14 07:20:01 +00:00
|
|
|
.find('.month_row')
|
|
|
|
.not('.month_row.header')
|
2012-09-14 13:59:20 +00:00
|
|
|
.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();
|
2012-09-14 07:20:01 +00:00
|
|
|
}
|
2012-09-12 08:16:01 +00:00
|
|
|
}
|
2012-09-14 13:59:20 +00:00
|
|
|
this.newCalendars = function(){
|
|
|
|
if($('.color-picker').length > 0){
|
|
|
|
$('.color-picker').miniColors(); // just in category view
|
|
|
|
}
|
2012-09-14 07:20:01 +00:00
|
|
|
}
|
2012-09-14 13:59:20 +00:00
|
|
|
this.displayEvent = function(){
|
|
|
|
|
|
|
|
c.event_quick_view_div.show()
|
2012-09-14 07:20:01 +00:00
|
|
|
}
|
2012-09-14 13:59:20 +00:00
|
|
|
c.initialize();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-09-14 07:20:01 +00:00
|
|
|
|