From 1d4836e6c4d488d84a87f8beab213e70e93277e3 Mon Sep 17 00:00:00 2001 From: Shish Date: Sat, 24 Mar 2012 23:30:19 +0000 Subject: [PATCH] toggle zoom on click --- ext/handle_pixel/script.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/ext/handle_pixel/script.js b/ext/handle_pixel/script.js index b0dc126b..c264f6e4 100644 --- a/ext/handle_pixel/script.js +++ b/ext/handle_pixel/script.js @@ -1,7 +1,13 @@ $(function() { $("#zoomer").change(function(e) { zoom(this.options[this.selectedIndex].value); - $.cookie("ui-image-zoom", this.options[this.selectedIndex].value, {path: '/', expires: 365}); + }); + + $("#main_image").click(function(e) { + switch($.cookie("ui-image-zoom")) { + case "full": zoom("width"); break; + default: zoom("full"); break; + } }); if($.cookie("ui-image-zoom")) { @@ -17,15 +23,16 @@ function zoom(zoom) { img.css('max-height', img.data('height') + 'px'); } if(zoom == "width") { - img.css('max-width', '90%'); + img.css('max-width', '95%'); img.css('max-height', img.data('height') + 'px'); } if(zoom == "height") { img.css('max-width', img.data('width') + 'px'); - img.css('max-height', (window.innerHeight * 0.9) + 'px'); + img.css('max-height', (window.innerHeight * 0.95) + 'px'); } if(zoom == "both") { - img.css('max-width', '90%'); - img.css('max-height', (window.innerHeight * 0.9) + 'px'); + img.css('max-width', '95%'); + img.css('max-height', (window.innerHeight * 0.95) + 'px'); } + $.cookie("ui-image-zoom", zoom, {path: '/', expires: 365}); }