/*
Copyright 2014, KISSY v1.43
MIT Licensed
build time: May 22 12:30
*/
KISSY.add("scroll-view/plugin/pull-to-refresh",["base"],function(d,e){var f=e("base"),g=d.substitute,h=d.Features.getTransformProperty();return f.extend({pluginId:this.getName(),_onSetState:function(a){if(this.scrollView){var a=a.newVal,b=this.scrollView.get("prefixCls"),c=this.$el;c.attr("class",b+"scroll-view-pull-to-refresh "+b+"scroll-view-"+a);this.labelEl.html(this.get(a+"Html"));this.elHeight=c.height()}},_onScrollMove:function(){var a=this.scrollView.get("scrollTop");-a>this.elHeight?this.set("state",
"releasing"):0>a&&this.set("state","pulling")},_onDragEnd:function(){var a=this,b=a.scrollView;if(-b.get("scrollTop")>a.elHeight){b.minScroll.top=-a.elHeight;var c=a.get("loadFn");a.set("state","loading");var d=function(){b.scrollTo({top:-a.elHeight});b.scrollTo({top:b.minScroll.top},{duration:b.get("snapDuration"),easing:b.get("snapEasing")});a.set("state","pulling")};c?c.call(a,d):d.call(a)}},_onSetScrollTop:function(a){a=a.newVal;0>a&&(this.el.style[h]="translate3d(0,"+-a+"px,0)")},pluginRenderUI:function(a){this.scrollView=
a;var b=a.get("prefixCls"),c=d.all(g('<div class="{prefixCls}scroll-view-pull-to-refresh"><div class="{prefixCls}scroll-view-pull-to-refresh-content"><span class="{prefixCls}scroll-view-pull-icon"></span><span class="{prefixCls}scroll-view-pull-label"></span></div></div>',{prefixCls:b}));this.labelEl=c.one("."+b+"scroll-view-pull-label");a.get("el").prepend(c);this.$el=c;this.el=c[0];this._onSetState({newValue:"pulling"})},pluginBindUI:function(a){a.on("scrollMove",this._onScrollMove,this);a.on("dragend",
this._onDragEnd,this);this.on("afterStateChange",this._onSetState,this);a.on("afterScrollTopChange",this._onSetScrollTop,this)},pluginDestructor:function(){this.$el.remove()}},{ATTRS:{pullingHtml:{value:"Pull down to refresh..."},releasingHtml:{value:"release to refresh..."},loadingHtml:{value:"loading..."},loadFn:{},state:{value:"pulling"}}})});
