Settings,r=e("require/index").Utilities,i=e("plugins/sony-iscroll"),s=function(e,r){var i=this;t.extend(i,t.fn.scrollerModule.defaults,r,t.fn.scrollerModule.settings),i.$el=e,i.$win=n.$window,i.unique=".sm_"+t.now(),i._init()};s.prototype={constructor:s,_init:function(){var e=this,r=t.debounce(e.throttleTime,t.proxy(e._onResize,e));e.$contentContainer=e.contentSelector?e.$el.find(e.contentSelector):e.$el.children().first(),e.$elements=e.itemElementSelector?e.$el.find(e.itemElementSelector):e.$contentContainer.children(),e.$sampleElement=e.$elements.eq(0),e.windowWidth=n.windowWidth,e.windowHeight=n.windowHeight,e.isPaginated=e.mode==="paginate",e.isPaginateMode=e.mode==="paginate",e.isCarouselMode=e.mode==="carousel",e.isFreeMode=e.mode==="free",e._setIscrollProps(),e.isCarouselMode&&e._setItemWidths(),e._setContentWidth(),e.isCarouselMode&&(e.generatePagination||e.generatePagination===undefined)&&e.$elements.length>1&&e._generatePagination(e.$elements.length),e.generateNav===undefined&&(e.generateNav=!e.nextSelector&&!e.prevSelector&&e.isCarouselMode),e.generateNav&&e.$elements.length>1&&e._generateNavPaddles(),e.$win.on(e.resizeEvent+e.unique,r),e.scroller=new IScroll(e.$el[0],e.iscrollProps),e.currentPage=e.scroller.currPageX,e._setupPaddles(),e._update(!0),e._showHideNavs(0,e._getNumberOfPages())},_getNumberOfPages:function(){var e=this.scroller.pagesX.length-1;return Math.max(0,e)},_setIscrollProps:function(){var e=this;return e.onScrollEnd=e.iscrollProps.onScrollEnd,e.onAnimationEnd=e.iscrollProps.onAnimationEnd,e.onBeforeScrollStart=e.iscrollProps.onBeforeScrollStart,e.mode==="carousel"&&(e.iscrollProps={snap:!0,hScrollbar:!1,momentum:!1}),e.iscrollProps.onScrollEnd=function(){e._onScrollEnd(this)},e.iscrollProps.onAnimationEnd=function(){e._onAnimationEnd(this)},e.iscrollProps.onBeforeScrollStart=function(t){e._onBeforeScrollStart(this,t)},e},_paginate:function(){function f(n,r,s){var u=e.$elements.slice(r,s+1),f,l;n===o-1&&e.lastPageCenter&&(a=e.$sampleElement.outerWidth(!0)*u.length),f=e.centerItems?Math.floor((i-a)*.5):0,l=Math.floor(n*i+f),u.css({position:"absolute",top:"0",left:"0"}),t.each(u,function(n){var r=t(this);e.autoGutters?r.css("left",Math.floor(l+n*r.outerWidth(!0))+"px"):n===0?r.css("left",Math.floor(l+n*r.outerWidth())+"px"):r.css("left",Math.floor(l+n*r.outerWidth())+n*e.gutterWidth+"px")})}var e=this,n=e.$sampleElement.outerWidth(!0),r=e.$elements.length,i=e.$el.width()-e.extraSpacing,s=e.fitPerPage||Math.floor(i/n)||1,o=Math.ceil(r/s),u=0,a=n*s;i+=e.extraSpacing,i+=e.extraMarging,e._setContentWidth(o,i);if(o===1||s>r)return!1;e.generatePagination&&e._generatePagination(o);for(;u<o;u++){var l=u*s,c=l+s-1;f(u,l,c)}return e.totalPages=o,e.itemsPerPage=s,e._fire("paginationcomplete"),!0},_generatePagination:function(e){var n=this,r=n.appendBulletsTo?t(n.appendBulletsTo):n.$el;if(!t.fn.sonyNavDots)return;if(n.$pagination){n.$pagination.sonyNavDots("reset",{buttonCount:e});return}n.$pagination=t("<div/>",{"class":"navigation-container"}),r.append(n.$pagination),n.$pagination.sonyNavDots({buttonCount:e}),n.$pagination.on("SonyNavDots:clicked",function(e,t){n.gotopage(t)})},_setupPaddles:function(){var e=this,t=e.$el[0].className;e.cssClassName=t?"."+t.split(" ").join("."):undefined,e.nextSelector&&(e.$navNext=e.nextSelector.jquery?e.nextSelector:e.$el.find(e.nextSelector),e.$navNext.on("click",function(t){t.preventDefault(),t.stopPropagation(),e.next()})),e.prevSelector&&(e.$navPrev=e.prevSelector.jquery?e.prevSelector:e.$el.find(e.prevSelector),e.$navPrev.on("click",function(t){t.preventDefault(),t.stopPropagation(),e.prev()}))},_generateNavPaddles:function(){var e=this,n=t(e.navTemplate),r=n.find(".nav-paddle-prev"),i=n.find(".nav-paddle-next"),s=e.appendNavOutside?e.$el.parent():e.$el;s.append(n).addClass(e.paddleTrigger),e.$nav=n,e.prevSelector=r,e.nextSelector=i},_update:function(e){var t=this;t.mode==="paginate"&&(t.isPaginated=t._paginate()),e||(t.isCarouselMode&&t._setItemWidths(),(t.isCarouselMode||t.isFreeMode)&&t._setContentWidth()),e&&t.isPaginated?t.scroller.refresh():!e&&(t.isPaginated||t.isCarouselMode||t.isFreeMode)&&(t.scroller.refresh(),t.scroller.scrollToPage(t.currentPage,0,400)),t._fire("update")},_onResize:function(){var e=this,t=e.$win.width(),n=e.$win.height(),r=t!==e.windowWidth||n!==e.windowHeight;if(e.destroyed||!r||!e.enabled)return;e.windowWidth=t,e.windowHeight=n,e._update()},_onScrollEnd:function(e){var t=this;t._fire("scrolled"),t.onScrollEnd&&t.onScrollEnd.call(e,e)},_showHideNavs:function(e,t){var n=this,i="hidden";n.$navPrev&&n.$navNext&&(e===0?n.$navPrev.addClass(i):n.$navPrev.removeClass(i),e===t?n.$navNext.addClass(i):n.$navNext.removeClass(i),r.forceFontIconRedraw(n.cssClassName))},_onBeforeScrollStart:function(e,t){var n=this,r=e.absDistX||0,i=e.absDistY||0;r>=i+n.threshhold&&t.preventDefault(),n.onBeforeScrollStart&&n.onBeforeScrollStart.call(e,e)},_onAnimationEnd:function(e){var t=this;e.pagesX&&e.pagesX.length&&(t.currentPage=e.currPageX,t._showHideNavs(t.currentPage,e.pagesX.length-1),t.$pagination&&t.$pagination.sonyNavDots("reset",{activeButton:t.currentPage})),t.onAnimationEnd&&t.onAnimationEnd.call(e,e)},_setContentWidth:function(e,n){var r=this,i=0;return e?i=e*n:typeof r.getContentWidth=="function"?i=r.getContentWidth(r.$elements):r.$elements.each(function(){i+=Math.round(t(this).outerWidth(!0))}),r.$contentContainer.css("width",i),r},_setItemWidths:function(){var e=this,t=e.$el.width();e.$elements.css("width",t)},_fire:function(e,t){return this.$el.trigger(e+".sm",t||[this]),this},setGutterWidth:function(e){var t=this;t.gutterWidth=e},setFitPerPage:function(e){var t=this;t.fitPerPage=e},setExtraMarging:function(e){var t=this;t.extraMarging=e},gotopage:function(e,t){t=t||400,this.scroller.scrollToPage(e,0,t)},next:function(){this.gotopage("next")},prev:function(){this.gotopage("prev")},refresh:function(){this._update()},destroy:function(){var e=this;e.$pagination&&e.$pagination.remove(),e.generateNav&&(e.$nav.remove(),e.addPaddleTrigger&&e.$el.closest(e.paddleTrigger).removeClass(e.paddleTrigger)),e.$contentContainer.css("width",""),e.$elements.css({position:"",top:"",left:""}),e.

Prev | Next
Pg.: 1 ... 37 38 39 40 41 42 43 44 45 46 47 ... 66


Back to home | File page

Subscribe | Register | Login | N