diff options
author | Chad Kieffer <ckieffer@gmail.com> | 2009-08-23 15:00:00 -0600 |
---|---|---|
committer | Chad Kieffer <ckieffer@gmail.com> | 2009-08-23 15:00:00 -0600 |
commit | 2264a80368be16b8ab898eec9234cd6ce9fe7652 (patch) | |
tree | 55d70e507a0877c9bfa5047e62f08a23bf97193d | |
parent | 457708311a466d8b116d5b28575be1bc3baad864 (diff) | |
parent | 256822a1e8d387ef9cc29e354a36099dbab17992 (diff) |
Merge branch 'master' of git@github.com:gallery/gallery3
-rw-r--r-- | lib/gallery.common.js | 25 | ||||
-rw-r--r-- | lib/gallery.show_full_size.js | 39 | ||||
-rw-r--r-- | modules/gallery/controllers/file_proxy.php | 2 |
3 files changed, 31 insertions, 35 deletions
diff --git a/lib/gallery.common.js b/lib/gallery.common.js index 16cb7ea2..a959d90d 100644 --- a/lib/gallery.common.js +++ b/lib/gallery.common.js @@ -129,5 +129,30 @@ ); }; + $.gallery_auto_fit_window = function(imageWidth, imageHeight) { + var size = $.gallery_get_viewport_size(); + var width = size.width() - 6, + height = size.height() - 6; + + var ratio = width / imageWidth; + imageWidth *= ratio; + imageHeight *= ratio; + + /* after scaling the width, check that the height fits */ + if (imageHeight > height) { + ratio = height / imageHeight; + imageWidth *= ratio; + imageHeight *= ratio; + } + + // handle the case where the calculation is almost zero (2.14e-14) + return { + top: Number((height - imageHeight) / 2), + left: Number((width - imageWidth) / 2), + width: Number(imageWidth), + height: Number(imageHeight) + }; + }; + })(jQuery); diff --git a/lib/gallery.show_full_size.js b/lib/gallery.show_full_size.js index c32195f6..2f365f0d 100644 --- a/lib/gallery.show_full_size.js +++ b/lib/gallery.show_full_size.js @@ -3,48 +3,19 @@ * @todo Move inline CSS out to external style sheet (theme style sheet) */ $.gallery_show_full_size = function(image_url, image_width, image_height) { - /* - * Calculate the size of the image panel based on the size of the image and the size of the - * window. Scale the image so the entire panel fits in the view port. - */ - function _auto_fit(imageWidth, imageHeight) { - // ui-dialog gives a padding of 2 pixels - var windowWidth = $(window).width() - 10; - var windowHeight = $(window).height() - 10; - - /* If the width is greater then scale the image width first */ - if (imageWidth > windowWidth) { - var ratio = windowWidth / imageWidth; - imageWidth *= ratio; - imageHeight *= ratio; - } - /* after scaling the width, check that the height fits */ - if (imageHeight > windowHeight) { - var ratio = windowHeight / imageHeight; - imageWidth *= ratio; - imageHeight *= ratio; - } - - // handle the case where the calculation is almost zero (2.14e-14) - return { - top: Number((windowHeight - imageHeight) / 2), - left: Number((windowWidth - imageWidth) / 2), - width: Number(imageWidth), - height: Number(imageHeight) - }; - } - var width = $(document).width(); var height = $(document).height(); + var size = $.gallery_get_viewport_size(); $("body").append('<div id="gFullsizeOverlay" class="ui-dialog-overlay" ' + 'style="border: none; margin: 0; padding: 0; background-color: #000; ' + 'position: absolute; top: 0px; left: 0px; ' + - 'width: ' + width + 'px; height: ' + height + 'px; opacity: 0.7; filter: alpha(opacity=70);' + + 'width: ' + size.width() + 'px; height: ' + size.height() + 'px;' + + ' opacity: 0.7; filter: alpha(opacity=70);' + '-moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; ' + '-moz-background-inline-policy: -moz-initial; z-index: 1001;"> </div>'); - var image_size = _auto_fit(image_width, image_height); + var image_size = $.gallery_auto_fit_window(image_width, image_height); $("body").append('<div id="gFullsize" class="ui-dialog ui-widget" ' + 'style="overflow: hidden; display: block; ' + @@ -66,7 +37,7 @@ $(window).resize(function() { $("#gFullsizeOverlay").width($(document).width()) .height($(document).height()); - image_size = _auto_fit(image_width, image_height); + image_size = $.gallery_auto_fit_window(image_width, image_height); $("#gFullsize").height(image_size.height) .width(image_size.width) .css("top", image_size.top) diff --git a/modules/gallery/controllers/file_proxy.php b/modules/gallery/controllers/file_proxy.php index a85f0a85..8cb90c50 100644 --- a/modules/gallery/controllers/file_proxy.php +++ b/modules/gallery/controllers/file_proxy.php @@ -119,7 +119,7 @@ class File_Proxy_Controller extends Controller { if (in_array($item->mime_type, array("video/x-flv", "video/mp4"))) { header("Content-type: image/jpeg"); } else { - print("Content-Type: $item->mime_type"); + header("Content-Type: $item->mime_type"); } Kohana::close_buffers(false); |