CC-3174 : showbuilder
refactoring playlist to work with group add/delete by resource id and using transactions.
This commit is contained in:
parent
bdc9707052
commit
46fdf56b70
|
@ -8,8 +8,8 @@ class PlaylistController extends Zend_Controller_Action
|
||||||
{
|
{
|
||||||
$ajaxContext = $this->_helper->getHelper('AjaxContext');
|
$ajaxContext = $this->_helper->getHelper('AjaxContext');
|
||||||
$ajaxContext->addActionContext('add-items', 'json')
|
$ajaxContext->addActionContext('add-items', 'json')
|
||||||
->addActionContext('move-item', 'json')
|
->addActionContext('move-items', 'json')
|
||||||
->addActionContext('delete-item', 'json')
|
->addActionContext('delete-items', 'json')
|
||||||
->addActionContext('set-fade', 'json')
|
->addActionContext('set-fade', 'json')
|
||||||
->addActionContext('set-cue', 'json')
|
->addActionContext('set-cue', 'json')
|
||||||
->addActionContext('new', 'json')
|
->addActionContext('new', 'json')
|
||||||
|
@ -165,7 +165,7 @@ class PlaylistController extends Zend_Controller_Action
|
||||||
$ids = $this->_getParam('ids');
|
$ids = $this->_getParam('ids');
|
||||||
$ids = (!is_array($ids)) ? array($ids) : $ids;
|
$ids = (!is_array($ids)) ? array($ids) : $ids;
|
||||||
$afterItem = $this->_getParam('afterItem', null);
|
$afterItem = $this->_getParam('afterItem', null);
|
||||||
|
//$afterItem = (!is_numeric($afterItem)) ? null : intval($afterItem);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$pl = $this->getPlaylist();
|
$pl = $this->getPlaylist();
|
||||||
|
@ -184,11 +184,12 @@ class PlaylistController extends Zend_Controller_Action
|
||||||
$this->createUpdateResponse($pl);
|
$this->createUpdateResponse($pl);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function moveItemAction()
|
public function moveItemsAction()
|
||||||
{
|
{
|
||||||
$ids = $this->_getParam('ids');
|
$ids = $this->_getParam('ids');
|
||||||
$ids = (!is_array($ids)) ? array($ids) : $ids;
|
$ids = (!is_array($ids)) ? array($ids) : $ids;
|
||||||
$afterItem = $this->_getParam('afterItem', null);
|
$afterItem = $this->_getParam('afterItem', null);
|
||||||
|
//$afterItem = (!is_numeric($afterItem)) ? null : intval($afterItem);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$pl = $this->getPlaylist();
|
$pl = $this->getPlaylist();
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
<div class="wrapper">
|
<div class="wrapper">
|
||||||
<!--Set to z-index 254 to make it lower than the top-panel and the ZFDebug info bar, but higher than the side-playlist-->
|
<!--Set to z-index 254 to make it lower than the top-panel and the ZFDebug info bar, but higher than the side-playlist-->
|
||||||
<div id="library_content" class="tabs ui-widget ui-widget-content block-shadow alpha-block padded" style="z-index:254"><?php echo $this->layout()->library ?></div>
|
<div id="library_content" class="tabs ui-widget ui-widget-content block-shadow alpha-block padded" style="z-index:254"><?php echo $this->layout()->library ?></div>
|
||||||
<div id="show_builder" style="width:600px;" class="ui-widget ui-widget-content block-shadow omega-block padded"><?php echo $this->layout()->builder ?></div>
|
<div id="show_builder" class="ui-widget ui-widget-content block-shadow omega-block padded"><?php echo $this->layout()->builder ?></div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -119,7 +119,11 @@ class Application_Model_Playlist {
|
||||||
return $this->pl->getDbDescription();
|
return $this->pl->getDbDescription();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSize() {
|
public function getLastModified($format = null) {
|
||||||
|
return $this->pl->getDbMtime($format);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getSize() {
|
||||||
|
|
||||||
return $this->pl->countCcPlaylistcontentss();
|
return $this->pl->countCcPlaylistcontentss();
|
||||||
}
|
}
|
||||||
|
@ -274,6 +278,55 @@ class Application_Model_Playlist {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
$contentsToMove = CcPlaylistcontentsQuery::create()
|
||||||
|
->filterByDbId($p_items, Criteria::IN)
|
||||||
|
->orderByDbPosition()
|
||||||
|
->find($this->con);
|
||||||
|
|
||||||
|
$otherContent = CcPlaylistcontentsQuery::create()
|
||||||
|
->filterByDbId($p_items, Criteria::NOT_IN)
|
||||||
|
->filterByDbPlaylistId($this->id)
|
||||||
|
->orderByDbPosition()
|
||||||
|
->find($this->con);
|
||||||
|
|
||||||
|
$pos = 0;
|
||||||
|
//moving items to beginning of the playlist.
|
||||||
|
if (is_null($p_afterItem)) {
|
||||||
|
Logging::log("moving items to beginning of playlist");
|
||||||
|
|
||||||
|
foreach ($contentsToMove as $item) {
|
||||||
|
Logging::log("item {$item->getDbId()} to pos {$pos}");
|
||||||
|
$item->setDbPosition($pos);
|
||||||
|
$item->save($this->con);
|
||||||
|
$pos = $pos + 1;
|
||||||
|
}
|
||||||
|
foreach ($otherContent as $item) {
|
||||||
|
Logging::log("item {$item->getDbId()} to pos {$pos}");
|
||||||
|
$item->setDbPosition($pos);
|
||||||
|
$item->save($this->con);
|
||||||
|
$pos = $pos + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Logging::log("moving items after {$p_afterItem}");
|
||||||
|
|
||||||
|
foreach ($otherContent as $item) {
|
||||||
|
Logging::log("item {$item->getDbId()} to pos {$pos}");
|
||||||
|
$item->setDbPosition($pos);
|
||||||
|
$item->save($this->con);
|
||||||
|
$pos = $pos + 1;
|
||||||
|
|
||||||
|
if ($item->getDbId() == $p_afterItem) {
|
||||||
|
foreach ($contentsToMove as $move) {
|
||||||
|
Logging::log("item {$move->getDbId()} to pos {$pos}");
|
||||||
|
$move->setDbPosition($pos);
|
||||||
|
$move->save($this->con);
|
||||||
|
$pos = $pos + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$this->con->commit();
|
$this->con->commit();
|
||||||
}
|
}
|
||||||
catch (Exception $e) {
|
catch (Exception $e) {
|
||||||
|
|
|
@ -15,5 +15,66 @@
|
||||||
*/
|
*/
|
||||||
class CcPlaylist extends BaseCcPlaylist {
|
class CcPlaylist extends BaseCcPlaylist {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the [optionally formatted] temporal [utime] column value.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param string $format The date/time format string (either date()-style or strftime()-style).
|
||||||
|
* If format is NULL, then the raw DateTime object will be returned.
|
||||||
|
* @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL
|
||||||
|
* @throws PropelException - if unable to parse/validate the date/time value.
|
||||||
|
*/
|
||||||
|
public function getDbUtime($format = 'Y-m-d H:i:s')
|
||||||
|
{
|
||||||
|
if ($this->utime === null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$dt = new DateTime($this->utime, new DateTimeZone("UTC"));
|
||||||
|
} catch (Exception $x) {
|
||||||
|
throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->utime, true), $x);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($format === null) {
|
||||||
|
// Because propel.useDateTimeClass is TRUE, we return a DateTime object.
|
||||||
|
return $dt;
|
||||||
|
} elseif (strpos($format, '%') !== false) {
|
||||||
|
return strftime($format, $dt->format('U'));
|
||||||
|
} else {
|
||||||
|
return $dt->format($format);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the [optionally formatted] temporal [mtime] column value.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param string $format The date/time format string (either date()-style or strftime()-style).
|
||||||
|
* If format is NULL, then the raw DateTime object will be returned.
|
||||||
|
* @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL
|
||||||
|
* @throws PropelException - if unable to parse/validate the date/time value.
|
||||||
|
*/
|
||||||
|
public function getDbMtime($format = 'Y-m-d H:i:s')
|
||||||
|
{
|
||||||
|
if ($this->mtime === null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$dt = new DateTime($this->mtime, new DateTimeZone("UTC"));
|
||||||
|
} catch (Exception $x) {
|
||||||
|
throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->mtime, true), $x);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($format === null) {
|
||||||
|
// Because propel.useDateTimeClass is TRUE, we return a DateTime object.
|
||||||
|
return $dt;
|
||||||
|
} elseif (strpos($format, '%') !== false) {
|
||||||
|
return strftime($format, $dt->format('U'));
|
||||||
|
} else {
|
||||||
|
return $dt->format($format);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // CcPlaylist
|
} // CcPlaylist
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
<button id="spl_new" class="ui-button" role="button" aria-disabled="false">New</button>
|
<button id="spl_new" class="ui-button ui-widget ui-state-default" role="button" aria-disabled="false">New</button>
|
||||||
<?php if (isset($this->pl)) : ?>
|
<?php if (isset($this->pl)) : ?>
|
||||||
<button id="spl_delete" class="ui-button" role="button" aria-disabled="false">Delete</button>
|
<button id="spl_delete" class="ui-button ui-widget ui-state-default" role="button" aria-disabled="false">Delete</button>
|
||||||
<a href="#" id="spl_crossfade" class="ui-button ui-button-icon-only ui-widget ui-state-default crossfade-main-button">
|
<a href="#" id="spl_crossfade" class="ui-button ui-button-icon-only ui-widget ui-state-default crossfade-main-button">
|
||||||
<span class="ui-icon crossfade-main-icon"></span><span class="ui-button-text">Playlist crossfade</span>
|
<span class="ui-icon crossfade-main-icon"></span><span class="ui-button-text">Playlist crossfade</span>
|
||||||
</a>
|
</a>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
<?php if (isset($this->pl)) : ?>
|
<?php if (isset($this->pl)) : ?>
|
||||||
|
<input id="pl_id" type="hidden" value="<?php echo $this->pl->getId(); ?>"></input>
|
||||||
|
<input id="pl_lastMod" type="hidden" value="<?php echo $this->pl->getLastModified('U'); ?>"></input>
|
||||||
<div class="playlist_title">
|
<div class="playlist_title">
|
||||||
<h3 id="spl_name">
|
<h3 id="spl_name">
|
||||||
<a id="playlist_name_display"><?php echo $this->pl->getName(); ?></a>
|
<a id="playlist_name_display"><?php echo $this->pl->getName(); ?></a>
|
||||||
|
|
|
@ -25,7 +25,7 @@ if (count($items)) : ?>
|
||||||
?>
|
?>
|
||||||
<div id="fade_<?php echo $i ?>" class="spl_fade_control ui-state-default"></div>
|
<div id="fade_<?php echo $i ?>" class="spl_fade_control ui-state-default"></div>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<span class="ui-icon ui-icon-closethick"></span>
|
<span id="remove_<?php echo $item["id"] ?>" class="ui-icon ui-icon-closethick"></span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="cues_<?php echo $i ?>" class="cue-edit clearfix" style="display: none">
|
<div id="cues_<?php echo $i ?>" class="cue-edit clearfix" style="display: none">
|
||||||
|
|
|
@ -27,7 +27,7 @@ function fnLibraryTableDrawCallback() {
|
||||||
},
|
},
|
||||||
*/
|
*/
|
||||||
cursor: 'pointer',
|
cursor: 'pointer',
|
||||||
connectToSortable: '#spl_sortable'
|
connectToSortable: '#side_playlist'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,6 +64,7 @@ function setupLibraryToolbar(oLibTable) {
|
||||||
{"format": "json", "mediaIds": aMediaIds, "schedIds": aSchedIds},
|
{"format": "json", "mediaIds": aMediaIds, "schedIds": aSchedIds},
|
||||||
function(json){
|
function(json){
|
||||||
oLibTT.fnSelectNone();
|
oLibTT.fnSelectNone();
|
||||||
|
oSchedTT.fnSelectNone();
|
||||||
oSchedTable.fnDraw();
|
oSchedTable.fnDraw();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -2,10 +2,123 @@
|
||||||
//Side Playlist Functions
|
//Side Playlist Functions
|
||||||
//--------------------------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
function stopAudioPreview() {
|
var AIRTIME = (function(AIRTIME){
|
||||||
// stop any preview playing
|
AIRTIME.playlist = {};
|
||||||
$('#jquery_jplayer_1').jPlayer('stop');
|
var mod = AIRTIME.playlist;
|
||||||
}
|
|
||||||
|
function stopAudioPreview() {
|
||||||
|
// stop any preview playing
|
||||||
|
$('#jquery_jplayer_1').jPlayer('stop');
|
||||||
|
}
|
||||||
|
|
||||||
|
function highlightActive(el) {
|
||||||
|
|
||||||
|
$(el).addClass("ui-state-active");
|
||||||
|
}
|
||||||
|
|
||||||
|
function unHighlightActive(el) {
|
||||||
|
|
||||||
|
$(el).removeClass("ui-state-active");
|
||||||
|
}
|
||||||
|
|
||||||
|
function redrawLib() {
|
||||||
|
var dt;
|
||||||
|
dt = $("#library_display").dataTable();
|
||||||
|
dt.fnStandingRedraw();
|
||||||
|
}
|
||||||
|
|
||||||
|
function setPlaylistContent(json) {
|
||||||
|
|
||||||
|
$('#spl_name > a')
|
||||||
|
.empty()
|
||||||
|
.append(json.name);
|
||||||
|
$('#spl_length')
|
||||||
|
.empty()
|
||||||
|
.append(json.length);
|
||||||
|
$('#fieldset-metadate_change textarea')
|
||||||
|
.empty()
|
||||||
|
.val(json.description);
|
||||||
|
$('#spl_sortable')
|
||||||
|
.empty()
|
||||||
|
.append(json.html);
|
||||||
|
|
||||||
|
redrawLib();
|
||||||
|
}
|
||||||
|
|
||||||
|
function getId() {
|
||||||
|
return parseInt($("#pl_id").val(), 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getModified() {
|
||||||
|
return parseInt($("#pl_lastMod").val(), 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
function openPlaylist(json) {
|
||||||
|
|
||||||
|
$("#side_playlist")
|
||||||
|
.empty()
|
||||||
|
.append(json.html);
|
||||||
|
}
|
||||||
|
|
||||||
|
mod.fnNew = function() {
|
||||||
|
var url;
|
||||||
|
|
||||||
|
stopAudioPreview();
|
||||||
|
url = '/Playlist/new';
|
||||||
|
|
||||||
|
$.post(url, {format: "json"}, function(json){
|
||||||
|
openPlaylist(json);
|
||||||
|
redrawLib();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
mod.fnDelete = function() {
|
||||||
|
var url, id, lastMod;
|
||||||
|
|
||||||
|
stopAudioPreview();
|
||||||
|
id = getId();
|
||||||
|
lastMod = getModified();
|
||||||
|
url = '/Playlist/delete';
|
||||||
|
|
||||||
|
$.post(url,
|
||||||
|
{format: "json", ids: id, modified: lastMod},
|
||||||
|
function(json){
|
||||||
|
openPlaylist(json);
|
||||||
|
redrawLib();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
mod.fnAddItems = function(aItem, iAfter) {
|
||||||
|
|
||||||
|
$.post("/playlist/add-items",
|
||||||
|
{format: "json", "ids": aItem, "afterItem": iAfter},
|
||||||
|
function(json){
|
||||||
|
setPlaylistContent(json);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
mod.fnMoveItems = function(aIds, iAfter) {
|
||||||
|
|
||||||
|
$.post("/playlist/move-items",
|
||||||
|
{format: "json", "ids": aIds, "afterItem": iAfter},
|
||||||
|
function(json){
|
||||||
|
setPlaylistContent(json);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
mod.fnDeleteItems = function(aItems) {
|
||||||
|
|
||||||
|
$.post("/playlist/delete-items",
|
||||||
|
{format: "json", "ids": aItems},
|
||||||
|
function(json){
|
||||||
|
setPlaylistContent(json);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
return AIRTIME;
|
||||||
|
|
||||||
|
}(AIRTIME || {}));
|
||||||
|
|
||||||
|
|
||||||
function isTimeValid(time) {
|
function isTimeValid(time) {
|
||||||
var regExpr = new RegExp("^\\d{2}[:]\\d{2}[:]\\d{2}([.]\\d{1,6})?$");
|
var regExpr = new RegExp("^\\d{2}[:]\\d{2}[:]\\d{2}([.]\\d{1,6})?$");
|
||||||
|
@ -167,16 +280,6 @@ function submitOnEnter(event) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function highlightActive(el) {
|
|
||||||
|
|
||||||
$(el).addClass("ui-state-active");
|
|
||||||
}
|
|
||||||
|
|
||||||
function unHighlightActive(el) {
|
|
||||||
|
|
||||||
$(el).removeClass("ui-state-active");
|
|
||||||
}
|
|
||||||
|
|
||||||
function openFadeEditor(event) {
|
function openFadeEditor(event) {
|
||||||
var pos, url, li;
|
var pos, url, li;
|
||||||
|
|
||||||
|
@ -212,137 +315,6 @@ function openCueEditor(event) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function redrawDataTablePage() {
|
|
||||||
var dt;
|
|
||||||
dt = $("#library_display").dataTable();
|
|
||||||
dt.fnStandingRedraw();
|
|
||||||
}
|
|
||||||
|
|
||||||
function setSPLContent(json) {
|
|
||||||
|
|
||||||
$('#spl_name > a')
|
|
||||||
.empty()
|
|
||||||
.append(json.name);
|
|
||||||
$('#spl_length')
|
|
||||||
.empty()
|
|
||||||
.append(json.length);
|
|
||||||
$('#fieldset-metadate_change textarea')
|
|
||||||
.empty()
|
|
||||||
.val(json.description);
|
|
||||||
$('#spl_sortable')
|
|
||||||
.empty()
|
|
||||||
.append(json.html);
|
|
||||||
|
|
||||||
//redraw the library list
|
|
||||||
redrawDataTablePage();
|
|
||||||
}
|
|
||||||
|
|
||||||
function addSPLItem(event, ui){
|
|
||||||
var url, tr, id, items, draggableOffset, elOffset, pos;
|
|
||||||
|
|
||||||
tr = ui.helper;
|
|
||||||
|
|
||||||
if(tr.get(0).tagName === 'LI')
|
|
||||||
return;
|
|
||||||
|
|
||||||
items = $(event.currentTarget).children();
|
|
||||||
|
|
||||||
draggableOffset = ui.offset;
|
|
||||||
|
|
||||||
$.each(items, function(i, val){
|
|
||||||
elOffset = $(this).offset();
|
|
||||||
|
|
||||||
if(elOffset.top > draggableOffset.top) {
|
|
||||||
pos = $(this).attr('id').split("_").pop();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
id = tr.attr('id').split("_").pop();
|
|
||||||
|
|
||||||
url = '/Playlist/add-item';
|
|
||||||
|
|
||||||
$.post(url, {format: "json", id: id, pos: pos}, setSPLContent);
|
|
||||||
}
|
|
||||||
|
|
||||||
function deleteSPLItem(event){
|
|
||||||
event.stopPropagation();
|
|
||||||
stopAudioPreview();
|
|
||||||
|
|
||||||
var url, pos;
|
|
||||||
|
|
||||||
pos = $(this).parent().parent().attr("id").split("_").pop();
|
|
||||||
url = '/Playlist/delete-item';
|
|
||||||
|
|
||||||
$.post(url, {format: "json", pos: pos}, setSPLContent);
|
|
||||||
}
|
|
||||||
|
|
||||||
function moveSPLItem(event, ui) {
|
|
||||||
var li, newPos, oldPos, url;
|
|
||||||
|
|
||||||
li = ui.item;
|
|
||||||
|
|
||||||
newPos = li.index();
|
|
||||||
oldPos = li.attr('id').split("_").pop();
|
|
||||||
|
|
||||||
url = '/Playlist/move-item';
|
|
||||||
|
|
||||||
$.post(url, {format: "json", oldPos: oldPos, newPos: newPos}, setSPLContent);
|
|
||||||
}
|
|
||||||
|
|
||||||
function noOpenPL(json) {
|
|
||||||
|
|
||||||
$("#side_playlist")
|
|
||||||
.empty()
|
|
||||||
.append(json.html)
|
|
||||||
.data("id", null);
|
|
||||||
|
|
||||||
$("#spl_new")
|
|
||||||
.button()
|
|
||||||
.click(newSPL);
|
|
||||||
}
|
|
||||||
|
|
||||||
function newSPL() {
|
|
||||||
var url;
|
|
||||||
|
|
||||||
stopAudioPreview();
|
|
||||||
url = '/Playlist/new';
|
|
||||||
|
|
||||||
$.post(url, {format: "json"}, function(json){
|
|
||||||
openDiffSPL(json);
|
|
||||||
|
|
||||||
//redraw the library list
|
|
||||||
redrawDataTablePage();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function deleteSPL() {
|
|
||||||
var url, id;
|
|
||||||
|
|
||||||
stopAudioPreview();
|
|
||||||
|
|
||||||
id = $("#side_playlist").data("id");
|
|
||||||
|
|
||||||
url = '/Playlist/delete';
|
|
||||||
|
|
||||||
$.post(url, {format: "json", ids: id}, function(json){
|
|
||||||
|
|
||||||
noOpenPL(json);
|
|
||||||
//redraw the library list
|
|
||||||
redrawDataTablePage();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function openDiffSPL(json) {
|
|
||||||
|
|
||||||
$("#side_playlist")
|
|
||||||
.empty()
|
|
||||||
.append(json.html)
|
|
||||||
.data("id", json.id);
|
|
||||||
|
|
||||||
setUpSPL();
|
|
||||||
}
|
|
||||||
|
|
||||||
function editName() {
|
function editName() {
|
||||||
var nameElement = $(this);
|
var nameElement = $(this);
|
||||||
var playlistName = nameElement.text();
|
var playlistName = nameElement.text();
|
||||||
|
@ -370,86 +342,249 @@ function editName() {
|
||||||
.focus();
|
.focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
function setUpSPL() {
|
|
||||||
|
|
||||||
|
$(document).ready(function() {
|
||||||
|
var playlist = $("#side_playlist"),
|
||||||
|
sortableConf;
|
||||||
|
|
||||||
var sortableConf = (function(){
|
function setUpSPL() {
|
||||||
|
|
||||||
|
/*
|
||||||
|
$("#spl_crossfade").on("click", function(){
|
||||||
|
|
||||||
|
if ($(this).hasClass("ui-state-active")) {
|
||||||
|
$(this).removeClass("ui-state-active");
|
||||||
|
$("#crossfade_main").hide();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$(this).addClass("ui-state-active");
|
||||||
|
|
||||||
|
var url = '/Playlist/set-playlist-fades';
|
||||||
|
|
||||||
|
$.get(url, {format: "json"}, function(json){
|
||||||
|
if(json.playlist_error == true){
|
||||||
|
alertPlaylistErrorAndReload();
|
||||||
|
}
|
||||||
|
$("#spl_fade_in_main").find("span")
|
||||||
|
.empty()
|
||||||
|
.append(json.fadeIn);
|
||||||
|
$("#spl_fade_out_main").find("span")
|
||||||
|
.empty()
|
||||||
|
.append(json.fadeOut);
|
||||||
|
|
||||||
|
$("#crossfade_main").show();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#playlist_name_display").on("click", editName);
|
||||||
|
|
||||||
|
$("#fieldset-metadate_change > legend").on("click", function(){
|
||||||
|
var descriptionElement = $(this).parent();
|
||||||
|
|
||||||
|
if(descriptionElement.hasClass("closed")) {
|
||||||
|
descriptionElement.removeClass("closed");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
descriptionElement.addClass("closed");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#description_save").on("click", function(){
|
||||||
|
var textarea = $("#fieldset-metadate_change textarea"),
|
||||||
|
description = textarea.val(),
|
||||||
|
url;
|
||||||
|
|
||||||
|
url = '/Playlist/set-playlist-description';
|
||||||
|
|
||||||
|
$.post(url, {format: "json", description: description}, function(json){
|
||||||
|
if(json.playlist_error == true){
|
||||||
|
alertPlaylistErrorAndReload();
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
textarea.val(json.playlistDescription);
|
||||||
|
}
|
||||||
|
|
||||||
|
$("#fieldset-metadate_change").addClass("closed");
|
||||||
|
|
||||||
|
// update the "Last Modified" time for this playlist
|
||||||
|
redrawDataTablePage();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#description_cancel").on("click", function(){
|
||||||
|
var textarea = $("#fieldset-metadate_change textarea"),
|
||||||
|
url;
|
||||||
|
|
||||||
|
url = '/Playlist/set-playlist-description';
|
||||||
|
|
||||||
|
$.post(url, {format: "json"}, function(json){
|
||||||
|
if(json.playlist_error == true){
|
||||||
|
alertPlaylistErrorAndReload();
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
textarea.val(json.playlistDescription);
|
||||||
|
}
|
||||||
|
|
||||||
|
$("#fieldset-metadate_change").addClass("closed");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#spl_fade_in_main span:first").on("blur", function(event){
|
||||||
|
event.stopPropagation();
|
||||||
|
|
||||||
|
var url, fadeIn, span;
|
||||||
|
|
||||||
|
span = $(this);
|
||||||
|
url = "/Playlist/set-playlist-fades";
|
||||||
|
fadeIn = $.trim(span.text());
|
||||||
|
|
||||||
|
if (!isTimeValid(fadeIn)){
|
||||||
|
showError(span, "please put in a time '00:00:00 (.000000)'");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$.post(url, {format: "json", fadeIn: fadeIn}, function(json){
|
||||||
|
if(json.playlist_error == true){
|
||||||
|
alertPlaylistErrorAndReload();
|
||||||
|
}
|
||||||
|
if(json.response.error) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
hideError(span);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#spl_fade_out_main span:first").on("blur", function(event){
|
||||||
|
event.stopPropagation();
|
||||||
|
|
||||||
|
var url, fadeIn, span;
|
||||||
|
|
||||||
|
span = $(this);
|
||||||
|
url = "/Playlist/set-playlist-fades";
|
||||||
|
fadeOut = $.trim(span.text());
|
||||||
|
|
||||||
|
if(!isTimeValid(fadeOut)){
|
||||||
|
showError(span, "please put in a time '00:00:00 (.000000)'");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$.post(url, {format: "json", fadeOut: fadeOut}, function(json){
|
||||||
|
if(json.playlist_error == true){
|
||||||
|
alertPlaylistErrorAndReload();
|
||||||
|
}
|
||||||
|
if(json.response.error) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
hideError(span);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#spl_fade_in_main span:first, #spl_fade_out_main span:first")
|
||||||
|
.on("keydown", submitOnEnter);
|
||||||
|
|
||||||
|
$("#crossfade_main > .ui-icon-closethick").on("click", function(){
|
||||||
|
$("#spl_crossfade").removeClass("ui-state-active");
|
||||||
|
$("#crossfade_main").hide();
|
||||||
|
});
|
||||||
|
*/
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function setPlaylistButtonEvents(el) {
|
||||||
|
|
||||||
|
$(el).delegate("#spl_new",
|
||||||
|
{"click": AIRTIME.playlist.fnNew});
|
||||||
|
|
||||||
|
$(el).delegate("#spl_delete",
|
||||||
|
{"click": AIRTIME.playlist.fnDelete});
|
||||||
|
}
|
||||||
|
|
||||||
|
//sets events dynamically for playlist entries (each row in the playlist)
|
||||||
|
function setPlaylistEntryEvents(el) {
|
||||||
|
|
||||||
|
$(el).delegate("#spl_sortable .ui-icon-closethick",
|
||||||
|
{"click": function(ev){
|
||||||
|
var id;
|
||||||
|
id = parseInt($(this).attr("id").split("_").pop(), 10);
|
||||||
|
AIRTIME.playlist.fnDeleteItems([id]);
|
||||||
|
}});
|
||||||
|
|
||||||
|
/*
|
||||||
|
$(el).delegate(".spl_fade_control",
|
||||||
|
{"click": openFadeEditor});
|
||||||
|
|
||||||
|
$(el).delegate(".spl_cue",
|
||||||
|
{"click": openCueEditor});
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
//sets events dynamically for the cue editor.
|
||||||
|
function setCueEvents(el) {
|
||||||
|
|
||||||
|
$(el).delegate(".spl_cue_in span",
|
||||||
|
{"focusout": changeCueIn,
|
||||||
|
"keydown": submitOnEnter});
|
||||||
|
|
||||||
|
$(el).delegate(".spl_cue_out span",
|
||||||
|
{"focusout": changeCueOut,
|
||||||
|
"keydown": submitOnEnter});
|
||||||
|
}
|
||||||
|
|
||||||
|
//sets events dynamically for the fade editor.
|
||||||
|
function setFadeEvents(el) {
|
||||||
|
|
||||||
|
$(el).delegate(".spl_fade_in span",
|
||||||
|
{"focusout": changeFadeIn,
|
||||||
|
"keydown": submitOnEnter});
|
||||||
|
|
||||||
|
$(el).delegate(".spl_fade_out span",
|
||||||
|
{"focusout": changeFadeOut,
|
||||||
|
"keydown": submitOnEnter});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
setPlaylistButtonEvents(playlist);
|
||||||
|
setPlaylistEntryEvents(playlist);
|
||||||
|
//setCueEvents(playlist);
|
||||||
|
//setFadeEvents(playlist);
|
||||||
|
|
||||||
|
sortableConf = (function(){
|
||||||
var origRow,
|
var origRow,
|
||||||
iItem,
|
|
||||||
iAfter,
|
|
||||||
setSPLContent,
|
|
||||||
fnAdd,
|
|
||||||
fnMove,
|
|
||||||
fnReceive,
|
fnReceive,
|
||||||
fnUpdate;
|
fnUpdate;
|
||||||
|
|
||||||
function redrawDataTablePage() {
|
|
||||||
var dt;
|
|
||||||
dt = $("#library_display").dataTable();
|
|
||||||
dt.fnStandingRedraw();
|
|
||||||
}
|
|
||||||
|
|
||||||
setSPLContent = function(json) {
|
|
||||||
|
|
||||||
$('#spl_name > a')
|
|
||||||
.empty()
|
|
||||||
.append(json.name);
|
|
||||||
$('#spl_length')
|
|
||||||
.empty()
|
|
||||||
.append(json.length);
|
|
||||||
$('#fieldset-metadate_change textarea')
|
|
||||||
.empty()
|
|
||||||
.val(json.description);
|
|
||||||
$('#spl_sortable')
|
|
||||||
.empty()
|
|
||||||
.append(json.html);
|
|
||||||
|
|
||||||
//redraw the library list
|
|
||||||
redrawDataTablePage();
|
|
||||||
}
|
|
||||||
|
|
||||||
fnAdd = function() {
|
|
||||||
|
|
||||||
$.post("/playlist/add-items",
|
|
||||||
{format: "json", "ids": iItem, "afterItem": iAfter},
|
|
||||||
function(json){
|
|
||||||
setSPLContent(json);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
fnMove = function() {
|
|
||||||
|
|
||||||
$.post("/showbuilder/schedule-move",
|
|
||||||
{"format": "json", "selectedItem": aSelect, "afterItem": aAfter},
|
|
||||||
function(json){
|
|
||||||
oTable.fnDraw();
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
fnReceive = function(event, ui) {
|
fnReceive = function(event, ui) {
|
||||||
origRow = ui.item;
|
origRow = ui.item;
|
||||||
};
|
};
|
||||||
|
|
||||||
fnUpdate = function(event, ui) {
|
fnUpdate = function(event, ui) {
|
||||||
var prev;
|
var prev,
|
||||||
|
aItem = [],
|
||||||
|
iAfter;
|
||||||
|
|
||||||
prev = ui.item.prev();
|
prev = ui.item.prev();
|
||||||
if (prev.hasClass("spl_empty") || prev.length === 0) {
|
if (prev.hasClass("spl_empty") || prev.length === 0) {
|
||||||
iAfter = null;
|
iAfter = undefined;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
iAfter = prev.attr("id").split("_").pop();
|
iAfter = parseInt(prev.attr("id").split("_").pop(), 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
//item was dragged in from library datatable
|
//item was dragged in from library datatable
|
||||||
if (origRow !== undefined) {
|
if (origRow !== undefined) {
|
||||||
iItem = origRow.data("aData").id;
|
aItem.push(origRow.data("aData").id);
|
||||||
origRow = undefined;
|
origRow = undefined;
|
||||||
fnAdd();
|
AIRTIME.playlist.fnAddItems(aItem, iAfter);
|
||||||
}
|
}
|
||||||
//item was reordered.
|
//item was reordered.
|
||||||
else {
|
else {
|
||||||
oItemData = ui.item.data("aData");
|
aItem.push(parseInt(ui.item.attr("id").split("_").pop(), 10));
|
||||||
fnMove();
|
AIRTIME.playlist.fnMoveItems(aItem, iAfter);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -469,199 +604,5 @@ function setUpSPL() {
|
||||||
};
|
};
|
||||||
}());
|
}());
|
||||||
|
|
||||||
$("#spl_sortable").sortable(sortableConf);
|
playlist.sortable(sortableConf);
|
||||||
|
|
||||||
$("#spl_remove_selected").click(deleteSPLItem);
|
|
||||||
|
|
||||||
$("#spl_new")
|
|
||||||
.button()
|
|
||||||
.click(newSPL);
|
|
||||||
|
|
||||||
$("#spl_crossfade").click(function(){
|
|
||||||
|
|
||||||
if($(this).hasClass("ui-state-active")) {
|
|
||||||
$(this).removeClass("ui-state-active");
|
|
||||||
$("#crossfade_main").hide();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$(this).addClass("ui-state-active");
|
|
||||||
|
|
||||||
var url = '/Playlist/set-playlist-fades';
|
|
||||||
|
|
||||||
$.get(url, {format: "json"}, function(json){
|
|
||||||
if(json.playlist_error == true){
|
|
||||||
alertPlaylistErrorAndReload();
|
|
||||||
}
|
|
||||||
$("#spl_fade_in_main").find("span")
|
|
||||||
.empty()
|
|
||||||
.append(json.fadeIn);
|
|
||||||
$("#spl_fade_out_main").find("span")
|
|
||||||
.empty()
|
|
||||||
.append(json.fadeOut);
|
|
||||||
|
|
||||||
$("#crossfade_main").show();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
$("#playlist_name_display").click(editName);
|
|
||||||
$("#fieldset-metadate_change > legend").click(function(){
|
|
||||||
var descriptionElement = $(this).parent();
|
|
||||||
|
|
||||||
if(descriptionElement.hasClass("closed")) {
|
|
||||||
descriptionElement.removeClass("closed");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
descriptionElement.addClass("closed");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
$("#description_save").click(function(){
|
|
||||||
var textarea = $("#fieldset-metadate_change textarea");
|
|
||||||
var description = textarea.val();
|
|
||||||
var url;
|
|
||||||
url = '/Playlist/set-playlist-description';
|
|
||||||
|
|
||||||
$.post(url, {format: "json", description: description}, function(json){
|
|
||||||
if(json.playlist_error == true){
|
|
||||||
alertPlaylistErrorAndReload();
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
textarea.val(json.playlistDescription);
|
|
||||||
}
|
|
||||||
|
|
||||||
$("#fieldset-metadate_change").addClass("closed");
|
|
||||||
|
|
||||||
// update the "Last Modified" time for this playlist
|
|
||||||
redrawDataTablePage();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
$("#description_cancel").click(function(){
|
|
||||||
var textarea = $("#fieldset-metadate_change textarea");
|
|
||||||
var url;
|
|
||||||
url = '/Playlist/set-playlist-description';
|
|
||||||
|
|
||||||
$.post(url, {format: "json"}, function(json){
|
|
||||||
if(json.playlist_error == true){
|
|
||||||
alertPlaylistErrorAndReload();
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
textarea.val(json.playlistDescription);
|
|
||||||
}
|
|
||||||
|
|
||||||
$("#fieldset-metadate_change").addClass("closed");
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
$("#spl_fade_in_main span:first").blur(function(event){
|
|
||||||
event.stopPropagation();
|
|
||||||
|
|
||||||
var url, fadeIn, span;
|
|
||||||
|
|
||||||
span = $(this);
|
|
||||||
url = "/Playlist/set-playlist-fades";
|
|
||||||
fadeIn = $.trim(span.text());
|
|
||||||
|
|
||||||
if(!isTimeValid(fadeIn)){
|
|
||||||
showError(span, "please put in a time '00:00:00 (.000000)'");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$.post(url, {format: "json", fadeIn: fadeIn}, function(json){
|
|
||||||
if(json.playlist_error == true){
|
|
||||||
alertPlaylistErrorAndReload();
|
|
||||||
}
|
|
||||||
if(json.response.error) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
hideError(span);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
$("#spl_fade_out_main span:first").blur(function(event){
|
|
||||||
event.stopPropagation();
|
|
||||||
|
|
||||||
var url, fadeIn, span;
|
|
||||||
|
|
||||||
span = $(this);
|
|
||||||
url = "/Playlist/set-playlist-fades";
|
|
||||||
fadeOut = $.trim(span.text());
|
|
||||||
|
|
||||||
if(!isTimeValid(fadeOut)){
|
|
||||||
showError(span, "please put in a time '00:00:00 (.000000)'");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$.post(url, {format: "json", fadeOut: fadeOut}, function(json){
|
|
||||||
if(json.playlist_error == true){
|
|
||||||
alertPlaylistErrorAndReload();
|
|
||||||
}
|
|
||||||
if(json.response.error) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
hideError(span);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
$("#spl_fade_in_main span:first, #spl_fade_out_main span:first")
|
|
||||||
.keydown(submitOnEnter);
|
|
||||||
|
|
||||||
$("#crossfade_main > .ui-icon-closethick").click(function(){
|
|
||||||
$("#spl_crossfade").removeClass("ui-state-active");
|
|
||||||
$("#crossfade_main").hide();
|
|
||||||
});
|
|
||||||
|
|
||||||
$("#spl_delete")
|
|
||||||
.button()
|
|
||||||
.click(deleteSPL);
|
|
||||||
}
|
|
||||||
|
|
||||||
//sets events dynamically for playlist entries (each row in the playlist)
|
|
||||||
function setPlaylistEntryEvents(el) {
|
|
||||||
|
|
||||||
$(el).delegate("#spl_sortable .ui-icon-closethick",
|
|
||||||
{"click": deleteSPLItem});
|
|
||||||
|
|
||||||
$(el).delegate(".spl_fade_control",
|
|
||||||
{"click": openFadeEditor});
|
|
||||||
|
|
||||||
$(el).delegate(".spl_cue",
|
|
||||||
{"click": openCueEditor});
|
|
||||||
}
|
|
||||||
|
|
||||||
//sets events dynamically for the cue editor.
|
|
||||||
function setCueEvents(el) {
|
|
||||||
|
|
||||||
$(el).delegate(".spl_cue_in span",
|
|
||||||
{"focusout": changeCueIn,
|
|
||||||
"keydown": submitOnEnter});
|
|
||||||
|
|
||||||
$(el).delegate(".spl_cue_out span",
|
|
||||||
{"focusout": changeCueOut,
|
|
||||||
"keydown": submitOnEnter});
|
|
||||||
}
|
|
||||||
|
|
||||||
//sets events dynamically for the fade editor.
|
|
||||||
function setFadeEvents(el) {
|
|
||||||
|
|
||||||
$(el).delegate(".spl_fade_in span",
|
|
||||||
{"focusout": changeFadeIn,
|
|
||||||
"keydown": submitOnEnter});
|
|
||||||
|
|
||||||
$(el).delegate(".spl_fade_out span",
|
|
||||||
{"focusout": changeFadeOut,
|
|
||||||
"keydown": submitOnEnter});
|
|
||||||
}
|
|
||||||
|
|
||||||
$(document).ready(function() {
|
|
||||||
var playlist = $("#side_playlist");
|
|
||||||
|
|
||||||
setUpSPL(playlist);
|
|
||||||
|
|
||||||
setPlaylistEntryEvents(playlist);
|
|
||||||
setCueEvents(playlist);
|
|
||||||
setFadeEvents(playlist);
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -192,6 +192,7 @@ $(document).ready(function() {
|
||||||
$.post( "/showbuilder/schedule-remove",
|
$.post( "/showbuilder/schedule-remove",
|
||||||
{"ids": ids, "format": "json"},
|
{"ids": ids, "format": "json"},
|
||||||
function(data) {
|
function(data) {
|
||||||
|
oTT.fnSelectNone();
|
||||||
oTable.fnDraw();
|
oTable.fnDraw();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -316,7 +317,8 @@ $(document).ready(function() {
|
||||||
fnAdd,
|
fnAdd,
|
||||||
fnMove,
|
fnMove,
|
||||||
fnReceive,
|
fnReceive,
|
||||||
fnUpdate;
|
fnUpdate,
|
||||||
|
oTT = TableTools.fnGetInstance('show_builder_table');
|
||||||
|
|
||||||
fnAdd = function() {
|
fnAdd = function() {
|
||||||
var aMediaIds = [],
|
var aMediaIds = [],
|
||||||
|
@ -328,6 +330,7 @@ $(document).ready(function() {
|
||||||
$.post("/showbuilder/schedule-add",
|
$.post("/showbuilder/schedule-add",
|
||||||
{"format": "json", "mediaIds": aMediaIds, "schedIds": aSchedIds},
|
{"format": "json", "mediaIds": aMediaIds, "schedIds": aSchedIds},
|
||||||
function(json){
|
function(json){
|
||||||
|
oTT.fnSelectNone();
|
||||||
oTable.fnDraw();
|
oTable.fnDraw();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue