git-svn-id: file:///home/shish/svn/shimmie2/trunk@297 7f39781d-f577-437e-ae19-be835c7a54ca
This commit is contained in:
shish 2007-07-16 15:25:13 +00:00
parent 2a85e6b17c
commit 79aa14ee57
2 changed files with 17 additions and 14 deletions

View File

@ -8,7 +8,7 @@ class Zoom extends Extension {
if(is_a($event, 'DisplayingImageEvent')) { if(is_a($event, 'DisplayingImageEvent')) {
global $config; 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')) { if(is_a($event, 'SetupBuildingEvent')) {

View File

@ -1,11 +1,11 @@
<?php <?php
class ZoomTheme extends Themelet { class ZoomTheme extends Themelet {
public function display_zoomer($page, $zoom_by_default) { public function display_zoomer($page, $image, $zoom_by_default) {
$page->add_block(new Block(null, $this->make_zoomer($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; global $config;
$default = $zoom_by_default ? "scale(img);" : ""; $default = $zoom_by_default ? "scale(img);" : "";
return <<<EOD return <<<EOD
@ -21,12 +21,14 @@ msg_div.style.display="none";
img.parentNode.insertBefore(msg_div, img); img.parentNode.insertBefore(msg_div, img);
orig_width = ""; needs_scaling = false;
orig_width = $image_width;
needs_scaling = (orig_width >= img.parentNode.clientWidth * 0.9);
function scale(img) { function scale(img) {
// element.clientWidth is not part of the JS standard :( if(needs_scaling) {
if(img.style.width != "90%" && (img.clientWidth >= img.parentNode.clientWidth * 0.9)) { if(img.style.width != "90%") {
origwidth = img.style.width;
img.style.width = "90%"; img.style.width = "90%";
msg_div.style.display = "block"; msg_div.style.display = "block";
} }
@ -35,6 +37,7 @@ function scale(img) {
msg_div.style.display = "none"; msg_div.style.display = "none";
} }
} }
}
$default $default
</script> </script>