/usr/share/tdiary/js/image_ex.js is in tdiary-contrib 3.2.2-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | /*
image_ex.js: javascript for image_ex.rb plugin of tDiary
Copyright (C) 2012 by Shugo Maeda
You can redistribute it and/or modify it under GPL2.
*/
$(function() {
function getWindowSize() {
if (window.innerWidth) {
return {
width: window.innerWidth,
height: window.innerHeight
};
}
else if (document.documentElement &&
document.documentElement.clientWidth != 0 ) {
return {
width: document.documentElement.clientWidth,
height: document.documentElement.clientHeight
};
}
else if ( document.body ) {
return {
width: document.body.clientWidth,
height: document.body.clientHeight
}
}
return false;
}
var maxSize = null;
function getMaxSize() {
if (maxSize != null) {
return maxSize;
}
var windowSize = getWindowSize();
if (windowSize == false) {
maxSize = false;
}
else {
maxSize = {
width: windowSize.width * 0.8,
height: windowSize.height * 0.8
};
}
return maxSize;
}
function resizeImage(img) {
var maxSize = getMaxSize();
if (img.width > maxSize.width || img.height > maxSize.height) {
if (img.width / maxSize.width > img.height / maxSize.height) {
img.width = maxSize.width;
}
else {
img.height = maxSize.height;
}
}
}
$(document).ready(function() {
$("img.image-ex").bind("load", function() {
resizeImage(this);
});
});
// for when images have been cached
$(window).bind("load", function() {
$("img.image-ex").each(function() {
resizeImage(this);
});
});
});
// vim: set ts=3 sw=3 noexpandtab :
|