This repository has been archived on 2024-09-05. You can view files and clone it, but cannot push or open issues or pull requests.
shimmie2/ext/handle_pixel/script.js

41 lines
985 B
JavaScript
Raw Normal View History

2012-03-24 11:16:59 +00:00
$(function() {
2012-08-15 18:46:51 +00:00
$(".shm-zoomer").change(function(e) {
2012-03-24 11:16:59 +00:00
zoom(this.options[this.selectedIndex].value);
2012-03-24 23:30:19 +00:00
});
2012-08-15 18:46:51 +00:00
$(".shm-main-image").click(function(e) {
2012-03-24 23:30:19 +00:00
switch($.cookie("ui-image-zoom")) {
case "full": zoom("width"); break;
default: zoom("full"); break;
}
2012-03-24 11:16:59 +00:00
});
if($.cookie("ui-image-zoom")) {
zoom($.cookie("ui-image-zoom"));
}
});
function zoom(zoom) {
2012-08-15 18:46:51 +00:00
var img = $('.shm-main-image');
2012-03-24 11:16:59 +00:00
if(zoom == "full") {
img.css('max-width', img.data('width') + 'px');
img.css('max-height', img.data('height') + 'px');
}
if(zoom == "width") {
2012-03-24 23:30:19 +00:00
img.css('max-width', '95%');
2012-03-24 11:16:59 +00:00
img.css('max-height', img.data('height') + 'px');
}
if(zoom == "height") {
img.css('max-width', img.data('width') + 'px');
2012-03-24 23:30:19 +00:00
img.css('max-height', (window.innerHeight * 0.95) + 'px');
2012-03-24 11:16:59 +00:00
}
if(zoom == "both") {
2012-03-24 23:30:19 +00:00
img.css('max-width', '95%');
img.css('max-height', (window.innerHeight * 0.95) + 'px');
2012-03-24 11:16:59 +00:00
}
2012-03-24 23:34:00 +00:00
2012-08-15 18:46:51 +00:00
$(".shm-zoomer").val(zoom);
2012-03-24 23:34:00 +00:00
2012-03-24 23:30:19 +00:00
$.cookie("ui-image-zoom", zoom, {path: '/', expires: 365});
2012-03-24 11:16:59 +00:00
}