summaryrefslogtreecommitdiff
path: root/lib/gallery.show_full_size.js
diff options
context:
space:
mode:
authorTim Almdal <tnalmdal@shaw.ca>2009-08-21 03:53:20 +0800
committerTim Almdal <tnalmdal@shaw.ca>2009-08-21 03:56:38 +0800
commit256822a1e8d387ef9cc29e354a36099dbab17992 (patch)
tree0c6f6481952101c6a859a8beec89b403f52f9032 /lib/gallery.show_full_size.js
parent2da7f937840b79b65bacb96e8dad06f2e7d41305 (diff)
Refactor the _auto_fit method in gallery.show_full_size to a common method in gallery.common.js
Signed-off-by: Tim Almdal <tnalmdal@shaw.ca>
Diffstat (limited to 'lib/gallery.show_full_size.js')
-rw-r--r--lib/gallery.show_full_size.js39
1 files changed, 5 insertions, 34 deletions
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)