!function($){$.fn.bgPhotoFrame=function(setting){function userAgent(){var e,n=navigator.userAgent;return e=n.indexOf("iPhone")>-1||n.indexOf("iPad")>-1||n.indexOf("iPod")>-1?"ios":n.indexOf("Android")>-1?"android":"pc"}function removeUnit(e){return parseInt(e.replace(/([a-z]+)/,""))}function setResizeEvent(){$(window).resize(function(){for(var e=0;eimgRatio?(imgWidth=windowWidth,imgHeight=parseInt(baseHeight*(imgWidth/baseWidth)),marginTop=-(imgHeight-windowHeight)/2,marginLeft=0):(imgHeight=windowHeight,imgWidth=parseInt(baseWidth*(imgHeight/baseHeight)),marginTop=0,marginLeft=-(imgWidth-windowWidth)/2):"photoframe"==currentMode&&(windowRatio>=imgRatio?(imgHeight=windowHeight,imgWidth=parseInt(baseWidth*(imgHeight/baseHeight)),marginLeft=(windowWidth-imgWidth)/2,marginTop=0):(imgWidth=windowWidth,imgHeight=parseInt(baseHeight*(imgWidth/baseWidth)),marginLeft=0,marginTop=(windowHeight-imgHeight)/2)),imgWidth=parseInt(imgWidth),imgHeight=parseInt(imgHeight),marginTop=parseInt(marginTop),marginLeft=parseInt(marginLeft),animation?_img.animate({width:imgWidth+"px",height:imgHeight+"px",marginTop:marginTop+"px",marginLeft:marginLeft+"px"},photoAnimeTime,easing,function(){callback&&eval(callback+"()")}):(_img.width(imgWidth),_img.height(imgHeight),_img.css({marginTop:marginTop+"px",marginLeft:marginLeft+"px"}))}}function stopResizeImages(){for(var e=0;e"),maskElement=$("#images-mask"),maskElement.css({background:"rgba("+setting.maskColor+","+setting.maskColor+","+setting.maskColor+","+setting.maskOpacity+")"})}function resizeMask(){maskElement.css({width:$(window).width()+"px",height:$(window).height()+"px"})}function setImageSize(e){var n=element.find("img").eq(e),t=(n.attr("src"),getImageTrueSize(n));t.ratio=t.width/t.height,imgInfo[e].width=t.width,imgInfo[e].height=t.height,imgInfo[e].ratio=t.ratio,imgInfo[e].loaded=!0,checkLoadComplete(e)}function getImageTrueSize(e){var n=[];if(e.prop("naturalWidth"))n.width=e.prop("naturalWidth"),n.height=e.prop("naturalHeight");else{var t=new Image;t.src=e.attr("src"),n.width=t.width,n.height=t.height}return n}function checkLoadComplete(e){var n=!0;if(0==e)LoadFirstImageComplete();else for(var t=0;t1&&(controls.append(''),controls.append(''),"pc"==device?$("."+navPrefix).click(function(){return navClick($(this)),!1}):$("."+navPrefix).bind("touchstart",function(e){navClick($(this)),e.preventDefault()}),$(window).resize(function(){resizeNav()}),nav=$("."+navPrefix))}function navClick(e){if(btnEnable&&nav.hasClass("active")){var e=e.attr("id").replace(navPrefix+"-","");command("imgChange",e)}}function showNav(){nav.stop(!1,!0),nav.fadeIn(fadeTime,function(){nav.addClass("active")}),navPosition()}function hideNav(){nav.removeClass("active"),nav.stop(!1,!0),nav.fadeOut()}function stopNav(){}function resizeNav(){navPosition()}function navPosition(){var e=($(window).height()-nav.width())/2;$("#"+navPrefix+"-prev, #"+navPrefix+"-next").css({top:e+"px"})}function initThumbs(){controls.append(''),thumbBtn=$("#"+thumbBtnClass),controls.append('
    '),thumbPage=$("#"+thumbPageClass+" ul");for(var e=0;e';thumbPage.append(n)}"pc"==device?thumbBtn.click(function(){return toggleThumbBtn(),!1}):thumbBtn.bind("touchstart",function(e){toggleThumbBtn(),e.preventDefault()}),$("#"+thumbPageClass).bind("click",function(){return closeThumbs(),!1})}function attachThumbImage(e,n){var t=thumbPage.find("li").eq(e).find("a"),i=new Image;i.src=n,imgWidth=imgInfo[e].width,imgHeight=imgInfo[e].height,imgRatio=imgInfo[e].ratio,thumbSize=thumbPage.find("li").width();var a,o,r=document.createElement("canvas"),s=r.getContext("2d"),m=0,c=0;imgRatio>1?(o=thumbSize,a=thumbSize*imgRatio,m=(thumbSize-thumbSize*imgRatio)/2):(a=thumbSize,o=imgHeight*(thumbSize/a),c=(thumbSize-thumbSize/imgRatio)/2),s.drawImage(i,m,c,a,o),t.append(r),t.click(function(){return ThumbClick(t),!1})}function resizeThumbs(){var e=$(window).width(),n=($(window).height(),.02*$(window).width());$("#"+thumbPageClass+"-inner").css({width:e+"px",padding:n+"px "+n+"px"});var t=thumbPage.find("li").width(),i=removeUnit(thumbPage.find("li").css("margin")),a=($("#"+thumbPageClass+" ul").width()-(t+2*i)*parseInt($("#"+thumbPageClass+" ul").width()/(2*i+t)))/2;$("#"+thumbPageClass+" ul").css({marginLeft:a+"px"})}function showThumbBtn(){thumbBtn.stop(!1,!0),thumbBtn.fadeIn(fadeTime)}function hideThumbBtn(){thumbBtn.stop(!1,!0),thumbBtn.fadeOut(fadeTime)}function toggleThumbBtn(){thumbBtn.toggleClass("active"),toggleThumbs()}function toggleThumbs(){thumbAnimationStop(),thumbBtn.hasClass("active")?openThumbs():closeThumbs()}function thumbAnimationStop(){$("#"+thumbPageClass).stop(!1,!0)}function openThumbs(){$("#"+thumbPageClass).show(),$("#"+thumbPageClass).animate({width:"100%",height:"100%"},thumbTime,easing)}function closeThumbs(){$("#"+thumbPageClass).animate({width:"0%",height:"0%"},thumbTime,easing,function(){$("#"+thumbPageClass).hide()}),thumbBtn.removeClass("active")}function ThumbClick(e){var n=e.attr("href").replace("#","");command("imgChange",n),closeThumbs()}function initTimer(){if(setting.autoChange&&element.find("li").length>1){var e='';controls.append(e),timerBtn=$("#"+timerBtnId),setting.autoChange&&element.find("li").length>1&&timerBtn.addClass("on"),"pc"==device?timerBtn.click(function(){return toggleTimer(),!1}):timerBtn.bind("touchend",function(e){toggleTimer(),e.preventDefault()})}}function toggleTimer(){timerBtn.toggleClass("on"),timerBtn.hasClass("on")?timerOn():timerOff()}function timerOn(){timerBtn.addClass("on"),setTimer()}function timerOff(){timerBtn.removeClass("on"),disableTimer()}function setTimer(){disableTimer(),setting.autoChange&&timerBtn.hasClass("on")&&element.find("li").length>1&&enableTimer()}function enableTimer(){timer.push(setTimeout(function(){timerChange()},setting.autoTimer))}function disableTimer(){for(var e=0;en;n++){var t=element.find("li").eq(n);t.stop(!1,!0)}}function transitionFadeEnd(){command("transitionEnd")}function swipeLoop(e,n){var t=easing,i=swipeSpeed;removeUnit(wrapper.css("marginLeft"));i=setSpeed(e,n),setSwipePosition(e,n),setSwipeImage(e,n),wrapper.animate({marginLeft:0},i,t,function(){swipeEnd(e,n)}),swipeAnmation=!0}function setSwipePosition(e,n){var t=0,i=removeUnit(wrapper.css("marginLeft"));"current"==n?t=removeUnit(wrapper.css("marginLeft")):"next"==n?t=$(window).width()+i:"prev"==n&&(t=-$(window).width()+i),wrapper.css({marginLeft:t+"px"})}function setSwipeImage(e,n){var t=element.find("li").eq(e);command("setSwipeImage",e),t.css({display:"block",marginLeft:0}),element.find("li:not(:eq("+e+"))").css({display:"none"})}function setSpeed(e,n){var t=0,i=1,a=removeUnit(wrapper.css("marginLeft"));return t=a>=0?($(window).width()-a)*i:($(window).width()+a)*i}function swipeEnd(e,n){swipeLoopStop(),command("swipeEnd")}function swipeLoopStop(){wrapper.stop(!0,!1),swipeAnmation=!1}function swipeDown(e){"photoframe"==currentMode&&(swipeLoopStop(),swipeActive=!0,swipeDistance=0,swipeSpeed=0,setSwipePosition(current,"current"),setSwipeImage(current,"current"),swipeActiveStart=e,swipeSpeedStart=e,swipeStartMargin=removeUnit(wrapper.css("marginLeft")),swipeSpeedTimer.push(setInterval(function(){setSwipeSpeed()},swipeSpeedTimerSpan)),command("swipeDown"))}function setSwipeSpeed(){swipeSpeed=swipeSpeedStart-swipeSpeedCurrent,swipeSpeedStart=swipeSpeedCurrent}function swipeMove(e){if(swipeActive){swipeLoopStop(),swipeDistance=e-swipeActiveStart,swipeSpeedCurrent=e;var n=swipeStartMargin+swipeDistance;wrapper.css({marginLeft:n+"px"})}}function swipeUp(e){if(swipeActive){swipeLoopStop();for(var n=0;nswipeSpeedLimit||-swipeSpeedLimit>swipeSpeed?t=swipeSpeed>0?"next":"prev":(i>$(window).width()/2||i<-$(window).width()/2)&&(t=0>i?"next":"prev"),t&&command("imgChange",t),command("swipeUp"),swipeDistance=0}swipeActive=!1}function initDammy(){element.after('
      '),dammyElement=$(".bg-photo-frame-dammy"),dammyElement.css({margin:"0px",padding:"0px",position:"absolute",display:"block",width:"100%"})}function dammyShow(e,n,t){command("setDammy",e);var i,a=element.find("li").eq(e).find("img"),o=a.width(),r=a.height(),s=a.css("marginTop");removeUnit(wrapper.css("marginLeft"));"left"==t?i=-$(window).width()+($(window).width()-o)/2:"right"==t&&(i=$(window).width()+($(window).width()-o)/2);var m=a.attr("src"),c=a.attr("alt"),d=$("
    • ");d.find("img").attr("src",m),d.find("img").attr("alt",c),d.addClass("bg-photo-frame-dammy-list").addClass("bg-photo-frame-dammy-"+t),d.css({width:"100%",position:"absolute",listStyle:"none"}),d.find("img").css({width:o+"px",height:r+"px",marginTop:s,marginLeft:i*(n+1)+"px"}),dammyElement.append(d)}var defaluts={suffle:!1,width:"100%",height:"auto",minHeight:"none",maxHeight:"none",autoChange:!0,autoTimer:4e3,interfaceTimer:!0,fadeSpeed:1e3,shuffle:!1,gradationColor:"0,0,0",callbackBefore:null,callbackAfter:null,callbackChange:null,photoFrame:!1,stopWhenClicked:!0,contents:"",maskColor:"light",maskOpacity:.7};if(setting=$.extend(defaluts,setting),this.length){var element=this,wrapper,controls,parent=element.parent(),num=element.find("li").length,imgInfo=[],current=0,previous=0,timer=[],device=userAgent(),loaded=!1,breakPoint=782,btnEnable=!0,clicked=!1,prefix="bg-photo-frame",easing="easeOutCubic",fadeTime=1e3,photoAnimeTime=1e3,photoAnimeEasing="easeOutQuad",mask=[],maskElement,commandProcess=[],interface=!1,contentFadeTime=500,currentMode="background",mode=[],toggleBtnId=prefix+"-toggle",iconClassPhotoFrame="glyphicon-picture",iconClassBlog="glyphicon-list-alt",toggleButtonSrc='',toggleButton,nav,prev,next,navClicked=!1,navPrefix=prefix+"-nav",thumbPage,thumbBtn,thumbPrefix=prefix+"-thumb",thumbPageClass=thumbPrefix+"-thumbs",thumbBtnClass=thumbPrefix+"-btn",thumbTime=500,timer,timerBtn,timerPrefix=prefix+"-timer",timerBtnId=timerPrefix+"-btn",change=[];transitionMode="fade";var fade=[],swipe=[],swipeSpeed=2e3,swipeAnmation=!1,currentSwipeNum=0,nextSwipeNum=0,swipeSpeedLimit=5,swipeSpeedTimerSpan=100,dammy=[],dammyElement;if(setting.callbackBefore&&window[setting.callbackBefore].apply(),element.find("li").length){if(element.wrap("
      "),wrapper=$("#bg-photo-frame-images-wrapper"),$("body").prepend("
      "),controls=$("#bg-photo-frame-controls"),element.css({margin:"0px",padding:"0px"}),wrapper.css({opacity:"1.0"}),"auto"!=setting.height&&element.css({height:setting.height+"px"}),element.find("li").css({position:"absolute",listStyle:"none",display:"none",overflow:"hidden"}),element.find("img").css({maxWidth:"none"}),"100%"==setting.width?(element.find("li").css({width:"100%"}),element.find("img").css({width:"100%"})):"auto"!=setting.width&&element.find("img").css({width:setting.width+"px"}),setting.shuffle){var shuffleElement=element.html().split("");shuffleElement.splice(shuffleElement.length-1);for(var i=shuffleElement.length-1;i>=0;i--){var r=Math.floor(i*Math.random()),tmp=shuffleElement[i];shuffleElement[i]=shuffleElement[r],shuffleElement[r]=tmp}element.empty();for(var i=0;it;t++){var i=element.find("li").eq(t);i.stop(!0,!1),e==t?(i.css({marginLeft:0}),e!=current&&("none"==i.css("display")?i.fadeIn(setting.fadeSpeed,function(){transitionFadeEnd()}):i.fadeTo(setting.fadeSpeed,1,function(){transitionFadeEnd()}),resizeImages(t))):i.fadeOut(setting.fadeSpeed)}transitionFadeEnd()},swipe.transitionSwipe=function(e,n){swipeAnmation||(currentSwipeNum=parseInt(current)),swipeLoopStop(),swipeLoop(e,n)};var swipeActive,swipeActiveStart,swipeActiveCurrent,swipeStartMargin,swipeDistance,swipeSpeed,swipeSpeedStart,swipeSpeedCurrent,swipeSpeedTimer=[];"pc"==device?(maskElement.mousedown(function(e){swipeDown(e.pageX)}),$(window).mousemove(function(e){swipeMove(e.pageX)}),$(window).mouseup(function(e){swipeUp(e.pageX)})):(maskElement.bind("touchstart",function(){swipeDown(event.changedTouches[0].pageX)}),$(window).bind("touchmove",function(){swipeMove(event.changedTouches[0].pageX)}),$(window).bind("touchend",function(){swipeUp(event.changedTouches[0].pageX)})),dammy.setDammy=function(e,n){dammyElement.find("li").remove();var t,i;t=-$(window).width(),i=$(window).width();var a=removeUnit(wrapper.css("marginLeft"));e=parseInt(e);var o,r=1,s=1;if(a>0?r=Math.floor((a+$(window).width())/$(window).width())+1:0>a&&(s=Math.floor(-(a-$(window).width())/$(window).width())+1),o=e,"next"==n||"current"==n)for(var m=0;r>m;m++){var c;c=0==o?element.find("li").length-1:o-1,dammyShow(c,m,"left"),o=c}if("prev"==n||"current"==n){o=e;for(var m=0;s>m;m++){var d;d=o==element.find("li").length-1?0:o+1,dammyShow(d,m,"right"),o=d}}dammyElement.css("display","block")},dammy.removeDammy=function(){dammyElement.find("li").remove()},initDammy()}}}}(jQuery),jQuery.easing.jswing=jQuery.easing.swing,jQuery.extend(jQuery.easing,{def:"easeOutQuad",swing:function(e,n,t,i,a){return jQuery.easing[jQuery.easing.def](e,n,t,i,a)},easeInQuad:function(e,n,t,i,a){return i*(n/=a)*n+t},easeOutQuad:function(e,n,t,i,a){return-i*(n/=a)*(n-2)+t},easeInOutQuad:function(e,n,t,i,a){return(n/=a/2)<1?i/2*n*n+t:-i/2*(--n*(n-2)-1)+t},easeInCubic:function(e,n,t,i,a){return i*(n/=a)*n*n+t},easeOutCubic:function(e,n,t,i,a){return i*((n=n/a-1)*n*n+1)+t},easeInOutCubic:function(e,n,t,i,a){return(n/=a/2)<1?i/2*n*n*n+t:i/2*((n-=2)*n*n+2)+t},easeInQuart:function(e,n,t,i,a){return i*(n/=a)*n*n*n+t},easeOutQuart:function(e,n,t,i,a){return-i*((n=n/a-1)*n*n*n-1)+t},easeInOutQuart:function(e,n,t,i,a){return(n/=a/2)<1?i/2*n*n*n*n+t:-i/2*((n-=2)*n*n*n-2)+t},easeInQuint:function(e,n,t,i,a){return i*(n/=a)*n*n*n*n+t},easeOutQuint:function(e,n,t,i,a){return i*((n=n/a-1)*n*n*n*n+1)+t},easeInOutQuint:function(e,n,t,i,a){return(n/=a/2)<1?i/2*n*n*n*n*n+t:i/2*((n-=2)*n*n*n*n+2)+t},easeInSine:function(e,n,t,i,a){return-i*Math.cos(n/a*(Math.PI/2))+i+t},easeOutSine:function(e,n,t,i,a){return i*Math.sin(n/a*(Math.PI/2))+t},easeInOutSine:function(e,n,t,i,a){return-i/2*(Math.cos(Math.PI*n/a)-1)+t},easeInExpo:function(e,n,t,i,a){return 0==n?t:i*Math.pow(2,10*(n/a-1))+t},easeOutExpo:function(e,n,t,i,a){return n==a?t+i:i*(-Math.pow(2,-10*n/a)+1)+t},easeInOutExpo:function(e,n,t,i,a){return 0==n?t:n==a?t+i:(n/=a/2)<1?i/2*Math.pow(2,10*(n-1))+t:i/2*(-Math.pow(2,-10*--n)+2)+t},easeInCirc:function(e,n,t,i,a){return-i*(Math.sqrt(1-(n/=a)*n)-1)+t},easeOutCirc:function(e,n,t,i,a){return i*Math.sqrt(1-(n=n/a-1)*n)+t},easeInOutCirc:function(e,n,t,i,a){return(n/=a/2)<1?-i/2*(Math.sqrt(1-n*n)-1)+t:i/2*(Math.sqrt(1-(n-=2)*n)+1)+t},easeInElastic:function(e,n,t,i,a){var o=1.70158,r=0,s=i;if(0==n)return t;if(1==(n/=a))return t+i;if(r||(r=.3*a),sn?-.5*(s*Math.pow(2,10*(n-=1))*Math.sin((n*a-o)*(2*Math.PI)/r))+t:s*Math.pow(2,-10*(n-=1))*Math.sin((n*a-o)*(2*Math.PI)/r)*.5+i+t},easeInBack:function(e,n,t,i,a,o){return void 0==o&&(o=1.70158),i*(n/=a)*n*((o+1)*n-o)+t},easeOutBack:function(e,n,t,i,a,o){return void 0==o&&(o=1.70158),i*((n=n/a-1)*n*((o+1)*n+o)+1)+t},easeInOutBack:function(e,n,t,i,a,o){return void 0==o&&(o=1.70158),(n/=a/2)<1?i/2*(n*n*(((o*=1.525)+1)*n-o))+t:i/2*((n-=2)*n*(((o*=1.525)+1)*n+o)+2)+t},easeInBounce:function(e,n,t,i,a){return i-jQuery.easing.easeOutBounce(e,a-n,0,i,a)+t},easeOutBounce:function(e,n,t,i,a){return(n/=a)<1/2.75?i*(7.5625*n*n)+t:2/2.75>n?i*(7.5625*(n-=1.5/2.75)*n+.75)+t:2.5/2.75>n?i*(7.5625*(n-=2.25/2.75)*n+.9375)+t:i*(7.5625*(n-=2.625/2.75)*n+.984375)+t},easeInOutBounce:function(e,n,t,i,a){return a/2>n?.5*jQuery.easing.easeInBounce(e,2*n,0,i,a)+t:.5*jQuery.easing.easeOutBounce(e,2*n-a,0,i,a)+.5*i+t}});