;(function($,exports,undefined){
"use strict";
// console.log(!$.fn.FadeWideBgImg)
if (!$.fn.FadeWideBgImg){
// ±âº» ¼³Á¤°ª Á¤ÀÇ
var defaultSettings = {
minwidth : 900, //À̹ÌÁö ¼î ÃÖ¼Ò ³ÐÀÌ
height : 400, // À̹ÌÁö ¼î ³ôÀÌ
speed : 1000, // Àüȯ ¼Óµµ
interval : 3000, // Àüȯ °£°Ý
cover : true // Ä¿¹ö ³ëÃâ ¿©ºÎ
};
// end - defaultSettings
$.fn.FadeWideBgImg = function (options){
var _this = this,
setValue = $.type(options) == 'object' ? $.extend({},defaultSettings, options) : defaultSettings;
// console.log(_this)
//¹Ýº¹½Ãų ´ë»ó
var $ShowTarget = $('li',_this),
$ShowTargetImg = $('img',$ShowTarget),
$ShowTotal = $ShowTarget.length, //ÃÑ °¹¼ö, ÇöÀç 3
ShowCurrent = $ShowTotal -1,
$ShowParent = _this.parent("div");
$ShowParent.css({
'position' : 'relative'
});
$(_this).css({
'position' : 'relative',
'height' : setValue.height,
'overflow' : 'hidden',
'margin' : '0',
'padding' : '0'
});
//À̹ÌÁö ¼î (li) ¿µ¿ª ¼³Á¤
$($ShowTarget).css({
'width' : '100%',
'min-width' : setValue.minwidth,
'position' : 'absolute',
'left' : '0'
});
//°¢ li ¾ÈÀÇ À̹ÌÁö¿¡ ´ëÇÑ ¼³Á¤
$ShowTargetImg.css({
'width' : '100%',
'opacity' : '0'
});
if(setValue.cover == true){
//¹Úº¹ ÆÐÅÏ ¹è°æ div »ý¼º
$('
').appendTo(_this.parent("div"));
//ÆÐÅÏ ¹è°æ ½ºÅ¸ÀÏ Àû¿ë
$('.fwb-patt').css({
'position': 'absolute',
'left': '0',
'top': '0',
'width': '100%',
'height': setValue.height,
'background': 'url(\'patt.png\') repeat'
});
}
//END if
//·Îµù div »ý¼º
$('Loading Images ...
').appendTo(_this.parent("div"));
$('.fwb-loading').css({
'position': 'absolute',
'left': '0',
'top': '0',
'width': '100%',
'height': setValue.height,
'font-size' : '13px',
'font-weight' : 'bold',
'color' : '#d9d9d9',
'text-align' : 'center',
'line-height' : setValue.height+'px',
'text-shadow' : '1px 1px #484848'
// 'background': 'url(\'loadingimage.gif\') no-repeat center'
});
function verticalCenter(){
// console.log("·Îµå¿Ï·á ÈÄ À̹ÌÁö ¼¼·Î Áß¾Ó Á¤·Ä")
$.each($ShowTargetImg, function() {
$(this).parent("li").css({
'margin-top' : (setValue.height-$(this).height())/2
});
});
};
//resize â Á¶Àý¿¡ µû¸¥ À̹ÌÁö ¼¼·Î Áß¾Ó Á¤·Ä
$(window).on('resize',function(){
verticalCenter();
});
//½½¶óÀ̵å¼î ±â´É
function slideshowstart(){
var SlideIntval;
SlideIntval = setInterval(function(){
// console.log("·Îµå¿Ï·á ÈÄ ÀÎÅ͹ú")
if(ShowCurrent > 0){
if(ShowCurrent == $ShowTotal - 1){
$ShowTargetImg.stop().animate({'opacity' : '1'},0,'swing');
}
$ShowTargetImg.eq(ShowCurrent).stop().animate({'opacity' : '0'},setValue.speed,'swing');
ShowCurrent = ShowCurrent - 1;
}else if(ShowCurrent == 0){
$ShowTargetImg.eq($ShowTotal - 1).stop().animate({'opacity' : '1'},setValue.speed,'swing');
ShowCurrent = $ShowTotal - 1; //¼øÂ÷ÀûÀ¸·Î Çϳª¾¿ ÆäÀÌµå ½ÃÅ´
};
// console.log('°á°ú ShowCurrent : '+ShowCurrent)
//END if
}, setValue.interval);
// end - setinterval
}
// end fn.slideshowstart
var loadedcount = 0;
// $ShowTargetImg.load({noncache: new Date().getTime()}, onloadedimage);
function onloadedimage(e){
loadedcount++;
if (loadedcount == $ShowTarget.children().length)
{
$('.fwb-loading').fadeOut(200);
verticalCenter();
$ShowTargetImg.eq($ShowTotal - 1).stop().animate({'opacity' : '1'},setValue.speed,'swing',function(){
slideshowstart();
});
}
}
//end onloadedimage
$(document).ready(function() {
var imageLoaded = function() {
onloadedimage();
}
$ShowTargetImg.each(function() {
var targetImg = new Image() ;
targetImg.onload = imageLoaded ;
targetImg.src = $(this).attr('src') ;
}) ;
}) ;
//
}
// end - fn
}
// end - if
})(window.jQuery, window);