/** * @brief 화면내에서 상위 영역보다 이미지가 크면 리사이즈를 하고 클릭시 원본을 보여줄수 있도록 변경 **/ (function($){ var xScreen = null; // 슬라이드를 위한 블랙 스크린을 만들거나 반환하는 함수 function getScreen() { var body = $(document.body); var controls, imgframe, closebtn, prevbtn, nextbtn; // 스크린이 없으면 스크린을 만든다. if (!xScreen) { // 검은 스크린 xScreen = $("
") .attr("id","xe_gallery_screen") .css({ position:"fixed", display:"none", backgroundColor:"black", zIndex:500, opacity:0.7 }); // 이미지를 보여주고 컨트롤 버튼을 다룰 레이어 controls = $("
") .attr("id","xe_gallery_controls") .css({ position:"fixed", display:"none", overflow:"hidden", zIndex:510 }); // 이전 버튼 prevbtn = $('
'); /** * 리사이즈 실행 함수 **/ 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) }); } $('.xe_content').each(function() { var contentWidth = dummy.appendTo(this).width(); dummy.remove(); if(!contentWidth) return; $('img', this).each(function() { var $img = $(this); var imgSrc = $img.attr('src'); if(regx_skip.test(imgSrc) && !regx_allow_i6pngfix.test(imgSrc)) return; $img.attr('rel', 'xe_gallery'); doResize.call($img, contentWidth); }); /* live 이벤트로 적용 (image_gallery 컴포넌트와의 호환 위함) */ $('img[rel=xe_gallery]', this).live('mouseover', function() { var $img = $(this); if(!$img.parent('a').length && !$img.attr('onclick')) { $img.css('cursor', 'pointer').click(slideshow); } }); }); }); })(jQuery);