#18073684 * r6660 보강

* 이미지 사이즈를 구하지 못하여 실패한 경우 재시도

git-svn-id: http://xe-core.googlecode.com/svn/sandbox@6663 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
bnu 2009-06-24 10:05:30 +00:00
parent 60b2f4ef29
commit f1b2afccdb

View file

@ -167,6 +167,38 @@ $(function() {
**/
var dummy = $('<div style="height:1; overflow:hidden; opacity:0; display:block; clear:both;"></div>');
/**
* 리사이즈 실행 함수
**/
function doResize(contentWidth, count) {
// 재시도 회수 제한
if(!count) count = 0;
if(count >= 10) return;
var $img = this;
var beforSize = {'width':$img.width(), 'height':$img.height()};
// 이미지 사이즈를 구하지 못했을 때 재시도
if(!beforSize.width || !beforSize.height) {
setTimeout(function() {
doResize.call($img, contentWidth, ++count)
}, 200);
return;
}
// 리사이즈 필요 없으면 리턴
if(beforSize.width <= contentWidth) return;
var resize_ratio = contentWidth / beforSize.width;
$img
.removeAttr('width').removeAttr('height')
.css({
'width':contentWidth,
'height':parseInt(beforSize.height * resize_ratio, 10)
});
}
$('div.xe_content').each(function() {
dummy.appendTo(this);
var contentWidth = dummy.width();
@ -180,16 +212,7 @@ $(function() {
$img.attr('rel', 'xe_gallery');
var beforSize = {'width':$img.width(), 'height':$img.height()};
if(beforSize.width && beforSize.width < contentWidth) return;
var resize_ratio = contentWidth / beforSize.width;
$img
.removeAttr('width').removeAttr('height')
.css({
'width':contentWidth,
'height':parseInt(beforSize.height * resize_ratio, 10)
});
doResize.call($img, contentWidth);
});
/* live 이벤트로 적용 (image_gallery 컴포넌트와의 호환 위함) */