haaaaax
git-svn-id: file:///home/shish/svn/shimmie2/trunk@297 7f39781d-f577-437e-ae19-be835c7a54ca
This commit is contained in:
parent
2a85e6b17c
commit
79aa14ee57
@ -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')) {
|
||||||
|
@ -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";
|
||||||
}
|
}
|
||||||
@ -34,6 +36,7 @@ function scale(img) {
|
|||||||
img.style.width = origwidth;
|
img.style.width = origwidth;
|
||||||
msg_div.style.display = "none";
|
msg_div.style.display = "none";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$default
|
$default
|
||||||
|
Loading…
x
Reference in New Issue
Block a user