CC-5450 : Refactor Media Management (Classes/DB) in Airtime
creating service function for column datatables settings script. context menu on right click, dblclick event now used for adding to shows/playlist.
This commit is contained in:
parent
eea17b9dcd
commit
fbe0b0a75d
|
@ -65,18 +65,7 @@ class LibraryController extends Zend_Controller_Action
|
|||
|
||||
//set audio columns for display of data.
|
||||
$mediaService = new Application_Service_MediaService();
|
||||
$columns = json_encode($mediaService->makeDatatablesColumns('AudioFile'));
|
||||
$script = "localStorage.setItem( 'datatables-audiofile-aoColumns', JSON.stringify($columns) ); ";
|
||||
|
||||
//set webstream columns for display of data.
|
||||
$columns = json_encode($mediaService->makeDatatablesColumns('Webstream'));
|
||||
$script .= "localStorage.setItem( 'datatables-webstream-aoColumns', JSON.stringify($columns) ); ";
|
||||
|
||||
//set playlist columns for display of data.
|
||||
$columns = json_encode($mediaService->makeDatatablesColumns('Playlist'));
|
||||
$script .= "localStorage.setItem( 'datatables-playlist-aoColumns', JSON.stringify($columns) ); ";
|
||||
|
||||
$this->view->headScript()->appendScript($script);
|
||||
$this->view->headScript()->appendScript($mediaService->createLibraryColumnsJavascript());
|
||||
|
||||
$this->view->obj = $mediaService->getSessionMediaObject();
|
||||
}
|
||||
|
|
|
@ -128,6 +128,11 @@ class ShowbuilderController extends Zend_Controller_Action
|
|||
|
||||
//only include library things on the page if the user can see it.
|
||||
if (!$disableLib) {
|
||||
|
||||
//set media columns for display of data.
|
||||
$mediaService = new Application_Service_MediaService();
|
||||
$this->view->headScript()->appendScript($mediaService->createLibraryColumnsJavascript());
|
||||
|
||||
$this->view->headScript()->appendFile($baseUrl.'js/airtime/library/events/lib_showbuilder.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
||||
$this->view->headScript()->appendFile($baseUrl.'js/airtime/library/lib_separate_table.js?'.$CC_CONFIG['airtime_version'], 'text/javascript');
|
||||
|
||||
|
@ -136,7 +141,7 @@ class ShowbuilderController extends Zend_Controller_Action
|
|||
$libraryTable = json_encode($data);
|
||||
$this->view->headScript()->appendScript("localStorage.setItem( 'datatables-library', JSON.stringify($libraryTable) );");
|
||||
} else {
|
||||
$this->view->headScript()->appendScript("localStorage.setItem( 'datatables-library', '' );");
|
||||
$this->view->headScript()->appendScript("localStorage.setItem( 'datatables-library', null );");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -145,7 +150,7 @@ class ShowbuilderController extends Zend_Controller_Action
|
|||
$timelineTable = json_encode($data);
|
||||
$this->view->headScript()->appendScript("localStorage.setItem( 'datatables-timeline', JSON.stringify($timelineTable) );");
|
||||
} else {
|
||||
$this->view->headScript()->appendScript("localStorage.setItem( 'datatables-timeline', '' );");
|
||||
$this->view->headScript()->appendScript("localStorage.setItem( 'datatables-timeline', null );");
|
||||
}
|
||||
|
||||
//populate date range form for show builder.
|
||||
|
|
|
@ -707,6 +707,23 @@ class Application_Service_MediaService
|
|||
}
|
||||
}
|
||||
|
||||
public function createLibraryColumnsJavascript() {
|
||||
|
||||
//set audio columns for display of data.
|
||||
$columns = json_encode(self::makeDatatablesColumns('AudioFile'));
|
||||
$script = "localStorage.setItem( 'datatables-audiofile-aoColumns', JSON.stringify($columns) ); ";
|
||||
|
||||
//set webstream columns for display of data.
|
||||
$columns = json_encode(self::makeDatatablesColumns('Webstream'));
|
||||
$script .= "localStorage.setItem( 'datatables-webstream-aoColumns', JSON.stringify($columns) ); ";
|
||||
|
||||
//set playlist columns for display of data.
|
||||
$columns = json_encode(self::makeDatatablesColumns('Playlist'));
|
||||
$script .= "localStorage.setItem( 'datatables-playlist-aoColumns', JSON.stringify($columns) ); ";
|
||||
|
||||
return $script;
|
||||
}
|
||||
|
||||
/*
|
||||
* @param $obj MediaItem object.
|
||||
* @return $service proper service for this item type.
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
sample playlist element here
|
||||
element_artist: ""
|
||||
element_id: 8041
|
||||
element_mp3: 6291
|
||||
element_position: 12
|
||||
element_title: "Mis-Adventures of Dirty Rice and Canned Beans"
|
||||
mime: "audio/mp3"
|
||||
type: 0
|
||||
uri: "/airtime_web_241/public/api/get-media/file/6291"
|
||||
*/
|
||||
|
||||
/*
|
||||
sample show element here
|
||||
"element_title":"Angel gets high (live)",
|
||||
"element_artist":"theAngelcy",
|
||||
"element_position":0,
|
||||
"element_id":1,
|
||||
"mime":"audio\/mp3",
|
||||
"type":0,
|
||||
"element_mp3":6630,
|
||||
"uri":"\/airtime_web_241\/public\/api\/get-media\/file\/6630"
|
||||
*/
|
||||
|
||||
/*
|
||||
sample audio file element here
|
||||
title
|
||||
artist
|
||||
mp3
|
||||
*/
|
|
@ -7,11 +7,8 @@ var AIRTIME = (function(AIRTIME) {
|
|||
|
||||
//stored in format chosenItems[tabname] = object of chosen ids for the tab.
|
||||
var chosenItems = {},
|
||||
LIB_SELECTED_CLASS = "lib-selected",
|
||||
//used for using dbclick vs click events on the library rows.
|
||||
alreadyclicked = false,
|
||||
alreadyclickedTimeout;
|
||||
|
||||
LIB_SELECTED_CLASS = "lib-selected";
|
||||
|
||||
function createDatatable(config) {
|
||||
|
||||
var table = $("#"+config.id).dataTable({
|
||||
|
@ -400,42 +397,31 @@ var AIRTIME = (function(AIRTIME) {
|
|||
}
|
||||
});
|
||||
|
||||
// call the context menu so we can prevent the event from
|
||||
// propagating.
|
||||
$library.on("click", 'td:not(.library_checkbox)', function(e) {
|
||||
$library.on("mousedown", 'td:not(.library_checkbox)', function(e) {
|
||||
//only trigger context menu on right click.
|
||||
if (e.which === 3) {
|
||||
var $el = $(this);
|
||||
|
||||
$el.contextMenu({x: e.pageX, y: e.pageY});
|
||||
}
|
||||
});
|
||||
|
||||
//perform the double click action on an item row.
|
||||
$library.on("dblclick", 'td:not(.library_checkbox)', function(e) {
|
||||
var $el = $(this),
|
||||
$tr,
|
||||
data;
|
||||
|
||||
var $el = $(this);
|
||||
|
||||
if (mod.alreadyclicked) {
|
||||
|
||||
// reset
|
||||
mod.alreadyclicked = false;
|
||||
// prevent this from happening
|
||||
clearTimeout(mod.alreadyclickedTimeout);
|
||||
|
||||
// do what needs to happen on double click.
|
||||
$tr = $el.parent();
|
||||
data = $tr.data("aData");
|
||||
mod.dblClickAdd(data);
|
||||
}
|
||||
else
|
||||
{
|
||||
mod.alreadyclicked = true;
|
||||
mod.alreadyclickedTimeout = setTimeout(function() {
|
||||
// reset when it happens
|
||||
mod.alreadyclicked = false;
|
||||
// do what needs to happen on single click.
|
||||
$el.contextMenu({x: e.pageX, y: e.pageY});
|
||||
}, 200); // <-- dblclick tolerance here
|
||||
}
|
||||
return false;
|
||||
});
|
||||
$tr = $el.parent();
|
||||
data = $tr.data("aData");
|
||||
mod.dblClickAdd(data);
|
||||
});
|
||||
|
||||
// begin context menu initialization.
|
||||
$.contextMenu({
|
||||
selector: '#lib_tabs td',
|
||||
trigger: "none",
|
||||
ignoreRightClick: true,
|
||||
ignoreRightClick: false,
|
||||
|
||||
build: function($el, e) {
|
||||
var data, items, $tr;
|
||||
|
|
Loading…
Reference in New Issue