/** * * Full Calendar callback methods. * */ function scheduleRefetchEvents() { $("#schedule_calendar").fullCalendar( 'refetchEvents' ); } function openAddShowForm() { if($("#add-show-form").length == 1) { if( ($("#add-show-form").css('display')=='none')) { $("#add-show-form").show(); var windowWidth = $(window).width(); // margin on showform are 16 px on each side var calendarWidth = 100-(($("#schedule-add-show").width() + (16 * 4))/windowWidth*100); var widthPercent = parseInt(calendarWidth)+"%"; $("#schedule_calendar").css("width", widthPercent); $("#schedule_calendar").fullCalendar('render'); } $("#schedule-show-what").show(0, function(){ $add_show_name = $("#add_show_name"); $add_show_name.focus(); $add_show_name.select(); }); } } function makeAddShowButton(){ $('.fc-header-left') .append('') .append('Show') .find('span.fc-button:last > a') .click(function(){ openAddShowForm(); removeAddShowButton(); }); } function removeAddShowButton(){ var aTag = $('.fc-header-left') .find("span.fc-button:last > a"); var span = aTag.parent(); span.prev().remove(); span.remove(); } function makeTimeStamp(date){ var sy, sm, sd, h, m, s, timestamp; sy = date.getFullYear(); sm = date.getMonth() + 1; sd = date.getDate(); h = date.getHours(); m = date.getMinutes(); s = date.getSeconds(); timestamp = sy+"-"+ sm +"-"+ sd +" "+ h +":"+ m +":"+ s; return timestamp; } function dayClick(date, allDay, jsEvent, view) { var now, today, selected, chosenDate, chosenTime; now = new Date(); if(view.name === "month") { today = new Date(now.getFullYear(), now.getMonth(), now.getDate()); selected = new Date(date.getFullYear(), date.getMonth(), date.getDate()); } else { today = new Date(now.getFullYear(), now.getMonth(), now.getDate(), now.getHours(), now.getMinutes()); selected = new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes()); } if(selected >= today) { var addShow = $('.add-button'); //remove the +show button if it exists. if(addShow.length == 1){ var span = $(addShow).parent(); $(span).prev().remove(); $(span).remove(); } chosenDate = selected.getFullYear(); var month = selected.getMonth() + 1; if(month < 10) { chosenDate = chosenDate+'-0'+month; } else { chosenDate = chosenDate+'-'+month; } var day = selected.getDate(); if(day < 10) { chosenDate = chosenDate+'-0'+day; } else { chosenDate = chosenDate+'-'+day; } var min = selected.getMinutes(); var hours = selected.getHours(); if(min < 10){ chosenTime = hours+":0"+min; } else { chosenTime = hours+":"+min; } if(hours < 10){ chosenTime = "0"+chosenTime; } var endHour = hours + 1; var chosenEndTime; if(min < 10){ chosenEndTime = endHour+":0"+min; } else { chosenEndTime = endHour+":"+min; } if(endHour < 10){ chosenEndTime = "0"+chosenEndTime; } $("#add_show_start_date").val(chosenDate); $("#add_show_end_date_no_repeat").val(chosenDate); $("#add_show_end_date").datepicker("option", "minDate", chosenDate); $("#add_show_end_date").val(chosenDate); $("#add_show_start_time").val(chosenTime); $("#add_show_end_time").val(chosenEndTime); $("#add_show_duration").val('1h'); $("#schedule-show-when").show(); openAddShowForm(); } } function viewDisplay( view ) { if(view.name === 'agendaDay' || view.name === 'agendaWeek') { var calendarEl = this; var select = $('