리사이즈 루틴 변경. 이미지가 게시글본문보다 크면 리사이즈+클릭해서 원본보기, 이미지가 원본과 다르면 클랙해서 원본보기 기능으로 변경

git-svn-id: http://xe-core.googlecode.com/svn/sandbox@3141 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
zero 2007-12-03 06:18:48 +00:00
parent 58ed59a79a
commit 2a66d2d8fe

View file

@ -233,27 +233,29 @@ function resizeImageContents() {
parent.style.width = '100%';
parent.style.overflow = 'hidden';
var parent_width = xWidth(parent);
if(parent.parentNode && xWidth(parent.parentNode)<parent_width) parent_width = xWidth(parent.parentNode);
var obj_width = xWidth(obj);
var obj_height = xHeight(obj);
var orig_img = new Image();
orig_img.src = obj.src;
if(parent_width<1 || obj_width <1 || parent_width-20 >= orig_img.width) continue;
obj.style.cursor = "pointer";
obj.source_width = orig_img.width;
obj.source_height = orig_img.height;
var new_w = parent_width-20;
var new_h = Math.round(orig_img.height * new_w/orig_img.width);
xWidth(obj, new_w);
xHeight(obj, new_h);
xAddEventListener(obj,"click", showOriginalImage);
// 만약 선택된 이미지의 가로 크기가 부모의 가로크기보다 크면 리사이즈 (이때 부모의 가로크기 - 20 정도로 지정해줌)
if(obj_width > parent_width - 20) {
obj.style.cursor = "pointer";
var new_w = parent_width - 20;
var new_h = Math.round(obj_height * new_w/obj_width);
xWidth(obj, new_w);
xHeight(obj, new_h);
xAddEventListener(obj,"click", showOriginalImage);
// 선택된 이미지가 부모보다 작을 경우 일단 원본 이미지를 불러와서 비교
} else {
var orig_img = new Image();
orig_img.src = obj.src;
if(orig_img.width > parent_width - 20 || orig_img.width != obj_width) {
obj.style.cursor = "pointer";
xAddEventListener(obj,"click", showOriginalImage);
}
}
}
}
xAddEventListener(window, "load", resizeImageContents);