CC-84: Smart Playlists
- removed criteria subform and reverted back to original criteria options design
This commit is contained in:
parent
64185dac95
commit
c82ea30809
|
@ -76,12 +76,9 @@ class PlaylistController extends Zend_Controller_Action
|
|||
$formatter = new LengthFormatter($pl->getLength());
|
||||
$this->view->length = $formatter->format();
|
||||
|
||||
$form = new Application_Form_SmartPlaylist();
|
||||
$form = new Application_Form_SmartPlaylistCriteria();
|
||||
$form->removeDecorator('DtDdWrapper');
|
||||
$form->startForm($pl->getId());
|
||||
/*$subform = new Application_Form_SmartPlaylistCriteriaSubForm();
|
||||
$form->removeDecorator('DtDdWrapper');
|
||||
$form->addSubForm($subform, 'sp_set_1');*/
|
||||
|
||||
$this->view->form = $form;
|
||||
|
||||
|
@ -175,7 +172,7 @@ class PlaylistController extends Zend_Controller_Action
|
|||
|
||||
if($isAdminOrPM || $pl->getCreatorId() == $userInfo->id){
|
||||
$this->view->pl = $pl;
|
||||
$form = new Application_Form_SmartPlaylist();
|
||||
$form = new Application_Form_SmartPlaylistCriteria();
|
||||
$form->startForm($this->pl_sess->id);
|
||||
$this->view->form = $form;
|
||||
}
|
||||
|
@ -503,4 +500,5 @@ class PlaylistController extends Zend_Controller_Action
|
|||
die(json_encode($result));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,89 +0,0 @@
|
|||
<?php
|
||||
class Application_Form_SmartPlaylist extends Zend_Form
|
||||
{
|
||||
public function init(){
|
||||
|
||||
}
|
||||
public function startForm($p_playlistId)
|
||||
{
|
||||
// load type
|
||||
$out = CcPlaylistQuery::create()->findPk($p_playlistId);
|
||||
if ($out->getDbType() == "static") {
|
||||
$playlistType = 0;
|
||||
} else {
|
||||
$playlistType = 1;
|
||||
}
|
||||
|
||||
$spType = new Zend_Form_Element_Radio('sp_type');
|
||||
$spType->setLabel('Set smart playlist type:')
|
||||
->setDecorators(array('viewHelper'))
|
||||
->setMultiOptions(array(
|
||||
'static' => 'Static',
|
||||
'dynamic' => 'Dynamic'
|
||||
))
|
||||
->setValue($playlistType);
|
||||
$this->addElement($spType);
|
||||
|
||||
/*
|
||||
// load criteria from db
|
||||
$out = CcPlaylistcriteriaQuery::create()->findByDbPlaylistId($p_playlistId);
|
||||
*/
|
||||
/*$storedCrit = array();
|
||||
foreach ($out as $crit) {
|
||||
$criteria = $crit->getDbCriteria();
|
||||
$modifier = $crit->getDbModifier();
|
||||
$value = $crit->getDbValue();
|
||||
$extra = $crit->getDbExtra();
|
||||
|
||||
if($criteria == "limit"){
|
||||
$storedCrit["limit"] = array("value"=>$value, "modifier"=>$modifier);
|
||||
}else{
|
||||
$storedCrit["crit"][] = array("criteria"=>$criteria, "value"=>$value, "modifier"=>$modifier, "extra"=>$extra);
|
||||
}
|
||||
}*/
|
||||
|
||||
$save = new Zend_Form_Element_Button('save_button');
|
||||
$save->setAttrib('class', 'ui-button ui-state-default sp-button');
|
||||
$save->setAttrib('title', 'Save criteria only');
|
||||
$save->setIgnore(true);
|
||||
$save->setLabel('Save');
|
||||
$save->setDecorators(array('viewHelper'));
|
||||
$this->addElement($save);
|
||||
|
||||
$generate = new Zend_Form_Element_Button('generate_button');
|
||||
$generate->setAttrib('class', 'ui-button ui-state-default sp-button');
|
||||
$generate->setAttrib('title', 'Save criteria and generate playlist content');
|
||||
$generate->setIgnore(true);
|
||||
$generate->setLabel('Generate');
|
||||
$generate->setDecorators(array('viewHelper'));
|
||||
$this->addElement($generate);
|
||||
|
||||
$shuffle = new Zend_Form_Element_Button('shuffle_button');
|
||||
$shuffle->setAttrib('class', 'ui-button ui-state-default sp-button');
|
||||
$shuffle->setAttrib('title', 'Shuffle playlist content');
|
||||
$shuffle->setIgnore(true);
|
||||
$shuffle->setLabel('Shuffle');
|
||||
$shuffle->setDecorators(array('viewHelper'));
|
||||
$this->addElement($shuffle);
|
||||
|
||||
$openSmartPlaylistOption = false;
|
||||
$numOfSubForm = 3;
|
||||
for ($i=0; $i<$numOfSubForm; $i++) {
|
||||
$subform = new Application_Form_SmartPlaylistCriteriaSubForm();
|
||||
$subform->setCriteriaSetNumber($i);
|
||||
$subform->startForm($p_playlistId);
|
||||
$this->addSubForm($subform, 'sp_set_'.$i);
|
||||
if ($subform->getIsOpen()) {
|
||||
$openSmartPlaylistOption = true;
|
||||
}
|
||||
}
|
||||
|
||||
//getting playlist content candidate count that meets criteria
|
||||
$pl = new Application_Model_Playlist($p_playlistId);
|
||||
$files = $pl->getListofFilesMeetCriteria();
|
||||
|
||||
$this->setDecorators(array(
|
||||
array('ViewScript', array('viewScript' => 'form/smart-playlist.phtml', "openOption"=> $openSmartPlaylistOption, "parent_form"=>$this, "numOfSubForm"=>$numOfSubForm))
|
||||
));
|
||||
}
|
||||
}
|
|
@ -1,246 +0,0 @@
|
|||
<?php
|
||||
class Application_Form_SmartPlaylistCriteriaSubForm extends Zend_Form_SubForm
|
||||
{
|
||||
private $setNumber;
|
||||
private $openSubset;
|
||||
|
||||
public function init(){
|
||||
|
||||
}
|
||||
|
||||
public function setCriteriaSetNumber($p_num)
|
||||
{
|
||||
$this->setNumber = $p_num;
|
||||
}
|
||||
|
||||
public function startForm($p_playlistId)
|
||||
{
|
||||
$criteriaOptions = array(
|
||||
0 => "Select criteria",
|
||||
"album_title" => "Album",
|
||||
"bit_rate" => "Bit Rate",
|
||||
"bpm" => "Bpm",
|
||||
"comments" => "Comments",
|
||||
"composer" => "Composer",
|
||||
"conductor" => "Conductor",
|
||||
"artist_name" => "Creator",
|
||||
"disc_number" => "Disc Number",
|
||||
"genre" => "Genre",
|
||||
"isrc_number" => "ISRC",
|
||||
"label" => "Label",
|
||||
"language" => "Language",
|
||||
"mtime" => "Last Modified",
|
||||
"lptime" => "Last Played",
|
||||
"length" => "Length",
|
||||
"lyricist" => "Lyricist",
|
||||
"mood" => "Mood",
|
||||
"name" => "Name",
|
||||
"orchestra" => "Orchestra",
|
||||
"radio_station_name" => "Radio Station Name",
|
||||
"rating" => "Rating",
|
||||
"sample_rate" => "Sample Rate",
|
||||
"track_title" => "Title",
|
||||
"track_num" => "Track Number",
|
||||
"utime" => "Uploaded",
|
||||
"year" => "Year"
|
||||
);
|
||||
|
||||
$criteriaTypes = array(
|
||||
0 => "",
|
||||
"album_title" => "s",
|
||||
"artist_name" => "s",
|
||||
"bit_rate" => "n",
|
||||
"bpm" => "n",
|
||||
"comments" => "s",
|
||||
"composer" => "s",
|
||||
"conductor" => "s",
|
||||
"utime" => "n",
|
||||
"mtime" => "n",
|
||||
"lptime" => "n",
|
||||
"disc_number" => "n",
|
||||
"genre" => "s",
|
||||
"isrc_number" => "s",
|
||||
"label" => "s",
|
||||
"language" => "s",
|
||||
"length" => "n",
|
||||
"lyricist" => "s",
|
||||
"mood" => "s",
|
||||
"name" => "s",
|
||||
"orchestra" => "s",
|
||||
"radio_station_name" => "s",
|
||||
"rating" => "n",
|
||||
"sample_rate" => "n",
|
||||
"track_title" => "s",
|
||||
"track_num" => "n",
|
||||
"year" => "n"
|
||||
);
|
||||
|
||||
$stringCriteriaOptions = array(
|
||||
"0" => "Select modifier",
|
||||
"contains" => "contains",
|
||||
"does not contain" => "does not contain",
|
||||
"is" => "is",
|
||||
"is not" => "is not",
|
||||
"starts with" => "starts with",
|
||||
"ends with" => "ends with"
|
||||
);
|
||||
|
||||
$numericCriteriaOptions = array(
|
||||
"0" => "Select modifier",
|
||||
"is" => "is",
|
||||
"is not" => "is not",
|
||||
"is greater than" => "is greater than",
|
||||
"is less than" => "is less than",
|
||||
"is in the range" => "is in the range"
|
||||
);
|
||||
|
||||
$limitOptions = array(
|
||||
"hours" => "hours",
|
||||
"minutes" => "minutes",
|
||||
"items" => "items"
|
||||
);
|
||||
|
||||
/*
|
||||
// load type
|
||||
$out = CcPlaylistQuery::create()->findPk($p_playlistId);
|
||||
if ($out->getDbType() == "static") {
|
||||
$playlistType = 0;
|
||||
} else {
|
||||
$playlistType = 1;
|
||||
}
|
||||
|
||||
|
||||
$spType = new Zend_Form_Element_Radio('sp_type');
|
||||
$spType->setLabel('Set smart playlist type:')
|
||||
->setDecorators(array('viewHelper'))
|
||||
->setMultiOptions(array(
|
||||
'static' => 'Static',
|
||||
'dynamic' => 'Dynamic'
|
||||
))
|
||||
->setValue($playlistType);
|
||||
$this->addElement($spType);
|
||||
*/
|
||||
|
||||
// load criteria from db
|
||||
$out = CcPlaylistcriteriaQuery::create()->findByDbPlaylistId($p_playlistId);
|
||||
|
||||
$storedCrit = array();
|
||||
foreach ($out as $crit) {
|
||||
$criteria = $crit->getDbCriteria();
|
||||
$modifier = $crit->getDbModifier();
|
||||
$value = $crit->getDbValue();
|
||||
$extra = $crit->getDbExtra();
|
||||
|
||||
if($criteria == "limit"){
|
||||
$storedCrit[]["limit"] = array("value"=>$value, "modifier"=>$modifier);
|
||||
}else{
|
||||
$storedCrit[]["crit"][] = array("criteria"=>$criteria, "value"=>$value, "modifier"=>$modifier, "extra"=>$extra);
|
||||
}
|
||||
}
|
||||
|
||||
$openSmartPlaylistOption = false;
|
||||
if (!empty($storedCrit)) {
|
||||
$openSmartPlaylistOption = true;
|
||||
$this->openSubset = $openSmartPlaylistOption;
|
||||
}
|
||||
|
||||
if(!empty($subsetOpen)){
|
||||
$openSmartPlaylistOption = true;
|
||||
}
|
||||
|
||||
$numElements = count($criteriaOptions);
|
||||
for ($i = 0; $i < $numElements; $i++) {
|
||||
$criteriaType = "";
|
||||
|
||||
$criteria = new Zend_Form_Element_Select("sp_criteria_field_".$this->setNumber."_".$i);
|
||||
$criteria->setAttrib('class', 'input_select sp_input_select')
|
||||
->setValue('Select criteria')
|
||||
->setDecorators(array('viewHelper'))
|
||||
->setMultiOptions($criteriaOptions);
|
||||
if ($i != 0 && !isset($storedCrit["crit"][$i])){
|
||||
$criteria->setAttrib('disabled', 'disabled');
|
||||
}
|
||||
if (isset($storedCrit["crit"][$i])) {
|
||||
$criteriaType = $criteriaTypes[$storedCrit["crit"][$i]["criteria"]];
|
||||
$criteria->setValue($storedCrit["crit"][$i]["criteria"]);
|
||||
}
|
||||
$this->addElement($criteria);
|
||||
|
||||
$criteriaModifers = new Zend_Form_Element_Select("sp_criteria_modifier_".$this->setNumber."_".$i);
|
||||
$criteriaModifers->setValue('Select modifier')
|
||||
->setAttrib('class', 'input_select sp_input_select')
|
||||
->setDecorators(array('viewHelper'));
|
||||
if ($i != 0 && !isset($storedCrit["crit"][$i])){
|
||||
$criteriaModifers->setAttrib('disabled', 'disabled');
|
||||
}
|
||||
if (isset($storedCrit["crit"][$i])) {
|
||||
if($criteriaType == "s"){
|
||||
$criteriaModifers->setMultiOptions($stringCriteriaOptions);
|
||||
}else{
|
||||
$criteriaModifers->setMultiOptions($numericCriteriaOptions);
|
||||
}
|
||||
$criteriaModifers->setValue($storedCrit["crit"][$i]["modifier"]);
|
||||
}else{
|
||||
$criteriaModifers->setMultiOptions(array('0' => 'Select modifier'));
|
||||
}
|
||||
$this->addElement($criteriaModifers);
|
||||
|
||||
$criteriaValue = new Zend_Form_Element_Text("sp_criteria_value_".$this->setNumber."_".$i);
|
||||
$criteriaValue->setAttrib('class', 'input_text sp_input_text')
|
||||
->setDecorators(array('viewHelper'));
|
||||
if ($i != 0 && !isset($storedCrit["crit"][$i])){
|
||||
$criteriaValue->setAttrib('disabled', 'disabled');
|
||||
}
|
||||
if (isset($storedCrit["crit"][$i])) {
|
||||
$criteriaValue->setValue($storedCrit["crit"][$i]["value"]);
|
||||
}
|
||||
$this->addElement($criteriaValue);
|
||||
|
||||
$criteriaExtra = new Zend_Form_Element_Text("sp_criteria_extra_".$this->setNumber."_".$i);
|
||||
$criteriaExtra->setAttrib('class', 'input_text sp_extra_input_text')
|
||||
->setDecorators(array('viewHelper'));
|
||||
if (isset($storedCrit["crit"][$i]["extra"])) {
|
||||
$criteriaExtra->setValue($storedCrit["crit"][$i]["extra"]);
|
||||
$criteriaValue->setAttrib('class', 'input_text sp_extra_input_text');
|
||||
}else{
|
||||
$criteriaExtra->setAttrib('disabled', 'disabled');
|
||||
}
|
||||
$this->addElement($criteriaExtra);
|
||||
}
|
||||
|
||||
$limit = new Zend_Form_Element_Select('sp_limit_options_'.$this->setNumber);
|
||||
$limit->setAttrib('class', 'sp_input_select')
|
||||
->setDecorators(array('viewHelper'))
|
||||
->setMultiOptions($limitOptions);
|
||||
if (isset($storedCrit["limit"])) {
|
||||
$limit->setValue($storedCrit["limit"]["modifier"]);
|
||||
}
|
||||
$this->addElement($limit);
|
||||
|
||||
$limitValue = new Zend_Form_Element_Text('sp_limit_value_'.$this->setNumber);
|
||||
$limitValue->setAttrib('class', 'sp_input_text_limit')
|
||||
->setLabel('Limit to')
|
||||
->setDecorators(array('viewHelper'));
|
||||
$this->addElement($limitValue);
|
||||
if (isset($storedCrit["limit"])) {
|
||||
$limitValue->setValue($storedCrit["limit"]["value"]);
|
||||
}
|
||||
|
||||
//getting playlist content candidate count that meets criteria
|
||||
$pl = new Application_Model_Playlist($p_playlistId);
|
||||
$files = $pl->getListofFilesMeetCriteria();
|
||||
|
||||
Logging::log($this->getElements());
|
||||
Logging::log(count($this->getElements()));
|
||||
|
||||
$this->setDecorators(array(
|
||||
array('ViewScript', array('viewScript' => 'form/smart-playlist-criteria.phtml', "openOption"=> $openSmartPlaylistOption,
|
||||
'criteriasLength' => count($criteriaOptions), 'poolCount' => $files['count'], 'setNumber' => $this->setNumber))
|
||||
));
|
||||
}
|
||||
|
||||
public function getIsOpen()
|
||||
{
|
||||
return $this->openSubset;
|
||||
}
|
||||
}
|
|
@ -1,20 +1,39 @@
|
|||
<h2 class="collapsible-header close" id='sp_set_<?php echo $this->setNumber?>' <?php echo $this->openOption || $this->setNumber == 0 ? "" : "style='display:none'"?>>
|
||||
<span class="arrow-icon"></span>Set <?php echo $this->setNumber?>
|
||||
</h2>
|
||||
<fieldset class='toggle <?php echo $this->openOption ? "" : "closed sp-closed"?>' id='sp_set_<?php echo $this->setNumber?>'>
|
||||
<form id="smart-playlist-form" method="post" action="">
|
||||
<fieldset class='toggle <?php echo $this->openOption ? "" : "closed"?>' id='smart_playlist_options'>
|
||||
<legend style='cursor: pointer;'><span class='ui-icon ui-icon-triangle-2-n-s'></span>Smart Playlist Options</legend>
|
||||
<dl class='zend_form'>
|
||||
<div id='sp-success' class='success' style='display:none'></div>
|
||||
<dd id='sp_type-element'>
|
||||
<label class='sp-label'>
|
||||
<?php echo $this->element->getElement('sp_type')->getLabel() ?>
|
||||
<span class='playlist_type_help_icon'></span>
|
||||
</label>
|
||||
<?php $i=0;
|
||||
$value = $this->element->getElement('sp_type')->getValue();
|
||||
foreach ($this->element->getElement('sp_type')->getMultiOptions() as $radio) : ?>
|
||||
|
||||
<label class='sp-label' for='sp_type-<?php echo $i?>'>
|
||||
<input type="radio" value="<?php echo $i ?>" id="sp_type-<?php echo $i ?>" name="sp_type" <?php if($i == $value){echo 'checked="checked"';}?> ><?php echo $radio ?>
|
||||
</label>
|
||||
<?php $i = $i + 1; ?>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<?php echo $this->element->getElement('save_button') ?>
|
||||
<?php echo $this->element->getElement('generate_button') ?>
|
||||
<?php echo $this->element->getElement('shuffle_button') ?>
|
||||
</dd>
|
||||
|
||||
<dd id='sp_criteria-element'>
|
||||
<?php for ($i = 0; $i < $this->criteriasLength; $i++) {?>
|
||||
<div <?php if (($i > 0) && ($this->element->getElement("sp_criteria_field_".$this->setNumber."_".$i)->getAttrib('disabled') == 'disabled')) {
|
||||
<div <?php if (($i > 0) && ($this->element->getElement("sp_criteria_field_".$i)->getAttrib('disabled') == 'disabled')) {
|
||||
echo 'style=display:none';
|
||||
} ?>>
|
||||
|
||||
<?php echo $this->element->getElement("sp_criteria_field_".$this->setNumber."_".$i) ?>
|
||||
<?php echo $this->element->getElement("sp_criteria_modifier_".$this->setNumber."_".$i) ?>
|
||||
<?php echo $this->element->getElement("sp_criteria_value_".$this->setNumber."_".$i) ?>
|
||||
<span class='sp_text_font' id="extra_criteria" <?php echo $this->element->getElement("sp_criteria_extra_".$this->setNumber."_".$i)->getAttrib("disabled") == "disabled"?'style="display:none;"':""?>> to <?php echo $this->element->getElement('sp_criteria_extra_'.$this->setNumber.'_'.$i) ?></span>
|
||||
<a class='ui-button sp-ui-button-icon-only' id='criteria_remove_<?php echo $this->setNumber ?>_<?php echo $i ?>'>
|
||||
<?php echo $this->element->getElement("sp_criteria_field_".$i) ?>
|
||||
<?php echo $this->element->getElement("sp_criteria_modifier_".$i) ?>
|
||||
<?php echo $this->element->getElement("sp_criteria_value_".$i) ?>
|
||||
<span class='sp_text_font' 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>
|
||||
<a class='ui-button sp-ui-button-icon-only' id='criteria_remove_<?php echo $i ?>'>
|
||||
<span class='ui-icon ui-icon-closethick'></span>
|
||||
</a>
|
||||
<br />
|
||||
|
@ -25,9 +44,9 @@
|
|||
</dd>
|
||||
|
||||
<dd id='sp_limit-element'>
|
||||
<span class='sp_text_font'><?php echo $this->element->getElement('sp_limit_value_'.$this->setNumber)->getLabel() ?></span>
|
||||
<?php echo $this->element->getElement('sp_limit_value_'.$this->setNumber)?>
|
||||
<?php echo $this->element->getElement('sp_limit_options_'.$this->setNumber) ?>
|
||||
<span class='sp_text_font'><?php echo $this->element->getElement('sp_limit_value')->getLabel() ?></span>
|
||||
<?php echo $this->element->getElement('sp_limit_value')?>
|
||||
<?php echo $this->element->getElement('sp_limit_options') ?>
|
||||
<br /><br />
|
||||
</dd>
|
||||
<div class='sp_text_font sp_text_font_bold'>
|
||||
|
@ -57,5 +76,12 @@
|
|||
?>
|
||||
</div>
|
||||
|
||||
|
||||
</dl>
|
||||
</fieldset>
|
||||
<?php /*
|
||||
for($i=0; $i<$this->numOfSubForm; $i++){
|
||||
echo $this->parent_form->getSubform('sp_set_'.$i);
|
||||
}*/
|
||||
?>
|
||||
</fieldset>
|
||||
</form>
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
<form id="smart-playlist-form" method="post" action="">
|
||||
<fieldset class='toggle <?php echo $this->openOption ? "" : "closed"?>' id='smart_playlist_options'>
|
||||
<legend style='cursor: pointer;'><span class='ui-icon ui-icon-triangle-2-n-s'></span>Smart Playlist Options</legend>
|
||||
<dl class='zend_form'>
|
||||
<div id='sp-success' class='success' style='display:none'></div>
|
||||
<dd id='sp_type-element'>
|
||||
<label class='sp-label'>
|
||||
<?php echo $this->element->getElement('sp_type')->getLabel() ?>
|
||||
<span class='playlist_type_help_icon'></span>
|
||||
</label>
|
||||
<?php $i=0;
|
||||
$value = $this->element->getElement('sp_type')->getValue();
|
||||
foreach ($this->element->getElement('sp_type')->getMultiOptions() as $radio) : ?>
|
||||
|
||||
<label class='sp-label' for='sp_type-<?php echo $i?>'>
|
||||
<input type="radio" value="<?php echo $i ?>" id="sp_type-<?php echo $i ?>" name="sp_type" <?php if($i == $value){echo 'checked="checked"';}?> ><?php echo $radio ?>
|
||||
</label>
|
||||
<?php $i = $i + 1; ?>
|
||||
<?php endforeach; ?>
|
||||
<?php echo $this->element->getElement('save_button') ?>
|
||||
<?php echo $this->element->getElement('generate_button') ?>
|
||||
<?php echo $this->element->getElement('shuffle_button') ?>
|
||||
</dd>
|
||||
</dl>
|
||||
<?php
|
||||
for($i=0; $i<$this->numOfSubForm; $i++){
|
||||
echo $this->parent_form->getSubform('sp_set_'.$i);
|
||||
}
|
||||
?>
|
||||
</fieldset>
|
||||
</form>
|
|
@ -3,9 +3,9 @@ $(document).ready(function() {
|
|||
});
|
||||
|
||||
function setSmartPlaylistEvents() {
|
||||
var form = $('#smart-playlist-form'),
|
||||
sets = form.find('h2[id^=sp_set]');
|
||||
var form = $('#smart-playlist-form');
|
||||
|
||||
/*
|
||||
sets.each(function(index, set){
|
||||
$(set).live('click', function(){
|
||||
if ($(this).next().hasClass('closed')) {
|
||||
|
@ -15,6 +15,7 @@ function setSmartPlaylistEvents() {
|
|||
}
|
||||
});
|
||||
});
|
||||
*/
|
||||
|
||||
form.find('.criteria_add').live('click', function(){
|
||||
|
||||
|
@ -333,39 +334,32 @@ function removeSuccessMsg() {
|
|||
function appendAddButton() {
|
||||
var add_button = "<a class='ui-button sp-ui-button-icon-only criteria_add'>" +
|
||||
"<span class='ui-icon ui-icon-plusthick'></span></a>";
|
||||
var rows = $('#smart_playlist_options'),
|
||||
enabled = rows.find('select[name^="sp_criteria_field"]:enabled');
|
||||
|
||||
var sets = $('fieldset[id^=sp_set]');
|
||||
rows.find('.criteria_add').remove();
|
||||
|
||||
sets.each(function(index, ele){
|
||||
var set = $(ele);
|
||||
set.find('.criteria_add').remove();
|
||||
|
||||
if (set.find('select[name^="sp_criteria_field"]:enabled').length > 1) {
|
||||
set.find('select[name^="sp_criteria_field"]:enabled:last')
|
||||
.siblings('a[id^="criteria_remove"]')
|
||||
.after(add_button);
|
||||
} else {
|
||||
set.find('select[name^="sp_criteria_field"]:enabled')
|
||||
.siblings('span[id="extra_criteria"]')
|
||||
.after(add_button);
|
||||
}
|
||||
});
|
||||
if (enabled.length > 1) {
|
||||
rows.find('select[name^="sp_criteria_field"]:enabled:last')
|
||||
.siblings('a[id^="criteria_remove"]')
|
||||
.after(add_button);
|
||||
} else {
|
||||
enabled.siblings('span[id="extra_criteria"]')
|
||||
.after(add_button);
|
||||
}
|
||||
}
|
||||
|
||||
function removeButtonCheck() {
|
||||
var sets = $('fieldset[id^=sp_set]');
|
||||
sets.each(function(index, ele){
|
||||
var set = $(ele);
|
||||
var temp = set.find('select[name^="sp_criteria_field"]:enabled');
|
||||
var ex = temp.siblings('a[id^="criteria_remove"]');
|
||||
if (temp.length == 1) {
|
||||
ex.attr('disabled', 'disabled');
|
||||
ex.hide();
|
||||
} else {
|
||||
ex.removeAttr('disabled');
|
||||
ex.show();
|
||||
}
|
||||
});
|
||||
var rows = $('dd[id="sp_criteria-element"]').children('div'),
|
||||
enabled = rows.find('select[name^="sp_criteria_field"]:enabled'),
|
||||
rmv_button = enabled.siblings('a[id^="criteria_remove"]');
|
||||
if (enabled.length == 1) {
|
||||
rmv_button.attr('disabled', 'disabled');
|
||||
rmv_button.hide();
|
||||
} else {
|
||||
rmv_button.removeAttr('disabled');
|
||||
rmv_button.show();
|
||||
}
|
||||
}
|
||||
|
||||
var criteriaTypes = {
|
||||
|
|
Loading…
Reference in New Issue