diff --git a/airtime_mvc/application/controllers/ScheduleController.php b/airtime_mvc/application/controllers/ScheduleController.php index 49f4ff723..cd48ccb13 100644 --- a/airtime_mvc/application/controllers/ScheduleController.php +++ b/airtime_mvc/application/controllers/ScheduleController.php @@ -9,6 +9,7 @@ class ScheduleController extends Zend_Controller_Action { $ajaxContext = $this->_helper->getHelper('AjaxContext'); $ajaxContext->addActionContext('event-feed', 'json') + ->addActionContext('event-feed-preload', 'json') ->addActionContext('make-context-menu', 'json') ->addActionContext('add-show-dialog', 'json') ->addActionContext('add-show', 'json') @@ -88,30 +89,13 @@ class ScheduleController extends Zend_Controller_Action $this->view->headLink()->appendStylesheet($baseUrl.'css/showbuilder.css?'.$CC_CONFIG['airtime_version']); //End Show builder JS/CSS requirements + Application_Model_Schedule::createNewFormSections($this->view); - $user = Application_Model_User::getCurrentUser(); - if ($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) { $this->view->preloadShowForm = true; } - $userInfo = Zend_Auth::getInstance()->getStorage()->read(); - $user = new Application_Model_User($userInfo->id); - if ($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) { - $editable = true; - } else { - $editable = false; - } - - $calendar_interval = Application_Model_Preference::GetCalendarTimeInterval(); - if ($calendar_interval == "agendaDay") { - } else if ($calendar_interval == "agendaWeek") { - } else if ($calendar_interval == "month") { - } - list($start, $end) = Application_Model_Show::getStartEndCurrentMonthView(); - $events = &Application_Model_Show::getFullCalendarEvents($start, $end, $editable); - $this->view->headScript()->appendScript( "var calendarPref = {};\n". "calendarPref.weekStart = ".Application_Model_Preference::GetWeekStartDay().";\n". @@ -120,7 +104,7 @@ class ScheduleController extends Zend_Controller_Action "calendarPref.timeScale = '".Application_Model_Preference::GetCalendarTimeScale()."';\n". "calendarPref.timeInterval = ".Application_Model_Preference::GetCalendarTimeInterval().";\n". "calendarPref.weekStartDay = ".Application_Model_Preference::GetWeekStartDay().";\n". - "var calendarEvents = ".json_encode($events).";" + "var calendarEvents = null;" ); } @@ -133,16 +117,29 @@ class ScheduleController extends Zend_Controller_Action $userInfo = Zend_Auth::getInstance()->getStorage()->read(); $user = new Application_Model_User($userInfo->id); - if ($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) { - $editable = true; - } else { - $editable = false; - } + $editable = $user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER)); $events = &Application_Model_Show::getFullCalendarEvents($start, $end, $editable); $this->view->events = $events; } + public function eventFeedPreloadAction() + { + $userInfo = Zend_Auth::getInstance()->getStorage()->read(); + $user = new Application_Model_User($userInfo->id); + $editable = $user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER)); + + $calendar_interval = Application_Model_Preference::GetCalendarTimeInterval(); + if ($calendar_interval == "agendaDay") { + } else if ($calendar_interval == "agendaWeek") { + } else if ($calendar_interval == "month") { + } + list($start, $end) = Application_Model_Show::getStartEndCurrentMonthView(); + $events = &Application_Model_Show::getFullCalendarEvents($start, $end, $editable); + + $this->view->events = $events; + } + public function getCurrentShowAction() { $currentShow = Application_Model_Show::getCurrentShow(); diff --git a/airtime_mvc/public/js/airtime/schedule/full-calendar-functions.js b/airtime_mvc/public/js/airtime/schedule/full-calendar-functions.js index 51cc4106a..2590bf29d 100644 --- a/airtime_mvc/public/js/airtime/schedule/full-calendar-functions.js +++ b/airtime_mvc/public/js/airtime/schedule/full-calendar-functions.js @@ -326,6 +326,17 @@ function eventResize( event, dayDelta, minuteDelta, revertFunc, jsEvent, ui, vie }); } +function preload () { + var url = baseUrl+'Schedule/event-feed-preload'; + var d = new Date(); + + $.post(url, {format: "json", cachep: d.getTime()}, function(json){ + calendarEvents = json.events; + createFullCalendar({calendarInit: calendarPref}); + }); +} +preload(); + var initialLoad = true; function getFullCalendarEvents(start, end, callback) { diff --git a/airtime_mvc/public/js/airtime/schedule/schedule.js b/airtime_mvc/public/js/airtime/schedule/schedule.js index beb1381cd..3c4f9fd3b 100644 --- a/airtime_mvc/public/js/airtime/schedule/schedule.js +++ b/airtime_mvc/public/js/airtime/schedule/schedule.js @@ -328,10 +328,6 @@ function alertShowErrorAndReload(){ } $(document).ready(function() { - var data = {}; - data.calendarInit = calendarPref; - createFullCalendar(data); - setInterval(checkCalendarSCUploadStatus, 5000); $.contextMenu({