diff --git a/airtime_mvc/application/controllers/LibraryController.php b/airtime_mvc/application/controllers/LibraryController.php index 3c07bc235..eff66ab05 100644 --- a/airtime_mvc/application/controllers/LibraryController.php +++ b/airtime_mvc/application/controllers/LibraryController.php @@ -38,7 +38,7 @@ class LibraryController extends Zend_Controller_Action $request = $this->getRequest(); $baseUrl = $request->getBaseUrl(); - $this->view->headScript()->appendFile($baseUrl.'/js/contextmenu/jjmenu.js','text/javascript'); + $this->view->headScript()->appendFile($baseUrl.'/js/contextmenu/jquery.contextMenu.js','text/javascript'); $this->view->headScript()->appendFile($baseUrl.'/js/datatables/js/jquery.dataTables.js','text/javascript'); $this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.pluginAPI.js','text/javascript'); @@ -52,7 +52,7 @@ class LibraryController extends Zend_Controller_Action $this->view->headScript()->appendFile($baseUrl.'/js/airtime/library/advancedsearch.js','text/javascript'); $this->view->headLink()->appendStylesheet($baseUrl.'/css/media_library.css'); - $this->view->headLink()->appendStylesheet($baseUrl.'/css/contextmenu.css'); + $this->view->headLink()->appendStylesheet($baseUrl.'/css/jquery.contextMenu.css'); $this->view->headLink()->appendStylesheet($baseUrl.'/css/datatables/css/ColVis.css'); $this->view->headLink()->appendStylesheet($baseUrl.'/css/datatables/css/ColReorder.css'); $this->view->headLink()->appendStylesheet($baseUrl.'/css/TableTools.css'); @@ -77,11 +77,6 @@ class LibraryController extends Zend_Controller_Action $request = $this->getRequest(); $baseUrl = $request->getBaseUrl(); - $params = '/format/json/id/#id#/type/#type#'; - - $paramsPop = str_replace('#id#', $id, $params); - $paramsPop = str_replace('#type#', $type, $paramsPop); - $userInfo = Zend_Auth::getInstance()->getStorage()->read(); $user = new Application_Model_User($userInfo->id); @@ -89,15 +84,23 @@ class LibraryController extends Zend_Controller_Action $file = Application_Model_StoredFile::Recall($id); - $menu[] = array('action' => array('type' => 'gourl', 'url' => '/Library/edit-file-md/id/#id#'), - 'title' => 'Edit Metadata'); + $menu["edit"] = array("name"=> "Edit Metadata", "icon" => "edit", "url" => "/library/edit-file-md/id/{$id}"); + + if ($user->isAdmin()) { + $menu["delete"] = array("name"=> "Delete", "icon" => "delete"); + } $url = $file->getRelativeFileUrl($baseUrl).'/download/true'; - $menu[] = array('action' => array('type' => 'gourl', 'url' => $url), - 'title' => 'Download'); + $menu["download"] = array("name" => "Download", "url" => $url); if (Application_Model_Preference::GetUploadToSoundcloudOption()) { + //create a menu separator + $menu["sep1"] = "-----------"; + + //create a sub menu for Soundcloud actions. + $menu["soundcloud"] = array("name" => "Soundcloud", "icon" => "soundcloud", "items" => array()); + $scid = $file->getSoundCloudId(); if (!is_null($scid)){ @@ -107,30 +110,24 @@ class LibraryController extends Zend_Controller_Action $text = "Upload to SoundCloud"; } - $menu[] = array('action' => array('type' => 'ajax', 'url' => '/Library/upload-file-soundcloud/id/#id#', - 'callback'=>"window['addProgressIcon']('$file_id')"),'title' => $text); - + $menu["soundcloud"]["items"]["upload"] = array("name" => $text, "url" => "/library/upload-file-soundcloud/id/{$id}"); if ($scid > 0){ - $link_to_file = $file->getSoundCloudLinkToFile(); - $menu[] = array('action' => array('type' => 'gourl', 'url' => $link_to_file, 'target' => '_blank'), - 'title' => 'View on Soundcloud'); + $url = $file->getSoundCloudLinkToFile(); + $menu["soundcloud"]["items"]["view"] = array("name" => "View on Soundcloud", "url" => $url); } } } else if ($type === "playlist") { if (!isset($this->pl_sess->id) || $this->pl_sess->id !== $id) { - $menu[] = array('action' => - array('type' => 'ajax', - 'url' => '/Playlist/edit'.$params, - 'callback' => 'window["openDiffSPL"]'), - 'title' => 'Edit'); + $menu["edit"] = array("name"=> "Edit", "icon" => "edit"); } + + $menu["delete"] = array("name"=> "Delete", "icon" => "delete"); } - //returns format jjmenu is looking for. - die(json_encode($menu)); + $this->view->items = $menu; } public function deleteAction() diff --git a/airtime_mvc/public/css/contextmenu/images/page_white_copy.png b/airtime_mvc/public/css/images/icon_copy.png similarity index 100% rename from airtime_mvc/public/css/contextmenu/images/page_white_copy.png rename to airtime_mvc/public/css/images/icon_copy.png diff --git a/airtime_mvc/public/css/contextmenu/images/cut.png b/airtime_mvc/public/css/images/icon_cut.png similarity index 100% rename from airtime_mvc/public/css/contextmenu/images/cut.png rename to airtime_mvc/public/css/images/icon_cut.png diff --git a/airtime_mvc/public/css/contextmenu/images/page_white_delete.png b/airtime_mvc/public/css/images/icon_delete.png similarity index 100% rename from airtime_mvc/public/css/contextmenu/images/page_white_delete.png rename to airtime_mvc/public/css/images/icon_delete.png diff --git a/airtime_mvc/public/css/contextmenu/images/door.png b/airtime_mvc/public/css/images/icon_door.png similarity index 100% rename from airtime_mvc/public/css/contextmenu/images/door.png rename to airtime_mvc/public/css/images/icon_door.png diff --git a/airtime_mvc/public/css/contextmenu/images/page_white_edit.png b/airtime_mvc/public/css/images/icon_edit.png similarity index 100% rename from airtime_mvc/public/css/contextmenu/images/page_white_edit.png rename to airtime_mvc/public/css/images/icon_edit.png diff --git a/airtime_mvc/public/css/contextmenu/images/page_white_paste.png b/airtime_mvc/public/css/images/icon_paste.png similarity index 100% rename from airtime_mvc/public/css/contextmenu/images/page_white_paste.png rename to airtime_mvc/public/css/images/icon_paste.png diff --git a/airtime_mvc/public/css/contextmenu/jquery.contextMenu.css b/airtime_mvc/public/css/jquery.contextMenu.css similarity index 80% rename from airtime_mvc/public/css/contextmenu/jquery.contextMenu.css rename to airtime_mvc/public/css/jquery.contextMenu.css index fc8d709f3..17c1555a9 100755 --- a/airtime_mvc/public/css/contextmenu/jquery.contextMenu.css +++ b/airtime_mvc/public/css/jquery.contextMenu.css @@ -36,7 +36,7 @@ } .context-menu-item { - padding: 2px 2px 2px 24px; + padding: 2px 2px 2px 28px; background-color: #EEE; position: relative; -moz-user-select: -moz-none; @@ -82,12 +82,13 @@ .context-menu-item.icon:before {} */ .context-menu-item.icon { min-height: 18px; background-repeat: no-repeat; background-position: 4px 2px; } -.context-menu-item.icon-edit { background-image: url(images/page_white_edit.png); } -.context-menu-item.icon-cut { background-image: url(images/cut.png); } -.context-menu-item.icon-copy { background-image: url(images/page_white_copy.png); } -.context-menu-item.icon-paste { background-image: url(images/page_white_paste.png); } -.context-menu-item.icon-delete { background-image: url(images/page_white_delete.png); } -.context-menu-item.icon-quit { background-image: url(images/door.png); } +.context-menu-item.icon-edit { background-image: url(images/icon_edit.png); } +.context-menu-item.icon-cut { background-image: url(images/icon_cut.png); } +.context-menu-item.icon-copy { background-image: url(images/icon_copy.png); } +.context-menu-item.icon-paste { background-image: url(images/icon_paste.png); } +.context-menu-item.icon-delete { background-image: url(images/icon_delete.png); } +.context-menu-item.icon-quit { background-image: url(images/icon_door.png); } +.context-menu-item.icon-soundcloud { background-image: url(images/icon_soundcloud.png); } /* vertically align inside labels */ .context-menu-input > label > * { vertical-align: top; } diff --git a/airtime_mvc/public/css/styles.css b/airtime_mvc/public/css/styles.css index 703d105c3..affe62851 100644 --- a/airtime_mvc/public/css/styles.css +++ b/airtime_mvc/public/css/styles.css @@ -128,10 +128,10 @@ select { /* Info Tooltip Ends */ /* Clearfix */ -.clearfix:after, li:after { content: "."; display: block; height: 0; clear: both; visibility: hidden;} -.clearfix, li { display: inline-block; } +.clearfix:after, #side_playlist li:after { content: "."; display: block; height: 0; clear: both; visibility: hidden;} +.clearfix, #side_playlist li { display: inline-block; } * html .clearfix, * html li { height: 1%;} -.clearfix, li { display: block; } +.clearfix, #side_playlist li { display: block; } /* Master Panel */ diff --git a/airtime_mvc/public/js/airtime/library/events/library_playlistbuilder.js b/airtime_mvc/public/js/airtime/library/events/library_playlistbuilder.js index a2aed00bc..a1e36f401 100644 --- a/airtime_mvc/public/js/airtime/library/events/library_playlistbuilder.js +++ b/airtime_mvc/public/js/airtime/library/events/library_playlistbuilder.js @@ -3,11 +3,16 @@ function fnLibraryTableRowCallback( nRow, aData, iDisplayIndex, iDisplayIndexFul $(nRow).attr("id", aData["tr_id"]); $(nRow).data("aData", aData); + //var oTT = TableTools.fnGetInstance('library_display'); + //oTT.fnSelect(el); + + /* $(nRow).find('td') .jjmenu("rightClick", [{get:"/Library/context-menu/format/json/id/#id#/type/#type#"}], {id: aData["id"], type: aData["ftype"]}, {xposition: "mouse", yposition: "mouse"}); + */ } function fnLibraryTableDrawCallback() { diff --git a/airtime_mvc/public/js/airtime/library/library.js b/airtime_mvc/public/js/airtime/library/library.js index 410736402..6a6d9523a 100644 --- a/airtime_mvc/public/js/airtime/library/library.js +++ b/airtime_mvc/public/js/airtime/library/library.js @@ -199,6 +199,15 @@ function addQtipToSCIcons(){ } function fnCreatedRow( nRow, aData, iDataIndex ) { + + //call the context menu so we can prevent the event from propagating. + $(nRow).find('td:not(.library_checkbox):not(.library_type)').click(function(e){ + var x; + + $(this).contextMenu(); + + return false; + }); //add a tool tip to appear when the user clicks on the type icon. $(nRow.children[1]).qtip({ @@ -369,4 +378,97 @@ $(document).ready(function() { //setInterval( "checkSCUploadStatus()", 5000 ); addQtipToSCIcons(); + + $.contextMenu({ + selector: 'td:not(.library_checkbox):not(.library_type)', + trigger: "left", + ignoreRightClick: true, + + build: function($el, e) { + var x, request, data, items, callback; + + data = $el.parent().data("aData"); + + function processMenuItems(oItems) { + + //define an edit callback. + if (oItems.edit !== undefined) { + + if (data.ftype === "audioclip") { + callback = function() { + document.location.href = oItems.edit.url; + }; + } + else { + + } + oItems.edit.callback = callback; + } + + //define a download callback. + if (oItems.download !== undefined) { + + callback = function() { + document.location.href = oItems.download.url; + }; + oItems.download.callback = callback; + } + //add callbacks for Soundcloud menu items. + if (oItems.soundcloud !== undefined) { + var soundcloud = oItems.soundcloud.items; + + //define an upload to soundcloud callback. + if (soundcloud.upload !== undefined) { + + callback = function() { + $.post(soundcloud.upload.url, function(){ + addProgressIcon(data.id); + }); + }; + soundcloud.upload.callback = callback; + } + + //define a view on soundcloud callback + if (soundcloud.view !== undefined) { + + callback = function() { + window.open(soundcloud.view.url); + }; + soundcloud.view.callback = callback; + } + } + + items = oItems; + } + + request = $.ajax({ + url: "/library/context-menu", + type: "GET", + data: {id : data.id, type: data.ftype, format: "json"}, + dataType: "json", + async: false, + success: function(json){ + processMenuItems(json.items); + } + }); + + + + // this callback is executed every time the menu is to be shown + // its results are destroyed every time the menu is hidden + // e is the original contextmenu event, containing e.pageX and e.pageY (amongst other data) + return { + callback: function(key, options) { + var m = "clicked: " + key; + window.console && console.log(m) || alert(m); + }, + 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'); + } + }; + } + }); });