text: (function(){var isTouchDevice=navigator.userAgent.match(/(iPhone|iPod|iPad|Android|playbook|silk|BlackBerry|BB10|Windows Phone|Tizen|Bada|webOS|IEMobile|Opera Mini)/);var isTouch=(('ontouchstart'in window)||(navigator.msMaxTouchPoints>0)||(navigator.maxTouchPoints));var getFirstTouchEventPos=function(e,orientation){var touches=e.touches,orientation=orientation||'y',changedTouches=e.changedTouches,touchVo=null;if(changedTouches&&changedTouches.length>0){touchVo=changedTouches[0]}else if(touches&&touches.length>0){touchVo=touches[0]}if(touchVo){return touchVo['client'+orientation.toLocaleUpperCase()]||touchVo['page'+orientation.toLocaleUpperCase()]}return NaN}var defaultOptions={orientation:'y',$el:null,perspective:NaN,speed:800,delayTime:500,touchStatu:false,isAlignCenter:false,callbacks:{init:null,begain:null,end:null,outBegain:null,outEnd:null}}var resetOptions={valid:true,allow:true,isDelayTime:false,startPos:NaN,movePos:NaN,endPos:NaN,triggerType:null}var actionOptions={prevIdx:NaN,nextIdx:NaN,idx:0}var Attrs={initialize:function(){var options=this.options,$el=options.$el,orientation=options.orientation;$el.addClass('petrus-slide-container');options.$pages=[];var $pages=$el.children();options.$pages=$pages;this.initializePages();this.setSize();if(options.callbacks.init){options.callbacks.init()}return true},initializePages:function(){var options=this.options,$el=options.$el,$pages=options.$pages,idx=options.idx;$pages.addClass('petrus-slide-page');$pages.eq(idx).css({left:0,top:0}).addClass('active').siblings().addClass('petrus-slide-hide');for(var i=0;i<$pages.length;i++){var $page=$($pages[i]);var $content=$page.children();var $table=$('<div class="petrus-slide-table"></div>');$page.append($table);var $cell=$('<div></div>');$table.append($cell);$cell.append($content);if(options.isAlignCenter)$cell.addClass('petrus-slide-table-cell')}},getSize:function(){return{w:$(window).width(),h:$(window).height()}},getNextIdx:function(isUp){var options=this.options,$pages=options.$pages,len=$pages.length;idx=options.idx,scope=1;var nextIdx=idx;if(isUp)scope=-1;nextIdx+=scope;if(nextIdx==-1){nextIdx=len-1}else if(nextIdx>=len){nextIdx=0}return nextIdx},getPagesNum:function(){var _this=this;options=this.options,$pages=options.$pages;return $pages.length},showNext:function(isUp){this.showPage(this.getNextIdx(isUp))},showPage:function(nextIdx){var _this=this;options=this.options,$pages=options.$pages,idx=options.idx,allow=options.allow,nextIdx=nextIdx==undefined?this.getNextIdx():nextIdx,animStyle=this.options.animStyle;if(!allow||idx==nextIdx){return false}var $page=$pages.eq(idx),$nextPage=$pages.eq(nextIdx),size=this.getSize();options.allow=false;if(options.callbacks.begain){options.callbacks.begain.call(null,nextIdx,idx)}if(options.callbacks.outBegain){options.callbacks.outBegain.call(null,idx,nextIdx)}var isUp=nextIdx>idx?true:false,top=isUp?'100%':'-100%',hideTop=isUp?'-100%':'100%',ac=isUp?'up':'down',anim=animStyle?('petrus-slide-anim-'+ac+'-'+animStyle):'default';$nextPage.css('z-index',1).siblings().css('z-index',0);var hideAnim=('petrus-slide-anim-'+ac+'-hide-'+animStyle);$page.addClass(hideAnim);setTimeout(function(){$page.addClass('petrus-slide-hide').removeClass(hideAnim);if(options.callbacks.outEnd){options.callbacks.outEnd.call(null,idx,nextIdx)}},800);$nextPage.removeClass('petrus-slide-hide');$nextPage.addClass(anim);setTimeout(function(){$nextPage.removeClass(anim);options.idx=nextIdx;if(options.callbacks.end){options.callbacks.end.call(null,nextIdx,idx)}$nextPage.addClass('active').siblings().removeClass('active');if(!isTouchDevice){setTimeout(function(){options.allow=true},50)}else{options.allow=true}},800)},getIdx:function(){return this.options.idx},setValid:function(statu){this.options.valid=statu},setSize:function(){var options=this.options,$el=options.$el,$pages=options.$pages,size=this.getSize();$el.width(size.w);$el.height(size.h);$pages.width(size.w);$pages.height(size.h)},slideStart:function(e){var options=this.options;if(options.touchStatu)return;var pos=NaN,$pages=options.$pages;if(e==null)return;pos=getFirstTouchEventPos(e);options.startPos=pos;options.touchStatu=true},slideMove:function(e){var options=this.options;if(!options.touchStatu){return}pos=getFirstTouchEventPos(e);if(!pos){return}options.movePos=pos},slideEnd:function(e){var isElec=true;var options=this.options;var touches=e.touches,orientation=orientation||'y',changedTouches=e.changedTouches;if(!options.touchStatu)return;var pos=getFirstTouchEventPos(e);if(!pos){options.endPos=options.movePos||options.startPos}else{options.endPos=pos}var isUp=false;var dis=options.endPos-options.startPos;var isTrigger=true;if(dis>0)isUp=true;if((options.idx==0&&isUp)||(options.idx==options.$pages.length-1&&!isUp))isTrigger=false;if(Math.abs(dis)<this.getSize().h*0.1)isTrigger=false;if(isTrigger)this.showNext(isUp);options.touchStatu=false},getAllow:function(){return this.options.allow}}var slide=function(settings){settings=settings||{};var options=this.options={};$.extend(true,options,resetOptions,actionOptions,defaultOptions,settings);this.options=options;var $el=this.$el=options.$el,idx=options.idx=0;if(!options.animStyle){animSpeed=options.speed||800}$.extend(true,this,Attrs);var initResult=this.initialize();if(!initResult)return;var _this=this;$(window).resize(function(){_this.setSize()});if(!isTouchDevice){$el.mousewheel(function(event,delta,deltaX,deltaY){if(!options.valid)return;if(options.isDelayTime)return;if(deltaY==0)return;var isUp=deltaY>0?true:false;if((options.idx==0&&isUp)||(options.idx==options.$pages.length-1&&!isUp))return;_this.showNext.call(_this,isUp);options.isDelayTime=true;window.setTimeout(function(){options.isDelayTime=false},(options.speed+options.delayTime));return false})}else{$el[0].addEventListener('touchstart',function(e){if(!options.allow||!options.valid)return;_this.slideStart(e)},false);$el[0].addEventListener('touchmove',function(e){_this.slideMove(e);if(e.preventDefault)e.preventDefault()},false);$el[0].addEventListener('touchend',function(e){_this.slideEnd(e)},false);$el[0].addEventListener('touchcancel',function(e){_this.slideEnd(e);if(e.preventDefault)e.preventDefault()},false)}return this}var petrus_slide=function(settings){var $slide=new slide(settings);return{getPagesNum:function(){return $slide.getPagesNum()},showNext:function(isUp){$slide.showNext(isUp)},showPage:function(nextIdx){$slide.showPage(nextIdx)},getIdx:function(){return $slide.getIdx()},setValid:function(statu){$slide.setValid(statu)},getAllow:function(){return $slide.getAllow()}}}$.fn.petrus_slide=function(settings){settings=settings||{};settings.$el=$(this);return petrus_slide(settings)}})()