// Fixed size and position of the carrier wizard logo

This commit is contained in:
Damien Metzger
2013-07-17 19:47:48 +02:00
parent 244830d505
commit d7c6516c32
2 changed files with 37 additions and 12 deletions
@@ -23,6 +23,17 @@
* International Registered Trademark & Property of PrestaShop SA * International Registered Trademark & Property of PrestaShop SA
*} *}
<div id="carrier_logo_block" style="position:absolute;top:15px;right:15px">
<img id="carrier_logo_img" src="{if $carrier_logo}{$carrier_logo}{else}../img/404.gif{/if}" />
<p>
<input id="carrier_logo_input" type="file" onchange="uploadCarrierLogo();" name="carrier_logo_input" />
<input type="hidden" id="logo" name="logo" value="" />
</p>
<p>
{l s='Format:'} JPG, GIF, PNG. {l s='Filesize:'} {$max_image_size|string_format:"%.2f"} {l s='MB max.'}
</p>
</div>
<script type="text/javascript"> <script type="text/javascript">
function uploadCarrierLogo() function uploadCarrierLogo()
{ {
@@ -38,20 +49,34 @@
{ {
$('#carrier_logo_img').attr('src', message); $('#carrier_logo_img').attr('src', message);
$('#logo').val(message); $('#logo').val(message);
fixCarrierLogoDisplay();
} }
else else
alert(message); alert(message);
} }
}); });
} }
</script>
<div id="carrier_logo_block" style="position:absolute;top:10px;right:10px"> function fixCarrierLogoDisplay()
<img id="carrier_logo_img" src="{if $carrier_logo}{$carrier_logo}{else}../img/404.gif{/if}" /> {
<p> $('<img/>').attr('src', $('#carrier_logo_img').attr('src')).load(function(){
<input id="carrier_logo_input" type="file" onchange="uploadCarrierLogo();" name="carrier_logo_input" /> var maxHeight = 200;
<input type="hidden" id="logo" name="logo" value="" /> var maxWidth = 200;
</p> var res = this.width / this.height;
<p class="preference_description" style="clear:both"> $('#carrier_logo_img').width(this.width);
{l s='Format:'} JPG, GIF, PNG. {l s='Filesize:'} {$max_image_size|string_format:"%.2f"} {l s='MB max.'} $('#carrier_logo_img').height(this.height);
</p> if ($('#carrier_logo_img').width() > maxWidth)
</div> {
$('#carrier_logo_img').width(maxWidth);
$('#carrier_logo_img').height(maxWidth / res);
}
if ($('#carrier_logo_img').height() > maxHeight)
{
$('#carrier_logo_img').height(maxHeight);
$('#carrier_logo_img').width(maxHeight * res);
}
});
}
fixCarrierLogoDisplay();
</script>
+1 -1
View File
@@ -49,8 +49,8 @@ function onShowStepCallback()
$('.anchor li a').each( function () { $('.anchor li a').each( function () {
$(this).parent('li').addClass($(this).attr('class')); $(this).parent('li').addClass($(this).attr('class'));
}); });
$('#carrier_logo_block').prependTo($('div.content').filter(function() { return $(this).css('display') != 'none' }).children('.defaultForm').children('fieldset'));
resizeWizard(); resizeWizard();
$('#carrier_logo_block').prependTo($('#fieldset_form'));
} }
function onFinishCallback(obj, context) function onFinishCallback(obj, context)