zoomla
Version:
16年专业研发|中文alexa排名第一的CMS品牌-基于dotNET core、功能强大,集成站群、微信开发、小程序与ERP及OA办公系统,支持国际语言和多民族语言,世界五百强与大型门户专用高端网站内核CMS系统
22 lines (21 loc) • 10.3 kB
JavaScript
(function(f,x){function S(M,b){function i(a,r,s){s=G(s)?s:b.speed;r&&w&&(r=T(a),F?(a=l[r.centerItem].offCenter,g[B?"activate":"toCenter"](r.centerItem,1)):a>c.min&&a<c.max&&(a=l[r.firstItem].offStart));if(!D||!b.elasticBounds)a=a<c.min?c.min:a,a=a>c.max?c.max:a;a!==c.cur&&(c.cur=a,f.extend(d,T(c.cur)),U(),V(),!D&&j.trigger(o+":move",[c,m,d]),a=b.horizontal?{left:-c.cur+"px"}:{top:-c.cur+"px"},16<s?h.animate(a,s,D?"swing":b.easing,function(){!D&&j.trigger(o+":moveEnd",[c,m,d])}):(h.css(a),!D&&j.trigger(o+
":moveEnd",[c,m,d])))}function z(a){p&&(e.cur=Math.round((c.cur-c.min)/(c.max-c.min)*e.max),e.cur=e.cur<e.min?e.min:e.cur>e.max?e.max:e.cur,p.stop().animate(b.horizontal?{left:e.cur+"px"}:{top:e.cur+"px"},G(a)?a:b.speed,b.easing));X()}function X(){N.length&&N.removeClass(b.activeClass).eq(d.activePage).addClass(b.activeClass)}function V(){h.add(p).stop()}function E(a){return G(a)?0>a?0:a>l.length-1?l.length-1:a:a===x?-1:m.index(a)}function n(a,b){return parseInt(a.css(b),10)}function T(a){for(var b=
{},s=B?0:t/2,d=0;d<u.length;d++){if(a>=c.max||d===u.length-1){b.activePage=u.length-1;break}if(a<=u[d]+s){b.activePage=d;break}}if(w){for(var f=d=s=!1,e=0;e<l.length;e++){!1===s&&a<=l[e].offStart&&(s=e);!1===f&&a-l[e].size/2<=l[e].offCenter&&(f=e);if(e===l.length-1||!1===d&&a<l[e+1].offEnd)d=e;if(!1!==d)break}b.firstItem=G(s)?s:0;b.centerItem=G(f)?f:b.firstItem;b.lastItem=G(d)?d:b.centerItem}return b}function U(){if(w){var a=0===d.activeItem,r=d.activeItem>=l.length-1;H.is("button,input")&&H.prop("disabled",
a);I.is("button,input")&&I.prop("disabled",r);H[a?"removeClass":"addClass"](b.disabledClass);I[r?"removeClass":"addClass"](b.disabledClass)}N.length&&(a=c.cur<=c.min,r=c.cur>=c.max,O.is("button,input")&&O.prop("disabled",a),P.is("button,input")&&P.prop("disabled",r),O[a?"removeClass":"addClass"](b.disabledClass),P[r?"removeClass":"addClass"](b.disabledClass))}function v(a,b){var c=a||window.event;c.preventDefault?c.preventDefault():c.returnValue=!1;b&&c.stopPropagation?c.stopPropagation():c.cancelBubble=
!0}function G(a){return!isNaN(parseFloat(a))&&isFinite(a)}var g=this,j=f(M),h=j.children().eq(0),t=0,k=0,c={cur:0,max:0,min:0},J=f(b.scrollBar).eq(0),p=J.length?J.children().eq(0):0,K=0,A=0,e={cur:0,max:0,min:0},W=f(b.pagesBar),N=0,u=[],Y="smart"===b.itemNav,B="forceCentered"===b.itemNav,F="centered"===b.itemNav||B,w="basic"===b.itemNav||Y||F||B,m=0,l=[],d={firstItem:0,lastItem:1,centerItem:1,activeItem:-1,activePage:0,items:0,pages:0},Z=b.scrollSource?f(b.scrollSource):j,S=b.dragSource?f(b.dragSource):
j,H=f(b.prev),I=f(b.next),O=f(b.prevPage),P=f(b.nextPage),L=0,$=0,D=0,fa=this.reload=function(){var a=0,r=f.extend({},c);clearTimeout(L);t=b.horizontal?j.width():j.height();K=b.horizontal?J.width():J.height();k=b.horizontal?h.outerWidth():h.outerHeight();m=h.children();l=[];u=[];c.min=0;c.max=k>t?k-t:0;d.items=m.length;if(w){var s=n(m,b.horizontal?"marginLeft":"marginTop"),C=n(m.slice(-1),b.horizontal?"marginRight":"marginBottom"),v=0,M=n(h,b.horizontal?"paddingLeft":"paddingTop"),ba=n(h,b.horizontal?
"paddingRight":"paddingBottom"),ca="none"!==m.css("float"),a=s?0:C;k=0;m.each(function(a,c){var d=f(c),r=b.horizontal?d.outerWidth(!0):d.outerHeight(!0),e=n(d,"marginTop"),i=n(d,"marginBottom"),g=n(d,"marginLeft"),d=n(d,"marginRight"),g={size:r,offStart:k-(!a||b.horizontal?0:e),offCenter:k-Math.round(t/2-r/2),offEnd:k-t+r-(s?0:d),margins:{top:e,bottom:i,left:g,right:d}};a||(v=-(B?Math.round(t/2-r/2):0)+M,k+=M);k+=r;!b.horizontal&&!ca&&i&&(e&&0<a)&&(k-=e<i?e:i);a===m.length-1&&(k+=ba);l.push(g)});
h.css(b.horizontal?{width:k+"px"}:{height:k+"px"});k-=a;c.min=v;c.max=B?l[l.length-1].offCenter:k>t?k-t:0;d.activeItem>=l.length&&g.activate(l.length-1)}f.extend(d,T(c.cur));p&&(A=b.dynamicHandle?Math.round(K*t/k):b.horizontal?p.width():p.height(),A=A>K?K:A,A=A<b.minHandleSize?b.minHandleSize:A,e.max=K-A,p.css(b.horizontal?{width:A+"px"}:{height:A+"px"}));var y=0,C="",ea=0;if(B)u=f.map(l,function(a){return a.offCenter});else for(;y-t<c.max;){var aa=y>c.max?c.max:y;u.push(aa);y+=t;if(y>c.max&&w&&c.max-
aa<(l[l.length-1].size-a)/2){u[u.length-1]=c.max;break}}if(W.length){for(a=0;a<u.length;a++)C+=b.pageBuilder(ea++);N=f(C).bind("click."+q,function(){g.activatePage(N.index(this))}).appendTo(W.empty())}m.unbind("."+q).bind("mouseup."+q,function(a){a.which===1&&!D&&g.activate(this)});c.cur<c.min&&i(c.min);c.cur>c.max&&i(c.max);d.pages=u.length;d.slideeSize=k;d.frameSize=t;d.sbSize=K;d.handleSize=A;z(0);U();w&&b.cycleBy&&(C="mouseenter."+q+" mouseleave."+q,b.pauseOnHover&&j.unbind(C).bind(C,function(a){!$&&
g.cycle(a.type==="mouseenter",1)}),g.cycle(b.startPaused));j.trigger(o+":load",[f.extend({},c,{old:r}),m,d])};this.prev=function(){g.activate(d.activeItem-1)};this.next=function(){g.activate(d.activeItem+1)};this.prevPage=function(){g.activatePage(d.activePage-1)};this.nextPage=function(){g.activatePage(d.activePage+1)};this.toStart=function(a){if(w){var d=E(a);if(a===x)i(c.min,1);else if(-1!==d){if(F)return;-1!==d&&i(l[d].offStart)}}else a===x?i(c.min):(a=h.find(a).eq(0),a.length&&(a=b.horizontal?
a.offset().left-h.offset().left:a.offset().top-h.offset().top,i(a)));z()};this.toEnd=function(a){if(w){var d=E(a);if(a===x)i(c.max,1);else if(-1!==d){if(F)return;i(l[d].offEnd)}}else a===x?i(c.max):(a=h.find(a).eq(0),a.length&&(d=b.horizontal?a.offset().left-h.offset().left:a.offset().top-h.offset().top,i(d-t+a[b.horizontal?"outerWidth":"outerHeight"]())));z()};this.toCenter=function(a){if(w){var d=E(a);a===x?i(Math.round(c.max/2+c.min/2),1):-1!==d&&(i(l[d].offCenter),B&&g.activate(d,1))}else a===
x?i(Math.round(c.max/2)):(a=h.find(a).eq(0),a.length&&(d=b.horizontal?a.offset().left-h.offset().left:a.offset().top-h.offset().top,i(d-t/2+a[b.horizontal?"outerWidth":"outerHeight"]()/2)));z()};this.activate=function(a,c){if(w&&a!==x){var e=E(a),f=d.activeItem;d.activeItem=e;m.removeClass(b.activeClass).eq(e).addClass(b.activeClass);e!==f&&m.eq(e).trigger(o+":active",[m,d]);c||(F?g.toCenter(e):Y&&(e>=d.lastItem?g.toStart(e):e<=d.firstItem&&g.toEnd(e)));U()}};this.activatePage=function(a){a=0>a?0:
a>=u.length?u.length-1:a;i(u[a],w);z()};this.cycle=function(a,e){w&&b.cycleBy&&(e||($=!!a),a?L&&(L=clearTimeout(L),j.trigger(o+":cyclePause",[c,m,d])):L||(j.trigger(o+":cycleStart",[c,m,d]),function C(){0!==b.cycleInterval&&(L=setTimeout(function(){if(!D)switch(b.cycleBy){case "items":g.activate(d.activeItem>=l.length-1?0:d.activeItem+1);break;case "pages":g.activatePage(d.activePage>=u.length-1?0:d.activePage+1)}j.trigger(o+":cycle",[c,m,d]);C()},b.cycleInterval))}()))};this.set=function(a,c){f.isPlainObject(a)?
b=f.extend({},b,a):"string"===typeof a&&(b[a]=c)};this.destroy=function(){j.add(document).add(h).add(m).add(Z).add(p).add(H).add(I).add(O).add(P).unbind("."+q);h.add(p).css(b.horizontal?{left:0}:{top:0});H.add(I).removeClass(b.disabledClass);W.empty();f.removeData(M,q)};var Q=f(document),R="mousemove."+q+" mouseup."+q,b=f.extend({},f.fn[o].defaults,b);"static"===j.css({overflow:"hidden"}).css("position")&&j.css({position:"relative"});"static"===J.css("position")&&J.css({position:"relative"});h.add(p).css(b.horizontal?
{position:"absolute",left:0}:{position:"absolute",top:0});fa();w?g.activate(b.startAt):i(b.startAt);z();b.scrollBy&&Z.bind("DOMMouseScroll."+q+" mousewheel."+q,function(a){if(c.min!==c.max){v(a,1);var a=a.originalEvent,e=0;a.wheelDelta&&(e=a.wheelDelta/120);a.detail&&(e=-a.detail/3);a=0>e;w?(a=E((F?B?d.activeItem:d.centerItem:d.firstItem)+(a?b.scrollBy:-b.scrollBy)),g[F?B?"activate":"toCenter":"toStart"](a)):i(c.cur+(a?b.scrollBy:-b.scrollBy));z()}});b.keyboardNav&&Q.bind("keydown."+q,function(a){switch(a.keyCode||
a.which){case b.horizontal?37:38:v(a);b.keyboardNavByPages?g.prevPage():g.prev();break;case b.horizontal?39:40:v(a),b.keyboardNavByPages?g.nextPage():g.next()}});b.prev&&H.bind("click."+q,function(a){v(a);g.prev()});b.next&&I.bind("click."+q,function(a){v(a);g.next()});b.prevPage&&O.bind("click."+q,function(a){v(a);g.prevPage()});b.nextPage&&P.bind("click."+q,function(a){v(a);g.nextPage()});b.dragContent&&S.bind("mousedown."+q,function(a){if(1===a.which){v(a);var d=a.clientX,e=a.clientY,g=c.cur,l=
+new Date,k=a.target,m=0;h.addClass(b.draggedClass);V();Q.bind(R,function(a){var y="mouseup"===a.type,p=b.horizontal?a.clientX-d:a.clientY-e,j=g-p;!m&&10<Math.abs(p)&&(m=1,h.trigger(o+":dragStart",[c]));j>c.max?j=b.elasticBounds?c.max+(j-c.max)/6:c.max:j<c.min&&(j=b.elasticBounds?c.min+(j-c.min)/6:c.min);if(y){Q.unbind(R);h.removeClass(b.draggedClass);var n=+new Date-l,n=300>n?Math.ceil(Math.pow(6/(n/300),2)*Math.abs(p)/120):0,j=j+(0<p?-n:n)}m&&(v(a),k&&(f(k).bind("click."+q,function da(a){v(a,true);
f(this).unbind("click."+q,da)}),k=0),D=!y,i(j,y,y?b.speed:0),z(y?null:0),m&&h.trigger(o+":drag",[c]),y&&h.trigger(o+":dragEnd",[c]))})}});p&&b.dragHandle&&p.bind("mousedown."+q,function(a){if(1===a.which){v(a);var d=a.clientX,f=a.clientY,g=e.cur,k=-e.cur,l=e.max-e.cur,j=0;p.addClass(b.draggedClass);V();Q.bind(R,function(a){v(a);var h="mouseup"===a.type,a=b.horizontal?a.clientX-d:a.clientY-f,m=g+a,n=+new Date;D=!h;h&&(Q.unbind(R),p.removeClass(b.draggedClass));if(a<l+5&&a>k-5||h){e.cur=m>e.max?e.max:
m<e.min?e.min:m;p.stop().css(b.horizontal?{left:e.cur+"px"}:{top:e.cur+"px"});j||p.trigger(o+":dragStart",[e]);p.trigger(o+":drag",[e]);h&&p.trigger(o+":dragEnd",[e]);if(j<=n||h||a>l||a<k)j=n+50,i(Math.round(e.cur/e.max*(c.max-c.min))+c.min,h,h?b.speed:50);X()}})}})}var o="sly",q="plugin_"+o;f.fn[o]=function(o,b){var i=!1,z,x=[];"undefined"!==typeof o&&!f.isPlainObject(o)&&(i=!1===o?"destroy":o,z=arguments,Array.prototype.shift.call(z));this.each(function(b,E){var n=f.data(E,q);n&&i?n[i]&&n[i].apply(n,
z):!n&&!i&&(n=f.data(E,q,new S(E,o)));x.push(n)});return b&&!i?1<x.length?x:x[0]:this};f.fn[o].defaults={horizontal:0,itemNav:0,scrollBar:null,dynamicHandle:1,dragHandle:1,minHandleSize:50,pagesBar:null,pageBuilder:function(f){return"<li>"+(f+1)+"</li>"},prev:null,next:null,prevPage:null,nextPage:null,cycleBy:0,cycleInterval:5E3,pauseOnHover:1,startPaused:0,scrollBy:0,dragContent:0,elasticBounds:0,speed:300,easing:"swing",scrollSource:null,dragSource:null,startAt:0,keyboardNav:0,keyboardNavByPages:0,
draggedClass:"dragged",activeClass:"active",disabledClass:"disabled"}})(jQuery);