Merge branch '2.5.x-albertenhancements' into 2.5.x

This commit is contained in:
Duncan Sommerville 2015-03-02 15:12:00 -05:00
commit 0805e734ef
5 changed files with 28 additions and 8 deletions

View file

@ -40,6 +40,7 @@ class PreferenceController extends Zend_Controller_Action
if ($form->isValid($values))
{
Application_Model_Preference::SetHeadTitle($values["stationName"], $this->view);
Application_Model_Preference::SetStationDescription($values["stationDescription"]);
Application_Model_Preference::SetDefaultCrossfadeDuration($values["stationDefaultCrossfadeDuration"]);
Application_Model_Preference::SetDefaultFadeIn($values["stationDefaultFadeIn"]);
Application_Model_Preference::SetDefaultFadeOut($values["stationDefaultFadeOut"]);
@ -51,7 +52,11 @@ class PreferenceController extends Zend_Controller_Action
$logoUploadElement = $form->getSubForm('preferences_general')->getElement('stationLogo');
$logoUploadElement->receive();
$imagePath = $logoUploadElement->getFileName();
Application_Model_Preference::SetStationLogo($imagePath);
// Only update the image logo if the new logo is non-empty
if (!is_null($imagePath) && $imagePath != "") {
Application_Model_Preference::SetStationLogo($imagePath);
}
Application_Model_Preference::SetEnableSystemEmail($values["enableSystemEmail"]);
Application_Model_Preference::SetSystemEmail($values["systemEmail"]);

View file

@ -49,6 +49,13 @@ class Application_Form_GeneralPreferences extends Zend_Form_SubForm
$stationLogoUpload->setAttrib('accept', 'image/*');
$this->addElement($stationLogoUpload);
$stationLogoRemove = new Zend_Form_Element_Button('stationLogoRemove');
$stationLogoRemove->setLabel(_('Remove'));
$stationLogoRemove->setAttrib('class', 'btn');
$stationLogoRemove->setAttrib('id', 'logo-remove-btn');
$stationLogoRemove->setAttrib('onclick', 'removeLogo();');
$this->addElement($stationLogoRemove);
//Default station crossfade duration
$this->addElement('text', 'stationDefaultCrossfadeDuration', array(
'class' => 'input_text',

View file

@ -7,10 +7,12 @@
<?php echo $this->element->getElement('stationLogo')->render() ?>
<button id="logo-remove-btn" value="Remove" class="btn">Remove</button>
<?php echo $this->element->getElement('stationLogoRemove')->render() ?>
<!-- <button id="logo-remove-btn" value="Remove" class="btn">Remove</button>-->
<div id="Logo-img-container">
<img onError="this.onerror = '';this.style.visibility='hidden';$('#logo-remove-btn').hide();" id="logo-img" onload='resizeImg(this, 450, 450);' src="data:image/png;base64,<?php echo $this->element->getView()->logoImg ?>" />
<img onError="this.onerror = '';this.style.visibility='hidden';$('#logo-remove-btn').hide();$('[id^=stationLogoRemove]').each(function(i,v){v.style.width=v.style.height=v.style.margin=v.style.padding='0px';});" id="logo-img" onload='resizeImg(this, 450, 450);' src="data:image/png;base64,<?php echo $this->element->getView()->logoImg ?>" />
</div>
<?php echo $this->element->getElement('locale')->render() ?>

View file

@ -2187,12 +2187,17 @@ dd.radio-inline-list, .preferences dd.radio-inline-list, .stream-config dd.radio
height: 120px;
}
.preferences #stationLogoRemove-label {
display: none;
}
.preferences #logo-remove-btn {
float: right;
margin-bottom: 4px;
}
.preferences #Logo-img-container {
float: left;
margin-top: 30px;
}
#show_time_info {

View file

@ -96,6 +96,11 @@ function setSoundCloudCheckBoxListener() {
});
}
function removeLogo() {
$.post(baseUrl+'Preference/remove-logo', function(json){});
location.reload();
}
$(document).ready(function() {
$('.collapsible-header').live('click',function() {
@ -104,10 +109,6 @@ $(document).ready(function() {
return false;
}).next().hide();
$('#logo-remove-btn').click(function() {
$.post(baseUrl+'Preference/remove-logo', function(json){});
});
/* No longer using AJAX for this form. Zend + our code makes it needlessly hard to deal with. -- Albert
$('#pref_save').live('click', function() {
var data = $('#pref_form').serialize();