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')) {
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')) {

View file

@ -1,11 +1,11 @@
<?php
class ZoomTheme extends Themelet {
public function display_zoomer($page, $zoom_by_default) {
$page->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 <<<EOD
@ -21,18 +21,21 @@ msg_div.style.display="none";
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) {
// 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";
}
}
}