#18073684 * resize_image 애드온 개선

* IE6에서 PNG 파일이 리사이즈 되지 않는 문제 고침
  * image_gallery 컴포넌트와의 호환성 확보

#17980094 * image_gallery 컴포넌트 리스트형에서 원본보기가 안되는 문제 고침

git-svn-id: http://xe-core.googlecode.com/svn/sandbox@6660 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
bnu 2009-06-24 05:51:14 +00:00
parent 69fbd4cf27
commit 2b4bc511ef
2 changed files with 55 additions and 66 deletions

View file

@ -157,57 +157,49 @@ function slideshow(event) {
xScreen.xeShow(); xScreen.xeShow();
} }
$(document).ready(function(){ /* DOM READY */
//if (jQuery.browser.safari && document.readyState != "complete"){ $(function() {
//setTimeout( arguments.callee, 100 ); var regx_skip = /(?:(modules|addons|classes|common|layouts|libs|widgets|widgetstyles)\/)/i;
//return; var regx_allow_i6pngfix = /(?:common\/tpl\/images\/blank\.gif$)/i;
//} /**
* 본문 구하기 위한 개체
* IE6에서 본문폭을 넘는 이미지가 있으면 크기로 구해지는 문제 우회용
**/
var dummy = $('<div style="height:1; overflow:hidden; opacity:0; display:block; clear:both;"></div>');
var regx_skip = /(?:modules|addons|classes|common|layouts|libs|widgets)/i; $('div.xe_content').each(function() {
var regx_parent = /(?:document|comment)_[0-9]+_[0-9]+/i; dummy.appendTo(this);
var contentWidth = dummy.width();
dummy.remove();
if(!contentWidth) return;
$(".xe_content").each(function() { $('img', this).each(function() {
$(this).find("img").each(function(){ var $img = $(this);
var img = $(this); var imgSrc = $img.attr('src');
var width = img.attr("width"); if(regx_skip.test(imgSrc) && !regx_allow_i6pngfix.test(imgSrc)) return;
if(!width) width = img.width();
if(!width) return;
img.attr("orig_width",width);
img.attr("width",1);
});
var offsetWidth = $(this).width();
$(this).find("img").each(function(){ $img.attr('rel', 'xe_gallery');
var img = $(this);
if(!img.attr("orig_width")) return;
var src = img.attr("src");
img.attr("width",img.attr("orig_width"));
img.removeAttr("orig_width",'');
var width = img.attr("width");
var height = img.attr("height");
// XE 내부 프로그램 또는 스킨의 이미지라면 이미지 리사이즈를 하지 않음 var beforSize = {'width':$img.width(), 'height':$img.height()};
if ( !regx_skip.test(src) ) { if(beforSize.width && beforSize.width < contentWidth) return;
// 커스텀 속성 추가 var resize_ratio = contentWidth / beforSize.width;
img.attr("rel", "xe_gallery");
// 크기를 계산한다 $img
if(width>offsetWidth) { .removeAttr('width').removeAttr('height')
img.attr("width",offsetWidth-10); .css({
img.attr("height",parseInt(offsetWidth/width*height,10)); 'width':contentWidth,
} 'height':parseInt(beforSize.height * resize_ratio, 10)
});
});
// 링크가 설정되어 있거나 onclick 이벤트가 부여되어 있으면 원본 보기를 하지 않음 /* live 이벤트로 적용 (image_gallery 컴포넌트와의 호환 위함) */
if ( !img.parent("a").size() && !img.attr("onclick") ) { $('img[rel=xe_gallery]', this).live('mouseover', function() {
// 스타일 설정 var $img = $(this);
img.css("cursor", "pointer"); if(!$img.parent('a').length && !$img.attr('onclick')) {
$img.css('cursor', 'pointer').click(slideshow);
// 클릭하면 슬라이드쇼 시작 }
img.click(slideshow); });
} });
}
});
});
}); });
})(jQuery); })(jQuery);

View file

@ -72,11 +72,8 @@ function start_list_gallery() {
obj.image.style.marginBottom = "10px"; obj.image.style.marginBottom = "10px";
obj.image.style.display = "block"; obj.image.style.display = "block";
// resize_scale이 1이 아니면, 즉 리사이즈 되었다면 해당 이미지 클릭시 원본을 새창으로 띄워줌 // 리사이즈 되었다면 resize_image 애드온의 slideshow() 기능 사용
if(resize_scale!=1 && typeof(showOriginalImage)=='function') { if(resize_scale != 1) obj.image.rel = 'xe_gallery';
obj.image.style.cursor = 'pointer';
xAddEventListener(obj.image, 'click', showOriginalImage);
}
zone.appendChild(obj.image); zone.appendChild(obj.image);
} }