2016-10-27 01:34:28 +08:00
|
|
|
function changeScale() {
|
2019-01-18 23:00:55 +08:00
|
|
|
var scale = $j('#scale').val();
|
|
|
|
var img = $j('#frameImg');
|
|
|
|
var controlsLinks = {
|
|
|
|
next: $j('#nextLink'),
|
|
|
|
prev: $j('#prevLink'),
|
|
|
|
first: $j('#firstLink'),
|
|
|
|
last: $j('#lastLink')
|
|
|
|
};
|
2017-11-22 11:49:27 +08:00
|
|
|
|
2017-12-07 23:31:25 +08:00
|
|
|
if ( img ) {
|
2019-01-18 23:00:55 +08:00
|
|
|
var baseWidth = $j('#base_width').val();
|
|
|
|
var baseHeight = $j('#base_height').val();
|
2020-07-23 05:28:41 +08:00
|
|
|
if ( ! parseInt(scale) ) {
|
2019-01-18 23:00:55 +08:00
|
|
|
var newSize = scaleToFit(baseWidth, baseHeight, img, $j('#controls'));
|
2017-11-22 11:49:27 +08:00
|
|
|
newWidth = newSize.width;
|
|
|
|
newHeight = newSize.height;
|
|
|
|
autoScale = newSize.autoScale;
|
|
|
|
} else {
|
|
|
|
$j(window).off('resize', endOfResize); //remove resize handler when Scale to Fit is not active
|
|
|
|
newWidth = baseWidth * scale / SCALE_BASE;
|
|
|
|
newHeight = baseHeight * scale / SCALE_BASE;
|
|
|
|
}
|
2017-12-07 23:31:25 +08:00
|
|
|
img.css('width', newWidth + 'px');
|
|
|
|
img.css('height', newHeight + 'px');
|
2016-10-27 01:34:28 +08:00
|
|
|
}
|
2020-07-23 05:28:41 +08:00
|
|
|
Cookie.write('zmWatchScale', scale, {duration: 10*365});
|
2019-01-19 23:32:40 +08:00
|
|
|
$j.each(controlsLinks, function(k, anchor) { //Make frames respect scale choices
|
2019-11-20 00:37:45 +08:00
|
|
|
if ( anchor ) {
|
2019-11-11 04:49:39 +08:00
|
|
|
anchor.prop('href', anchor.prop('href').replace(/scale=.*&/, 'scale=' + scale + '&'));
|
2019-11-20 00:37:45 +08:00
|
|
|
}
|
2017-11-22 11:49:27 +08:00
|
|
|
});
|
2016-10-27 01:34:28 +08:00
|
|
|
}
|
|
|
|
|
2020-07-23 05:28:41 +08:00
|
|
|
if ( !scale ) {
|
2019-02-10 07:10:42 +08:00
|
|
|
$j(document).ready(changeScale);
|
|
|
|
}
|
|
|
|
|
|
|
|
document.addEventListener('DOMContentLoaded', function onDCL() {
|
|
|
|
document.getElementById('scale').addEventListener('change', changeScale);
|
|
|
|
});
|