Merge branch 'devel' of dev.sourcefabric.org:airtime into devel

This commit is contained in:
Martin Konecny 2012-08-08 13:09:03 -04:00
commit c7b583c789
4 changed files with 55 additions and 32 deletions

View File

@ -29,13 +29,12 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm
"mood" => "Mood", "mood" => "Mood",
"name" => "Name", "name" => "Name",
"orchestra" => "Orchestra", "orchestra" => "Orchestra",
"radio_station_name" => "Radio Station Name",
"rating" => "Rating", "rating" => "Rating",
"sample_rate" => "Sample Rate", "sample_rate" => "Sample Rate",
"track_title" => "Title", "track_title" => "Title",
"track_number" => "Track Number", "track_number" => "Track Number",
"utime" => "Uploaded", "utime" => "Uploaded",
"year" => "Year" "year" => "Year"
); );
$criteriaTypes = array( $criteriaTypes = array(
@ -60,7 +59,6 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm
"mood" => "s", "mood" => "s",
"name" => "s", "name" => "s",
"orchestra" => "s", "orchestra" => "s",
"radio_station_name" => "s",
"rating" => "n", "rating" => "n",
"sample_rate" => "n", "sample_rate" => "n",
"track_title" => "s", "track_title" => "s",
@ -210,7 +208,7 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm
/* This is where the additional modifier rows get defined /* This is where the additional modifier rows get defined
* The additional row count starts at 0 and gets appended * The additional row count starts at 0 and gets appended
* to the parent field name * to the parent field name
*/ */
} else if (count($storedCrit["crit"][$criteriaKeys[$i]]) > 1) { } else if (count($storedCrit["crit"][$criteriaKeys[$i]]) > 1) {
$n = $j - 1; $n = $j - 1;
$criteria = new Zend_Form_Element_Select("sp_criteria_field_".$i."_".$n); $criteria = new Zend_Form_Element_Select("sp_criteria_field_".$i."_".$n);
@ -251,7 +249,7 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm
$this->addElement($criteriaExtra); $this->addElement($criteriaExtra);
} }
}//for }//for
}//for }//for

View File

@ -76,7 +76,6 @@ class Application_Model_Block
"mood" => "DbMood", "mood" => "DbMood",
"name" => "DbName", "name" => "DbName",
"orchestra" => "DbOrchestra", "orchestra" => "DbOrchestra",
"radio_station_name" => "DbRadioStationName",
"rating" => "DbRating", "rating" => "DbRating",
"sample_rate" => "DbSampleRate", "sample_rate" => "DbSampleRate",
"track_title" => "DbTrackTitle", "track_title" => "DbTrackTitle",
@ -1255,7 +1254,6 @@ EOT;
"mood" => "Mood", "mood" => "Mood",
"name" => "Name", "name" => "Name",
"orchestra" => "Orchestra", "orchestra" => "Orchestra",
"radio_station_name" => "Radio Station Name",
"rating" => "Rating", "rating" => "Rating",
"sample_rate" => "Sample Rate", "sample_rate" => "Sample Rate",
"track_title" => "Title", "track_title" => "Title",

View File

@ -10,7 +10,7 @@ if ($item['type'] == 2) {
} }
?> ?>
<li class="ui-state-default" id="spl_<?php echo $item["id"] ?>" unqid="<?php echo $item["id"]; ?>"> <li class="ui-state-default" id="spl_<?php echo $item["id"] ?>" unqid="<?php echo $item["id"]; ?>">
<div class="list-item-container"> <div class="list-item-container">
<?php if ($item['type'] == 0 && $item['exists']):?> <?php if ($item['type'] == 0 && $item['exists']):?>
<div class="big_play" audioFile="<?php echo $item["id"]; ?>"> <div class="big_play" audioFile="<?php echo $item["id"]; ?>">
@ -39,11 +39,11 @@ if ($item['type'] == 2) {
<span class="spl_title"><?php echo $item['track_title'] ?></span> <span class="spl_title"><?php echo $item['track_title'] ?></span>
</div> </div>
<div class="text-row"> <div class="text-row">
<span class="spl_artist"><?php echo $item['creator'] ?></span> <span class="spl_artist"><?php echo $item['creator'] ?></span>
<span class="spl_offset"><?php echo $item["offset"]?></span> <span class="spl_offset"><?php echo $item["offset"]?></span>
</div> </div>
<?php //create the crossfade icon. <?php //create the crossfade icon.
if ($i < count($items) -1): if (($i < count($items) -1) && !($items[$i]['type'] == 2 && $items[$i+1]['type'])):
?> ?>
<div id="fade_<?php echo $i ?>" class="spl_fade_control ui-state-default"></div> <div id="fade_<?php echo $i ?>" class="spl_fade_control ui-state-default"></div>
<?php endif; ?> <?php endif; ?>
@ -62,7 +62,7 @@ if ($item['type'] == 2) {
<?php //create a fade editor box <?php //create a fade editor box
//(fadeout of current position + fade in of next position) //(fadeout of current position + fade in of next position)
if($i < count($items) -1): if(($i < count($items) -1) && !($items[$i]['type'] == 2 && $items[$i+1]['type'])):
?> ?>
<div id="crossfade_<?php echo $i ?>-<?php echo $i+1 ?>" class="crossfade clearfix" style="display: none"> <div id="crossfade_<?php echo $i ?>-<?php echo $i+1 ?>" class="crossfade clearfix" style="display: none">
<?php echo $this->partial('playlist/set-fade.phtml', array( <?php echo $this->partial('playlist/set-fade.phtml', array(

View File

@ -17,6 +17,7 @@ function setSmartPlaylistEvents() {
$(this).hide(); $(this).hide();
} }
appendAddButton(); appendAddButton();
appendModAddButton();
removeButtonCheck(); removeButtonCheck();
}); });
@ -87,6 +88,8 @@ function setSmartPlaylistEvents() {
var count = list_length - curr_pos; var count = list_length - curr_pos;
var next = curr.next(); var next = curr.next();
var item_to_hide; var item_to_hide;
var prev;
var index;
//remove error message from current row, if any //remove error message from current row, if any
var error_element = curr.find('span[class="errors sp-errors"]'); var error_element = curr.find('span[class="errors sp-errors"]');
@ -94,10 +97,13 @@ function setSmartPlaylistEvents() {
error_element.remove(); error_element.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
* the row getting removed * the row getting removed
*/ */
for (var i=0; i<count; i++) { for (var i=0; i<count; i++) {
index = getRowIndex(curr);
var criteria = next.find('[name^="sp_criteria_field"]').val(); var criteria = next.find('[name^="sp_criteria_field"]').val();
curr.find('[name^="sp_criteria_field"]').val(criteria); curr.find('[name^="sp_criteria_field"]').val(criteria);
@ -107,12 +113,6 @@ function setSmartPlaylistEvents() {
var criteria_value = next.find('[name^="sp_criteria_value"]').val(); var criteria_value = next.find('[name^="sp_criteria_value"]').val();
curr.find('[name^="sp_criteria_value"]').val(criteria_value); curr.find('[name^="sp_criteria_value"]').val(criteria_value);
var id = curr.find('[name^="sp_criteria"]').attr('id'),
delimiter = '_',
start = 3,
tokens = id.split(delimiter).slice(start),
index = tokens.join(delimiter);
/* if current and next row have the extra criteria value /* if current and next row have the extra criteria value
* (for 'is in the range' modifier), then assign the next * (for 'is in the range' modifier), then assign the next
@ -143,16 +143,34 @@ function setSmartPlaylistEvents() {
curr.find('[name^="sp_criteria_extra"]').val(criteria_extra); curr.find('[name^="sp_criteria_extra"]').val(criteria_extra);
} }
/* determine if current row is a modifier row
* if it is, make the criteria select invisible
*/
prev = curr.prev();
if (curr.find('[name^="sp_criteria_field"]').val() == prev.find('[name^="sp_criteria_field"]').val()) {
if (!curr.find('select[name^="sp_criteria_field"]').hasClass('sp-invisible')) {
curr.find('select[name^="sp_criteria_field"]').addClass('sp-invisible');
}
} else {
if (curr.find('select[name^="sp_criteria_field"]').hasClass('sp-invisible')) {
curr.find('select[name^="sp_criteria_field"]').removeClass('sp-invisible');
}
}
curr = next; curr = next;
next = curr.next(); next = curr.next();
} }
/* Disable the last visible row since it holds the values the user removed /* Disable the last visible row since it holds the values the user removed
* Reset the values to empty and resize the criteria value textbox * Reset the values to empty and resize the criteria value textbox
* in case the row had the extra criteria textbox * in case the row had the extra criteria textbox
*/ */
item_to_hide = list.find('div:visible:last'); item_to_hide = list.find('div:visible:last');
item_to_hide.children().attr('disabled', 'disabled'); item_to_hide.children().attr('disabled', 'disabled');
if (item_to_hide.find('select[name^="sp_criteria_field"]').hasClass('sp-invisible')) {
item_to_hide.find('select[name^="sp_criteria_field"]').removeClass('sp-invisible');
}
item_to_hide.find('[name^="sp_criteria_field"]').val(0).end() item_to_hide.find('[name^="sp_criteria_field"]').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('').end() .find('[name^="sp_criteria_value"]').val('').end()
@ -163,12 +181,22 @@ function setSmartPlaylistEvents() {
list.next().show(); list.next().show();
//check if last row is a modifier row
var last_row = list.find('div:visible:last');
if (last_row.find('[name^="sp_criteria_field"]').val() == last_row.prev().find('[name^="sp_criteria_field"]').val()) {
if (!last_row.find('select[name^="sp_criteria_field"]').hasClass('sp-invisible')) {
last_row.find('select[name^="sp_criteria_field"]').addClass('sp-invisible');
}
}
// always put '+' button on the last enabled row // always put '+' button on the last enabled row
appendAddButton(); appendAddButton();
reindexElements();
// always put '+' button on the last modifier row // always put '+' button on the last modifier row
appendModAddButton(); appendModAddButton();
reindexElements();
// remove the 'x' button if only one row is enabled // remove the 'x' button if only one row is enabled
removeButtonCheck(); removeButtonCheck();
}); });
@ -246,13 +274,15 @@ function setSmartPlaylistEvents() {
removeButtonCheck(); removeButtonCheck();
} }
var static_length = $('.playlist_title').children('h4[id$="_length"]').text(); function getRowIndex(ele) {
var id = ele.find('[name^="sp_criteria"]').attr('id'),
/* delimiter = '_',
function setStaticLengthHolder(lenVal) { start = 3,
static_length = lenVal; tokens = id.split(delimiter).slice(start),
index = tokens.join(delimiter);
return index;
} }
*/
/* This function appends a '+' button for the last /* This function appends a '+' button for the last
* modifier row of each criteria. * modifier row of each criteria.
@ -339,12 +369,10 @@ function setupUI() {
$('button[id="generate_button"]').show(); $('button[id="generate_button"]').show();
$('button[id="shuffle_button"]').show(); $('button[id="shuffle_button"]').show();
$('#spl_sortable').show(); $('#spl_sortable').show();
//$('.playlist_title').children('h4[id$="_length"]').text(static_length);
} else { } else {
$('button[id="generate_button"]').hide(); $('button[id="generate_button"]').hide();
$('button[id="shuffle_button"]').hide(); $('button[id="shuffle_button"]').hide();
$('#spl_sortable').hide(); $('#spl_sortable').hide();
//$('.playlist_title').children('h4[id$="_length"]').text(dynamic_length);
} }
} }
@ -562,7 +590,6 @@ var criteriaTypes = {
"mood" : "s", "mood" : "s",
"name" : "s", "name" : "s",
"orchestra" : "s", "orchestra" : "s",
"radio_station_name" : "s",
"rating" : "n", "rating" : "n",
"sample_rate" : "n", "sample_rate" : "n",
"track_title" : "s", "track_title" : "s",