-
Notifications
You must be signed in to change notification settings - Fork 0
/
curtain_imageresizer.js
executable file
·88 lines (80 loc) · 2.39 KB
/
curtain_imageresizer.js
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
80
81
82
83
84
85
86
87
88
if (navigator.appName=="Netscape") {
document.write("<style type='text/css'>body {overflow-y:scroll;}<\/style>");
}
var userAgent = navigator.userAgent.toLowerCase();
var is_ie = (userAgent.indexOf('msie') != -1) && userAgent.substr(userAgent.indexOf('msie') + 5, 3);
/*
function $() {
var elements = new Array();
for (var i = 0; i < arguments.length; i++) {
var element = arguments[i];
if (typeof element == 'string')
element = document.getElementById(element);
if (arguments.length == 1)
return element;
elements.push(element);
}
return elements;
}
*/
function Scale(image, max_width, max_height) {
var tempimage = new Image();
tempimage.src = image.src;
var tempwidth = tempimage.width;
var tempheight = tempimage.height;
if (tempwidth > max_width) {
image.height = tempheight = Math.round(((max_width)/tempwidth) * tempheight);
image.width = tempwidth = max_width;
}
if (max_height != 0 && tempheight > max_height)
{
image.width = Math.round(((max_height)/tempheight) * tempwidth);
image.height = max_height;
}
}
function check_avatar(image, langfolder){
var tempimage = new Image();
tempimage.src = image.src;
var displayheight = image.height;
var tempwidth = tempimage.width;
var tempheight = tempimage.height;
if (tempwidth > 250 || tempheight > 250 || displayheight > 250) {
image.src='pic/forum_pic/'+langfolder+'/avatartoobig.png';
}
}
function Preview(image) { //修复冲突错误
if (!is_ie || is_ie >= 7){
$('#lightbox').html("<a onclick=\"Return();\"><img src=\"" + image.src + "\" /></a>");
$('#curtain').css({"display":"block"});
$('#lightbox').css({"display":"block"});
}
else{
window.open(image.src);
}
}
function Previewurl(url) { //修复冲突错误
if (!is_ie || is_ie >= 7){
$('#lightbox').html("<a onclick=\"Return();\"><img src=\"" + url + "\" /></a>");
$('#curtain').css({"display":"block"});
$('#lightbox').css({"display":"block"});
}
else{
window.open(url);
}
}
function findPosition( oElement ) {
if( typeof( oElement.offsetParent ) != 'undefined' ) {
for( var posX = 0, posY = 0; oElement; oElement = oElement.offsetParent ) {
posX += oElement.offsetLeft;
posY += oElement.offsetTop;
}
return [ posX, posY ];
} else {
return [ oElement.x, oElement.y ];
}
}
function Return() { //修复冲突错误
$('#lightbox').html("");
$('#curtain').css({"display":"none"});
$('#lightbox').css({"display":"none"});
}