CC-84: Smart Playlists
-added save button for static playlists
This commit is contained in:
parent
fc09baacd7
commit
e0a674a96c
6 changed files with 44 additions and 36 deletions
|
@ -205,8 +205,16 @@ class Application_Form_SmartPlaylistCriteria extends Zend_Form_SubForm
|
||||||
$save = new Zend_Form_Element_Button('save_button');
|
$save = new Zend_Form_Element_Button('save_button');
|
||||||
$save->setAttrib('class', 'ui-button ui-state-default right-floated');
|
$save->setAttrib('class', 'ui-button ui-state-default right-floated');
|
||||||
$save->setIgnore(true);
|
$save->setIgnore(true);
|
||||||
$save->setLabel('Generate');
|
$save->setLabel('Save');
|
||||||
|
$save->setDecorators(array('viewHelper'));
|
||||||
$this->addElement($save);
|
$this->addElement($save);
|
||||||
|
|
||||||
|
$generate = new Zend_Form_Element_Button('generate_button');
|
||||||
|
$generate->setAttrib('class', 'ui-button ui-state-default right-floated');
|
||||||
|
$generate->setIgnore(true);
|
||||||
|
$generate->setLabel('Generate');
|
||||||
|
$generate->setDecorators(array('viewHelper'));
|
||||||
|
$this->addElement($generate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
<?php echo $this->element->getElement('sp_criteria_modifier_'.$i) ?>
|
<?php echo $this->element->getElement('sp_criteria_modifier_'.$i) ?>
|
||||||
<?php echo $this->element->getElement('sp_criteria_value_'.$i) ?><span id="extra_criteria" <?php echo $this->element->getElement('sp_criteria_extra_'.$i)->getAttrib("disabled") == "disabled"?'style="display:none;"':""?>> to <?php echo $this->element->getElement('sp_criteria_extra_'.$i) ?></span>
|
<?php echo $this->element->getElement('sp_criteria_value_'.$i) ?><span id="extra_criteria" <?php echo $this->element->getElement('sp_criteria_extra_'.$i)->getAttrib("disabled") == "disabled"?'style="display:none;"':""?>> to <?php echo $this->element->getElement('sp_criteria_extra_'.$i) ?></span>
|
||||||
<?php if ($i != 0) { ?>
|
<?php if ($i != 0) { ?>
|
||||||
<a class='ui-button sp-add sp-ui-button-icon-only' id='criteria_remove_<?php echo $i ?>'>
|
<a class='ui-button sp-ui-button-icon-only' id='criteria_remove_<?php echo $i ?>'>
|
||||||
<span class='ui-icon ui-icon-closethick'></span>
|
<span class='ui-icon ui-icon-closethick'></span>
|
||||||
</a>
|
</a>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
@ -45,9 +45,9 @@
|
||||||
<?php echo $this->element->getElement('sp_limit_options') ?>
|
<?php echo $this->element->getElement('sp_limit_options') ?>
|
||||||
</label>
|
</label>
|
||||||
</dd>
|
</dd>
|
||||||
|
<dd id='action_buttons'>
|
||||||
<dd id='sp_save'>
|
|
||||||
<?php echo $this->element->getElement('save_button') ?>
|
<?php echo $this->element->getElement('save_button') ?>
|
||||||
|
<?php echo $this->element->getElement('generate_button') ?>
|
||||||
</dd>
|
</dd>
|
||||||
|
|
||||||
</dl>
|
</dl>
|
||||||
|
|
|
@ -31,9 +31,7 @@
|
||||||
</dl>
|
</dl>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
<?php
|
<?php echo $this->form; ?>
|
||||||
|
|
||||||
echo $this->form; ?>
|
|
||||||
|
|
||||||
<div id="crossfade_main" class="crossfade-main clearfix" style="display:none;">
|
<div id="crossfade_main" class="crossfade-main clearfix" style="display:none;">
|
||||||
<span class="ui-icon ui-icon-closethick"></span>
|
<span class="ui-icon ui-icon-closethick"></span>
|
||||||
|
|
|
@ -440,7 +440,11 @@ input.input_text.sp_extra_input_text{
|
||||||
}
|
}
|
||||||
|
|
||||||
.sp-add.sp-ui-button-icon-only .ui-icon{
|
.sp-add.sp-ui-button-icon-only .ui-icon{
|
||||||
left: 90% !important;
|
margin-left: 20px !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sp-ui-button-icon-only .ui-icon-closethick:hover, .sp-ui-button-icon-only .ui-icon-plusthick:hover {
|
||||||
|
background-image:url(redmond/images/ui-icons_ff5d1a_256x240.png)
|
||||||
}
|
}
|
||||||
|
|
||||||
label {
|
label {
|
||||||
|
|
|
@ -111,31 +111,29 @@ function setSmartPlaylistEvents() {
|
||||||
form.find('button[id="save_button"]').live("click", function(event){
|
form.find('button[id="save_button"]').live("click", function(event){
|
||||||
var playlist_type = form.find('input:radio[name=sp_type]:checked').val(),
|
var playlist_type = form.find('input:radio[name=sp_type]:checked').val(),
|
||||||
data = $('form').serializeArray(),
|
data = $('form').serializeArray(),
|
||||||
static_action = 'Playlist/smart-playlist-generate',
|
save_action = 'Playlist/smart-playlist-criteria-save',
|
||||||
dynamic_action ='Playlist/smart-playlist-criteria-save',
|
|
||||||
action,
|
|
||||||
callback,
|
|
||||||
playlist_id = $('input[id="pl_id"]').val();
|
playlist_id = $('input[id="pl_id"]').val();
|
||||||
|
|
||||||
if (playlist_type == "0") {
|
$.post(save_action, {format: "json", data: data, pl_id: playlist_id}, saveCallback);
|
||||||
action = static_action;
|
});
|
||||||
callback = staticCallback;
|
|
||||||
} else {
|
form.find('button[id="generate_button"]').live("click", function(event){
|
||||||
action = dynamic_action;
|
var playlist_type = form.find('input:radio[name=sp_type]:checked').val(),
|
||||||
callback = dynamicCallback;
|
data = $('form').serializeArray(),
|
||||||
}
|
generate_action = 'Playlist/smart-playlist-generate',
|
||||||
$.post(action, {format: "json", data: data, pl_id: playlist_id}, callback);
|
playlist_id = $('input[id="pl_id"]').val();
|
||||||
|
|
||||||
|
$.post(generate_action, {format: "json", data: data, pl_id: playlist_id}, generateCallback);
|
||||||
});
|
});
|
||||||
|
|
||||||
form.find('dd[id="sp_type-element"]').live("change", function(){
|
form.find('dd[id="sp_type-element"]').live("change", function(){
|
||||||
var playlist_type = $('input:radio[name=sp_type]:checked').val(),
|
var playlist_type = $('input:radio[name=sp_type]:checked').val();
|
||||||
button_text;
|
|
||||||
if (playlist_type == "0") {
|
if (playlist_type == "0") {
|
||||||
button_text = 'Generate';
|
$('button[id="generate_button"]').show();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
button_text = 'Save';
|
$('button[id="generate_button"]').hide();
|
||||||
}
|
}
|
||||||
$('button[id="save_button"]').text(button_text);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
form.find('select[id^="sp_criteria"]:not([id^="sp_criteria_modifier"])').live("change", function(){
|
form.find('select[id^="sp_criteria"]:not([id^="sp_criteria_modifier"])').live("change", function(){
|
||||||
|
@ -176,7 +174,7 @@ function disableAndHideExtraField(valEle, index) {
|
||||||
spanExtra.children('#sp_criteria_extra_'+index).val("").attr("disabled", "disabled");
|
spanExtra.children('#sp_criteria_extra_'+index).val("").attr("disabled", "disabled");
|
||||||
spanExtra.hide();
|
spanExtra.hide();
|
||||||
|
|
||||||
//make value input larger because we don't have extra field now
|
//make value input larger since we don't have extra field now
|
||||||
var criteria_value = $('#sp_criteria_value_'+index);
|
var criteria_value = $('#sp_criteria_value_'+index);
|
||||||
sizeTextBoxes(criteria_value, 'sp_extra_input_text', 'sp_input_text');
|
sizeTextBoxes(criteria_value, 'sp_extra_input_text', 'sp_input_text');
|
||||||
}
|
}
|
||||||
|
@ -209,7 +207,7 @@ function populateModifierSelect(e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function staticCallback(data) {
|
function generateCallback(data) {
|
||||||
var form = $('#smart-playlist-form');
|
var form = $('#smart-playlist-form');
|
||||||
form.find('span[class="errors sp-errors"]').remove();
|
form.find('span[class="errors sp-errors"]').remove();
|
||||||
var json = $.parseJSON(data);
|
var json = $.parseJSON(data);
|
||||||
|
@ -229,7 +227,7 @@ function staticCallback(data) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function dynamicCallback(json) {
|
function saveCallback(json) {
|
||||||
var form = $('#smart-playlist-form');
|
var form = $('#smart-playlist-form');
|
||||||
form.find('span[class="errors sp-errors"]').remove();
|
form.find('span[class="errors sp-errors"]').remove();
|
||||||
var json = $.parseJSON(json);
|
var json = $.parseJSON(json);
|
||||||
|
@ -247,8 +245,8 @@ function dynamicCallback(json) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function appendAddButton(rows) {
|
function appendAddButton(rows) {
|
||||||
var add_button = "<a class='ui-button sp-ui-button-icon-only' id='criteria_add' class='criteria_add'>" +
|
var add_button = "<a class='ui-button sp-add sp-ui-button-icon-only' id='criteria_add' class='criteria_add'>" +
|
||||||
"<span class='ui-icon ui-icon-plusthick'</span></a>";
|
"<span class='ui-icon ui-icon-plusthick'></span></a>";
|
||||||
|
|
||||||
if (rows.find('select[name^="sp_criteria_field"]:enabled').length > 1) {
|
if (rows.find('select[name^="sp_criteria_field"]:enabled').length > 1) {
|
||||||
rows.find('select[name^="sp_criteria_field"]:enabled:last')
|
rows.find('select[name^="sp_criteria_field"]:enabled:last')
|
||||||
|
@ -256,7 +254,7 @@ function appendAddButton(rows) {
|
||||||
.after(add_button);
|
.after(add_button);
|
||||||
} else {
|
} else {
|
||||||
rows.find('select[name^="sp_criteria_field"]:enabled')
|
rows.find('select[name^="sp_criteria_field"]:enabled')
|
||||||
.siblings('[name^="sp_criteria_value"]')
|
.siblings('input:last')
|
||||||
.after(add_button);
|
.after(add_button);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 0653ec0b89362921f075af96ee8772538b801a7c
|
Subproject commit 492242f4bb7367afebbf2f096067cb5a5d3c0449
|
Loading…
Add table
Add a link
Reference in a new issue