1
0
This repository has been archived on 2021-04-26. You can view files and clone it, but cannot push or open issues or pull requests.
gallery3-contrib/3.0/modules/fittoscreen/views/fittoscreen_photo.html.php
2011-10-15 15:48:03 +02:00

36 lines
1.2 KiB
PHP

<?php defined("SYSPATH") or die("No direct script access.") ?>
<script type="text/javascript">
function dynresize() {
var $maxheight = <?= $item->resize_height ?>;
var $maxwidth = <?= $item->resize_width ?>;
var $ratio = $maxwidth/$maxheight;
var $winwidth = $(window).width() <?= (module::get_var("fittoscreen", "width_unit")=="pr" ? "*".number_format(module::get_var("fittoscreen", "width")/100,2,".","") : "-".module::get_var("fittoscreen", "width")) ?>;
var $winheight = $(window).height() <?= (module::get_var("fittoscreen", "height_unit")=="pr" ? "*".number_format(module::get_var("fittoscreen", "height")/100,2,".","") : "-".module::get_var("fittoscreen", "height")) ?>;
if (($winwidth/$winheight)<$ratio) {
$finalwidth = ($winwidth > $maxwidth ? $maxwidth : $winwidth);
$finalheight = $finalwidth / $ratio;
}
else {
$finalheight = ($winheight > $maxheight ? $maxheight : $winheight);
$finalwidth = $finalheight * $ratio;
}
// $('body').prepend('<div>' + $finalheight + " " + $finalwidth + '</div>');
$("img.g-resize").attr({
height: $finalheight,
width: $finalwidth,
});
}
$(window).resize(dynresize);
$(document).ready(dynresize);
</script>