git-svn-id: file:///home/shish/svn/shimmie2/trunk@466 7f39781d-f577-437e-ae19-be835c7a54ca
		
			
				
	
	
		
			44 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			44 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
 | 
						|
class ZoomTheme extends Themelet {
 | 
						|
	public function display_zoomer($page, $image, $zoom_by_default) {
 | 
						|
		$page->add_block(new Block(null, $this->make_zoomer($image->width, $zoom_by_default)));
 | 
						|
	}
 | 
						|
	
 | 
						|
	protected function make_zoomer($image_width, $zoom_by_default) {
 | 
						|
		global $config;
 | 
						|
		$default = $zoom_by_default ? "scale(img);" : "";
 | 
						|
		return <<<EOD
 | 
						|
<script type="text/javascript">
 | 
						|
img = document.getElementById("main_image");
 | 
						|
 | 
						|
img.onclick = function() {scale(img);};
 | 
						|
 | 
						|
msg_div = document.createElement("div");
 | 
						|
msg_div.id = "msg_div";
 | 
						|
msg_div.appendChild(document.createTextNode("Note: Image has been scaled to fit the screen; click to enlarge"));
 | 
						|
msg_div.style.display="none";
 | 
						|
img.parentNode.insertBefore(msg_div, img);
 | 
						|
 | 
						|
orig_width = $image_width;
 | 
						|
 | 
						|
function scale(img) {
 | 
						|
	if(orig_width >= img.parentNode.clientWidth * 0.9) {
 | 
						|
		if(img.style.width != "90%") {
 | 
						|
			img.style.width = "90%";
 | 
						|
			msg_div.style.display = "block";
 | 
						|
		}
 | 
						|
		else {
 | 
						|
			img.style.width = orig_width + 'px';
 | 
						|
			msg_div.style.display = "none";
 | 
						|
		}
 | 
						|
	}
 | 
						|
}
 | 
						|
 | 
						|
$default
 | 
						|
</script>
 | 
						|
EOD;
 | 
						|
	}
 | 
						|
}
 | 
						|
?>
 |