diff --git a/application/controllers/ScheduleController.php b/application/controllers/ScheduleController.php index 3bc619212..a283ac959 100644 --- a/application/controllers/ScheduleController.php +++ b/application/controllers/ScheduleController.php @@ -14,6 +14,7 @@ class ScheduleController extends Zend_Controller_Action $ajaxContext = $this->_helper->getHelper('AjaxContext'); $ajaxContext->addActionContext('event-feed', 'json') + ->addActionContext('make-context-menu', 'json') ->addActionContext('add-show-dialog', 'json') ->addActionContext('add-show', 'json') ->addActionContext('move-show', 'json') @@ -33,24 +34,13 @@ class ScheduleController extends Zend_Controller_Action public function indexAction() { $this->view->headScript()->appendFile('/js/fullcalendar/fullcalendar.min.js','text/javascript'); - $this->view->headScript()->appendFile('/js/contextmenu/jquery.contextMenu.js','text/javascript'); + $this->view->headScript()->appendFile('/js/contextmenu/jjmenu.js','text/javascript'); $this->view->headScript()->appendFile('/js/datatables/js/jquery.dataTables.js','text/javascript'); $this->view->headScript()->appendFile('/js/airtime/schedule/full-calendar-functions.js','text/javascript'); $this->view->headScript()->appendFile('/js/airtime/schedule/schedule.js','text/javascript'); - $this->view->headLink()->appendStylesheet('/css/jquery.contextMenu.css'); + $this->view->headLink()->appendStylesheet('/css/contextmenu.css'); $this->view->headLink()->appendStylesheet('/css/fullcalendar.css'); - - $eventDefaultMenu = array(); - //$eventDefaultMenu[] = array('action' => '/Schedule/delete-show', 'text' => 'Delete'); - - $this->view->eventDefaultMenu = $eventDefaultMenu; - - $eventHostMenu[] = array('action' => '/Schedule/delete-show', 'text' => 'Delete'); - $eventHostMenu[] = array('action' => '/Schedule/schedule-show', 'text' => 'Schedule'); - $eventHostMenu[] = array('action' => '/Schedule/clear-show', 'text' => 'Clear'); - - $this->view->eventHostMenu = $eventHostMenu; } public function eventFeedAction() @@ -175,19 +165,42 @@ class ScheduleController extends Zend_Controller_Action public function deleteShowAction() { - $showId = $this->_getParam('showId'); - $date = $this->_getParam('date'); + $showId = $this->_getParam('id'); + $start_timestamp = $this->_getParam('start'); $userInfo = Zend_Auth::getInstance()->getStorage()->read(); $user = new User($userInfo->id, $userInfo->type); $show = new Show($user, $showId); - $show->deleteShow($date); + $show->deleteShow($start_timestamp); } public function makeContextMenuAction() { - // action body + $id = $this->_getParam('id'); + $start_timestamp = $this->_getParam('start'); + + $today_timestamp = date("Y-m-d H:i:s"); + + $params = '/format/json/id/#id#/start/#start#/end/#end#'; + + if(strtotime($today_timestamp) < strtotime($start_timestamp)) { + + $menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/delete-show'.$params, 'callback' => 'window["scheduleRefetchEvents"]'), + 'title' => 'Delete'); + + $menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/clear-show'.$params, 'callback' => 'window["scheduleRefetchEvents"]'), + 'title' => 'Clear'); + + $menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/schedule-show-dialog'.$params, 'callback' => 'window["buildScheduleDialog"]'), + 'title' => 'Schedule'); + } + else { + + } + + //returns format jjmenu is looking for. + die(json_encode($menu)); } public function scheduleShowAction() @@ -221,7 +234,7 @@ class ScheduleController extends Zend_Controller_Action public function clearShowAction() { $start = $this->_getParam('start'); - $showId = $this->_getParam('showId'); + $showId = $this->_getParam('id'); $userInfo = Zend_Auth::getInstance()->getStorage()->read(); $user = new User($userInfo->id, $userInfo->type); @@ -278,7 +291,7 @@ class ScheduleController extends Zend_Controller_Action { $start_timestamp = $this->_getParam('start'); $end_timestamp = $this->_getParam('end'); - $showId = $this->_getParam('showId'); + $showId = $this->_getParam('id'); $this->sched_sess->showId = $showId; $this->sched_sess->showStart = $start_timestamp; diff --git a/application/views/scripts/schedule/index.phtml b/application/views/scripts/schedule/index.phtml index 2c342ddc5..9f43c06f8 100644 --- a/application/views/scripts/schedule/index.phtml +++ b/application/views/scripts/schedule/index.phtml @@ -1,8 +1 @@
- - - diff --git a/public/css/contextmenu.css b/public/css/contextmenu.css index 1d5d4fe57..9a18e9dac 100644 --- a/public/css/contextmenu.css +++ b/public/css/contextmenu.css @@ -5,6 +5,7 @@ div.jjmenu { border-bottom:2px solid gray; border-right:1px solid gray; padding:0px; + z-index: 100; } div.jj_menu_item { diff --git a/public/js/airtime/library/context-menu.js b/public/js/airtime/library/context-menu.js deleted file mode 100644 index 23e0341dd..000000000 --- a/public/js/airtime/library/context-menu.js +++ /dev/null @@ -1,33 +0,0 @@ -/* -function contextMenu(action, el, pos) { - var method = action.split('/').pop(), - url, tr_id, id; - - tr_id = $(el).attr('id'); - id = tr_id.split("_").pop(); - url = '/'+action; - - if (method === 'delete') { - url = url + '/format/json'; - url = url + '/id/' + id; - $.post(url, function(json) { - - if(json.message) { - alert(json.message); - return; - } - - $("#library_display tr#" +tr_id).remove(); - }); - } - else if (method === 'add-item') { - url = url + '/format/json'; - url = url + '/id/' + id; - $.post(url, setSPLContent); - } -} -*/ - -function contextMenu() { - alert("callback"); -} diff --git a/public/js/airtime/library/quicksearch.js b/public/js/airtime/library/quicksearch.js deleted file mode 100644 index 2cb84d12c..000000000 --- a/public/js/airtime/library/quicksearch.js +++ /dev/null @@ -1,28 +0,0 @@ -function setUpQuickSearch() { - - $("#library_quick_search input").keyup(function(ev){ - var url, string; - //alert(x); - - url = "/Library/quick-search/format/json"; - string = $(this).val(); - - $.post(url, {search: string}, function(json){ - var html, data; - //hacky way until I can figure out paginator better. - html = json.html.replace(/quick-search\/format\/json/g, "index"); - - var el = $(html); - - data = el.find("tr:not(:first-child)"); - setLibraryContents(data); - - var lib = $("#library_content"); - - lib.find("div.paginationControl").remove(); - lib.append(el[2]); - - }); - }); - -} diff --git a/public/js/airtime/schedule/full-calendar-functions.js b/public/js/airtime/schedule/full-calendar-functions.js index 3a078dfdc..337be235d 100644 --- a/public/js/airtime/schedule/full-calendar-functions.js +++ b/public/js/airtime/schedule/full-calendar-functions.js @@ -59,20 +59,22 @@ function eventRender(event, element, view) { } function eventAfterRender( event, element, view ) { - var today = new Date(); - if(event.isHost === true && event.start > today) { - $(element).contextMenu( - {menu: 'schedule_event_host_menu'}, eventMenu - ); - } - else{ - $(element).contextMenu( - {menu: 'schedule_event_default_menu'}, eventMenu - ); - } + function getStartTS() { + var start = makeTimeStamp(event.start); + return start; + } - $(element).data({'event': event}); + function getEndTS() { + var start = makeTimeStamp(event.end); + return start; + } + + $(element) + .jjmenu("rightClick", + [{get:"/Schedule/make-context-menu/format/json/id/#id#/start/#start#/end/#end#"}], + {id: event.id, start: getStartTS, end: getEndTS}, + {xposition: "mouse", yposition: "mouse"}); } function eventClick(event, jsEvent, view) { diff --git a/public/js/airtime/schedule/schedule.js b/public/js/airtime/schedule/schedule.js index d10b23487..de32a389f 100644 --- a/public/js/airtime/schedule/schedule.js +++ b/public/js/airtime/schedule/schedule.js @@ -165,69 +165,29 @@ function makeScheduleDialog(dialog, json) { setScheduleDialogEvents(dialog); } -function openScheduleDialog(show) { - var url, start_date, end_date; +function buildScheduleDialog(json){ + var dialog = $(json.dialog); - url = '/Schedule/schedule-show-dialog/format/json'; - - start_date = makeTimeStamp(show.start); - end_date = makeTimeStamp(show.end); + makeScheduleDialog(dialog, json); - $.post(url, - {start: start_date, end: end_date, showId: show.id}, - function(json){ - var dialog = $(json.dialog); + dialog.dialog({ + autoOpen: false, + title: 'Schedule Playlist', + width: 1100, + height: 500, + modal: true, + close: closeDialog, + buttons: {"Ok": function() { + dialog.remove(); + $("#schedule_calendar").fullCalendar( 'refetchEvents' ); + }} + }); - makeScheduleDialog(dialog, json, show); - - dialog.dialog({ - autoOpen: false, - title: 'Schedule Playlist', - width: 1100, - height: 500, - modal: true, - close: closeDialog, - buttons: {"Ok": function() { - dialog.remove(); - $("#schedule_calendar").fullCalendar( 'refetchEvents' ); - }} - }); - - dialog.dialog('open'); - }); + dialog.dialog('open'); } -function eventMenu(action, el, pos) { - var method, event, start_timestamp, url; - - method = action.split('/').pop(); - event = $(el).data('event'); - start_timestamp = makeTimeStamp(event.start); - - if (method === 'delete-show') { - - url = '/Schedule/delete-show'; - - $.post(action, - {format: "json", showId: event.id, date: start_timestamp}, - function(json){ - $("#schedule_calendar").fullCalendar( 'refetchEvents' ); - }); - } - else if (method === 'schedule-show') { - - openScheduleDialog(event); - } - else if (method === 'clear-show') { - - url = '/Schedule/clear-show'; - - $.post(url, - {format: "json", start: start_timestamp, showId: event.id}, - function(json){ - $("#schedule_calendar").fullCalendar( 'refetchEvents' ); - }); - } +function scheduleRefetchEvents() { + $("#schedule_calendar").fullCalendar( 'refetchEvents' ); } $(document).ready(function() { @@ -244,7 +204,7 @@ $(document).ready(function() { events: getFullCalendarEvents, - //callbacks (from full-calendar-functions.js + //callbacks (in full-calendar-functions.js) dayClick: dayClick, eventRender: eventRender, eventAfterRender: eventAfterRender, @@ -253,9 +213,7 @@ $(document).ready(function() { eventMouseout: eventMouseout, eventDrop: eventDrop, eventResize: eventResize - }); - }); $(window).load(function() {