app-base-min.js revision 042de896986219bc3b2b86b6c356c0ec7d662d32
YUI.add("app-base",function(d){var c=d.Lang,b=d.Transition,a;a=d.App=d.Base.create("app",d.Base,[d.View,d.Router,d.PjaxBase],{views:{},transitions:{navigate:{viewIn:"app:fadeIn",viewOut:"app:fadeOut"},toChild:{viewIn:"app:slideLeft",viewOut:"app:slideLeft"},toParent:{viewIn:"app:slideRight",viewOut:"app:slideRight"}},initializer:function(e){e||(e={});this.views=e.views?d.merge(this.views,e.views):this.views;this.transitions=e.transitions?d.merge(this.transitions,e.transitions):this.transitions;this._viewInfoMap={};this.after("activeViewChange",this._afterActiveViewChange);},create:function(){var e=d.View.prototype.create.apply(this,arguments);return e&&e.addClass(a.CSS_CLASS);},render:function(){var e=this.get("viewContainer"),f=this.get("activeView");f&&e.setContent(f.get("container"));e.appendTo(this.get("container"));return this;},getViewInfo:function(e){if(e instanceof d.View){return this._viewInfoMap[d.stamp(e,true)];}return this.views[e];},createView:function(h,g){var f=this.getViewInfo(h),i=f&&f.type,j=c.isString(i)?d[i]:i,e;if(c.isFunction(j)){e=new j(g).render();this._viewInfoMap[d.stamp(e,true)]=f;}return e;},showView:function(e,h,g){var f;if(c.isString(e)){f=this.getViewInfo(e)||{};e=f.instance||this.createView(e,h);}c.isFunction(g)&&(g={callback:g});return this._set("activeView",e,g);},_isChildView:function(e,h){var g=this.getViewInfo(e),f=this.getViewInfo(h);if(g&&f){return this.getViewInfo(g.parent)===f;}},_isParentView:function(e,h){var f=this.getViewInfo(e),g=this.getViewInfo(h);if(f&&g){return this.getViewInfo(g.parent)===f;}},_setViewContainer:function(e){e=d.one(e);return e&&e.addClass(a.VIEWS_CSS_CLASS);},_transitionViews:function(l,h,j,e,k){var g=this,i=false;function f(){if(!i){i=true;k&&k.call(g);}}l&&l.get("container").transition(j.viewIn,e.viewIn,f);h&&h.get("container").transition(j.viewOut,e.viewOut,f);},_attachView:function(e){var f;if(e){e.addTarget(this);f=this.getViewInfo(e);f&&(f.instance=e);}},_detachView:function(e){if(!e){return;}var f=this.getViewInfo(e)||{};if(f.preserve){e.remove();}else{e.destroy();delete this._viewInfoMap[d.stamp(e,true)];if(e===f.instance){delete f.instance;}}e.removeTarget(this);},_afterActiveViewChange:function(j){var g=j.newVal,l=j.prevVal,m=j.callback,f=this._isChildView(g,l),i=!f&&this._isParentView(g,l),n=!!j.prepend||i,h=this.transitions,k=j.transitions||{};if(g===l){return m&&m.call(this,g);}if(f){h=h.toChild;}else{if(i){h=h.toParent;}else{h=h.navigate;}}if(g&&n){this.get("viewContainer").prepend(g.get("container"));}else{if(g){this.get("viewContainer").append(g.get("container"));}}this._transitionViews(g,l,h,k,function(){this._detachView(l);this._attachView(g);m&&m.call(this,g);});}},{ATTRS:{container:{value:"body"},viewContainer:{valueFn:function(){return d.Node.create("<div/>");},setter:"_setViewContainer",writeOnce:"initOnly"},linkSelector:{value:"a"},activeView:{readOnly:true}},CSS_CLASS:d.ClassNameManager.getClassName("app"),VIEWS_CSS_CLASS:d.ClassNameManager.getClassName("app","views")});d.mix(b.fx,{"app:fadeIn":{opacity:1,duration:0.35,on:{start:function(){this.setStyle("opacity",0);},end:function(){}}},"app:fadeOut":{opacity:0,duration:0.35,on:{start:function(){},end:function(){}}},"app:slideLeft":{duration:0.35,transform:"translateX(-100%)",on:{end:function(){this.setStyle("transform","none");}}},"app:slideRight":{duration:0.35,transform:"translateX(0)",on:{start:function(){this.setStyle("transform","translateX(-100%)");},end:function(){this.setStyle("transform","none");}}}});},"@VERSION@",{requires:["controller","pjax-base","view","transition"]});