//>>built
define("dojox/app/controllers/Transition","require dojo/_base/lang dojo/_base/declare dojo/has dojo/on dojo/Deferred dojo/when dojo/dom-style ../Controller ../utils/constraints".split(" "),function(A,m,B,E,F,G,x,y,C,u){var v;return B("dojox.app.controllers.Transition",C,{proceeding:!1,waitingQueue:[],constructor:function(a,b){this.events={"app-transition":this.transition,"app-domNode":this.onDomNodeChange};A([this.app.transit||"dojox/css3/transit"],function(d){v=d});if(this.app.domNode)this.onDomNodeChange({oldNode:null,
newNode:this.app.domNode})},transition:function(a){this.app.log("logTransitions:","app/controllers/Transition:transition"," ");this.app.log("logTransitions:","app/controllers/Transition:transition","New Transition event.viewId\x3d["+a.viewId+"]");this.app.log("app/controllers/Transition:transition","event.viewId\x3d["+a.viewId+"]","event.opts\x3d",a.opts);var b=a.viewId||"";this.proceedingSaved=this.proceeding;var d=b.split("+");b=b.split("-");if(0<d.length||0<b.length){for(;1<d.length;){var e=d.shift();
b=m.clone(a);if(0<=e.indexOf("-")){var c=e.split("-");if(0<c.length){if(e=c.shift())b._removeView=!1,b.viewId=e,this.proceeding=!0,this.proceedTransition(b),b=m.clone(a);if(e=c.shift())b._removeView=!0,b.viewId=e,this.proceeding=!0,this.proceedTransition(b)}}else b._removeView=!1,b.viewId=e,this.proceeding=!0,this.proceedTransition(b)}e=d.shift();c=e.split("-");0<c.length&&(e=c.shift());0<e.length&&(this.proceeding=this.proceedingSaved,a.viewId=e,a._doResize=!0,a._removeView=!1,this.proceedTransition(a));
if(0<c.length)for(;0<c.length;)d=c.shift(),b=m.clone(a),b.viewId=d,b._removeView=!0,b._doResize=!0,this.proceedTransition(b)}else a._doResize=!0,a._removeView=!1,this.proceedTransition(a)},onDomNodeChange:function(a){null!=a.oldNode&&this.unbind(a.oldNode,"startTransition");this.bind(a.newNode,"startTransition",m.hitch(this,this.onStartTransition))},onStartTransition:function(a){a.preventDefault&&a.preventDefault();a.cancelBubble=!0;a.stopPropagation&&a.stopPropagation();var b=a.detail.target,d=/#(.+)/;
!b&&d.test(a.detail.href)&&(b=a.detail.href.match(d)[1]);this.transition({viewId:b,opts:m.mixin({},a.detail),data:a.detail.data})},_addTransitionEventToWaitingQueue:function(a){if(a.defaultView&&0<this.waitingQueue.length){for(var b=!1,d=0;d<this.waitingQueue.length;d++)if(!this.waitingQueue[d].defaultView){this.waitingQueue.splice(d,0,a);b=!0;break}b||this.waitingQueue.push(a)}else this.waitingQueue.push(a)},proceedTransition:function(a){if(this.proceeding)this._addTransitionEventToWaitingQueue(a),
this.app.log("app/controllers/Transition:proceedTransition added this event to waitingQueue",a),this.processingQueue=!1;else{this.app.log("app/controllers/Transition:proceedTransition this.waitingQueue.length \x3d"+this.waitingQueue.length+" this.processingQueue\x3d"+this.processingQueue);0<this.waitingQueue.length&&!this.processingQueue&&(this.processingQueue=!0,this._addTransitionEventToWaitingQueue(a),this.app.log("app/controllers/Transition:proceedTransition added this event to waitingQueue passed proceeding",
a),a=this.waitingQueue.shift(),this.app.log("app/controllers/Transition:proceedTransition shifted waitingQueue to process",a));this.proceeding=!0;this.app.log("app/controllers/Transition:proceedTransition calling trigger load",a);a.opts||(a.opts={});var b=a.params||a.opts.params;this.app.emit("app-load",{viewId:a.viewId,params:b,forceTransitionNone:a.forceTransitionNone,callback:m.hitch(this,function(d,e){if(d){this.proceeding=!1;this.processingQueue=!0;var c=e?this.waitingQueue.shift():this.waitingQueue.pop();
c&&this.proceedTransition(c)}else c=this._doTransition(a.viewId,a.opts,b,a.opts.data,this.app,a._removeView,a._doResize,a.forceTransitionNone),x(c,m.hitch(this,function(){this.proceeding=!1;this.processingQueue=!0;var f=this.waitingQueue.shift();f&&this.proceedTransition(f)}))})})}},_getTransition:function(a,b,d,e,c){if(c)return"none";c=null;a&&(c=a.transition);!c&&b.views[d]&&(c=b.views[d].transition);c||(c=b.transition);for(a=a&&a.defaultTransition?a.defaultTransition:b.defaultTransition;!c&&b.parent;)b=
b.parent,c=b.transition,a||(a=b.defaultTransition);return c||e.transition||a||"none"},_getParamsForView:function(a,b){var d={},e;for(e in b){var c=b[e];m.isObject(c)?e==a&&(d=m.mixin(d,c)):e&&null!=c&&(d[e]=b[e])}return d},_doTransition:function(a,b,d,e,c,f,p,h,z){if(!c)throw Error("view parent not found in transition.");this.app.log("app/controllers/Transition:_doTransition transitionTo\x3d[",a,"], removeView\x3d[",f,"] parent.name\x3d[",c.name,"], opts\x3d",b);a=a?a.split(","):c.defaultView.split(",");
var t=a.shift();var k=a.join(",");var g=c.children[c.id+"_"+t];if(!g){if(f){this.app.log("app/controllers/Transition:_doTransition called with removeView true, but that view is not available to remove");return}throw Error("child view must be loaded before transition.");}!k&&g.defaultView&&(k=g.defaultView);var n=[g||c];k&&(n=this._getNextSubViewArray(k,g,c));var r=u.getSelectedChild(c,g.constraint),w=this._getCurrentSubViewArray(c,n,f);a=this._getNamesFromArray(w,!1);var q=this._getNamesFromArray(n,
!0);g.params=this._getParamsForView(g.name,d);if(f){if(g!==r){this.app.log("app/controllers/Transition:_doTransition called with removeView true, but that view is not available to remove");return}this.app.log("logTransitions:","app/controllers/Transition:_doTransition","Transition Remove current From\x3d["+a+"]");g=null}if(q==a&&g==r)this.app.log("logTransitions:","app/controllers/Transition:_doTransition","Transition current and next DO MATCH From\x3d["+a+"] TO\x3d["+q+"]"),this._handleMatchingViews(n,
g,r,c,e,f,p,k,a,t,h,b);else{this.app.log("logTransitions:","app/controllers/Transition:_doTransition","Transition current and next DO NOT MATCH From\x3d["+a+"] TO\x3d["+q+"]");if(!f&&g)for(d=this.nextLastSubChildMatch||g,a=!1,q=n.length-1;0<=q;q--){var l=n[q];if(a||l.id==d.id)a=!0,!l._needsResize&&l.domNode&&(this.app.log("logTransitions:","app/controllers/Transition:_doTransition"," setting domStyle visibility hidden for v.id\x3d["+l.id+"], display\x3d["+l.domNode.style.display+"], visibility\x3d["+
l.domNode.style.visibility+"]"),this._setViewVisible(l,!1))}r&&r._active&&this._handleBeforeDeactivateCalls(w,this.nextLastSubChildMatch||g,r,e,k);g&&(this.app.log("app/controllers/Transition:_doTransition calling _handleBeforeActivateCalls next name\x3d[",g.name,"], parent.name\x3d[",g.parent.name,"]"),this._handleBeforeActivateCalls(n,this.currentLastSubChildMatch||r,e,k));if(f)for(q=0;q<n.length;q++)l=n[q],this.app.log("logTransitions:","app/controllers/Transition:_doTransition","setting visibility visible for v.id\x3d["+
l.id+"]"),l.domNode&&(this.app.log("logTransitions:","app/controllers/Transition:_doTransition","  setting domStyle for removeView visibility visible for v.id\x3d["+l.id+"], display\x3d["+l.domNode.style.display+"]"),this._setViewVisible(l,!0));else d=this.nextLastSubChildMatch||g,d=this._getTransition(d,c,t,b,h),this.app.log("app/controllers/Transition:_doTransition calling _handleLayoutAndResizeCalls trans\x3d"+d),this._handleLayoutAndResizeCalls(n,f,p,k,h,d);d=!0;!v||z&&null==this.currentLastSubChildMatch||
this.currentLastSubChildMatch===g||(d=this._handleTransit(g,c,this.currentLastSubChildMatch,b,t,f,h,p));x(d,m.hitch(this,function(){g&&this.app.log("app/controllers/Transition:_doTransition back from transit for next \x3d"+g.name);if(f){var D=this._getTransition(this.nextLastSubChildMatch||g,c,t,b,h);this._handleLayoutAndResizeCalls(n,f,p,k,h,D)}this._handleAfterDeactivateCalls(w,this.nextLastSubChildMatch||g,r,e,k);this._handleAfterActivateCalls(n,f,this.currentLastSubChildMatch||r,e,k)}));return d}},
_handleMatchingViews:function(a,b,d,e,c,f,p,h,z,t,k,g){this._handleBeforeDeactivateCalls(a,this.nextLastSubChildMatch||b,d,c,h);this._handleAfterDeactivateCalls(a,this.nextLastSubChildMatch||b,d,c,h);this._handleBeforeActivateCalls(a,this.currentLastSubChildMatch||d,c,h);b=this._getTransition(this.nextLastSubChildMatch||b,e,t,g,k);this._handleLayoutAndResizeCalls(a,f,p,h,b);this._handleAfterActivateCalls(a,f,this.currentLastSubChildMatch||d,c,h)},_handleBeforeDeactivateCalls:function(a,b,d,e,c){if(d._active)for(d=
a.length-1;0<=d;d--)(c=a[d])&&c.beforeDeactivate&&c._active&&(this.app.log("logTransitions:","app/controllers/Transition:_handleBeforeDeactivateCalls","beforeDeactivate for v.id\x3d"+c.id),c.beforeDeactivate(b,e))},_handleAfterDeactivateCalls:function(a,b,d,e,c){if(d&&d._active)for(d=0;d<a.length;d++)(c=a[d])&&c.beforeDeactivate&&c._active&&(this.app.log("logTransitions:","app/controllers/Transition:_handleAfterDeactivateCalls","afterDeactivate for v.id\x3d"+c.id),c.afterDeactivate(b,e),c._active=
!1)},_handleBeforeActivateCalls:function(a,b,d,e){for(e=a.length-1;0<=e;e--){var c=a[e];this.app.log("logTransitions:","app/controllers/Transition:_handleBeforeActivateCalls","beforeActivate for v.id\x3d"+c.id);c.beforeActivate(b,d)}},_handleLayoutAndResizeCalls:function(a,b,d,e,c,f){for(e=0;e<a.length;e++)c=a[e],this.app.log("logTransitions:","app/controllers/Transition:_handleLayoutAndResizeCalls","emit layoutView v.id\x3d["+c.id+"] removeView\x3d["+b+"]"),this.app.emit("app-layoutView",{parent:c.parent,
view:c,removeView:b,doResize:!1,transition:f,currentLastSubChildMatch:this.currentLastSubChildMatch}),b=!1;d&&(this.app.log("logTransitions:","app/controllers/Transition:_handleLayoutAndResizeCalls","emit doResize called"),this.app.emit("app-resize"),"none"==f&&this._showSelectedChildren(this.app))},_showSelectedChildren:function(a){this.app.log("logTransitions:","app/controllers/Transition:_showSelectedChildren"," setting domStyle visibility visible for w.id\x3d["+a.id+"], display\x3d["+a.domNode.style.display+
"], visibility\x3d["+a.domNode.style.visibility+"]");this._setViewVisible(a,!0);a._needsResize=!1;for(var b in a.selectedChildren)a.selectedChildren[b]&&a.selectedChildren[b].domNode&&(this.app.log("logTransitions:","app/controllers/Transition:_showSelectedChildren"," calling _showSelectedChildren for w.selectedChildren[hash].id\x3d"+a.selectedChildren[b].id),this._showSelectedChildren(a.selectedChildren[b]))},_setViewVisible:function(a,b){b?y.set(a.domNode,"visibility","visible"):y.set(a.domNode,
"visibility","hidden")},_handleAfterActivateCalls:function(a,b,d,e,c){c=0;b&&1<a.length&&(c=1);for(b=c;b<a.length;b++)c=a[b],c.afterActivate&&(this.app.log("logTransitions:","app/controllers/Transition:_handleAfterActivateCalls","afterActivate for v.id\x3d"+c.id),c.afterActivate(d,e),c._active=!0)},_getNextSubViewArray:function(a,b,d){var e=[];b=b||d;a&&(e=a.split(","));a=[b];for(d=0;d<e.length;d++){toId=e[d];var c=b.children[b.id+"_"+toId];c&&(a.push(c),b=c)}a.reverse();return a},_getCurrentSubViewArray:function(a,
b,d){var e=[];this.nextLastSubChildMatch=this.currentLastSubChildMatch=null;for(var c=b.length-1;0<=c;c--){var f=b[c].constraint;var p=typeof f;f="string"==p||"number"==p?f:f.__hash;if(a&&a.selectedChildren&&a.selectedChildren[f])if(a.selectedChildren[f]==b[c])this.currentLastSubChildMatch=a.selectedChildren[f],this.nextLastSubChildMatch=b[c],e.push(this.currentLastSubChildMatch),a=this.currentLastSubChildMatch;else{this.currentLastSubChildMatch=a.selectedChildren[f];e.push(this.currentLastSubChildMatch);
this.nextLastSubChildMatch=b[c];d||(b=u.getAllSelectedChildren(this.currentLastSubChildMatch),e=e.concat(b));break}else{this.currentLastSubChildMatch=null;this.nextLastSubChildMatch=b[c];break}}d&&(b=u.getAllSelectedChildren(a),e=e.concat(b));return e},_getNamesFromArray:function(a,b){var d="";if(b)for(var e=a.length-1;0<=e;e--)d=d?d+","+a[e].name:a[e].name;else for(e=0;e<a.length;e++)d=d?d+","+a[e].name:a[e].name;return d},_handleTransit:function(a,b,d,e,c,f,p,h){a=this.nextLastSubChildMatch||a;
e=m.mixin({},e);e=m.mixin({},e,{reverse:e.reverse||-1===e.transitionDir?!0:!1,transition:this._getTransition(a,b,c,e,p)});f&&(a=null);d&&this.app.log("logTransitions:","app/controllers/Transition:_handleTransit","transit FROM currentLastSubChild.id\x3d["+d.id+"]");a?("none"!==e.transition&&(!h&&a._needsResize&&(this.app.log("logTransitions:","app/controllers/Transition:_handleTransit","emit doResize called from _handleTransit"),this.app.emit("app-resize")),this.app.log("logTransitions:","app/controllers/Transition:_handleTransit",
"  calling _showSelectedChildren for w3.id\x3d["+a.id+"], display\x3d["+a.domNode.style.display+"], visibility\x3d["+a.domNode.style.visibility+"]"),this._showSelectedChildren(this.app)),this.app.log("logTransitions:","app/controllers/Transition:_handleTransit","transit TO nextLastSubChild.id\x3d["+a.id+"] transition\x3d["+e.transition+"]")):this._showSelectedChildren(this.app);return v(d&&d.domNode,a&&a.domNode,e)}})});