(function(f){function r(a,d){var c=d[0],b=d[1];a._isVer?(c=b,0>c-a._start?c=d[1]=a._start:c>a._end&&(c=d[1]=a._end)):0>c-a._start?c=d[0]=a._start:c>a._end&&(c=d[0]=a._end);if(a._lastPos&&3>Math.abs(a._lastPos-c))return d;a._lastPos=c;return d}function t(a){var d=a.control,c=d.opts;a._steps=c.startStep;a._endStep=c.endStep-c.viewport;a._scale=d._scale;a._epos=d.epos;a._lastP=a._start;d._isVer?(a._isVer=!0,a._start=c.startPosition,f(d.eend).isVisible()?(a._end=d.eend.offsetTop+Math.ceil(a.handle.offsetHeight/
2),a._end>c.viewportSize+a._start&&(a._end=c.viewportSize+a._start)):a._end=c.viewportSize+a._start,a._end-=a.node.offsetHeight-d._gap):(a._isVer=!1,a._start=c.startPosition,f(d.eend).isVisible()?(a._end=d.eend.offsetLeft+Math.ceil(a.handle.offsetWidth/2),a._end>c.viewportSize+a._start&&(a._end=c.viewportSize+a._start)):a._end=c.viewportSize+a._start,a._end-=a.node.offsetWidth-d._gap);jq(a._epos).show().delay(200).fadeIn(500);a._timer&&clearTimeout(a._timer);var b,e=[],g=10,n=function(l){var h=f.parseFloat(a.node.style[l]),
m=h-f.parseFloat(a._epos.style[l]);if(b==h){if(e.push(a._lastSteps),4<e.length&&e.shift()==a._lastSteps){e[0]=a._lastSteps;clearTimeout(a._timer);a._timer=setTimeout(function(){n(l)},100);return}}else g=10;b=h;var p=0<m,q=p?Math.max(0,m/a._scale):Math.min(0,m/a._scale),k=Math.round(d.$class.easing(g/600,g,0,q,600));p?1<q&&(k=Math.max(1,k)):1<-q&&(k=Math.min(-1,k));0==m&&0==k&&(h==a._start?k=-a._steps:h==a._end&&(k=a._endStep-a._steps));a._steps+=k;p?a._steps>a._endStep&&(a._steps=a._endStep):0>a._steps&&
(a._steps=0);a._epos.style[l]=a._start+a._scale*a._steps+"px";g+=30;a._lastSteps!=a._steps&&(a._lastSteps=a._steps,h="top"==l?d.opts.onScrollY:d.opts.onScrollX,"function"==typeof h&&h.call(a.control.widget,a._steps+d.opts.offset));clearTimeout(a._timer);a._timer=setTimeout(function(){n(l)},30)};a._timer=setTimeout(function(){n(a._isVer?"top":"left")},50)}function u(a,d){d=a.control;a._timer&&clearTimeout(a._timer);if(a._isVer){var c=f.parseInt(a._epos.style.top);var b=a._end;c>b&&(c=b);jq(a.node).animate({top:c+
"px"},400,"swing")}else c=f.parseInt(a._epos.style.left),b=a._end,c>b&&(c=b),jq(a.node).animate({left:c+"px"},400,"swing");d.opts.startStep=a._steps;d._syncButtonStatus();d=jq(a._epos).css("opacity");jq(a._epos).delay(300).fadeOut(500).css("opacity",d)}function v(a,d,c){return a.control.edragBody!=c.domTarget}zul.WScroll=f.$extends(f.Object,{_gap:0,$init:function(a,d){this.control=a;this.opts=f.$default(d,{orient:"horizontal",startPosition:0,startStep:0,offset:0});this.anchor=this.opts.anchor||a.parentNode;
this.widget=f.Widget.$(a);this.uid=this.widget.uuid;this.zcls=this.widget.getZclass();this._isVer="vertical"==d.orient;if(!d.viewportSize&&0!=d.viewportSize)throw"Handle required for a viewport size: {viewportSize: size}";this.redraw(this.anchor);this._initDragdrop();this._listenMouseEvent();!1!==this.opts.syncSize&&this.syncSize();this._syncButtonStatus()},syncSize:function(a){a&&(this.opts=f.copy(this.opts,a));this.edrag.style.display="";if(this._isVer){a=this.opts;var d=a.startPosition,c=a.startStep,
b=a.viewport,e=a.endStep,g=a.viewportSize;b=e-b;e=this.edrag.offsetHeight-this._gap;0>=b?(this.eend.style.display=this.edrag.style.display="none","function"==typeof this.opts.onScrollY&&this.opts.onScrollY.call(this.widget,a.offset)):(g-=e,g>b?(this.epos.style.height=e+"px",this._scale=1,a=this.eend.style,a.display="",a.top=d+e+b+"px"):(a=g/b,this.epos.style.height=Math.max(e*a,5)+"px",this._scale=a,this.eend.style.display="none",10>g&&(this.edrag.style.display="none")),c=d+this._scale*c,g=d+g,c>
g&&(c=g),this.epos.style.top=this.edrag.style.top=c+"px")}else a=this.opts,d=a.startPosition,c=a.startStep,b=a.viewport,e=a.endStep,g=a.viewportSize,b=e-b,e=this.edrag.offsetWidth-this._gap,0>=b?(this.eend.style.display=this.edrag.style.display="none","function"==typeof this.opts.onScrollX&&this.opts.onScrollX.call(this.widget,a.offset)):(g-=e,g>b?(this.epos.style.width=e+"px",this._scale=1,a=this.eend.style,a.display="",a.left=d+e+b+"px"):(a=g/b,this.epos.style.width=Math.max(e*a,5)+"px",this._scale=
a,this.eend.style.display="none",10>g&&(this.edrag.style.display="none")),c=d+this._scale*c,g=d+g,c>g&&(c=g),this.epos.style.left=this.edrag.style.left=c+"px")},_listenMouseEvent:function(){this._isVer?jq(this.control).mousewheel(this.proxy(this._mousewheelY)):11>f.ie&&f.opera||jq(this.control).mousewheel(this.proxy(this._mousewheelX));var a=jq(this.edrag);a.children("div").on("mouseover",this.proxy(this._mouseOver)).on("mouseout",this.proxy(this._mouseOut)).on("mouseup",this.proxy(this._mouseUp)).on("mousedown",
this.proxy(this._mouseDown));a.on("click",f.$void)},_unlistenMouseEvent:function(){this._isVer?jq(this.control).unmousewheel(this.proxy(this._mousewheelY)):11>f.ie&&f.opera||jq(this.control).unmousewheel(this.proxy(this._mousewheelX));var a=jq(this.edrag);a.children("div").off("mouseover",this.proxy(this._mouseOver)).off("mouseout",this.proxy(this._mouseOut)).off("mouseup",this.proxy(this._mouseUp)).off("mousedown",this.proxy(this._mouseDown));a.off("click",f.$void)},_mouseOver:function(a){a=a.target.className;
var d=a.lastIndexOf("-"),c=a.substring(d+1);d=jq(this.edrag);d.hasClass(a+"-clk")&&d.removeClass(a+"-clk");switch(c){case "home":case "up":0<this.opts.startStep&&d.addClass(a+"-over");break;case "down":case "end":c=this.opts,c.startStep<c.endStep-c.viewport&&d.addClass(a+"-over")}},_mouseOut:function(a){a=a.target.className;var d=jq(this.edrag);d.removeClass(a+"-over");d.hasClass(a+"-clk")&&d.removeClass(a+"-clk")},_mouseUp:function(a){jq(this.edrag).removeClass(a.target.className+"-clk")},_mouseDown:function(a){a=
a.target.className;var d=a.lastIndexOf("-"),c=a.substring(d+1);d=jq(this.edrag);if(d.hasClass(a+"-over")||f.mobile){d.addClass(a+"-clk");var b=this.opts;switch(c){case "home":0<b.startStep&&(b.startStep=0,this._isVer?(c=b.startPosition+"px",this.epos.style.top=c,d.animate({top:c},500),"function"==typeof this.opts.onScrollY&&this.opts.onScrollY.call(this.widget,b.startStep+b.offset)):(c=b.startPosition+"px",this.epos.style.left=c,d.animate({left:c},500),"function"==typeof this.opts.onScrollX&&this.opts.onScrollX.call(this.widget,
b.startStep+b.offset)),d.removeClass(a+"-over"));break;case "up":if(0<b.startStep){--b.startStep;c=b.startPosition+b.startStep*this._scale;if(this._isVer){var e=f(this.eend).isVisible()?this.eend.offsetTop:b.viewportSize+b.startPosition;e-=this.edrag.offsetHeight-this._gap;this.epos.style.top=c+"px";this.edrag.style.top=e<c?e+"px":c+"px";"function"==typeof this.opts.onScrollY&&this.opts.onScrollY.call(this.widget,b.startStep+b.offset)}else e=f(this.eend).isVisible()?this.eend.offsetLeft:b.viewportSize+
b.startPosition,e-=this.edrag.offsetWidth-this._gap,this.epos.style.left=c+"px",this.edrag.style.left=e<c?e+"px":c+"px","function"==typeof this.opts.onScrollX&&this.opts.onScrollX.call(this.widget,b.startStep+b.offset);0==b.startStep&&d.removeClass(a+"-over")}break;case "down":b.startStep<b.endStep-b.viewport&&(b.startStep+=1,c=b.startPosition+b.startStep*this._scale,this._isVer?(e=f(this.eend).isVisible()?this.eend.offsetTop:b.viewportSize+b.startPosition,e-=this.edrag.offsetHeight-this._gap,this.epos.style.top=
c+"px",this.edrag.style.top=e<c?e+"px":c+"px","function"==typeof this.opts.onScrollY&&this.opts.onScrollY.call(this.widget,b.startStep+b.offset)):(e=f(this.eend).isVisible()?this.eend.offsetLeft:b.viewportSize+b.startPosition,e-=this.edrag.offsetWidth-this._gap,this.epos.style.left=c+"px",this.edrag.style.left=e<c?e+"px":c+"px","function"==typeof this.opts.onScrollX&&this.opts.onScrollX.call(this.widget,b.startStep+b.offset)),b.startStep==b.endStep-b.viewport&&d.removeClass(a+"-over"));break;case "end":b.startStep<
b.endStep-b.viewport&&(b.startStep=b.endStep-b.viewport,this._isVer?(c=f(this.eend).isVisible()?this.eend.offsetTop-(this.edrag.offsetHeight-this._gap):b.startPosition+b.viewportSize-(this.edrag.offsetHeight-this._gap),this.epos.style.top=c,d.animate({top:c},500),"function"==typeof this.opts.onScrollY&&this.opts.onScrollY.call(this.widget,b.startStep+b.offset)):(c=f(this.eend).isVisible()?this.eend.offsetLeft-(this.edrag.offsetWidth-this._gap):b.startPosition+b.viewportSize-(this.edrag.offsetWidth-
this._gap),this.epos.style.left=c,d.animate({left:c},500),"function"==typeof this.opts.onScrollX&&this.opts.onScrollX.call(this.widget,b.startStep+b.offset)),d.removeClass(a+"-over"))}this._syncButtonStatus()}},_mousewheelY:function(a,d,c,b){if(b){a.stop();a=this.opts;d=a.startStep;c=a.endStep-a.viewport;var e=this._scale,g=this.widget;0<b?(a.startStep-=Math.max(Math.round(g._cols/5),1),0>a.startStep&&(a.startStep=0)):(a.startStep+=Math.max(Math.round(g._cols/5),1),a.startStep>c&&(a.startStep=c));
d!=a.startStep&&(b=a.startPosition+a.startStep*e,d=f(this.eend).isVisible()?this.eend.offsetTop-(this.edrag.offsetHeight-this._gap):a.startPosition+a.viewportSize-(this.edrag.offsetHeight-this._gap),this.epos.style.top=b+"px",b>d&&(b=d),this.edrag.style.top=b+"px","function"==typeof this.opts.onScrollY&&this.opts.onScrollY.call(this.widget,a.startStep+a.offset),this._syncButtonStatus())}},_mousewheelX:function(a,d,c,b){if(c){a.stop();a=this.opts;d=a.startStep;b=a.endStep-a.viewport;var e=this._scale,
g=this.widget;0>c?(a.startStep-=Math.max(Math.round(g._cols/5),1),0>a.startStep&&(a.startStep=0)):(a.startStep+=Math.max(Math.round(g._cols/5),1),a.startStep>b&&(a.startStep=b));d!=a.startStep&&(c=a.startPosition+a.startStep*e,d=f(this.eend).isVisible()?this.eend.offsetLeft-(this.edrag.offsetWidth-this._gap):a.startPosition+a.viewportSize-(this.edrag.offsetWidth-this._gap),this.epos.style.left=c+"px",c>d&&(c=d),this.edrag.style.left=c+"px","function"==typeof this.opts.onScrollX&&this.opts.onScrollX.call(this.widget,
a.startStep+a.offset),this._syncButtonStatus())}},_initDragdrop:function(){this.node=jq(this.uid+"-"+(this._isVer?"v":"h")+"bar",f)[0];this.edrag=this.node.firstChild;this.edragBody=this.edrag.childNodes[2];this.epos=this.edrag.nextSibling;this.eend=this.node.lastChild;var a=this.epos.style,d=a.display;a.display="block";this._gap=this._isVer?this.edrag.offsetHeight-this.epos.offsetHeight:this.edrag.offsetWidth-this.epos.offsetWidth;a.display=d;this.drag=new f.Draggable(this,this.edrag,{constraint:this._isVer?
"vertical":"horizontal",snap:r,starteffect:t,zIndex:12E3,ignoredrag:v,endeffect:u});jq(this.epos).hide()},destroy:function(){this.drag.destroy();this._unlistenMouseEvent();jq(this.node).remove();this.node=this.edrag=this.epos=this.drag=null},redraw:function(a){var d=this._isVer?"vertical":"horizontal",c=this.uid+"-"+(this._isVer?"v":"h")+"bar",b=this.widget.$s("wscroll");jq(a).append('<div id="'+c+'" class="'+b+"-"+d+'"><div class="'+b+'-drag"><div class="'+b+'-home" title="'+msgzul.WS_HOME+'"></div><div class="'+
b+'-up" title="'+msgzul.WS_PREV+'"></div><div class="'+b+'-body"></div><div class="'+b+'-down" title="'+msgzul.WS_NEXT+'"></div><div class="'+b+'-end" title="'+msgzul.WS_END+'"></div></div><div class="'+b+'-pos"></div><div class="'+b+'-endbar"></div></div>')},_syncButtonStatus:function(){var a=this.zcls+"-wscroll",d=jq(this.edrag),c=this.opts;d.toggleClass(a+"-head",0==c.startStep);d.toggleClass(a+"-tail",c.startStep==c.endStep-c.viewport)}},{easing:function(a,d,c,b,e){return-b*((d=d/e-1)*d*d*d-1)+
c}})})(zk);
