Comparing version 1.2.5 to 1.2.6
@@ -60,2 +60,3 @@ "use strict"; | ||
if (newTransition) { | ||
newTransition.queryParamsOnly = true; | ||
return newTransition; | ||
@@ -77,2 +78,8 @@ } | ||
// transition is to same route with same params, only query params differ. | ||
// not caught above probably because refresh() has been used | ||
if ( handlerInfosSameExceptQueryParams(newState.handlerInfos, oldState.handlerInfos ) ) { | ||
newTransition.queryParamsOnly = true; | ||
} | ||
// Abort and usurp any previously active transition. | ||
@@ -787,2 +794,46 @@ if (this.activeTransition) { | ||
function handlerInfosSameExceptQueryParams(handlerInfos, otherHandlerInfos) { | ||
if (handlerInfos.length !== otherHandlerInfos.length) { | ||
return false; | ||
} | ||
for (var i = 0, len = handlerInfos.length; i < len; ++i) { | ||
if (handlerInfos[i].name !== otherHandlerInfos[i].name) { | ||
return false; | ||
} | ||
if (!paramsEqual(handlerInfos[i].params, otherHandlerInfos[i].params)) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
function paramsEqual(params, otherParams) { | ||
if (!params && !otherParams) { | ||
return true; | ||
} else if (!params && !!otherParams || !!params && !otherParams) { | ||
// one is falsy but other is not; | ||
return false; | ||
} | ||
var keys = Object.keys(params); | ||
var otherKeys = Object.keys(otherParams); | ||
if (keys.length !== otherKeys.length) { | ||
return false; | ||
} | ||
for (var i = 0, len = keys.length; i < len; ++i) { | ||
var key = keys[i]; | ||
if ( params[key] !== otherParams[key] ) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
function finalizeQueryParamChange(router, resolvedHandlers, newQueryParams, transition) { | ||
@@ -789,0 +840,0 @@ // We fire a finalizeQueryParamChange event which |
@@ -1,1 +0,1 @@ | ||
(function(e,r,t){var n,i,a,s;(function(){var e={},r={};n=function(r,t,n){e[r]={deps:t,callback:n}};s=a=i=function(t){if(r[t]){return r[t]}r[t]={};if(!e[t]){throw new Error("Could not find module "+t)}var n=e[t],a=n.deps,s=n.callback,o=[],l;for(var u=0,h=a.length;u<h;u++){if(a[u]==="exports"){o.push(l={})}else{o.push(i(d(a[u])))}}var f=s.apply(this,o);return r[t]=l||f;function d(e){if(e.charAt(0)!=="."){return e}var r=e.split("/");var n=t.split("/").slice(0,-1);for(var i=0,a=r.length;i<a;i++){var s=r[i];if(s===".."){n.pop()}else if(s==="."){continue}else{n.push(s)}}return n.join("/")}}})();n("router/handler-info",["./utils","rsvp","exports"],function(e,r,t){"use strict";var n=e.bind;var i=e.merge;var a=e.promiseLabel;var s=e.applyHook;var o=e.isPromise;var l=r.Promise;var u=Object.freeze({});function h(e){var r=e||{};this._handler=u;if(r.handler){var t=r.name;this.handlerPromise=l.resolve(r.handler);if(o(r.handler)){this.handlerPromise=this.handlerPromise.then(n(this,this.updateHandler));r.handler=undefined}else if(r.handler){r.handler._handlerName=t}}i(this,r);this.initialize(r)}h.prototype={name:null,getHandler:function(){},fetchHandler:function(){var e=this.getHandler(this.name);this.handlerPromise=l.resolve(e);if(o(e)){this.handlerPromise=this.handlerPromise.then(n(this,this.updateHandler))}else if(e){e._handlerName=this.name;return this.handler=e}return this.handler=undefined},_handlerPromise:undefined,params:null,context:null,factory:null,initialize:function(){},log:function(e,r){if(e.log){e.log(this.name+": "+r)}},promiseLabel:function(e){return a("'"+this.name+"' "+e)},getUnresolved:function(){return this},serialize:function(){return this.params||{}},updateHandler:function(e){e._handlerName=this.name;return this.handler=e},resolve:function(e,r){var t=n(this,this.checkForAbort,e),i=n(this,this.runBeforeModelHook,r),a=n(this,this.getModel,r),s=n(this,this.runAfterModelHook,r),o=n(this,this.becomeResolved,r),u=this;return l.resolve(this.handlerPromise,this.promiseLabel("Start handler")).then(function(e){return l.resolve(e).then(t,null,u.promiseLabel("Check for abort")).then(i,null,u.promiseLabel("Before model")).then(t,null,u.promiseLabel("Check if aborted during 'beforeModel' hook")).then(a,null,u.promiseLabel("Model")).then(t,null,u.promiseLabel("Check if aborted in 'model' hook")).then(s,null,u.promiseLabel("After model")).then(t,null,u.promiseLabel("Check if aborted in 'afterModel' hook")).then(o,null,u.promiseLabel("Become resolved"))},function(e){throw e})},runBeforeModelHook:function(e){if(e.trigger){e.trigger(true,"willResolveModel",e,this.handler)}return this.runSharedModelHook(e,"beforeModel",[])},runAfterModelHook:function(e,r){var t=this.name;this.stashResolvedModel(e,r);return this.runSharedModelHook(e,"afterModel",[r]).then(function(){return e.resolvedModels[t]},null,this.promiseLabel("Ignore fulfillment value and return model value"))},runSharedModelHook:function(e,r,t){this.log(e,"calling "+r+" hook");if(this.queryParams){t.push(this.queryParams)}t.push(e);var n=s(this.handler,r,t);if(n&&n.isTransition){n=null}return l.resolve(n,this.promiseLabel("Resolve value returned from one of the model hooks"))},getModel:null,checkForAbort:function(e,r){return l.resolve(e(),this.promiseLabel("Check for abort")).then(function(){return r},null,this.promiseLabel("Ignore fulfillment value and continue"))},stashResolvedModel:function(e,r){e.resolvedModels=e.resolvedModels||{};e.resolvedModels[this.name]=r},becomeResolved:function(e,r){var t=this.serialize(r);if(e){this.stashResolvedModel(e,r);e.params=e.params||{};e.params[this.name]=t}return this.factory("resolved",{context:r,name:this.name,handler:this.handler,params:t})},shouldSupercede:function(e){if(!e){return true}var r=e.context===this.context;return e.name!==this.name||this.hasOwnProperty("context")&&!r||this.hasOwnProperty("params")&&!f(this.params,e.params)}};Object.defineProperty(h.prototype,"handler",{get:function(){if(this._handler!==u){return this._handler}return this.fetchHandler()},set:function(e){return this._handler=e}});Object.defineProperty(h.prototype,"handlerPromise",{get:function(){if(this._handlerPromise){return this._handlerPromise}this.fetchHandler();return this._handlerPromise},set:function(e){return this._handlerPromise=e}});function f(e,r){if(!e^!r){return false}if(!e){return true}for(var t in e){if(e.hasOwnProperty(t)&&e[t]!==r[t]){return false}}return true}t["default"]=h});n("router/handler-info/factory",["./resolved-handler-info","./unresolved-handler-info-by-object","./unresolved-handler-info-by-param","exports"],function(e,r,t,n){"use strict";var i=e["default"];var a=r["default"];var s=t["default"];o.klasses={resolved:i,param:s,object:a};function o(e,r){var t=o.klasses[e],n=new t(r||{});n.factory=o;return n}n["default"]=o});n("router/handler-info/resolved-handler-info",["../handler-info","../utils","rsvp","exports"],function(e,r,t,n){"use strict";var i=e["default"];var a=r.subclass;var s=t.Promise;var o=a(i,{resolve:function(e,r){if(r&&r.resolvedModels){r.resolvedModels[this.name]=this.context}return s.resolve(this,this.promiseLabel("Resolve"))},getUnresolved:function(){return this.factory("param",{name:this.name,handler:this.handler,params:this.params})},isResolved:true});n["default"]=o});n("router/handler-info/unresolved-handler-info-by-object",["../handler-info","../utils","rsvp","exports"],function(e,r,t,n){"use strict";var i=e["default"];var a=r.subclass;var s=r.isParam;var o=t.Promise;var l=a(i,{getModel:function(e){this.log(e,this.name+": resolving provided model");return o.resolve(this.context)},initialize:function(e){this.names=e.names||[];this.context=e.context},serialize:function(e){var r=e||this.context,t=this.names,n=this.serializer||this.handler&&this.handler.serialize;var i={};if(s(r)){i[t[0]]=r;return i}if(n){return n(r,t)}if(t.length!==1){return}var a=t[0];if(/_id$/.test(a)){i[a]=r.id}else{i[a]=r}return i}});n["default"]=l});n("router/handler-info/unresolved-handler-info-by-param",["../handler-info","../utils","exports"],function(e,r,t){"use strict";var n=e["default"];var i=r.resolveHook;var a=r.merge;var s=r.subclass;var o=s(n,{initialize:function(e){this.params=e.params||{}},getModel:function(e){var r=this.params;if(e&&e.queryParams){r={};a(r,this.params);r.queryParams=e.queryParams}var t=this.handler;var n=i(t,"deserialize")||i(t,"model");return this.runSharedModelHook(e,n,[r])}});t["default"]=o});n("router/router",["route-recognizer","rsvp","./utils","./transition-state","./transition","./transition-aborted-error","./transition-intent/named-transition-intent","./transition-intent/url-transition-intent","exports"],function(e,r,t,n,i,a,s,o,l){"use strict";var u=e["default"];var h=r.Promise;var f=t.trigger;var d=t.log;var c=t.slice;var v=t.forEach;var m=t.merge;var p=t.extractQueryParams;var g=t.getChangelist;var y=t.promiseLabel;var b=t.callHook;var P=n["default"];var I=i.logAbort;var w=i.Transition;var x=a["default"];var T=s["default"];var H=o["default"];var q=Array.prototype.pop;function L(e){var r=e||{};this.getHandler=r.getHandler||this.getHandler;this.getSerializer=r.getSerializer||this.getSerializer;this.updateURL=r.updateURL||this.updateURL;this.replaceURL=r.replaceURL||this.replaceURL;this.didTransition=r.didTransition||this.didTransition;this.willTransition=r.willTransition||this.willTransition;this.delegate=r.delegate||this.delegate;this.triggerEvent=r.triggerEvent||this.triggerEvent;this.log=r.log||this.log;this.dslCallBacks=[];this.state=undefined;this.activeTransition=undefined;this._changedQueryParams=undefined;this.oldState=undefined;this.currentHandlerInfos=undefined;this.state=undefined;this.currentSequence=0;this.recognizer=new u;this.reset()}function k(e,r){var t=!!this.activeTransition;var n=t?this.activeTransition.state:this.state;var i;var a=e.applyToState(n,this.recognizer,this.getHandler,r,this.getSerializer);var s=g(n.queryParams,a.queryParams);if(U(a.handlerInfos,n.handlerInfos)){if(s){i=this.queryParamsTransition(s,t,n,a);if(i){return i}}return this.activeTransition||new w(this)}if(r){R(this,a);return}i=new w(this,e,a,undefined,this.activeTransition);if(this.activeTransition){this.activeTransition.abort()}this.activeTransition=i;i.promise=i.promise.then(function(e){return C(i,e.state)},null,y("Settle transition promise when transition is finalized"));if(!t){O(this,a,i)}z(this,a,s);return i}L.prototype={map:function(e){this.recognizer.delegate=this.delegate;this.recognizer.map(e,function(e,r){for(var t=r.length-1,n=true;t>=0&&n;--t){var i=r[t];e.add(r,{as:i.handler});n=i.path==="/"||i.path===""||i.handler.slice(-6)===".index"}})},hasRoute:function(e){return this.recognizer.hasRoute(e)},getHandler:function(){},getSerializer:function(){},queryParamsTransition:function(e,r,t,n){var i=this;z(this,n,e);if(!r&&this.activeTransition){return this.activeTransition}else{var a=new w(this);a.queryParamsOnly=true;t.queryParams=j(this,n.handlerInfos,n.queryParams,a);a.promise=a.promise.then(function(e){M(a,t,true);if(i.didTransition){i.didTransition(i.currentHandlerInfos)}return e},null,y("Transition complete"));return a}},transitionByIntent:function(e){try{return k.apply(this,arguments)}catch(r){return new w(this,e,null,r)}},reset:function(){if(this.state){v(this.state.handlerInfos.slice().reverse(),function(e){var r=e.handler;b(r,"exit")})}this.oldState=undefined;this.state=new P;this.currentHandlerInfos=null},activeTransition:null,handleURL:function(e){var r=c.call(arguments);if(e.charAt(0)!=="/"){r[0]="/"+e}return E(this,r).method(null)},updateURL:function(){throw new Error("updateURL is not implemented")},replaceURL:function(e){this.updateURL(e)},transitionTo:function(){return E(this,arguments)},intermediateTransitionTo:function(){return E(this,arguments,true)},refresh:function(e){var r=this.activeTransition?this.activeTransition.state:this.state;var t=r.handlerInfos;var n={};for(var i=0,a=t.length;i<a;++i){var s=t[i];n[s.name]=s.params||{}}d(this,"Starting a refresh transition");var o=new T({name:t[t.length-1].name,pivotHandler:e||t[0].handler,contexts:[],queryParams:this._changedQueryParams||r.queryParams||{}});return this.transitionByIntent(o,false)},replaceWith:function(){return E(this,arguments).method("replace")},generate:function(e){var r=p(c.call(arguments,1)),t=r[0],n=r[1];var i=new T({name:e,contexts:t});var a=i.applyToState(this.state,this.recognizer,this.getHandler,null,this.getSerializer);var s={};for(var o=0,l=a.handlerInfos.length;o<l;++o){var u=a.handlerInfos[o];var h=u.serialize();m(s,h)}s.queryParams=n;return this.recognizer.generate(e,s)},applyIntent:function(e,r){var t=new T({name:e,contexts:r});var n=this.activeTransition&&this.activeTransition.state||this.state;return t.applyToState(n,this.recognizer,this.getHandler,null,this.getSerializer)},isActiveIntent:function(e,r,t,n){var i=n||this.state,a=i.handlerInfos,s,o;if(!a.length){return false}var l=a[a.length-1].name;var u=this.recognizer.handlersFor(l);var h=0;for(o=u.length;h<o;++h){s=a[h];if(s.name===e){break}}if(h===u.length){return false}var f=new P;f.handlerInfos=a.slice(0,h+1);u=u.slice(0,h+1);var d=new T({name:l,contexts:r});var c=d.applyToHandlers(f,u,this.getHandler,l,true,true,this.getSerializer);var v=U(c.handlerInfos,f.handlerInfos);if(!t||!v){return v}var p={};m(p,t);var y=i.queryParams;for(var b in y){if(y.hasOwnProperty(b)&&p.hasOwnProperty(b)){p[b]=y[b]}}return v&&!g(p,t)},isActive:function(e){var r=p(c.call(arguments,1));return this.isActiveIntent(e,r[0],r[1])},trigger:function(){var e=c.call(arguments);f(this,this.currentHandlerInfos,false,e)},log:null};function z(e,r,t){if(t){e._changedQueryParams=t.all;f(e,r.handlerInfos,true,["queryParamsDidChange",t.changed,t.all,t.removed]);e._changedQueryParams=null}}function R(e,r,t){var n=A(e.state,r);var i,a,s;for(i=0,a=n.exited.length;i<a;i++){s=n.exited[i].handler;delete s.context;b(s,"reset",true,t);b(s,"exit",t)}var o=e.oldState=e.state;e.state=r;var l=e.currentHandlerInfos=n.unchanged.slice();try{for(i=0,a=n.reset.length;i<a;i++){s=n.reset[i].handler;b(s,"reset",false,t)}for(i=0,a=n.updatedContext.length;i<a;i++){S(l,n.updatedContext[i],false,t)}for(i=0,a=n.entered.length;i<a;i++){S(l,n.entered[i],true,t)}}catch(u){e.state=o;e.currentHandlerInfos=o.handlerInfos;throw u}e.state.queryParams=j(e,l,r.queryParams,t)}function S(e,r,t,n){var i=r.handler,a=r.context;function s(i){if(t){b(i,"enter",n)}if(n&&n.isAborted){throw new x}i.context=a;b(i,"contextDidChange");b(i,"setup",a,n);if(n&&n.isAborted){throw new x}e.push(r)}if(!i){r.handlerPromise=r.handlerPromise.then(s)}else{s(i)}return true}function A(e,r){var t=e.handlerInfos;var n=r.handlerInfos;var i={updatedContext:[],exited:[],entered:[],unchanged:[],reset:undefined};var a,s=false,o,l;for(o=0,l=n.length;o<l;o++){var u=t[o],h=n[o];if(!u||u.handler!==h.handler){a=true}if(a){i.entered.push(h);if(u){i.exited.unshift(u)}}else if(s||u.context!==h.context){s=true;i.updatedContext.push(h)}else{i.unchanged.push(u)}}for(o=n.length,l=t.length;o<l;o++){i.exited.unshift(t[o])}i.reset=i.updatedContext.slice();i.reset.reverse();return i}function M(e,r){var t=e.urlMethod;if(!t){return}var n=e.router,i=r.handlerInfos,a=i[i.length-1].name,s={};for(var o=i.length-1;o>=0;--o){var l=i[o];m(s,l.params);if(l.handler.inaccessibleByURL){t=null}}if(t){s.queryParams=e._visibleQueryParams||r.queryParams;var u=n.recognizer.generate(a,s);var h=e.isCausedByInitialTransition;var f=t==="replace"&&!e.isCausedByAbortingTransition;if(h||f){n.replaceURL(u)}else{n.updateURL(u)}}}function C(e,r){try{d(e.router,e.sequence,"Resolved all models on destination route; finalizing transition.");var t=e.router,n=r.handlerInfos;R(t,r,e);if(e.isAborted){t.state.handlerInfos=t.currentHandlerInfos;return h.reject(I(e))}M(e,r,e.intent.url);e.isActive=false;t.activeTransition=null;f(t,t.currentHandlerInfos,true,["didTransition"]);if(t.didTransition){t.didTransition(t.currentHandlerInfos)}d(t,e.sequence,"TRANSITION COMPLETE.");return n[n.length-1].handler}catch(i){if(!((i instanceof x))){var a=e.state.handlerInfos;e.trigger(true,"error",i,e,a[a.length-1].handler);e.abort()}throw i}}function E(e,r,t){var n=r[0]||"/";var i=r[r.length-1];var a={};if(i&&i.hasOwnProperty("queryParams")){a=q.call(r).queryParams}var s;if(r.length===0){d(e,"Updating query params");var o=e.state.handlerInfos;s=new T({name:o[o.length-1].name,contexts:[],queryParams:a})}else if(n.charAt(0)==="/"){d(e,"Attempting URL transition to "+n);s=new H({url:n})}else{d(e,"Attempting transition to "+n);s=new T({name:r[0],contexts:c.call(r,1),queryParams:a})}return e.transitionByIntent(s,t)}function U(e,r){if(e.length!==r.length){return false}for(var t=0,n=e.length;t<n;++t){if(e[t]!==r[t]){return false}}return true}function j(e,r,t,n){for(var i in t){if(t.hasOwnProperty(i)&&t[i]===null){delete t[i]}}var a=[];f(e,r,true,["finalizeQueryParamChange",t,a,n]);if(n){n._visibleQueryParams={}}var s={};for(var o=0,l=a.length;o<l;++o){var u=a[o];s[u.key]=u.value;if(n&&u.visible!==false){n._visibleQueryParams[u.key]=u.value}}return s}function O(e,r,t){var n=e.state.handlerInfos,i=[],a=null,s,o,l,u,h,d;u=n.length;for(l=0;l<u;l++){h=n[l];d=r.handlerInfos[l];if(!d||h.name!==d.name){a=l;break}if(!d.isResolved){i.push(h)}}if(a!==null){s=n.slice(a,u);o=function(e){for(var r=0,t=s.length;r<t;r++){if(s[r].name===e){return true}}return false}}f(e,n,true,["willTransition",t]);if(e.willTransition){e.willTransition(n,r.handlerInfos,t)}}l["default"]=L});n("router/transition-aborted-error",["./utils","exports"],function(e,r){"use strict";var t=e.oCreate;function n(e){if(!(this instanceof n)){return new n(e)}var r=Error.call(this,e);if(Error.captureStackTrace){Error.captureStackTrace(this,n)}else{this.stack=r.stack}this.description=r.description;this.fileName=r.fileName;this.lineNumber=r.lineNumber;this.message=r.message||"TransitionAborted";this.name="TransitionAborted";this.number=r.number;this.code=r.code}n.prototype=t(Error.prototype);r["default"]=n});n("router/transition-intent",["exports"],function(e){"use strict";function r(e){this.initialize(e);this.data=this.data||{}}r.prototype={initialize:null,applyToState:null};e["default"]=r});n("router/transition-intent/named-transition-intent",["../transition-intent","../transition-state","../handler-info/factory","../utils","exports"],function(e,r,t,n,i){"use strict";var a=e["default"];var s=r["default"];var o=t["default"];var l=n.isParam;var u=n.extractQueryParams;var h=n.merge;var f=n.subclass;i["default"]=f(a,{name:null,pivotHandler:null,contexts:null,queryParams:null,initialize:function(e){this.name=e.name;this.pivotHandler=e.pivotHandler;this.contexts=e.contexts||[];this.queryParams=e.queryParams},applyToState:function(e,r,t,n,i){var a=u([this.name].concat(this.contexts)),s=a[0],o=r.handlersFor(s[0]);var l=o[o.length-1].handler;return this.applyToHandlers(e,o,t,l,n,null,i)},applyToHandlers:function(e,r,t,n,i,a,o){var l,u;var f=new s;var d=this.contexts.slice(0);var c=r.length;if(this.pivotHandler){for(l=0,u=r.length;l<u;++l){if(r[l].handler===this.pivotHandler._handlerName){c=l;break}}}for(l=r.length-1;l>=0;--l){var v=r[l];var m=v.handler;var p=e.handlerInfos[l];var g=null;if(v.names.length>0){if(l>=c){g=this.createParamHandlerInfo(m,t,v.names,d,p)}else{var y=o(m);g=this.getHandlerInfoForDynamicSegment(m,t,v.names,d,p,n,l,y)}}else{g=this.createParamHandlerInfo(m,t,v.names,d,p)}if(a){g=g.becomeResolved(null,g.context);var b=p&&p.context;if(v.names.length>0&&g.context===b){g.params=p&&p.params}g.context=b}var P=p;if(l>=c||g.shouldSupercede(p)){c=Math.min(l,c);P=g}if(i&&!a){P=P.becomeResolved(null,P.context)}f.handlerInfos.unshift(P)}if(d.length>0){throw new Error("More context objects were passed than there are dynamic segments for the route: "+n)}if(!i){this.invalidateChildren(f.handlerInfos,c)}h(f.queryParams,this.queryParams||{});return f},invalidateChildren:function(e,r){for(var t=r,n=e.length;t<n;++t){var i=e[t];e[t]=i.getUnresolved()}},getHandlerInfoForDynamicSegment:function(e,r,t,n,i,a,s,u){var h;if(n.length>0){h=n[n.length-1];if(l(h)){return this.createParamHandlerInfo(e,r,t,n,i)}else{n.pop()}}else if(i&&i.name===e){return i}else{if(this.preTransitionState){var f=this.preTransitionState.handlerInfos[s];h=f&&f.context}else{return i}}return o("object",{name:e,getHandler:r,serializer:u,context:h,names:t})},createParamHandlerInfo:function(e,r,t,n,i){var a={};var s=t.length;while(s--){var u=i&&e===i.name&&i.params||{};var h=n[n.length-1];var f=t[s];if(l(h)){a[f]=""+n.pop()}else{if(u.hasOwnProperty(f)){a[f]=u[f]}else{throw new Error("You didn't provide enough string/numeric parameters to satisfy all of the dynamic segments for route "+e)}}}return o("param",{name:e,getHandler:r,params:a})}})});n("router/transition-intent/url-transition-intent",["../transition-intent","../transition-state","../handler-info/factory","../utils","../unrecognized-url-error","exports"],function(e,r,t,n,i,a){"use strict";var s=e["default"];var o=r["default"];var l=t["default"];var u=n.merge;var h=n.subclass;var f=i["default"];a["default"]=h(s,{url:null,initialize:function(e){this.url=e.url},applyToState:function(e,r,t){var n=new o;var i=r.recognize(this.url),a,s;if(!i){throw new f(this.url)}var h=false;var d=this.url;function c(e){if(e&&e.inaccessibleByURL){throw new f(d)}return e}for(a=0,s=i.length;a<s;++a){var v=i[a];var m=v.handler;var p=l("param",{name:m,getHandler:t,params:v.params});var g=p.handler;if(g){c(g)}else{p.handlerPromise=p.handlerPromise.then(c)}var y=e.handlerInfos[a];if(h||p.shouldSupercede(y)){h=true;n.handlerInfos[a]=p}else{n.handlerInfos[a]=y}}u(n.queryParams,i.queryParams);return n}})});n("router/transition-state",["./utils","rsvp","exports"],function(e,r,t){"use strict";var n=e.forEach;var i=e.promiseLabel;var a=e.callHook;var s=r.Promise;function o(){this.handlerInfos=[];this.queryParams={};this.params={}}o.prototype={promiseLabel:function(e){var r="";n(this.handlerInfos,function(e){if(r!==""){r+="."}r+=e.name});return i("'"+r+"': "+e)},resolve:function(e,r){var t=this.params;n(this.handlerInfos,function(e){t[e.name]=e.params||{}});r=r||{};r.resolveIndex=0;var i=this;var o=false;return s.resolve(null,this.promiseLabel("Start transition")).then(f,null,this.promiseLabel("Resolve handler"))["catch"](u,this.promiseLabel("Handle error"));function l(){return s.resolve(e(),i.promiseLabel("Check if should continue"))["catch"](function(e){o=true;return s.reject(e)},i.promiseLabel("Handle abort"))}function u(e){var t=i.handlerInfos;var n=r.resolveIndex>=t.length?t.length-1:r.resolveIndex;return s.reject({error:e,handlerWithError:i.handlerInfos[n].handler,wasAborted:o,state:i})}function h(e){var t=i.handlerInfos[r.resolveIndex].isResolved;i.handlerInfos[r.resolveIndex++]=e;if(!t){var n=e.handler;a(n,"redirect",e.context,r)}return l().then(f,null,i.promiseLabel("Resolve handler"))}function f(){if(r.resolveIndex===i.handlerInfos.length){return{error:null,state:i}}var e=i.handlerInfos[r.resolveIndex];return e.resolve(l,r).then(h,null,i.promiseLabel("Proceed"))}}};t["default"]=o});n("router/transition",["rsvp","./utils","./transition-aborted-error","exports"],function(e,r,t,n){"use strict";var i=e.Promise;var a=r.trigger;var s=r.slice;var o=r.log;var l=r.promiseLabel;var u=t["default"];function h(e,r,t,n,a){var s=this;this.state=t||e.state;this.intent=r;this.router=e;this.data=this.intent&&this.intent.data||{};this.resolvedModels={};this.queryParams={};this.promise=undefined;this.error=undefined;this.params=undefined;this.handlerInfos=undefined;this.targetName=undefined;this.pivotHandler=undefined;this.sequence=undefined;this.isAborted=false;this.isActive=true;if(n){this.promise=i.reject(n);this.error=n;return}this.isCausedByAbortingTransition=!!a;this.isCausedByInitialTransition=a&&(a.isCausedByInitialTransition||a.sequence===0);if(t){this.params=t.params;this.queryParams=t.queryParams;this.handlerInfos=t.handlerInfos;var o=t.handlerInfos.length;if(o){this.targetName=t.handlerInfos[o-1].name}for(var u=0;u<o;++u){var h=t.handlerInfos[u];if(!h.isResolved){break}this.pivotHandler=h.handler}this.sequence=e.currentSequence++;this.promise=t.resolve(d,this)["catch"](f(s),l("Handle Abort"))}else{this.promise=i.resolve(this.state);this.params={}}function d(){if(s.isAborted){return i.reject(undefined,l("Transition aborted - reject"))}}}function f(e){return function(r){if(r.wasAborted||e.isAborted){return i.reject(d(e))}else{e.trigger("error",r.error,e,r.handlerWithError);e.abort();return i.reject(r.error)}}}h.prototype={targetName:null,urlMethod:"update",intent:null,pivotHandler:null,resolveIndex:0,resolvedModels:null,state:null,queryParamsOnly:false,isTransition:true,isExiting:function(e){var r=this.handlerInfos;for(var t=0,n=r.length;t<n;++t){var i=r[t];if(i.name===e||i.handler===e){return false}}return true},promise:null,data:null,then:function(e,r,t){return this.promise.then(e,r,t)},"catch":function(e,r){return this.promise["catch"](e,r)},"finally":function(e,r){return this.promise["finally"](e,r)},abort:function(){if(this.isAborted){return this}o(this.router,this.sequence,this.targetName+": transition was aborted");this.intent.preTransitionState=this.router.state;this.isAborted=true;this.isActive=false;this.router.activeTransition=null;return this},retry:function(){this.abort();return this.router.transitionByIntent(this.intent,false)},method:function(e){this.urlMethod=e;return this},trigger:function(e){var r=s.call(arguments);if(typeof e==="boolean"){r.shift()}else{e=false}a(this.router,this.state.handlerInfos.slice(0,this.resolveIndex+1),e,r)},followRedirects:function(){var e=this.router;return this.promise["catch"](function(r){if(e.activeTransition){return e.activeTransition.followRedirects()}return i.reject(r)})},toString:function(){return"Transition (sequence "+this.sequence+")"},log:function(e){o(this.router,this.sequence,e)}};h.prototype.send=h.prototype.trigger;function d(e){o(e.router,e.sequence,"detected abort.");return new u}n.Transition=h;n.logAbort=d;n.TransitionAbortedError=u});n("router/unrecognized-url-error",["./utils","exports"],function(e,r){"use strict";var t=e.oCreate;function n(e){if(!(this instanceof n)){return new n(e)}var r=Error.call(this,e);if(Error.captureStackTrace){Error.captureStackTrace(this,n)}else{this.stack=r.stack}this.description=r.description;this.fileName=r.fileName;this.lineNumber=r.lineNumber;this.message=r.message||"UnrecognizedURL";this.name="UnrecognizedURLError";this.number=r.number;this.code=r.code}n.prototype=t(Error.prototype);r["default"]=n});n("router/utils",["exports"],function(e){"use strict";var r=Array.prototype.slice;var t;if(!Array.isArray){t=function(e){return Object.prototype.toString.call(e)==="[object Array]"}}else{t=Array.isArray}var n=t;e.isArray=n;function i(e){return(typeof e==="object"&&e!==null||typeof e==="function")&&typeof e.then==="function"}e.isPromise=i;function a(e,r){for(var t in r){if(r.hasOwnProperty(t)){e[t]=r[t]}}}var s=Object.create||function(e){function r(){}r.prototype=e;return new r};e.oCreate=s;function o(e){var t=e&&e.length,n,i;if(t&&t>0&&e[t-1]&&e[t-1].hasOwnProperty("queryParams")){i=e[t-1].queryParams;n=r.call(e,0,t-1);return[n,i]}else{return[e,null]}}e.extractQueryParams=o;function l(e){for(var r in e){if(typeof e[r]==="number"){e[r]=""+e[r]}else if(n(e[r])){for(var t=0,i=e[r].length;t<i;t++){e[r][t]=""+e[r][t]}}}}function u(e,r,t){if(!e.log){return}if(arguments.length===3){e.log("Transition #"+r+": "+t)}else{t=r;e.log(t)}}e.log=u;function h(e,t){var n=arguments;return function(i){var a=r.call(n,2);a.push(i);return t.apply(e,a)}}e.bind=h;function f(e){return typeof e==="string"||e instanceof String||typeof e==="number"||e instanceof Number}function d(e,r){for(var t=0,n=e.length;t<n&&false!==r(e[t]);t++){}}e.forEach=d;function c(e,r,t,n){if(e.triggerEvent){e.triggerEvent(r,t,n);return}var i=n.shift();if(!r){if(t){return}throw new Error("Could not trigger event '"+i+"'. There are no active handlers")}var a=false;function s(e,r,t){t.events[e].apply(t,r)}for(var o=r.length-1;o>=0;o--){var l=r[o],u=l.handler;if(!u){l.handlerPromise.then(h(null,s,i,n));continue}if(u.events&&u.events[i]){if(u.events[i].apply(u,n)===true){a=true}else{return}}}if(i==="error"&&n[0].name==="UnrecognizedURLError"){throw n[0]}else if(!a&&!t){throw new Error("Nothing handled the event '"+i+"'.")}}e.trigger=c;function v(e,r){var t;var i={all:{},changed:{},removed:{}};a(i.all,r);var s=false;l(e);l(r);for(t in e){if(e.hasOwnProperty(t)){if(!r.hasOwnProperty(t)){s=true;i.removed[t]=e[t]}}}for(t in r){if(r.hasOwnProperty(t)){if(n(e[t])&&n(r[t])){if(e[t].length!==r[t].length){i.changed[t]=r[t];s=true}else{for(var o=0,u=e[t].length;o<u;o++){if(e[t][o]!==r[t][o]){i.changed[t]=r[t];s=true}}}}else{if(e[t]!==r[t]){i.changed[t]=r[t];s=true}}}}return s&&i}e.getChangelist=v;function m(e){return"Router: "+e}e.promiseLabel=m;function p(e,r){function t(r){e.call(this,r||{})}t.prototype=s(e.prototype);a(t.prototype,r);return t}e.subclass=p;function g(e,r){if(!e){return}var t="_"+r;return e[t]&&t||e[r]&&r}function y(e,r,t,n){var i=g(e,r);return i&&e[i].call(e,t,n)}function b(e,r,t){var n=g(e,r);if(n){if(t.length===0){return e[n].call(e)}else if(t.length===1){return e[n].call(e,t[0])}else if(t.length===2){return e[n].call(e,t[0],t[1])}else{return e[n].apply(e,t)}}}e.merge=a;e.slice=r;e.isParam=f;e.coerceQueryParamsToString=l;e.callHook=y;e.resolveHook=g;e.applyHook=b});n("router",["./router/router","./router/transition","exports"],function(e,r,t){"use strict";var n=e["default"];var i=r.Transition;t["default"]=n;t.Transition=i});n("route-recognizer",[],function(){return{"default":t}});n("rsvp",[],function(){return r});n("rsvp/promise",[],function(){return{"default":r.Promise}});window.Router=i("router")})(window,window.RSVP,window.RouteRecognizer); | ||
(function(e,r,t){var n,a,i,s;(function(){var e={},r={};n=function(r,t,n){e[r]={deps:t,callback:n}};s=i=a=function(t){if(r[t]){return r[t]}r[t]={};if(!e[t]){throw new Error("Could not find module "+t)}var n=e[t],i=n.deps,s=n.callback,o=[],l;for(var u=0,h=i.length;u<h;u++){if(i[u]==="exports"){o.push(l={})}else{o.push(a(d(i[u])))}}var f=s.apply(this,o);return r[t]=l||f;function d(e){if(e.charAt(0)!=="."){return e}var r=e.split("/");var n=t.split("/").slice(0,-1);for(var a=0,i=r.length;a<i;a++){var s=r[a];if(s===".."){n.pop()}else if(s==="."){continue}else{n.push(s)}}return n.join("/")}}})();n("router/handler-info",["./utils","rsvp","exports"],function(e,r,t){"use strict";var n=e.bind;var a=e.merge;var i=e.promiseLabel;var s=e.applyHook;var o=e.isPromise;var l=r.Promise;var u=Object.freeze({});function h(e){var r=e||{};this._handler=u;if(r.handler){var t=r.name;this.handlerPromise=l.resolve(r.handler);if(o(r.handler)){this.handlerPromise=this.handlerPromise.then(n(this,this.updateHandler));r.handler=undefined}else if(r.handler){r.handler._handlerName=t}}a(this,r);this.initialize(r)}h.prototype={name:null,getHandler:function(){},fetchHandler:function(){var e=this.getHandler(this.name);this.handlerPromise=l.resolve(e);if(o(e)){this.handlerPromise=this.handlerPromise.then(n(this,this.updateHandler))}else if(e){e._handlerName=this.name;return this.handler=e}return this.handler=undefined},_handlerPromise:undefined,params:null,context:null,factory:null,initialize:function(){},log:function(e,r){if(e.log){e.log(this.name+": "+r)}},promiseLabel:function(e){return i("'"+this.name+"' "+e)},getUnresolved:function(){return this},serialize:function(){return this.params||{}},updateHandler:function(e){e._handlerName=this.name;return this.handler=e},resolve:function(e,r){var t=n(this,this.checkForAbort,e),a=n(this,this.runBeforeModelHook,r),i=n(this,this.getModel,r),s=n(this,this.runAfterModelHook,r),o=n(this,this.becomeResolved,r),u=this;return l.resolve(this.handlerPromise,this.promiseLabel("Start handler")).then(function(e){return l.resolve(e).then(t,null,u.promiseLabel("Check for abort")).then(a,null,u.promiseLabel("Before model")).then(t,null,u.promiseLabel("Check if aborted during 'beforeModel' hook")).then(i,null,u.promiseLabel("Model")).then(t,null,u.promiseLabel("Check if aborted in 'model' hook")).then(s,null,u.promiseLabel("After model")).then(t,null,u.promiseLabel("Check if aborted in 'afterModel' hook")).then(o,null,u.promiseLabel("Become resolved"))},function(e){throw e})},runBeforeModelHook:function(e){if(e.trigger){e.trigger(true,"willResolveModel",e,this.handler)}return this.runSharedModelHook(e,"beforeModel",[])},runAfterModelHook:function(e,r){var t=this.name;this.stashResolvedModel(e,r);return this.runSharedModelHook(e,"afterModel",[r]).then(function(){return e.resolvedModels[t]},null,this.promiseLabel("Ignore fulfillment value and return model value"))},runSharedModelHook:function(e,r,t){this.log(e,"calling "+r+" hook");if(this.queryParams){t.push(this.queryParams)}t.push(e);var n=s(this.handler,r,t);if(n&&n.isTransition){n=null}return l.resolve(n,this.promiseLabel("Resolve value returned from one of the model hooks"))},getModel:null,checkForAbort:function(e,r){return l.resolve(e(),this.promiseLabel("Check for abort")).then(function(){return r},null,this.promiseLabel("Ignore fulfillment value and continue"))},stashResolvedModel:function(e,r){e.resolvedModels=e.resolvedModels||{};e.resolvedModels[this.name]=r},becomeResolved:function(e,r){var t=this.serialize(r);if(e){this.stashResolvedModel(e,r);e.params=e.params||{};e.params[this.name]=t}return this.factory("resolved",{context:r,name:this.name,handler:this.handler,params:t})},shouldSupercede:function(e){if(!e){return true}var r=e.context===this.context;return e.name!==this.name||this.hasOwnProperty("context")&&!r||this.hasOwnProperty("params")&&!f(this.params,e.params)}};Object.defineProperty(h.prototype,"handler",{get:function(){if(this._handler!==u){return this._handler}return this.fetchHandler()},set:function(e){return this._handler=e}});Object.defineProperty(h.prototype,"handlerPromise",{get:function(){if(this._handlerPromise){return this._handlerPromise}this.fetchHandler();return this._handlerPromise},set:function(e){return this._handlerPromise=e}});function f(e,r){if(!e^!r){return false}if(!e){return true}for(var t in e){if(e.hasOwnProperty(t)&&e[t]!==r[t]){return false}}return true}t["default"]=h});n("router/handler-info/factory",["./resolved-handler-info","./unresolved-handler-info-by-object","./unresolved-handler-info-by-param","exports"],function(e,r,t,n){"use strict";var a=e["default"];var i=r["default"];var s=t["default"];o.klasses={resolved:a,param:s,object:i};function o(e,r){var t=o.klasses[e],n=new t(r||{});n.factory=o;return n}n["default"]=o});n("router/handler-info/resolved-handler-info",["../handler-info","../utils","rsvp","exports"],function(e,r,t,n){"use strict";var a=e["default"];var i=r.subclass;var s=t.Promise;var o=i(a,{resolve:function(e,r){if(r&&r.resolvedModels){r.resolvedModels[this.name]=this.context}return s.resolve(this,this.promiseLabel("Resolve"))},getUnresolved:function(){return this.factory("param",{name:this.name,handler:this.handler,params:this.params})},isResolved:true});n["default"]=o});n("router/handler-info/unresolved-handler-info-by-object",["../handler-info","../utils","rsvp","exports"],function(e,r,t,n){"use strict";var a=e["default"];var i=r.subclass;var s=r.isParam;var o=t.Promise;var l=i(a,{getModel:function(e){this.log(e,this.name+": resolving provided model");return o.resolve(this.context)},initialize:function(e){this.names=e.names||[];this.context=e.context},serialize:function(e){var r=e||this.context,t=this.names,n=this.serializer||this.handler&&this.handler.serialize;var a={};if(s(r)){a[t[0]]=r;return a}if(n){return n(r,t)}if(t.length!==1){return}var i=t[0];if(/_id$/.test(i)){a[i]=r.id}else{a[i]=r}return a}});n["default"]=l});n("router/handler-info/unresolved-handler-info-by-param",["../handler-info","../utils","exports"],function(e,r,t){"use strict";var n=e["default"];var a=r.resolveHook;var i=r.merge;var s=r.subclass;var o=s(n,{initialize:function(e){this.params=e.params||{}},getModel:function(e){var r=this.params;if(e&&e.queryParams){r={};i(r,this.params);r.queryParams=e.queryParams}var t=this.handler;var n=a(t,"deserialize")||a(t,"model");return this.runSharedModelHook(e,n,[r])}});t["default"]=o});n("router/router",["route-recognizer","rsvp","./utils","./transition-state","./transition","./transition-aborted-error","./transition-intent/named-transition-intent","./transition-intent/url-transition-intent","exports"],function(e,r,t,n,a,i,s,o,l){"use strict";var u=e["default"];var h=r.Promise;var f=t.trigger;var d=t.log;var c=t.slice;var v=t.forEach;var m=t.merge;var p=t.extractQueryParams;var g=t.getChangelist;var y=t.promiseLabel;var b=t.callHook;var P=n["default"];var I=a.logAbort;var w=a.Transition;var x=i["default"];var T=s["default"];var H=o["default"];var q=Array.prototype.pop;function k(e){var r=e||{};this.getHandler=r.getHandler||this.getHandler;this.getSerializer=r.getSerializer||this.getSerializer;this.updateURL=r.updateURL||this.updateURL;this.replaceURL=r.replaceURL||this.replaceURL;this.didTransition=r.didTransition||this.didTransition;this.willTransition=r.willTransition||this.willTransition;this.delegate=r.delegate||this.delegate;this.triggerEvent=r.triggerEvent||this.triggerEvent;this.log=r.log||this.log;this.dslCallBacks=[];this.state=undefined;this.activeTransition=undefined;this._changedQueryParams=undefined;this.oldState=undefined;this.currentHandlerInfos=undefined;this.state=undefined;this.currentSequence=0;this.recognizer=new u;this.reset()}function L(e,r){var t=!!this.activeTransition;var n=t?this.activeTransition.state:this.state;var a;var i=e.applyToState(n,this.recognizer,this.getHandler,r,this.getSerializer);var s=g(n.queryParams,i.queryParams);if(O(i.handlerInfos,n.handlerInfos)){if(s){a=this.queryParamsTransition(s,t,n,i);if(a){a.queryParamsOnly=true;return a}}return this.activeTransition||new w(this)}if(r){R(this,i);return}a=new w(this,e,i,undefined,this.activeTransition);if(U(i.handlerInfos,n.handlerInfos)){a.queryParamsOnly=true}if(this.activeTransition){this.activeTransition.abort()}this.activeTransition=a;a.promise=a.promise.then(function(e){return C(a,e.state)},null,y("Settle transition promise when transition is finalized"));if(!t){N(this,i,a)}z(this,i,s);return a}k.prototype={map:function(e){this.recognizer.delegate=this.delegate;this.recognizer.map(e,function(e,r){for(var t=r.length-1,n=true;t>=0&&n;--t){var a=r[t];e.add(r,{as:a.handler});n=a.path==="/"||a.path===""||a.handler.slice(-6)===".index"}})},hasRoute:function(e){return this.recognizer.hasRoute(e)},getHandler:function(){},getSerializer:function(){},queryParamsTransition:function(e,r,t,n){var a=this;z(this,n,e);if(!r&&this.activeTransition){return this.activeTransition}else{var i=new w(this);i.queryParamsOnly=true;t.queryParams=_(this,n.handlerInfos,n.queryParams,i);i.promise=i.promise.then(function(e){M(i,t,true);if(a.didTransition){a.didTransition(a.currentHandlerInfos)}return e},null,y("Transition complete"));return i}},transitionByIntent:function(e){try{return L.apply(this,arguments)}catch(r){return new w(this,e,null,r)}},reset:function(){if(this.state){v(this.state.handlerInfos.slice().reverse(),function(e){var r=e.handler;b(r,"exit")})}this.oldState=undefined;this.state=new P;this.currentHandlerInfos=null},activeTransition:null,handleURL:function(e){var r=c.call(arguments);if(e.charAt(0)!=="/"){r[0]="/"+e}return E(this,r).method(null)},updateURL:function(){throw new Error("updateURL is not implemented")},replaceURL:function(e){this.updateURL(e)},transitionTo:function(){return E(this,arguments)},intermediateTransitionTo:function(){return E(this,arguments,true)},refresh:function(e){var r=this.activeTransition?this.activeTransition.state:this.state;var t=r.handlerInfos;var n={};for(var a=0,i=t.length;a<i;++a){var s=t[a];n[s.name]=s.params||{}}d(this,"Starting a refresh transition");var o=new T({name:t[t.length-1].name,pivotHandler:e||t[0].handler,contexts:[],queryParams:this._changedQueryParams||r.queryParams||{}});return this.transitionByIntent(o,false)},replaceWith:function(){return E(this,arguments).method("replace")},generate:function(e){var r=p(c.call(arguments,1)),t=r[0],n=r[1];var a=new T({name:e,contexts:t});var i=a.applyToState(this.state,this.recognizer,this.getHandler,null,this.getSerializer);var s={};for(var o=0,l=i.handlerInfos.length;o<l;++o){var u=i.handlerInfos[o];var h=u.serialize();m(s,h)}s.queryParams=n;return this.recognizer.generate(e,s)},applyIntent:function(e,r){var t=new T({name:e,contexts:r});var n=this.activeTransition&&this.activeTransition.state||this.state;return t.applyToState(n,this.recognizer,this.getHandler,null,this.getSerializer)},isActiveIntent:function(e,r,t,n){var a=n||this.state,i=a.handlerInfos,s,o;if(!i.length){return false}var l=i[i.length-1].name;var u=this.recognizer.handlersFor(l);var h=0;for(o=u.length;h<o;++h){s=i[h];if(s.name===e){break}}if(h===u.length){return false}var f=new P;f.handlerInfos=i.slice(0,h+1);u=u.slice(0,h+1);var d=new T({name:l,contexts:r});var c=d.applyToHandlers(f,u,this.getHandler,l,true,true,this.getSerializer);var v=O(c.handlerInfos,f.handlerInfos);if(!t||!v){return v}var p={};m(p,t);var y=a.queryParams;for(var b in y){if(y.hasOwnProperty(b)&&p.hasOwnProperty(b)){p[b]=y[b]}}return v&&!g(p,t)},isActive:function(e){var r=p(c.call(arguments,1));return this.isActiveIntent(e,r[0],r[1])},trigger:function(){var e=c.call(arguments);f(this,this.currentHandlerInfos,false,e)},log:null};function z(e,r,t){if(t){e._changedQueryParams=t.all;f(e,r.handlerInfos,true,["queryParamsDidChange",t.changed,t.all,t.removed]);e._changedQueryParams=null}}function R(e,r,t){var n=A(e.state,r);var a,i,s;for(a=0,i=n.exited.length;a<i;a++){s=n.exited[a].handler;delete s.context;b(s,"reset",true,t);b(s,"exit",t)}var o=e.oldState=e.state;e.state=r;var l=e.currentHandlerInfos=n.unchanged.slice();try{for(a=0,i=n.reset.length;a<i;a++){s=n.reset[a].handler;b(s,"reset",false,t)}for(a=0,i=n.updatedContext.length;a<i;a++){S(l,n.updatedContext[a],false,t)}for(a=0,i=n.entered.length;a<i;a++){S(l,n.entered[a],true,t)}}catch(u){e.state=o;e.currentHandlerInfos=o.handlerInfos;throw u}e.state.queryParams=_(e,l,r.queryParams,t)}function S(e,r,t,n){var a=r.handler,i=r.context;function s(a){if(t){b(a,"enter",n)}if(n&&n.isAborted){throw new x}a.context=i;b(a,"contextDidChange");b(a,"setup",i,n);if(n&&n.isAborted){throw new x}e.push(r)}if(!a){r.handlerPromise=r.handlerPromise.then(s)}else{s(a)}return true}function A(e,r){var t=e.handlerInfos;var n=r.handlerInfos;var a={updatedContext:[],exited:[],entered:[],unchanged:[],reset:undefined};var i,s=false,o,l;for(o=0,l=n.length;o<l;o++){var u=t[o],h=n[o];if(!u||u.handler!==h.handler){i=true}if(i){a.entered.push(h);if(u){a.exited.unshift(u)}}else if(s||u.context!==h.context){s=true;a.updatedContext.push(h)}else{a.unchanged.push(u)}}for(o=n.length,l=t.length;o<l;o++){a.exited.unshift(t[o])}a.reset=a.updatedContext.slice();a.reset.reverse();return a}function M(e,r){var t=e.urlMethod;if(!t){return}var n=e.router,a=r.handlerInfos,i=a[a.length-1].name,s={};for(var o=a.length-1;o>=0;--o){var l=a[o];m(s,l.params);if(l.handler.inaccessibleByURL){t=null}}if(t){s.queryParams=e._visibleQueryParams||r.queryParams;var u=n.recognizer.generate(i,s);var h=e.isCausedByInitialTransition;var f=t==="replace"&&!e.isCausedByAbortingTransition;if(h||f){n.replaceURL(u)}else{n.updateURL(u)}}}function C(e,r){try{d(e.router,e.sequence,"Resolved all models on destination route; finalizing transition.");var t=e.router,n=r.handlerInfos;R(t,r,e);if(e.isAborted){t.state.handlerInfos=t.currentHandlerInfos;return h.reject(I(e))}M(e,r,e.intent.url);e.isActive=false;t.activeTransition=null;f(t,t.currentHandlerInfos,true,["didTransition"]);if(t.didTransition){t.didTransition(t.currentHandlerInfos)}d(t,e.sequence,"TRANSITION COMPLETE.");return n[n.length-1].handler}catch(a){if(!((a instanceof x))){var i=e.state.handlerInfos;e.trigger(true,"error",a,e,i[i.length-1].handler);e.abort()}throw a}}function E(e,r,t){var n=r[0]||"/";var a=r[r.length-1];var i={};if(a&&a.hasOwnProperty("queryParams")){i=q.call(r).queryParams}var s;if(r.length===0){d(e,"Updating query params");var o=e.state.handlerInfos;s=new T({name:o[o.length-1].name,contexts:[],queryParams:i})}else if(n.charAt(0)==="/"){d(e,"Attempting URL transition to "+n);s=new H({url:n})}else{d(e,"Attempting transition to "+n);s=new T({name:r[0],contexts:c.call(r,1),queryParams:i})}return e.transitionByIntent(s,t)}function O(e,r){if(e.length!==r.length){return false}for(var t=0,n=e.length;t<n;++t){if(e[t]!==r[t]){return false}}return true}function U(e,r){if(e.length!==r.length){return false}for(var t=0,n=e.length;t<n;++t){if(e[t].name!==r[t].name){return false}if(!j(e[t].params,r[t].params)){return false}}return true}function j(e,r){if(!e&&!r){return true}else if(!e&&!!r||!!e&&!r){return false}var t=Object.keys(e);var n=Object.keys(r);if(t.length!==n.length){return false}for(var a=0,i=t.length;a<i;++a){var s=t[a];if(e[s]!==r[s]){return false}}return true}function _(e,r,t,n){for(var a in t){if(t.hasOwnProperty(a)&&t[a]===null){delete t[a]}}var i=[];f(e,r,true,["finalizeQueryParamChange",t,i,n]);if(n){n._visibleQueryParams={}}var s={};for(var o=0,l=i.length;o<l;++o){var u=i[o];s[u.key]=u.value;if(n&&u.visible!==false){n._visibleQueryParams[u.key]=u.value}}return s}function N(e,r,t){var n=e.state.handlerInfos,a=[],i=null,s,o,l,u,h,d;u=n.length;for(l=0;l<u;l++){h=n[l];d=r.handlerInfos[l];if(!d||h.name!==d.name){i=l;break}if(!d.isResolved){a.push(h)}}if(i!==null){s=n.slice(i,u);o=function(e){for(var r=0,t=s.length;r<t;r++){if(s[r].name===e){return true}}return false}}f(e,n,true,["willTransition",t]);if(e.willTransition){e.willTransition(n,r.handlerInfos,t)}}l["default"]=k});n("router/transition-aborted-error",["./utils","exports"],function(e,r){"use strict";var t=e.oCreate;function n(e){if(!(this instanceof n)){return new n(e)}var r=Error.call(this,e);if(Error.captureStackTrace){Error.captureStackTrace(this,n)}else{this.stack=r.stack}this.description=r.description;this.fileName=r.fileName;this.lineNumber=r.lineNumber;this.message=r.message||"TransitionAborted";this.name="TransitionAborted";this.number=r.number;this.code=r.code}n.prototype=t(Error.prototype);r["default"]=n});n("router/transition-intent",["exports"],function(e){"use strict";function r(e){this.initialize(e);this.data=this.data||{}}r.prototype={initialize:null,applyToState:null};e["default"]=r});n("router/transition-intent/named-transition-intent",["../transition-intent","../transition-state","../handler-info/factory","../utils","exports"],function(e,r,t,n,a){"use strict";var i=e["default"];var s=r["default"];var o=t["default"];var l=n.isParam;var u=n.extractQueryParams;var h=n.merge;var f=n.subclass;a["default"]=f(i,{name:null,pivotHandler:null,contexts:null,queryParams:null,initialize:function(e){this.name=e.name;this.pivotHandler=e.pivotHandler;this.contexts=e.contexts||[];this.queryParams=e.queryParams},applyToState:function(e,r,t,n,a){var i=u([this.name].concat(this.contexts)),s=i[0],o=r.handlersFor(s[0]);var l=o[o.length-1].handler;return this.applyToHandlers(e,o,t,l,n,null,a)},applyToHandlers:function(e,r,t,n,a,i,o){var l,u;var f=new s;var d=this.contexts.slice(0);var c=r.length;if(this.pivotHandler){for(l=0,u=r.length;l<u;++l){if(r[l].handler===this.pivotHandler._handlerName){c=l;break}}}for(l=r.length-1;l>=0;--l){var v=r[l];var m=v.handler;var p=e.handlerInfos[l];var g=null;if(v.names.length>0){if(l>=c){g=this.createParamHandlerInfo(m,t,v.names,d,p)}else{var y=o(m);g=this.getHandlerInfoForDynamicSegment(m,t,v.names,d,p,n,l,y)}}else{g=this.createParamHandlerInfo(m,t,v.names,d,p)}if(i){g=g.becomeResolved(null,g.context);var b=p&&p.context;if(v.names.length>0&&g.context===b){g.params=p&&p.params}g.context=b}var P=p;if(l>=c||g.shouldSupercede(p)){c=Math.min(l,c);P=g}if(a&&!i){P=P.becomeResolved(null,P.context)}f.handlerInfos.unshift(P)}if(d.length>0){throw new Error("More context objects were passed than there are dynamic segments for the route: "+n)}if(!a){this.invalidateChildren(f.handlerInfos,c)}h(f.queryParams,this.queryParams||{});return f},invalidateChildren:function(e,r){for(var t=r,n=e.length;t<n;++t){var a=e[t];e[t]=a.getUnresolved()}},getHandlerInfoForDynamicSegment:function(e,r,t,n,a,i,s,u){var h;if(n.length>0){h=n[n.length-1];if(l(h)){return this.createParamHandlerInfo(e,r,t,n,a)}else{n.pop()}}else if(a&&a.name===e){return a}else{if(this.preTransitionState){var f=this.preTransitionState.handlerInfos[s];h=f&&f.context}else{return a}}return o("object",{name:e,getHandler:r,serializer:u,context:h,names:t})},createParamHandlerInfo:function(e,r,t,n,a){var i={};var s=t.length;while(s--){var u=a&&e===a.name&&a.params||{};var h=n[n.length-1];var f=t[s];if(l(h)){i[f]=""+n.pop()}else{if(u.hasOwnProperty(f)){i[f]=u[f]}else{throw new Error("You didn't provide enough string/numeric parameters to satisfy all of the dynamic segments for route "+e)}}}return o("param",{name:e,getHandler:r,params:i})}})});n("router/transition-intent/url-transition-intent",["../transition-intent","../transition-state","../handler-info/factory","../utils","../unrecognized-url-error","exports"],function(e,r,t,n,a,i){"use strict";var s=e["default"];var o=r["default"];var l=t["default"];var u=n.merge;var h=n.subclass;var f=a["default"];i["default"]=h(s,{url:null,initialize:function(e){this.url=e.url},applyToState:function(e,r,t){var n=new o;var a=r.recognize(this.url),i,s;if(!a){throw new f(this.url)}var h=false;var d=this.url;function c(e){if(e&&e.inaccessibleByURL){throw new f(d)}return e}for(i=0,s=a.length;i<s;++i){var v=a[i];var m=v.handler;var p=l("param",{name:m,getHandler:t,params:v.params});var g=p.handler;if(g){c(g)}else{p.handlerPromise=p.handlerPromise.then(c)}var y=e.handlerInfos[i];if(h||p.shouldSupercede(y)){h=true;n.handlerInfos[i]=p}else{n.handlerInfos[i]=y}}u(n.queryParams,a.queryParams);return n}})});n("router/transition-state",["./utils","rsvp","exports"],function(e,r,t){"use strict";var n=e.forEach;var a=e.promiseLabel;var i=e.callHook;var s=r.Promise;function o(){this.handlerInfos=[];this.queryParams={};this.params={}}o.prototype={promiseLabel:function(e){var r="";n(this.handlerInfos,function(e){if(r!==""){r+="."}r+=e.name});return a("'"+r+"': "+e)},resolve:function(e,r){var t=this.params;n(this.handlerInfos,function(e){t[e.name]=e.params||{}});r=r||{};r.resolveIndex=0;var a=this;var o=false;return s.resolve(null,this.promiseLabel("Start transition")).then(f,null,this.promiseLabel("Resolve handler"))["catch"](u,this.promiseLabel("Handle error"));function l(){return s.resolve(e(),a.promiseLabel("Check if should continue"))["catch"](function(e){o=true;return s.reject(e)},a.promiseLabel("Handle abort"))}function u(e){var t=a.handlerInfos;var n=r.resolveIndex>=t.length?t.length-1:r.resolveIndex;return s.reject({error:e,handlerWithError:a.handlerInfos[n].handler,wasAborted:o,state:a})}function h(e){var t=a.handlerInfos[r.resolveIndex].isResolved;a.handlerInfos[r.resolveIndex++]=e;if(!t){var n=e.handler;i(n,"redirect",e.context,r)}return l().then(f,null,a.promiseLabel("Resolve handler"))}function f(){if(r.resolveIndex===a.handlerInfos.length){return{error:null,state:a}}var e=a.handlerInfos[r.resolveIndex];return e.resolve(l,r).then(h,null,a.promiseLabel("Proceed"))}}};t["default"]=o});n("router/transition",["rsvp","./utils","./transition-aborted-error","exports"],function(e,r,t,n){"use strict";var a=e.Promise;var i=r.trigger;var s=r.slice;var o=r.log;var l=r.promiseLabel;var u=t["default"];function h(e,r,t,n,i){var s=this;this.state=t||e.state;this.intent=r;this.router=e;this.data=this.intent&&this.intent.data||{};this.resolvedModels={};this.queryParams={};this.promise=undefined;this.error=undefined;this.params=undefined;this.handlerInfos=undefined;this.targetName=undefined;this.pivotHandler=undefined;this.sequence=undefined;this.isAborted=false;this.isActive=true;if(n){this.promise=a.reject(n);this.error=n;return}this.isCausedByAbortingTransition=!!i;this.isCausedByInitialTransition=i&&(i.isCausedByInitialTransition||i.sequence===0);if(t){this.params=t.params;this.queryParams=t.queryParams;this.handlerInfos=t.handlerInfos;var o=t.handlerInfos.length;if(o){this.targetName=t.handlerInfos[o-1].name}for(var u=0;u<o;++u){var h=t.handlerInfos[u];if(!h.isResolved){break}this.pivotHandler=h.handler}this.sequence=e.currentSequence++;this.promise=t.resolve(d,this)["catch"](f(s),l("Handle Abort"))}else{this.promise=a.resolve(this.state);this.params={}}function d(){if(s.isAborted){return a.reject(undefined,l("Transition aborted - reject"))}}}function f(e){return function(r){if(r.wasAborted||e.isAborted){return a.reject(d(e))}else{e.trigger("error",r.error,e,r.handlerWithError);e.abort();return a.reject(r.error)}}}h.prototype={targetName:null,urlMethod:"update",intent:null,pivotHandler:null,resolveIndex:0,resolvedModels:null,state:null,queryParamsOnly:false,isTransition:true,isExiting:function(e){var r=this.handlerInfos;for(var t=0,n=r.length;t<n;++t){var a=r[t];if(a.name===e||a.handler===e){return false}}return true},promise:null,data:null,then:function(e,r,t){return this.promise.then(e,r,t)},"catch":function(e,r){return this.promise["catch"](e,r)},"finally":function(e,r){return this.promise["finally"](e,r)},abort:function(){if(this.isAborted){return this}o(this.router,this.sequence,this.targetName+": transition was aborted");this.intent.preTransitionState=this.router.state;this.isAborted=true;this.isActive=false;this.router.activeTransition=null;return this},retry:function(){this.abort();return this.router.transitionByIntent(this.intent,false)},method:function(e){this.urlMethod=e;return this},trigger:function(e){var r=s.call(arguments);if(typeof e==="boolean"){r.shift()}else{e=false}i(this.router,this.state.handlerInfos.slice(0,this.resolveIndex+1),e,r)},followRedirects:function(){var e=this.router;return this.promise["catch"](function(r){if(e.activeTransition){return e.activeTransition.followRedirects()}return a.reject(r)})},toString:function(){return"Transition (sequence "+this.sequence+")"},log:function(e){o(this.router,this.sequence,e)}};h.prototype.send=h.prototype.trigger;function d(e){o(e.router,e.sequence,"detected abort.");return new u}n.Transition=h;n.logAbort=d;n.TransitionAbortedError=u});n("router/unrecognized-url-error",["./utils","exports"],function(e,r){"use strict";var t=e.oCreate;function n(e){if(!(this instanceof n)){return new n(e)}var r=Error.call(this,e);if(Error.captureStackTrace){Error.captureStackTrace(this,n)}else{this.stack=r.stack}this.description=r.description;this.fileName=r.fileName;this.lineNumber=r.lineNumber;this.message=r.message||"UnrecognizedURL";this.name="UnrecognizedURLError";this.number=r.number;this.code=r.code}n.prototype=t(Error.prototype);r["default"]=n});n("router/utils",["exports"],function(e){"use strict";var r=Array.prototype.slice;var t;if(!Array.isArray){t=function(e){return Object.prototype.toString.call(e)==="[object Array]"}}else{t=Array.isArray}var n=t;e.isArray=n;function a(e){return(typeof e==="object"&&e!==null||typeof e==="function")&&typeof e.then==="function"}e.isPromise=a;function i(e,r){for(var t in r){if(r.hasOwnProperty(t)){e[t]=r[t]}}}var s=Object.create||function(e){function r(){}r.prototype=e;return new r};e.oCreate=s;function o(e){var t=e&&e.length,n,a;if(t&&t>0&&e[t-1]&&e[t-1].hasOwnProperty("queryParams")){a=e[t-1].queryParams;n=r.call(e,0,t-1);return[n,a]}else{return[e,null]}}e.extractQueryParams=o;function l(e){for(var r in e){if(typeof e[r]==="number"){e[r]=""+e[r]}else if(n(e[r])){for(var t=0,a=e[r].length;t<a;t++){e[r][t]=""+e[r][t]}}}}function u(e,r,t){if(!e.log){return}if(arguments.length===3){e.log("Transition #"+r+": "+t)}else{t=r;e.log(t)}}e.log=u;function h(e,t){var n=arguments;return function(a){var i=r.call(n,2);i.push(a);return t.apply(e,i)}}e.bind=h;function f(e){return typeof e==="string"||e instanceof String||typeof e==="number"||e instanceof Number}function d(e,r){for(var t=0,n=e.length;t<n&&false!==r(e[t]);t++){}}e.forEach=d;function c(e,r,t,n){if(e.triggerEvent){e.triggerEvent(r,t,n);return}var a=n.shift();if(!r){if(t){return}throw new Error("Could not trigger event '"+a+"'. There are no active handlers")}var i=false;function s(e,r,t){t.events[e].apply(t,r)}for(var o=r.length-1;o>=0;o--){var l=r[o],u=l.handler;if(!u){l.handlerPromise.then(h(null,s,a,n));continue}if(u.events&&u.events[a]){if(u.events[a].apply(u,n)===true){i=true}else{return}}}if(a==="error"&&n[0].name==="UnrecognizedURLError"){throw n[0]}else if(!i&&!t){throw new Error("Nothing handled the event '"+a+"'.")}}e.trigger=c;function v(e,r){var t;var a={all:{},changed:{},removed:{}};i(a.all,r);var s=false;l(e);l(r);for(t in e){if(e.hasOwnProperty(t)){if(!r.hasOwnProperty(t)){s=true;a.removed[t]=e[t]}}}for(t in r){if(r.hasOwnProperty(t)){if(n(e[t])&&n(r[t])){if(e[t].length!==r[t].length){a.changed[t]=r[t];s=true}else{for(var o=0,u=e[t].length;o<u;o++){if(e[t][o]!==r[t][o]){a.changed[t]=r[t];s=true}}}}else{if(e[t]!==r[t]){a.changed[t]=r[t];s=true}}}}return s&&a}e.getChangelist=v;function m(e){return"Router: "+e}e.promiseLabel=m;function p(e,r){function t(r){e.call(this,r||{})}t.prototype=s(e.prototype);i(t.prototype,r);return t}e.subclass=p;function g(e,r){if(!e){return}var t="_"+r;return e[t]&&t||e[r]&&r}function y(e,r,t,n){var a=g(e,r);return a&&e[a].call(e,t,n)}function b(e,r,t){var n=g(e,r);if(n){if(t.length===0){return e[n].call(e)}else if(t.length===1){return e[n].call(e,t[0])}else if(t.length===2){return e[n].call(e,t[0],t[1])}else{return e[n].apply(e,t)}}}e.merge=i;e.slice=r;e.isParam=f;e.coerceQueryParamsToString=l;e.callHook=y;e.resolveHook=g;e.applyHook=b});n("router",["./router/router","./router/transition","exports"],function(e,r,t){"use strict";var n=e["default"];var a=r.Transition;t["default"]=n;t.Transition=a});n("route-recognizer",[],function(){return{"default":t}});n("rsvp",[],function(){return r});n("rsvp/promise",[],function(){return{"default":r.Promise}});window.Router=a("router")})(window,window.RSVP,window.RouteRecognizer); |
@@ -50,2 +50,3 @@ import RouteRecognizer from 'route-recognizer'; | ||
if (newTransition) { | ||
newTransition.queryParamsOnly = true; | ||
return newTransition; | ||
@@ -67,2 +68,8 @@ } | ||
// transition is to same route with same params, only query params differ. | ||
// not caught above probably because refresh() has been used | ||
if ( handlerInfosSameExceptQueryParams(newState.handlerInfos, oldState.handlerInfos ) ) { | ||
newTransition.queryParamsOnly = true; | ||
} | ||
// Abort and usurp any previously active transition. | ||
@@ -777,2 +784,46 @@ if (this.activeTransition) { | ||
function handlerInfosSameExceptQueryParams(handlerInfos, otherHandlerInfos) { | ||
if (handlerInfos.length !== otherHandlerInfos.length) { | ||
return false; | ||
} | ||
for (var i = 0, len = handlerInfos.length; i < len; ++i) { | ||
if (handlerInfos[i].name !== otherHandlerInfos[i].name) { | ||
return false; | ||
} | ||
if (!paramsEqual(handlerInfos[i].params, otherHandlerInfos[i].params)) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
function paramsEqual(params, otherParams) { | ||
if (!params && !otherParams) { | ||
return true; | ||
} else if (!params && !!otherParams || !!params && !otherParams) { | ||
// one is falsy but other is not; | ||
return false; | ||
} | ||
var keys = Object.keys(params); | ||
var otherKeys = Object.keys(otherParams); | ||
if (keys.length !== otherKeys.length) { | ||
return false; | ||
} | ||
for (var i = 0, len = keys.length; i < len; ++i) { | ||
var key = keys[i]; | ||
if ( params[key] !== otherParams[key] ) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
function finalizeQueryParamChange(router, resolvedHandlers, newQueryParams, transition) { | ||
@@ -779,0 +830,0 @@ // We fire a finalizeQueryParamChange event which |
{ | ||
"name": "router_js", | ||
"namespace": "Router", | ||
"version": "1.2.5", | ||
"version": "1.2.6", | ||
"description": "A lightweight JavaScript library is built on top of route-recognizer and rsvp.js to provide an API for handling routes", | ||
@@ -6,0 +6,0 @@ "author": "Tilde, Inc.", |
@@ -160,2 +160,57 @@ import { module, test, flushBackburner, transitionTo } from "tests/test_helpers"; | ||
test("Refreshing the route when changing only query params should correctly set queryParamsOnly", function(assert) { | ||
assert.expect(10); | ||
var initialTransition = true; | ||
handlers.index = { | ||
events: { | ||
finalizeQueryParamChange: function(params, finalParams, transition) { | ||
if (initialTransition) { | ||
assert.notOk(transition.queryParamsOnly, 'should not be query params only transition'); | ||
initialTransition = false; | ||
} else { | ||
assert.ok(transition.queryParamsOnly, 'should be query params only transition'); | ||
} | ||
}, | ||
queryParamsDidChange: function() { | ||
router.refresh(); | ||
} | ||
} | ||
}; | ||
handlers.child = { | ||
events: { | ||
finalizeQueryParamChange: function(params, finalParams, transition) { | ||
assert.notOk(transition.queryParamsOnly, 'should be normal transition'); | ||
return true; | ||
}, | ||
} | ||
}; | ||
var transition = transitionTo(router, '/index'); | ||
assert.notOk(transition.queryParamsOnly, "Initial transition is not query params only transition"); | ||
transition = transitionTo(router, '/index?foo=123'); | ||
assert.ok(transition.queryParamsOnly, "Second transition with updateURL intent is query params only"); | ||
transition = router.replaceWith('/index?foo=456'); | ||
flushBackburner(); | ||
assert.ok(transition.queryParamsOnly, "Third transition with replaceURL intent is query params only"); | ||
transition = transitionTo(router, '/parent/child?foo=789'); | ||
assert.notOk(transition.queryParamsOnly, "Fourth transition with transtionTo intent is not query params only"); | ||
transition = transitionTo(router, '/parent/child?foo=901'); | ||
assert.ok(transition.queryParamsOnly, "Firth transition with transtionTo intent is query params only"); | ||
transition = transitionTo(router, '/index?foo=123'); | ||
assert.notOk(transition.queryParamsOnly, "Firth transition with transtionTo intent is not query params only"); | ||
}); | ||
test("a handler can opt into a full-on transition by calling refresh", function(assert) { | ||
@@ -162,0 +217,0 @@ assert.expect(3); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
744861
19070