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

View File

@ -20,9 +20,10 @@
<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>
<div>
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.
<div><p>
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.
</p>
</div>
</div>
</fieldset>

View File

@ -2,8 +2,10 @@
<div id="current-user-container">
<?php if(Application_Model_User::getCurrentUser()->isSuperAdmin()) : ?>
<div class="user-data" id="user_details_superadmin_message" style="text-align: center;">
<?=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");?>
<div id="user_details_superadmin_message">
<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>
</div>
<?php endif; ?>

View File

@ -65,7 +65,9 @@
<dt><label><?php echo(_("Search Criteria:"));?></label></dt>
<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
// i.e. if we have 'Album contains 1' and 'Album contains 2' the modRowMap
// 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_modifier_".$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>
<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>
<span class='db-logic-label' <?php if ($nextDisabled) echo "style='display:none'"?>>
<?php echo $logicLabel;?>
</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 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)) : ?>
<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">
<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'); ?>"/>
@ -33,6 +37,11 @@ if (isset($this->obj)) {
<div class="ui-widget-header fg-toolbar btn-toolbar clearfix">
<h4 class="obj_length"><?php echo($this->length); ?></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'>
<button class="btn" title='<?php echo _("Shuffle playlist") ?>' type="button" id="playlist_shuffle_button"><?php echo _("Shuffle") ?></button>
</div>

View File

@ -6,6 +6,10 @@ 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">
<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'); ?>"/>
@ -40,6 +44,9 @@ if (isset($this->obj)) {
<h4 class="obj_length"><?php echo($this->length); ?></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'>
<?php echo $this->form->getElement('generate_button');?>
</div>

View File

@ -1,6 +1,6 @@
<?php
$items = $this->contents;
if (count($items)) : ?>
if (count($items) && ($this->obj instanceof Application_Model_Block && $this->obj->isStatic())) : ?>
<?php $i = 0; ?>
<?php foreach($items as $item) :
$staticBlock = null;
@ -131,8 +131,15 @@ if (($i < count($items) -1) && ($items[$i+1]['type'] == 0)) {
<?php else : ?>
<div class="spl_empty">
<?php
echo _("Drag tracks here from your library to add them to the "
. ($this->obj instanceof Application_Model_Block ? "smart block" : "playlist"));
if ($this->obj instanceof Application_Model_Block) {
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>
<?php endif; ?>

View File

@ -4,27 +4,32 @@
<input class="obj_type" type="hidden" value="webstream"/>
<div class="status" style="display:none;"></div>
<div class="playlist_title">
<div id="name-error" class="errors" style="display:none;"></div>
<h3 class="ws_name">
<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 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>
<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>
<dd id="description-element">
<textarea cols="80" rows="24" id="description" name="description"><?php echo $this->obj->getDescription(); ?></textarea>
</dd>
</dl>
<dl class="zend_form">
<dt id="submit-label" style="display: none;">&nbsp;</dt>
<div id="url-error" class="errors" style="display:none;"></div>
<dt id="streamurl-label"><label for="streamurl"><?php echo _("Stream URL:"); ?></label></dt>
<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>
<div id="length-error" class="errors" style="display:none;"></div>
<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() ?>"/>
</dd>
</dl>
</div>
<div class="btn-toolbar spl-no-margin clearfix">
<div class="btn-toolbar clearfix">
<div class="btn-group pull-right">
<button class="btn" type="button" id="webstream_cancel" name="submit"><?php echo _("Cancel") ?></button>
</div>

View File

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

View File

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

View File

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

View File

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

View File

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