Completed smart block, playlist, and webstream editor form overhauls

* CC-6088: Smart Block form needs to have a form layout
* CC-6089: Editor view name fields must be made <input> fields
* CC-6103: Cannot create webstreams
* Reworked a big chunk of the smart block editor flow to send only the
  playlist contents back rather than the entire HTML fragment for the
  editor.
* Keep more of the playlist/smartblock editor view persistent across
  saves, generates, and shuffles.
This commit is contained in:
Albert Santoni 2015-08-27 19:00:23 -04:00
parent 98ac8fd851
commit b6f33f6083
13 changed files with 229 additions and 106 deletions

View File

@ -1,5 +1,6 @@
<?php <?php
class PlaylistController extends Zend_Controller_Action class PlaylistController extends Zend_Controller_Action
{ {
@ -534,8 +535,12 @@ class PlaylistController extends Zend_Controller_Action
if ($form->isValid($params)) { if ($form->isValid($params)) {
$this->setPlaylistNameDescAction(); $this->setPlaylistNameDescAction();
$bl->saveSmartBlockCriteria($params['data']); $bl->saveSmartBlockCriteria($params['data']);
$this->createUpdateResponse($bl);
$this->view->result = 0;
/*
$result['html'] = $this->createFullResponse($bl, true, true); $result['html'] = $this->createFullResponse($bl, true, true);
$result['result'] = 0; */
} else { } else {
$this->view->form = $form; $this->view->form = $form;
$this->view->unsavedName = $params['name']; $this->view->unsavedName = $params['name'];
@ -543,18 +548,21 @@ class PlaylistController extends Zend_Controller_Action
$viewPath = 'playlist/smart-block.phtml'; $viewPath = 'playlist/smart-block.phtml';
$this->view->obj = $bl; $this->view->obj = $bl;
$this->view->id = $bl->getId(); $this->view->id = $bl->getId();
$result['html'] = $this->view->render($viewPath); $this->view->html = $this->view->render($viewPath);
$result['result'] = 1; $this->view->result = 1;
} }
$result['type'] = "sb"; $this->view->name = $bl->getName();
$result['id'] = $bl->getId(); $this->view->type = "sb";
$result["modified"] = $bl->getLastModified("U"); $this->view->id = $bl->getId();
$this->view->modified = $bl->getLastModified("U");
} else if ($params['type'] == 'playlist') { } else if ($params['type'] == 'playlist') {
$this->setPlaylistNameDescAction(); $this->setPlaylistNameDescAction();
$result["modified"] = $this->view->modified; $this->view->modified = $this->view->modified;
$this->view->name = $params['name'];
} }
$this->_helper->json->sendJson($result);
//$this->_helper->json->sendJson($result);
} }
public function smartBlockGenerateAction() public function smartBlockGenerateAction()
@ -570,7 +578,9 @@ class PlaylistController extends Zend_Controller_Action
$form->startForm($params['obj_id']); $form->startForm($params['obj_id']);
if ($form->isValid($params)) { if ($form->isValid($params)) {
$result = $bl->generateSmartBlock($params['data']); $result = $bl->generateSmartBlock($params['data']);
$this->_helper->json->sendJson(array("result"=>0, "html"=>$this->createFullResponse($bl, true, true))); $this->view->result = $result['result'];
$this->createUpdateResponse($bl);
#$this->_helper->json->sendJson(array("result"=>0, "html"=>$this->createFullResponse($bl, true, true)));
} else { } else {
$this->view->obj = $bl; $this->view->obj = $bl;
$this->view->id = $bl->getId(); $this->view->id = $bl->getId();
@ -595,12 +605,20 @@ class PlaylistController extends Zend_Controller_Action
try { try {
$bl = new Application_Model_Block($params['obj_id']); $bl = new Application_Model_Block($params['obj_id']);
$result = $bl->shuffleSmartBlock(); $result = $bl->shuffleSmartBlock();
$this->view->result = $result["result"];
$this->createUpdateResponse($bl);
/*
if ($result['result'] == 0) { if ($result['result'] == 0) {
$this->_helper->json->sendJson(array("result"=>0, "html"=>$this->createFullResponse($bl, true))); $this->_helper->json->sendJson(array(
"result"=>0,
"contents" => $bl->getContents());
///"html"=>$this->viwe));
} else { } else {
$this->_helper->json->sendJson($result); $this->_helper->json->sendJson($result);
} }*/
} catch (BlockNotFoundException $e) { } catch (BlockNotFoundException $e) {
$this->playlistNotFound('block', true); $this->playlistNotFound('block', true);
} catch (Exception $e) { } catch (Exception $e) {
@ -615,12 +633,18 @@ class PlaylistController extends Zend_Controller_Action
try { try {
$pl = new Application_Model_Playlist($params['obj_id']); $pl = new Application_Model_Playlist($params['obj_id']);
$result = $pl->shuffle(); $result = $pl->shuffle();
$this->view->result = $result["result"];
$this->createUpdateResponse($pl);
/*
if ($result['result'] == 0) { if ($result['result'] == 0) {
$this->_helper->json->sendJson(array("result"=>0, "html"=>$this->createFullResponse($pl, true))); $this->_helper->json->sendJson(array(
"result"=>0,
"contents" => $pl->getContents(),
"html"=>$this->createUpdateResponse($pl, true)));
} else { } else {
$this->_helper->json->sendJson($result); $this->_helper->json->sendJson($result);
} }*/
} catch (PlaylistNotFoundException $e) { } catch (PlaylistNotFoundException $e) {
$this->playlistNotFound('block', true); $this->playlistNotFound('block', true);
} catch (Exception $e) { } catch (Exception $e) {

View File

@ -20,9 +20,10 @@
<label>Embeddable Code:</label> <label>Embeddable Code:</label>
<textarea style="width:98%" rows="3" readonly="readonly"><iframe height="400px" width="550px" scrolling="no" frameborder="0" src=<?php echo Application_Common_HTTPHelper::getStationUrl()."embed/weekly-program"?>></iframe> <textarea style="width:98%" rows="3" readonly="readonly"><iframe height="400px" width="550px" scrolling="no" frameborder="0" src=<?php echo Application_Common_HTTPHelper::getStationUrl()."embed/weekly-program"?>></iframe>
</textarea> </textarea>
<div> <div><p>
Copy this code and paste it into your website's HTML to embed the weekly schedule in your site. Copy this code and paste it into your website's HTML to embed the weekly schedule in your site.
Adjust the height and width attributes to your desired size. Adjust the height and width attributes to your desired size.
</p>
</div> </div>
</div> </div>
</fieldset> </fieldset>

View File

@ -2,8 +2,10 @@
<div id="current-user-container"> <div id="current-user-container">
<?php if(Application_Model_User::getCurrentUser()->isSuperAdmin()) : ?> <?php if(Application_Model_User::getCurrentUser()->isSuperAdmin()) : ?>
<div class="user-data" id="user_details_superadmin_message" style="text-align: center;"> <div id="user_details_superadmin_message">
<?=sprintf(_("<b>Note:</b> You are a special \"Super Admin\" type of user.<br>Account details for Super Admins can be changed in your <a href=\"%s\">Billing Settings</a> instead."), "/billing/client");?> <p class="alert alert-error">
<?=sprintf(_("<b>Note:</b> Since you're the station owner, your account information can be edited in <a href=\"%s\">Billing Settings</a> instead."), "/billing/client");?>
</p>
<br><br> <br><br>
</div> </div>
<?php endif; ?> <?php endif; ?>

View File

@ -65,7 +65,9 @@
<dt><label><?php echo(_("Search Criteria:"));?></label></dt> <dt><label><?php echo(_("Search Criteria:"));?></label></dt>
<dd id='sp_criteria-element' class='criteria-element'> <dd id='sp_criteria-element' class='criteria-element'>
<?php for ($i = 0; $i < $this->criteriasLength; $i++) { <a class='btn btn-small' id='criteria_add'><i class='icon-white icon-plus'></i><?php echo(_("New Criteria")); ?></a>
<?php for ($i = 0; $i < $this->criteriasLength; $i++) {
// modRowMap holds the number of modifier rows for each criteria element // modRowMap holds the number of modifier rows for each criteria element
// i.e. if we have 'Album contains 1' and 'Album contains 2' the modRowMap // i.e. if we have 'Album contains 1' and 'Album contains 2' the modRowMap
// for Album is 2 // for Album is 2
@ -93,16 +95,17 @@
<?php echo $this->element->getElement("sp_criteria_field_".$i."_".$j) ?> <?php echo $this->element->getElement("sp_criteria_field_".$i."_".$j) ?>
<?php echo $this->element->getElement("sp_criteria_modifier_".$i."_".$j) ?> <?php echo $this->element->getElement("sp_criteria_modifier_".$i."_".$j) ?>
<?php echo $this->element->getElement("sp_criteria_value_".$i."_".$j) ?> <?php echo $this->element->getElement("sp_criteria_value_".$i."_".$j) ?>
<a class='btn btn-small' id='modifier_add_<?php echo $i ?>'>
<i class='icon-white icon-plus'></i><?php echo(_("New Modifier")); ?>
</a>
<span class='sp_text_font' id="extra_criteria" <?php echo $this->element->getElement("sp_criteria_extra_".$i."_".$j)->getAttrib("disabled") == "disabled"?'style="display:none;"':""?>><?php echo _(" to "); ?><?php echo $this->element->getElement('sp_criteria_extra_'.$i."_".$j) ?></span> <span class='sp_text_font' id="extra_criteria" <?php echo $this->element->getElement("sp_criteria_extra_".$i."_".$j)->getAttrib("disabled") == "disabled"?'style="display:none;"':""?>><?php echo _(" to "); ?><?php echo $this->element->getElement('sp_criteria_extra_'.$i."_".$j) ?></span>
<a style='margin-right:3px' class='btn btn-small btn-danger' id='criteria_remove_<?php echo $i ?>'> <a style='margin-right:3px' class='btn btn-small btn-danger' id='criteria_remove_<?php echo $i ?>'>
<i class='icon-white icon-remove'></i> <i class='icon-white icon-remove spl-no-r-margin'></i>
</a> </a>
<span class='db-logic-label' <?php if ($nextDisabled) echo "style='display:none'"?>> <span class='db-logic-label' <?php if ($nextDisabled) echo "style='display:none'"?>>
<?php echo $logicLabel;?> <?php echo $logicLabel;?>
</span> </span>
<a class='btn btn-small' id='modifier_add_<?php echo $i ?>'>
<i class='icon-white icon-plus'></i>
</a>
<?php if($this->element->getElement("sp_criteria_field_".$i."_".$j)->hasErrors()) : ?> <?php if($this->element->getElement("sp_criteria_field_".$i."_".$j)->hasErrors()) : ?>
<?php foreach($this->element->getElement("sp_criteria_field_".$i."_".$j)->getMessages() as $error): ?> <?php foreach($this->element->getElement("sp_criteria_field_".$i."_".$j)->getMessages() as $error): ?>

View File

@ -6,6 +6,10 @@ if (isset($this->obj)) {
?> ?>
<?php if (isset($this->obj)) : ?> <?php if (isset($this->obj)) : ?>
<div class="inner_editor_title">
<H2><?php echo(_("Editing "));?>"<span class="title_obj_name"><?php if (isset($this->unsavedName)) echo $this->unsavedName;
else echo $this->escape($this->obj->getName());?></span>"</H2>
</div>
<div class="inner_editor_wrapper"> <div class="inner_editor_wrapper">
<input class="obj_id" type="hidden" value="<?php echo $this->obj->getId(); ?>"/> <input class="obj_id" type="hidden" value="<?php echo $this->obj->getId(); ?>"/>
<input class="obj_lastMod" type="hidden" value="<?php echo $this->obj->getLastModified('U'); ?>"/> <input class="obj_lastMod" type="hidden" value="<?php echo $this->obj->getLastModified('U'); ?>"/>
@ -33,6 +37,11 @@ if (isset($this->obj)) {
<div class="ui-widget-header fg-toolbar btn-toolbar clearfix"> <div class="ui-widget-header fg-toolbar btn-toolbar clearfix">
<h4 class="obj_length"><?php echo($this->length); ?></h4> <h4 class="obj_length"><?php echo($this->length); ?></h4>
<h4 class="obj_length_label"><?php echo(_("Duration:"));?></h4> <h4 class="obj_length_label"><?php echo(_("Duration:"));?></h4>
<div class='btn-group'>
<button class="btn toggle-editor-form" title='<?php echo _("Toggle Details") ?>' type="button"><span class="icon-white spl-no-r-margin icon-chevron-up"></span></button>
</div>
<div class='btn-group'> <div class='btn-group'>
<button class="btn" title='<?php echo _("Shuffle playlist") ?>' type="button" id="playlist_shuffle_button"><?php echo _("Shuffle") ?></button> <button class="btn" title='<?php echo _("Shuffle playlist") ?>' type="button" id="playlist_shuffle_button"><?php echo _("Shuffle") ?></button>
</div> </div>

View File

@ -6,6 +6,10 @@ if (isset($this->obj)) {
?> ?>
<?php if (isset($this->obj)) : ?> <?php if (isset($this->obj)) : ?>
<div class="inner_editor_title">
<H2><?php echo(_("Editing "));?>"<span class="title_obj_name"><?php if (isset($this->unsavedName)) echo $this->unsavedName;
else echo $this->escape($this->obj->getName());?></span>"</H2>
</div>
<div class="inner_editor_wrapper"> <div class="inner_editor_wrapper">
<input class="obj_id" type="hidden" value="<?php echo $this->obj->getId(); ?>"/> <input class="obj_id" type="hidden" value="<?php echo $this->obj->getId(); ?>"/>
<input class="obj_lastMod" type="hidden" value="<?php echo $this->obj->getLastModified('U'); ?>"/> <input class="obj_lastMod" type="hidden" value="<?php echo $this->obj->getLastModified('U'); ?>"/>
@ -40,6 +44,9 @@ if (isset($this->obj)) {
<h4 class="obj_length"><?php echo($this->length); ?></h4> <h4 class="obj_length"><?php echo($this->length); ?></h4>
<h4 class="obj_length_label"><?php echo(_("Duration:"));?></h4> <h4 class="obj_length_label"><?php echo(_("Duration:"));?></h4>
<div class='btn-group'>
<button class="btn toggle-editor-form" title='<?php echo _("Toggle Details") ?>' type="button"><span class="icon-white spl-no-r-margin icon-chevron-up"></span></button>
</div>
<div class='btn-group'> <div class='btn-group'>
<?php echo $this->form->getElement('generate_button');?> <?php echo $this->form->getElement('generate_button');?>
</div> </div>

View File

@ -1,6 +1,6 @@
<?php <?php
$items = $this->contents; $items = $this->contents;
if (count($items)) : ?> if (count($items) && ($this->obj instanceof Application_Model_Block && $this->obj->isStatic())) : ?>
<?php $i = 0; ?> <?php $i = 0; ?>
<?php foreach($items as $item) : <?php foreach($items as $item) :
$staticBlock = null; $staticBlock = null;
@ -131,8 +131,15 @@ if (($i < count($items) -1) && ($items[$i+1]['type'] == 0)) {
<?php else : ?> <?php else : ?>
<div class="spl_empty"> <div class="spl_empty">
<?php <?php
echo _("Drag tracks here from your library to add them to the " if ($this->obj instanceof Application_Model_Block) {
. ($this->obj instanceof Application_Model_Block ? "smart block" : "playlist")); if ($this->obj->isStatic()) {
echo _("Choose some search criteria above and click Generate to create this playlist.");
} else {
echo _("A track list will be generated when you schedule this smart block into a show.");
}
} else {
echo _("Drag tracks here from your library to add them to the playlist");
}
?> ?>
</div> </div>
<?php endif; ?> <?php endif; ?>

View File

@ -4,27 +4,32 @@
<input class="obj_type" type="hidden" value="webstream"/> <input class="obj_type" type="hidden" value="webstream"/>
<div class="status" style="display:none;"></div> <div class="status" style="display:none;"></div>
<div class="playlist_title"> <div class="inner_editor_title">
<div id="name-error" class="errors" style="display:none;"></div> <H2><?php echo(_("Editing "));?>"<span class="title_obj_name"><?php if (isset($this->unsavedName)) echo $this->unsavedName;
<h3 class="ws_name"> else echo $this->escape($this->obj->getName());?></span>"</H2>
<a class="playlist_name_display" contenteditable="true"><?php echo $this->escape($this->obj->getName()); ?></a>
</h3>
<h4 class="ws_length"><?php echo $this->obj->getDefaultLength(); ?></h4>
</div> </div>
<dl class="zend_form"> <div class="inner_editor_wrapper">
<dl class="zend_form side_playlist playlist_editor">
<dt>
<label><?php echo(_("Name:")); ?></label>
</dt>
<dd>
<div id="name-error" class="errors" style="display:none;"></div>
<input class="playlist_name_display" type="text" contenteditable="true" value="<?php echo $this->escape($this->obj->getName()); ?>">
</dd>
<dt id="description-label"><label for="description"><?php echo _("Description") ?></label></dt> <dt id="description-label"><label for="description"><?php echo _("Description") ?></label></dt>
<dd id="description-element"> <dd id="description-element">
<textarea cols="80" rows="24" id="description" name="description"><?php echo $this->obj->getDescription(); ?></textarea> <textarea cols="80" rows="24" id="description" name="description"><?php echo $this->obj->getDescription(); ?></textarea>
</dd> </dd>
</dl>
<dl class="zend_form">
<dt id="submit-label" style="display: none;">&nbsp;</dt> <dt id="submit-label" style="display: none;">&nbsp;</dt>
<div id="url-error" class="errors" style="display:none;"></div> <div id="url-error" class="errors" style="display:none;"></div>
<dt id="streamurl-label"><label for="streamurl"><?php echo _("Stream URL:"); ?></label></dt> <dt id="streamurl-label"><label for="streamurl"><?php echo _("Stream URL:"); ?></label></dt>
<dd id="streamurl-element"> <dd id="streamurl-element">
<input type="text" value="<?php echo $this->obj->getUrl(); ?>" size="40"/> <input type="url" value="<?php echo $this->obj->getUrl(); ?>" size="40"/>
</dd> </dd>
<div id="length-error" class="errors" style="display:none;"></div> <div id="length-error" class="errors" style="display:none;"></div>
<dt id="streamlength-label"><label for="streamlength"><?php echo _("Default Length:"); ?></label></dt> <dt id="streamlength-label"><label for="streamlength"><?php echo _("Default Length:"); ?></label></dt>
@ -32,8 +37,10 @@
<input type="text" value="<?php echo $this->obj->getDefaultLength() ?>"/> <input type="text" value="<?php echo $this->obj->getDefaultLength() ?>"/>
</dd> </dd>
</dl> </dl>
</div>
<div class="btn-toolbar spl-no-margin clearfix">
<div class="btn-toolbar clearfix">
<div class="btn-group pull-right"> <div class="btn-group pull-right">
<button class="btn" type="button" id="webstream_cancel" name="submit"><?php echo _("Cancel") ?></button> <button class="btn" type="button" id="webstream_cancel" name="submit"><?php echo _("Cancel") ?></button>
</div> </div>

View File

@ -420,6 +420,14 @@ li.ui-state-default {
box-sizing: border-box; box-sizing: border-box;
} }
.inner_editor_title h2 {
margin: 10px 0 0 10px;
}
.inner_editor_title span {
font-size: inherit;
line-height: inherit;
}
.clearfix:after, .side_playlist li:after { .clearfix:after, .side_playlist li:after {
display: none !important; display: none !important;
} }
@ -432,6 +440,10 @@ li.ui-state-default {
margin-left: 0 !important; margin-left: 0 !important;
} }
.spl-no-r-margin {
margin-right: 0px;
}
.spl_sortable { .spl_sortable {
position: relative; position: relative;
height: 100%; height: 100%;
@ -445,6 +457,8 @@ li.ui-state-default {
border-radius: 3px; border-radius: 3px;
box-sizing: border-box; box-sizing: border-box;
background-color: #111; background-color: #111;
display: flex;
flex-direction: column;
} }
.spl_sortable .list-item-container { .spl_sortable .list-item-container {
@ -454,11 +468,16 @@ li.ui-state-default {
.spl_empty { .spl_empty {
width: 100%; width: 100%;
margin-top: 100px;
color: #efefef; color: #efefef;
text-align: center; text-align: center;
font-size: 20px; font-size: 20px;
flex: 1 1 auto;
/* Position the text label inside it centered*/
display: flex;
justify-content: center;
flex-direction: column;
} }
.crossfade-main { .crossfade-main {

View File

@ -604,4 +604,8 @@ li.spl_empty {
} }
.expand-block-separate { .expand-block-separate {
border-top: 1px solid #5B5B5B; border-top: 1px solid #5B5B5B;
}
#criteria_add {
margin-bottom: 5px;
} }

View File

@ -140,6 +140,9 @@ select {
#current-user-container { #current-user-container {
padding-bottom: 20px; padding-bottom: 20px;
} }
#current-user-container p {
font-size: 1.0rem;
}
.edit-current-user { .edit-current-user {
width: 365px; width: 365px;
@ -538,7 +541,7 @@ fieldset.plain {
.padded-strong { .padded-strong {
padding:10px; padding:10px;
} }
.input_text, input[type="text"], input[type="password"] { .input_text, input[type="text"], input[type="password"], input[type="url"] {
font-family:Arial, Helvetica, sans-serif; font-family:Arial, Helvetica, sans-serif;
border: 1px solid #5b5b5b; border: 1px solid #5b5b5b;
font-size: 12px; font-size: 12px;
@ -1323,6 +1326,10 @@ input[type="checkbox"] {
z-index:999; z-index:999;
} }
#user_details_superadmin_message a {
color: inherit;
font-weight: bold;
}
/*---//////////////////// Schedule Show ////////////////////---*/ /*---//////////////////// Schedule Show ////////////////////---*/

View File

@ -31,8 +31,6 @@ var AIRTIME = (function(AIRTIME){
function playlistError(json) { function playlistError(json) {
alert(json.error); alert(json.error);
//closeTab();
//openPlaylist(json);
} }
function stopAudioPreview() { function stopAudioPreview() {
@ -71,7 +69,7 @@ var AIRTIME = (function(AIRTIME){
cueIn = $.trim(span.text()), cueIn = $.trim(span.text()),
li = span.parents("li"), li = span.parents("li"),
unqid = li.attr("unqid"), unqid = li.attr("unqid"),
lastMod = getModified(), lastMod = mod.getModified(),
type = $pl.find('.obj_type').val(); type = $pl.find('.obj_type').val();
if (!isTimeValid(cueIn)){ if (!isTimeValid(cueIn)){
@ -108,7 +106,7 @@ var AIRTIME = (function(AIRTIME){
cueOut = $.trim(span.text()), cueOut = $.trim(span.text()),
li = span.parents("li"), li = span.parents("li"),
unqid = li.attr("unqid"), unqid = li.attr("unqid"),
lastMod = getModified(), lastMod = mod.getModified(),
type = $pl.find('.obj_type').val(); type = $pl.find('.obj_type').val();
if (!isTimeValid(cueOut)){ if (!isTimeValid(cueOut)){
@ -142,7 +140,7 @@ var AIRTIME = (function(AIRTIME){
function changeCues($el, id, cueIn, cueOut) { function changeCues($el, id, cueIn, cueOut) {
var url = baseUrl+"playlist/set-cue", var url = baseUrl+"playlist/set-cue",
lastMod = getModified(), lastMod = mod.getModified(),
type = $pl.find('.obj_type').val(), type = $pl.find('.obj_type').val(),
li, li,
span; span;
@ -212,7 +210,7 @@ var AIRTIME = (function(AIRTIME){
function changeCrossfade($el, id1, id2, fadeIn, fadeOut, offset, id) { function changeCrossfade($el, id1, id2, fadeIn, fadeOut, offset, id) {
var url = baseUrl+"playlist/set-crossfade", var url = baseUrl+"playlist/set-crossfade",
lastMod = getModified(), lastMod = mod.getModified(),
type = $pl.find('.obj_type').val(); type = $pl.find('.obj_type').val();
$.post(url, $.post(url,
@ -244,7 +242,7 @@ var AIRTIME = (function(AIRTIME){
fadeIn = $.trim(span.text()), fadeIn = $.trim(span.text()),
li = span.parents("li"), li = span.parents("li"),
unqid = li.attr("unqid"), unqid = li.attr("unqid"),
lastMod = getModified(), lastMod = mod.getModified(),
type = $pl.find('.obj_type').val(); type = $pl.find('.obj_type').val();
if (!isFadeValid(fadeIn)){ if (!isFadeValid(fadeIn)){
@ -282,7 +280,7 @@ var AIRTIME = (function(AIRTIME){
fadeOut = $.trim(span.text()), fadeOut = $.trim(span.text()),
li = span.parents("li"), li = span.parents("li"),
unqid = li.attr("unqid"), unqid = li.attr("unqid"),
lastMod = getModified(), lastMod = mod.getModified(),
type = $pl.find('.obj_type').val(); type = $pl.find('.obj_type').val();
if (!isFadeValid(fadeOut)){ if (!isFadeValid(fadeOut)){
@ -354,13 +352,15 @@ var AIRTIME = (function(AIRTIME){
} }
} }
function editName() { function updateActiveTabName(newTabName) {
/*
var nameElement = $(this); var nameElement = $(this);
//remove any newlines if user somehow snuck them in (easy to do if dragging/dropping text) //remove any newlines if user somehow snuck them in (easy to do if dragging/dropping text)
nameElement.text(nameElement.text().replace("\n", "")); nameElement.text(nameElement.text().replace("\n", ""));
var name = $pl.find(".playlist_name_display").val(); var name = $pl.find(".playlist_name_display").val();
$(".nav.nav-tabs .active a > span.tab-name").text(name); */
$(".nav.nav-tabs .active a > span.tab-name").text(newTabName);
} }
function redrawLib() { function redrawLib() {
@ -389,7 +389,9 @@ var AIRTIME = (function(AIRTIME){
.append($html); .append($html);
setCueEvents(); setCueEvents();
setFadeEvents(); setFadeEvents();
setModified(json.modified); mod.setModified(json.modified);
updateActiveTabName(json.name);
AIRTIME.playlist.validatePlaylistElements(); AIRTIME.playlist.validatePlaylistElements();
redrawLib(); redrawLib();
} }
@ -423,14 +425,19 @@ var AIRTIME = (function(AIRTIME){
return parseInt($pl.find(".obj_id").val(), 10); return parseInt($pl.find(".obj_id").val(), 10);
} }
function getModified() { mod.getModified = function() {
return parseInt($pl.find(".obj_lastMod").val(), 10); return parseInt($pl.find(".obj_lastMod").val(), 10);
} }
function setModified(modified) { mod.setModified = function(modified) {
$pl.find(".obj_lastMod").val(modified); $pl.find(".obj_lastMod").val(modified);
} }
function setTitleLabel(title) {
$pl.find(".title_obj_name").text(title);
}
/* /*
* Should all be moved to builder.js eventually * Should all be moved to builder.js eventually
*/ */
@ -712,7 +719,7 @@ var AIRTIME = (function(AIRTIME){
//main playlist fades events //main playlist fades events
$pl.on("click", "#spl_crossfade", function() { $pl.on("click", "#spl_crossfade", function() {
var lastMod = getModified(), var lastMod = mod.getModified(),
type = $pl.find('.obj_type').val(); type = $pl.find('.obj_type').val();
if ($(this).hasClass("ui-state-active")) { if ($(this).hasClass("ui-state-active")) {
@ -762,7 +769,7 @@ var AIRTIME = (function(AIRTIME){
var url = baseUrl+"playlist/set-playlist-fades", var url = baseUrl+"playlist/set-playlist-fades",
span = $(this), span = $(this),
fadeIn = $.trim(span.text()), fadeIn = $.trim(span.text()),
lastMod = getModified(), lastMod = mod.getModified(),
type = $pl.find('.obj_type').val(); type = $pl.find('.obj_type').val();
if (!isFadeValid(fadeIn)){ if (!isFadeValid(fadeIn)){
@ -775,7 +782,7 @@ var AIRTIME = (function(AIRTIME){
function(json){ function(json){
hideError(span); hideError(span);
if (json.modified !== undefined) { if (json.modified !== undefined) {
setModified(json.modified); mod.setModified(json.modified);
} }
}); });
}); });
@ -786,7 +793,7 @@ var AIRTIME = (function(AIRTIME){
var url = baseUrl+"playlist/set-playlist-fades", var url = baseUrl+"playlist/set-playlist-fades",
span = $(this), span = $(this),
fadeOut = $.trim(span.text()), fadeOut = $.trim(span.text()),
lastMod = getModified(), lastMod = mod.getModified(),
type = $pl.find('.obj_type').val(); type = $pl.find('.obj_type').val();
if (!isFadeValid(fadeOut)){ if (!isFadeValid(fadeOut)){
@ -799,7 +806,7 @@ var AIRTIME = (function(AIRTIME){
function(json){ function(json){
hideError(span); hideError(span);
if (json.modified !== undefined) { if (json.modified !== undefined) {
setModified(json.modified); mod.setModified(json.modified);
} }
}); });
}); });
@ -814,7 +821,7 @@ var AIRTIME = (function(AIRTIME){
//edit playlist name event //edit playlist name event
$pl.on("keydown", ".playlist_name_display", submitOnEnter); $pl.on("keydown", ".playlist_name_display", submitOnEnter);
$pl.on("blur", ".playlist_name_display", editName); //$pl.on("blur", ".playlist_name_display", editName);
//edit playlist description events //edit playlist description events
$pl.on("click", "legend", function(){ $pl.on("click", "legend", function(){
@ -838,14 +845,12 @@ var AIRTIME = (function(AIRTIME){
if (json.error !== undefined) { if (json.error !== undefined) {
alert(json.error); alert(json.error);
} } else {
if (json.html !== undefined) { if (json.result == "0") {
closeTab(); $pl.find('.success').text($.i18n._('Playlist shuffled'));
openPlaylist(json); $pl.find('.success').show();
} mod.playlistResponse(json);
if (json.result == "0") { }
$pl.find('.success').text($.i18n._('Playlist shuffled'));
$pl.find('.success').show();
} }
disableLoadingIcon(); disableLoadingIcon();
setTimeout(removeSuccessMsg, 5000); setTimeout(removeSuccessMsg, 5000);
@ -886,12 +891,15 @@ var AIRTIME = (function(AIRTIME){
$status.show(); $status.show();
setTimeout(function(){$status.fadeOut("slow", function(){$status.empty()})}, 5000); setTimeout(function(){$status.fadeOut("slow", function(){$status.empty()})}, 5000);
$pl.find(".title_obj_name").val(name);
updateActiveTabName(name);
var $ws_id = $(".active-tab .obj_id"); var $ws_id = $(".active-tab .obj_id");
$ws_id.attr("value", json.streamId); $ws_id.attr("value", json.streamId);
var $ws_id = $("#ws_delete"); var $ws_id = $("#ws_delete");
$ws_id.show(); $ws_id.show();
editName();
var length = $(".side_playlist.active-tab .ws_length"); var length = $(".side_playlist.active-tab .ws_length");
length.text(json.length); length.text(json.length);
@ -978,7 +986,7 @@ var AIRTIME = (function(AIRTIME){
save_action = baseUrl+'playlist/save', save_action = baseUrl+'playlist/save',
obj_id = $pl.find(".obj_id").val(), obj_id = $pl.find(".obj_id").val(),
obj_type = $pl.find('.obj_type').val(), obj_type = $pl.find('.obj_type').val(),
lastMod = getModified(), lastMod = mod.getModified(),
dt = $('table[id="library_display"]').dataTable(); dt = $('table[id="library_display"]').dataTable();
enableLoadingIcon(); enableLoadingIcon();
$.post(save_action, $.post(save_action,
@ -986,19 +994,19 @@ var AIRTIME = (function(AIRTIME){
function(json){ function(json){
if (json.error !== undefined) { if (json.error !== undefined) {
alert(json.error); alert(json.error);
}
if (json.html !== undefined) {
closeTab();
openPlaylist(json);
}
setModified(json.modified);
if (obj_type == "block") {
callback(json, "save");
} else { } else {
$pl.find('.success').text($.i18n._('Playlist saved'));
$pl.find('.success').show(); setTitleLabel(json.name);
setTimeout(removeSuccessMsg, 5000); mod.setModified(json.modified);
dt.fnStandingRedraw();
if (obj_type == "block") {
callback(json, "save");
} else {
$pl.find('.success').text($.i18n._('Playlist saved'));
$pl.find('.success').show();
setTimeout(removeSuccessMsg, 5000);
dt.fnStandingRedraw();
}
} }
setFadeIcon(); setFadeIcon();
disableLoadingIcon(); disableLoadingIcon();
@ -1011,6 +1019,13 @@ var AIRTIME = (function(AIRTIME){
oData = {}; oData = {};
playlistRequest(sUrl, oData); playlistRequest(sUrl, oData);
}); });
$pl.find(".toggle-editor-form").unbind().on("click", function(event) {
$pl.find(".inner_editor_wrapper").slideToggle(200);
var buttonIcon = $(this).find('span.icon-white');
buttonIcon.toggleClass('icon-chevron-up');
buttonIcon.toggleClass('icon-chevron-down');
});
} }
function setUpPlaylist() { function setUpPlaylist() {
@ -1094,6 +1109,7 @@ var AIRTIME = (function(AIRTIME){
//handle: 'div.list-item-container', //handle: 'div.list-item-container',
start: function(event, ui) { start: function(event, ui) {
ui.placeholder.height(56); ui.placeholder.height(56);
ui.placeholder.css('min-height', 56);
}, },
axis: "y", axis: "y",
containment: "document", containment: "document",
@ -1168,7 +1184,7 @@ var AIRTIME = (function(AIRTIME){
stopAudioPreview(); stopAudioPreview();
id = (plid === undefined) ? getId() : plid; id = (plid === undefined) ? getId() : plid;
lastMod = getModified(); lastMod = mod.getModified();
type = pl.find('.obj_type').val(); type = pl.find('.obj_type').val();
url = baseUrl+'playlist/delete'; url = baseUrl+'playlist/delete';
@ -1185,7 +1201,7 @@ var AIRTIME = (function(AIRTIME){
stopAudioPreview(); stopAudioPreview();
id = (wsid === undefined) ? getId() : wsid; id = (wsid === undefined) ? getId() : wsid;
lastMod = getModified(); lastMod = mod.getModified();
type = $pl.find('.obj_type').val(); type = $pl.find('.obj_type').val();
url = baseUrl+'webstream/delete'; url = baseUrl+'webstream/delete';
@ -1223,7 +1239,7 @@ var AIRTIME = (function(AIRTIME){
setupUI(); setupUI();
}; };
function playlistResponse(json){ mod.playlistResponse = function(json){
if (json.error !== undefined) { if (json.error !== undefined) {
playlistError(json); playlistError(json);
} }
@ -1241,7 +1257,7 @@ var AIRTIME = (function(AIRTIME){
mod.disableUI(); mod.disableUI();
lastMod = getModified(); lastMod = mod.getModified();
oData["modified"] = lastMod; oData["modified"] = lastMod;
oData["obj_type"] = obj_type; oData["obj_type"] = obj_type;
@ -1250,7 +1266,7 @@ var AIRTIME = (function(AIRTIME){
$.post( $.post(
sUrl, sUrl,
oData, oData,
playlistResponse mod.playlistResponse
); );
} }

View File

@ -5,7 +5,7 @@ $(document).ready(function() {
function setSmartBlockEvents() { function setSmartBlockEvents() {
var activeTab = $('.active-tab'), var activeTab = $('.active-tab'),
form = activeTab.find('.smart-block-form'); form = activeTab.find('.smart-block-form');
/********** ADD CRITERIA ROW **********/ /********** ADD CRITERIA ROW **********/
form.find('#criteria_add').live('click', function(){ form.find('#criteria_add').live('click', function(){
@ -190,7 +190,7 @@ function setSmartBlockEvents() {
/********** SAVE ACTION **********/ /********** SAVE ACTION **********/
// moved to spl.js // moved to spl.js
/********** GENERATE ACTION **********/ /********** GENERATE ACTION **********/
activeTab.find('button[id="generate_button"]').live("click", function(){ activeTab.find('button[id="generate_button"]').live("click", function(){
buttonClickAction('generate', 'playlist/smart-block-generate'); buttonClickAction('generate', 'playlist/smart-block-generate');
@ -203,6 +203,8 @@ function setSmartBlockEvents() {
/********** CHANGE PLAYLIST TYPE **********/ /********** CHANGE PLAYLIST TYPE **********/
form.find('dd[id="sp_type-element"]').live("change", function(){ form.find('dd[id="sp_type-element"]').live("change", function(){
//buttonClickAction('generate', 'playlist/empty-content');
$(".active-tab").find('button[id="save_button"]').click();
setupUI(); setupUI();
AIRTIME.library.checkAddButton(); AIRTIME.library.checkAddButton();
}); });
@ -336,7 +338,9 @@ function buttonClickAction(clickType, url){
obj_id = $('.active-tab .obj_id').val(); obj_id = $('.active-tab .obj_id').val();
enableLoadingIcon(); enableLoadingIcon();
$.post(url, {format: "json", data: data, obj_id: obj_id}, function(data){ $.post(url, {format: "json", data: data, obj_id: obj_id, obj_type: "block",
modified: AIRTIME.playlist.getModified()
}, function(data){
callback(data, clickType); callback(data, clickType);
disableLoadingIcon(); disableLoadingIcon();
}); });
@ -351,7 +355,9 @@ function setupUI() {
*/ */
var sortable = activeTab.find('.spl_sortable'), var sortable = activeTab.find('.spl_sortable'),
plContents = sortable.children(), plContents = sortable.children(),
shuffleButton = activeTab.find('button[name="shuffle_button"], #pl-bl-clear-content'); shuffleButton = activeTab.find('button[name="shuffle_button"], #pl-bl-clear-content'),
generateButton = activeTab.find('button[name="generate_button"], #pl-bl-clear-content'),
fadesButton = activeTab.find('#spl_crossfade, #pl-bl-clear-content');
if (!plContents.hasClass('spl_empty')) { if (!plContents.hasClass('spl_empty')) {
if (shuffleButton.hasClass('ui-state-disabled')) { if (shuffleButton.hasClass('ui-state-disabled')) {
@ -365,11 +371,15 @@ function setupUI() {
if (activeTab.find('.obj_type').val() == 'block') { if (activeTab.find('.obj_type').val() == 'block') {
if (playlist_type == "0") { if (playlist_type == "0") {
shuffleButton.parent().show(); shuffleButton.removeAttr("disabled");
sortable.show(); generateButton.removeAttr("disabled");
fadesButton.removeAttr("disabled");
//sortable.children().show();
} else { } else {
shuffleButton.parent().hide(); shuffleButton.attr("disabled", "disabled");
sortable.hide(); generateButton.attr("disabled", "disabled");
fadesButton.attr("disabled", "disabled");
//sortable.children().hide();
} }
} }
@ -481,41 +491,47 @@ function callback(json, type) {
var dt = $('table[id="library_display"]').dataTable(), var dt = $('table[id="library_display"]').dataTable(),
form = $('.active-tab .smart-block-form'); form = $('.active-tab .smart-block-form');
if (json.modified !== undefined) {
AIRTIME.playlist.setModified(json.modified);
}
if (type == 'shuffle' || type == 'generate') { if (type == 'shuffle' || type == 'generate') {
if (json.error !== undefined) { if (json.error !== undefined) {
alert(json.error); alert(json.error);
} }
AIRTIME.playlist.closeTab();
AIRTIME.playlist.fnOpenPlaylist(json);
if (json.result == "0") { if (json.result == "0") {
if (type == 'shuffle') { if (type == 'shuffle') {
form.find('.success').text($.i18n._('Smart block shuffled')); form.find('.success').text($.i18n._('Smart block shuffled'));
} else if (type == 'generate') { } else if (type == 'generate') {
form.find('.success').text($.i18n._('Smart block generated and criteria saved')); form.find('.success').text($.i18n._('Smart block generated and criteria saved'));
//redraw library table so the length gets updated //redraw library table so the length gets updated
dt.fnStandingRedraw(); dt.fnStandingRedraw();
} }
AIRTIME.playlist.playlistResponse(json);
form.find('.success').show(); form.find('.success').show();
} }
form.find('#smart_block_options').removeClass("closed"); form.find('.smart-block-form').removeClass("closed");
} else { } else {
AIRTIME.playlist.closeTab();
AIRTIME.playlist.fnOpenPlaylist(json);
if (json.result == "0") { if (json.result == "0") {
$('.active-tab #sp-success-saved').text($.i18n._('Smart block saved')).show(); $('.active-tab #sp-success-saved').text($.i18n._('Smart block saved')).show();
AIRTIME.playlist.playlistResponse(json);
//redraw library table so the length gets updated //redraw library table so the length gets updated
dt.fnStandingRedraw(); dt.fnStandingRedraw();
} }
form.find('#smart_block_options').removeClass("closed"); form.find('.smart-block-form').removeClass("closed");
} }
setTimeout(removeSuccessMsg, 5000); setTimeout(removeSuccessMsg, 5000);
} }
function appendAddButton() { function appendAddButton() {
/*
var add_button = "<a class='btn btn-small' id='criteria_add'>" + var add_button = "<a class='btn btn-small' id='criteria_add'>" +
"<i class='icon-white icon-plus'></i></a>"; "<i class='icon-white icon-plus'></i>Add Criteria</a>";
var rows = $('.active-tab #smart_block_options'), var rows = $('.active-tab .smart-block-form'),
enabled = rows.find('select[name^="sp_criteria_field"]:enabled'); enabled = rows.find('select[name^="sp_criteria_field"]:enabled');
rows.find('#criteria_add').remove(); rows.find('#criteria_add').remove();
@ -528,6 +544,7 @@ function appendAddButton() {
enabled.siblings('span[id="extra_criteria"]') enabled.siblings('span[id="extra_criteria"]')
.after(add_button); .after(add_button);
} }
*/
} }
function removeButtonCheck() { function removeButtonCheck() {