toggle zoom on click

This commit is contained in:
Shish 2012-03-24 23:30:19 +00:00
parent 8336fbfce5
commit 1d4836e6c4

View File

@ -1,7 +1,13 @@
$(function() { $(function() {
$("#zoomer").change(function(e) { $("#zoomer").change(function(e) {
zoom(this.options[this.selectedIndex].value); 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")) { if($.cookie("ui-image-zoom")) {
@ -17,15 +23,16 @@ function zoom(zoom) {
img.css('max-height', img.data('height') + 'px'); img.css('max-height', img.data('height') + 'px');
} }
if(zoom == "width") { if(zoom == "width") {
img.css('max-width', '90%'); img.css('max-width', '95%');
img.css('max-height', img.data('height') + 'px'); img.css('max-height', img.data('height') + 'px');
} }
if(zoom == "height") { if(zoom == "height") {
img.css('max-width', img.data('width') + 'px'); 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") { if(zoom == "both") {
img.css('max-width', '90%'); img.css('max-width', '95%');
img.css('max-height', (window.innerHeight * 0.9) + 'px'); img.css('max-height', (window.innerHeight * 0.95) + 'px');
} }
$.cookie("ui-image-zoom", zoom, {path: '/', expires: 365});
} }