From 79aa14ee5723de3259e3cdb9956b4bc73366aede Mon Sep 17 00:00:00 2001 From: shish Date: Mon, 16 Jul 2007 15:25:13 +0000 Subject: [PATCH] haaaaax git-svn-id: file:///home/shish/svn/shimmie2/trunk@297 7f39781d-f577-437e-ae19-be835c7a54ca --- ext/zoom/main.php | 2 +- ext/zoom/theme.php | 29 ++++++++++++++++------------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/ext/zoom/main.php b/ext/zoom/main.php index f795cc6b..f8193e52 100644 --- a/ext/zoom/main.php +++ b/ext/zoom/main.php @@ -8,7 +8,7 @@ class Zoom extends Extension { if(is_a($event, 'DisplayingImageEvent')) { global $config; - $this->theme->display_zoomer($event->page, $config->get_bool("image_zoom", false)); + $this->theme->display_zoomer($event->page, $event->image, $config->get_bool("image_zoom", false)); } if(is_a($event, 'SetupBuildingEvent')) { diff --git a/ext/zoom/theme.php b/ext/zoom/theme.php index 0c95f5a7..c8384e73 100644 --- a/ext/zoom/theme.php +++ b/ext/zoom/theme.php @@ -1,11 +1,11 @@ add_block(new Block(null, $this->make_zoomer($zoom_by_default))); + public function display_zoomer($page, $image, $zoom_by_default) { + $page->add_block(new Block(null, $this->make_zoomer($image->width, $zoom_by_default))); } - private function make_zoomer($zoom_by_default) { + private function make_zoomer($image_width, $zoom_by_default) { global $config; $default = $zoom_by_default ? "scale(img);" : ""; return <<= img.parentNode.clientWidth * 0.9); function scale(img) { - // element.clientWidth is not part of the JS standard :( - if(img.style.width != "90%" && (img.clientWidth >= img.parentNode.clientWidth * 0.9)) { - origwidth = img.style.width; - img.style.width = "90%"; - msg_div.style.display = "block"; - } - else { - img.style.width = origwidth; - msg_div.style.display = "none"; + if(needs_scaling) { + if(img.style.width != "90%") { + img.style.width = "90%"; + msg_div.style.display = "block"; + } + else { + img.style.width = origwidth; + msg_div.style.display = "none"; + } } }