image scaling cookie

This commit is contained in:
Shish
2012-03-24 11:16:59 +00:00
parent ecad3b9891
commit eb705d29f5
3 changed files with 45 additions and 34 deletions

View File

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