")
.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 = $('
')
.css({
left: "10px",
backgroundPosition: "0 -64px"
})
.click(function(){xScreen.xePrev()})
.appendTo(controls);
// 닫기 버튼
closebtn = $('
')
.css({
top: "10px",
backgroundPosition: "0 0"
})
.click(function(){xScreen.xeHide()})
.appendTo(controls);
// 다음 버튼
nextbtn = $('
')
.attr("id", "xe_gallery_nextbtn")
.css({
right: "10px",
backgroundPosition: "0 -128px"
})
.click(function(){xScreen.xeNext()})
.appendTo(controls);
// 버튼 공통 속성
controls.find(">button")
.css({
position : "absolute",
width : "64px",
height : "64px",
zIndex : 530,
cursor : "pointer",
border : 0,
margin : 0,
padding : 0,
backgroundColor: "transparent",
backgroundImage: "url(" + request_uri + "addons/resize_image/btn.png)",
backgroundRepeat: "no-repeat",
opacity: ".5",
filter: "alpha(opacity=50)"
})
.mouseover(function(){
$(this).css({
opacity: "1",
filter: "alpha(opacity=100)"
});
})
.mouseout(function(){
$(this).css({
opacity: ".5",
filter: "alpha(opacity=50)"
});
})
.focus(function(){
$(this).trigger('mouseover');
})
.blur(function(){
$(this).trigger('mouseout');
})
;
// 이미지 홀더
imgframe = $("
")
.attr("id", "xe_gallery_holder")
.css({
border: '5px solid white',
zindex: 520,
maxWidth: 'none',
borderRadius: '5px',
boxShadow: '0 0 10px #000'
})
.appendTo(controls).draggable();
body.append(xScreen).append(controls);
// xScreen 객체를 확장한다.
xScreen.xeShow = function() {
var clientWidth = $(window).width();
var clientHeight = $(window).height();
$("#xe_gallery_controls,#xe_gallery_screen").show().css({
top : 0,
right : 0,
bottom : 0,
left : 0
});
$("#xe_gallery_prevbtn,#xe_gallery_nextbtn").css("top", Math.round(clientHeight/2 - 32) + "px");
this.xeMove(0);
};
xScreen.xeHide = function(event) {
xScreen.hide();
controls.hide();
};
xScreen.xePrev = function() {
this.xeMove(-1);
};
xScreen.xeNext = function() {
this.xeMove(1);
};
xScreen.xeMove = function(val) {
var clientWidth = $(window).width();
var clientHeight = $(window).height();
this.index += val;
prevbtn.css("visibility", (this.index>0)?"visible":"hidden");
nextbtn.css("visibility", (this.index
');
/**
* 리사이즈 실행 함수
**/
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);