From 216ce80ceb465ddb95cd215bc20f083d1ccf89ee Mon Sep 17 00:00:00 2001 From: Naomi Aro Date: Wed, 8 Feb 2012 11:16:23 +0100 Subject: [PATCH] CC-3174 : showbuilder have to replace context menus on calendar page. --- .../controllers/ScheduleController.php | 5 +- .../schedule/full-calendar-functions.js | 28 ++++----- .../public/js/airtime/schedule/schedule.js | 62 +++++++++++++++---- 3 files changed, 65 insertions(+), 30 deletions(-) diff --git a/airtime_mvc/application/controllers/ScheduleController.php b/airtime_mvc/application/controllers/ScheduleController.php index 78e054fa7..710a7056c 100644 --- a/airtime_mvc/application/controllers/ScheduleController.php +++ b/airtime_mvc/application/controllers/ScheduleController.php @@ -41,7 +41,7 @@ class ScheduleController extends Zend_Controller_Action $baseUrl = $request->getBaseUrl(); $baseDir = dirname($_SERVER['SCRIPT_FILENAME']); - $this->view->headScript()->appendFile($baseUrl.'/js/contextmenu/jjmenu.js?'.filemtime($baseDir.'/js/contextmenu/jjmenu.js'),'text/javascript'); + $this->view->headScript()->appendFile($baseUrl.'/js/contextmenu/jquery.contextMenu.js?'.filemtime($baseDir.'/js/contextmenu/jquery.contextMenu.js'),'text/javascript'); $this->view->headScript()->appendFile($baseUrl.'/js/datatables/js/jquery.dataTables.js?'.filemtime($baseDir.'/js/datatables/js/jquery.dataTables.js'),'text/javascript'); $this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.pluginAPI.js?'.filemtime($baseDir.'/js/datatables/plugin/dataTables.pluginAPI.js'),'text/javascript'); @@ -50,7 +50,6 @@ class ScheduleController extends Zend_Controller_Action $this->view->headScript()->appendFile($baseUrl.'/js/airtime/schedule/full-calendar-functions.js?'.filemtime($baseDir.'/js/airtime/schedule/full-calendar-functions.js'),'text/javascript'); - $this->view->headScript()->appendFile($baseUrl.'/js/fullcalendar/fullcalendar.js?'.filemtime($baseDir.'/js/fullcalendar/fullcalendar.js'),'text/javascript'); $this->view->headScript()->appendFile($baseUrl.'/js/timepicker/jquery.ui.timepicker.js?'.filemtime($baseDir.'/js/timepicker/jquery.ui.timepicker.js'),'text/javascript'); $this->view->headScript()->appendFile($baseUrl.'/js/colorpicker/js/colorpicker.js?'.filemtime($baseDir.'/js/colorpicker/js/colorpicker.js'),'text/javascript'); @@ -63,7 +62,7 @@ class ScheduleController extends Zend_Controller_Action $this->view->headLink()->appendStylesheet($baseUrl.'/css/fullcalendar.css?'.filemtime($baseDir.'/css/fullcalendar.css')); $this->view->headLink()->appendStylesheet($baseUrl.'/css/colorpicker/css/colorpicker.css?'.filemtime($baseDir.'/css/colorpicker/css/colorpicker.css')); $this->view->headLink()->appendStylesheet($baseUrl.'/css/add-show.css?'.filemtime($baseDir.'/css/add-show.css')); - $this->view->headLink()->appendStylesheet($baseUrl.'/css/contextmenu.css?'.filemtime($baseDir.'/css/contextmenu.css')); + $this->view->headLink()->appendStylesheet($baseUrl.'/css/jquery.contextMenu.css?'.filemtime($baseDir.'/css/jquery.contextMenu.css')); Application_Model_Schedule::createNewFormSections($this->view); 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 cb78ee285..978b55523 100644 --- a/airtime_mvc/public/js/airtime/schedule/full-calendar-functions.js +++ b/airtime_mvc/public/js/airtime/schedule/full-calendar-functions.js @@ -6,7 +6,7 @@ function scheduleRefetchEvents(json) { if(json.show_error == true){ - alert("The show instance doesn't exist anymore!") + alert("The show instance doesn't exist anymore!"); } if(json.show_id) { var dialog_id = parseInt($("#add_show_id").val(), 10); @@ -41,9 +41,9 @@ function openAddShowForm() { $.mask.masks = $.extend($.mask.masks,{ date:{ mask: '9999-19-39', selectCharsOnFocus: true, autoTab: false}, time:{ mask: '29:69', selectCharsOnFocus: true, autoTab: false} - }) + }); - $('input:text').setMask() + $('input:text').setMask(); } function makeAddShowButton(){ @@ -280,14 +280,10 @@ function eventRender(event, element, view) { } function eventAfterRender( event, element, view ) { - $(element) - .jjmenu("click", - [{get:"/Schedule/make-context-menu/format/json/id/#id#"}], - {id: event.id}, - {xposition: "mouse", yposition: "mouse"}); + $(element).find(".small-icon").live('mouseover',function(){ addQtipToSCIcons($(this)); - }) + }); } function eventDrop(event, dayDelta, minuteDelta, allDay, revertFunc, jsEvent, ui, view) { @@ -354,7 +350,7 @@ function checkSCUploadStatus(){ $("span[id="+id+"]").removeClass("progress").addClass("sc-error"); } }); - }) + }); } function addQtipToSCIcons(ele){ @@ -376,7 +372,7 @@ function addQtipToSCIcons(ele){ show: { ready: true // Needed to make it show on first mouseover event } - }) + }); }else if($(ele).hasClass("soundcloud")){ $(ele).qtip({ content: { @@ -386,7 +382,7 @@ function addQtipToSCIcons(ele){ type: "post", data: ({format: "json", id : id, type: "file"}), success: function(json, status){ - this.set('content.text', "The soundcloud id for this file is: "+json.sc_id) + this.set('content.text', "The soundcloud id for this file is: "+json.sc_id); } } }, @@ -402,7 +398,7 @@ function addQtipToSCIcons(ele){ show: { ready: true // Needed to make it show on first mouseover event } - }) + }); }else if($(ele).hasClass("sc-error")){ $(ele).qtip({ content: { @@ -413,7 +409,7 @@ function addQtipToSCIcons(ele){ data: ({format: "json", id : id, type: "show"}), success: function(json, status){ this.set('content.text', "There was error while uploading to soundcloud.
"+"Error code: "+json.error_code+ - "
"+"Error msg: "+json.error_msg+"
") + "
"+"Error msg: "+json.error_msg+"
"); } } }, @@ -429,7 +425,7 @@ function addQtipToSCIcons(ele){ show: { ready: true // Needed to make it show on first mouseover event } - }) + }); } } @@ -442,4 +438,4 @@ function alertShowErrorAndReload(){ $(document).ready(function(){ setInterval( "checkSCUploadStatus()", 5000 ); -}) +}); diff --git a/airtime_mvc/public/js/airtime/schedule/schedule.js b/airtime_mvc/public/js/airtime/schedule/schedule.js index 9d6d085e1..726bd3c4e 100644 --- a/airtime_mvc/public/js/airtime/schedule/schedule.js +++ b/airtime_mvc/public/js/airtime/schedule/schedule.js @@ -208,22 +208,13 @@ function uploadToSoundCloud(show_instance_id){ if(span.length == 0){ span = $(window.triggerElement).find(".soundcloud"); span.removeClass("soundcloud") - .addClass("progress") + .addClass("progress"); }else{ span.removeClass("recording") - .addClass("progress"); + .addClass("progress"); } } -//used by jjmenu -function getId() { - var tr_id = $(this.triggerElement).attr("id"); - tr_id = tr_id.split("_"); - - return tr_id[1]; -} -//end functions used by jjmenu - function buildContentDialog(json){ if(json.show_error == true){ alertShowErrorAndReload(); @@ -380,4 +371,53 @@ function alertShowErrorAndReload(){ $(window).load(function() { $.ajax({ url: "/Api/calendar-init/format/json", dataType:"json", success:createFullCalendar , error:function(jqXHR, textStatus, errorThrown){}}); + + + $.contextMenu({ + selector: 'div.fc-event', + trigger: "left", + ignoreRightClick: true, + + build: function($el, e) { + var x, request, data, screen, items, callback, $tr; + + $tr = $el.parent(); + data = $tr.data("aData"); + screen = $tr.data("screen"); + + function processMenuItems(oItems) { + + //define a download callback. + if (oItems.download !== undefined) { + + callback = function() { + document.location.href = oItems.download.url; + }; + oItems.download.callback = callback; + } + + items = oItems; + } + + request = $.ajax({ + url: "/library/context-menu", + type: "GET", + data: {id : data.id, type: data.ftype, format: "json", "screen": screen}, + dataType: "json", + async: false, + success: function(json){ + processMenuItems(json.items); + } + }); + + return { + items: items, + determinePosition : function($menu, x, y) { + $menu.css('display', 'block') + .position({ my: "left top", at: "right top", of: this, offset: "-20 10", collision: "fit"}) + .css('display', 'none'); + } + }; + } + }); }); \ No newline at end of file