CC-84: Smart Playlists
-fixed add/remove behaviour
This commit is contained in:
parent
971b4cf7cf
commit
b48fb49947
2 changed files with 19 additions and 13 deletions
|
@ -1,5 +1,5 @@
|
||||||
<form id="smart-playlist-form" method="post" action="">
|
<form id="smart-playlist-form" method="post" action="">
|
||||||
<fieldset class='toggle closed' id='smart_playlist_options'>
|
<fieldset class='toggle closed' id='smart_playlist_options' style='overflow-x:auto; width:781px'>
|
||||||
<legend style='cursor: pointer;'><span class='ui-icon ui-icon-triangle-2-n-s'></span>Smart Playlist Options</legend>
|
<legend style='cursor: pointer;'><span class='ui-icon ui-icon-triangle-2-n-s'></span>Smart Playlist Options</legend>
|
||||||
<dl class='zend_form'>
|
<dl class='zend_form'>
|
||||||
<dd id='sp_type-element' class='radio-inline-list'>
|
<dd id='sp_type-element' class='radio-inline-list'>
|
||||||
|
@ -28,7 +28,7 @@
|
||||||
<?php if ($i != 0) { ?>
|
<?php if ($i != 0) { ?>
|
||||||
<a href='#' id='criteria_remove_<?php echo $i ?>'>Remove </a>
|
<a href='#' id='criteria_remove_<?php echo $i ?>'>Remove </a>
|
||||||
<?php } else { ?>
|
<?php } else { ?>
|
||||||
<a href='#' id='criteria_add'>Add</a>
|
<a href='#' id='criteria_add' class='criteria_add'>Add</a>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<br />
|
<br />
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -28,10 +28,9 @@ function setSmartPlaylistEvents() {
|
||||||
var add_button = form.find('a[id="criteria_add"]');
|
var add_button = form.find('a[id="criteria_add"]');
|
||||||
|
|
||||||
//remove error message from current row, if any
|
//remove error message from current row, if any
|
||||||
var error_element = curr.find('span[class="sp-errors"]');
|
var error_element = curr.find('span[class="errors sp-errors"]');
|
||||||
if (error_element.is(':visible')) {
|
if (error_element.is(':visible')) {
|
||||||
error_element.remove();
|
error_element.remove();
|
||||||
curr.find('span[id="sp-errors"]').remove();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* assign next row to current row for all rows below and including
|
/* assign next row to current row for all rows below and including
|
||||||
|
@ -93,19 +92,25 @@ function setSmartPlaylistEvents() {
|
||||||
}
|
}
|
||||||
|
|
||||||
list.find('div:visible:last').children().attr('disabled', 'disabled');
|
list.find('div:visible:last').children().attr('disabled', 'disabled');
|
||||||
list.find("div:visible:last")
|
list.find('div:visible:last')
|
||||||
.find('[name^="sp_criteria"]').val(0).end()
|
.find('[name^="sp_criteria"]').val(0).end()
|
||||||
.find('[name^="sp_criteria_modifier"]').val(0).end()
|
.find('[name^="sp_criteria_modifier"]').val(0).end()
|
||||||
.find('[name^="sp_criteria_value"]').val('')
|
.find('[name^="sp_criteria_value"]').val('');
|
||||||
.end().hide();
|
|
||||||
|
if (list.find('div:visible:last').children().hasClass('criteria_add')) {
|
||||||
|
list.find('div:visible:last').find('.criteria_add').remove();
|
||||||
|
}
|
||||||
|
list.find('div:visible:last').hide();
|
||||||
|
|
||||||
list.next().show();
|
list.next().show();
|
||||||
|
|
||||||
// always put 'add' button on the last row
|
// always put 'add' button on the last row
|
||||||
if (list.find('div:visible').length > 1) {
|
if (list.find('div:visible').length > 1) {
|
||||||
list.find('div:visible:last').find('a[id^="criteria_remove"]').after(add_button);
|
list.find('div:visible:last').find('a[id^="criteria_remove"]')
|
||||||
|
.after("<a href='#' id='criteria_add' class='criteria_add'>Add</a>");
|
||||||
} else {
|
} else {
|
||||||
list.find('div:visible:last').find('[name^="sp_criteria_value"]').after(add_button);
|
list.find('div:visible:last').find('[name^="sp_criteria_value"]')
|
||||||
|
.after("<a href='#' id='criteria_add' class='criteria_add'>Add</a>");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -210,24 +215,25 @@ function populateModifierSelect(e) {
|
||||||
|
|
||||||
function staticCallback(data) {
|
function staticCallback(data) {
|
||||||
var form = $('#smart-playlist-form');
|
var form = $('#smart-playlist-form');
|
||||||
form.find('span[class="sp-errors"]').remove();
|
form.find('span[class="errors sp-errors"]').remove();
|
||||||
form.find(' span[id="sp-errors"]').remove();
|
|
||||||
var json = $.parseJSON(data);
|
var json = $.parseJSON(data);
|
||||||
if (json.result == "1") {
|
if (json.result == "1") {
|
||||||
$.each(json.errors, function(index, error){
|
$.each(json.errors, function(index, error){
|
||||||
$.each(error.msg, function(index, message){
|
$.each(error.msg, function(index, message){
|
||||||
$('#'+error.element).parent().append("<span class='sp-errors'>"+message+"</span><span id='sp-errors'><br /></span>");
|
$('#'+error.element).parent().append("<span class='errors sp-errors'>"+message+"</span>");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function dynamicCallback(json) {
|
function dynamicCallback(json) {
|
||||||
|
var form = $('#smart-playlist-form');
|
||||||
|
form.find('span[class="errors sp-errors"]').remove();
|
||||||
var json = $.parseJSON(data);
|
var json = $.parseJSON(data);
|
||||||
if (json.result == "1") {
|
if (json.result == "1") {
|
||||||
$.each(json.errors, function(index, error){
|
$.each(json.errors, function(index, error){
|
||||||
$.each(error.msg, function(index, message){
|
$.each(error.msg, function(index, message){
|
||||||
$('#'+error.element).parent().append("<span class='errors'>"+message+"<br /></span>");
|
$('#'+error.element).parent().append("<span class='errors sp-errors'>"+message+"</span>");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue