Skip to content
This repository has been archived by the owner on Sep 20, 2020. It is now read-only.

Commit

Permalink
release 0.1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
christopherthielen committed Oct 5, 2016
1 parent 897fd46 commit 1a3d7c0
Show file tree
Hide file tree
Showing 16 changed files with 85 additions and 55 deletions.
53 changes: 34 additions & 19 deletions release/ct-ui-router-extras.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* UI-Router Extras: Sticky states, Future States, Deep State Redirect, Transition promise
* Monolithic build (all modules)
* @version 0.1.2
* @version 0.1.3
* @link http://christopherthielen.github.io/ui-router-extras/
* @license MIT License, http://www.opensource.org/licenses/MIT
*/
Expand Down Expand Up @@ -201,7 +201,7 @@ angular.module('ct.ui.router.extras.dsr', [ 'ct.ui.router.extras.core' ]).config
$provide.decorator("$state", ['$delegate', '$q', function ($state, $q) {
$state_transitionTo = $state.transitionTo;
$state.transitionTo = function (to, toParams, options) {
if (options.ignoreDsr) {
if (options && options.ignoreDsr) {
ignoreDsr = options.ignoreDsr;
}

Expand Down Expand Up @@ -333,7 +333,12 @@ angular.module('ct.ui.router.extras.dsr').service("$deepStateRedirect", [ '$root
computeDeepStateStatus(state)
var cfg = getConfig(state);
var key = getParamsString(params, cfg.params);
var redirect = lastSubstate[state.name][key] || cfg['default'];
var redirect = lastSubstate[state.name];
if (redirect && redirect[key]) {
redirect = redirect[key];
} else {
redirect = cfg['default'];
}
return redirect;
},
reset: function(stateOrName, params) {
Expand Down Expand Up @@ -511,10 +516,13 @@ function $StickyStateProvider($stateProvider, uirextras_coreProvider) {
};
}

function sortByStateDepth(a,b) {
return a.name.split(".").length - b.name.split(".").length;
}

var stickySupport = {
getInactiveStates: function () {
return map(inactiveStates, angular.identity);
return map(inactiveStates, angular.identity).sort(sortByStateDepth);
},
getInactiveStatesByParent: function () {
return mapInactives();
Expand All @@ -532,7 +540,7 @@ function $StickyStateProvider($stateProvider, uirextras_coreProvider) {
// }
processTransition: function (transition) {
var treeChanges = calcTreeChanges(transition);
var currentInactives = map(inactiveStates, angular.identity);
var currentInactives = stickySupport.getInactiveStates();
var futureInactives, exitingTypes, enteringTypes;
var keep = treeChanges.keep;

Expand Down Expand Up @@ -620,7 +628,7 @@ function $StickyStateProvider($stateProvider, uirextras_coreProvider) {
.reduce(flattenReduce, [])
.concat(orphanedRoots)
// Sort by depth to exit orphans in proper order
.sort(function (a,b) { return a.name.split(".").length - b.name.split(".").length; });
.sort(sortByStateDepth);

// Add them to the list of states being exited.
var exitOrOrphaned = exitingTypes
Expand All @@ -634,7 +642,8 @@ function $StickyStateProvider($stateProvider, uirextras_coreProvider) {
futureInactives = currentInactives
.filter(notIn(exitOrOrphaned))
.filter(notIn(treeChanges.entering))
.concat(exitingTypes.filter(typeIs("inactivate")).map(prop("state")));
.concat(exitingTypes.filter(typeIs("inactivate")).map(prop("state")))
.sort(sortByStateDepth);

return {
keep: keep,
Expand Down Expand Up @@ -1254,30 +1263,36 @@ angular.module("ct.ui.router.extras.sticky").config(
return s.self.name;
}));

var viewMsg = function (local, name) {
return "'" + name + "' (" + local.$$state.name + ")";
};
var statesOnly = function (local, name) {
return name != 'globals' && name != 'resolve';
};

var viewsForState = function (state) {
var views = map(filterObj(state.locals, statesOnly), viewMsg).join(", ");
return "(" + (state.self.name ? state.self.name : "root") + ".locals" + (views.length ? ": " + views : "") + ")";
var viewLocals = filterObj(state.locals, statesOnly);

if (!Object.keys(viewLocals).length) {
viewLocals[''] = { $$state: { name: null } };
}

return map(viewLocals, function(local, name) {
return {
localsFor: state.self.name ? state.self.name : "(root)",
uiViewName: name || null,
filledByState: local.$$state.name
};
});
};

var message = viewsForState(currentState);
var viewsByState = viewsForState(currentState);
var parent = currentState.parent;
while (parent && parent !== currentState) {
if (parent.self.name === "") {
// Show the __inactives before showing root state.
message = viewsForState($state.$current.path[0]) + " / " + message;
}
message = viewsForState(parent) + " / " + message;
viewsByState = viewsByState.concat(viewsForState(parent));
currentState = parent;
parent = currentState.parent;
}

$log.debug("Views: " + message);
$log.debug("Views active on each state:");
console.table(viewsByState.reverse());
}
}
]
Expand Down
4 changes: 2 additions & 2 deletions release/ct-ui-router-extras.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion release/modular/ct-ui-router-extras.core.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* UI-Router Extras: Sticky states, Future States, Deep State Redirect, Transition promise
* Module: core
* @version 0.1.2
* @version 0.1.3
* @link http://christopherthielen.github.io/ui-router-extras/
* @license MIT License, http://www.opensource.org/licenses/MIT
*/
Expand Down
2 changes: 1 addition & 1 deletion release/modular/ct-ui-router-extras.core.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 8 additions & 3 deletions release/modular/ct-ui-router-extras.dsr.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* UI-Router Extras: Sticky states, Future States, Deep State Redirect, Transition promise
* Module: dsr
* @version 0.1.2
* @version 0.1.3
* @link http://christopherthielen.github.io/ui-router-extras/
* @license MIT License, http://www.opensource.org/licenses/MIT
*/
Expand All @@ -19,7 +19,7 @@ angular.module('ct.ui.router.extras.dsr', [ 'ct.ui.router.extras.core' ]).config
$provide.decorator("$state", ['$delegate', '$q', function ($state, $q) {
$state_transitionTo = $state.transitionTo;
$state.transitionTo = function (to, toParams, options) {
if (options.ignoreDsr) {
if (options && options.ignoreDsr) {
ignoreDsr = options.ignoreDsr;
}

Expand Down Expand Up @@ -151,7 +151,12 @@ angular.module('ct.ui.router.extras.dsr').service("$deepStateRedirect", [ '$root
computeDeepStateStatus(state)
var cfg = getConfig(state);
var key = getParamsString(params, cfg.params);
var redirect = lastSubstate[state.name][key] || cfg['default'];
var redirect = lastSubstate[state.name];
if (redirect && redirect[key]) {
redirect = redirect[key];
} else {
redirect = cfg['default'];
}
return redirect;
},
reset: function(stateOrName, params) {
Expand Down
4 changes: 2 additions & 2 deletions release/modular/ct-ui-router-extras.dsr.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion release/modular/ct-ui-router-extras.future.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* UI-Router Extras: Sticky states, Future States, Deep State Redirect, Transition promise
* Module: future
* @version 0.1.2
* @version 0.1.3
* @link http://christopherthielen.github.io/ui-router-extras/
* @license MIT License, http://www.opensource.org/licenses/MIT
*/
Expand Down
2 changes: 1 addition & 1 deletion release/modular/ct-ui-router-extras.future.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion release/modular/ct-ui-router-extras.previous.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* UI-Router Extras: Sticky states, Future States, Deep State Redirect, Transition promise
* Module: previous
* @version 0.1.2
* @version 0.1.3
* @link http://christopherthielen.github.io/ui-router-extras/
* @license MIT License, http://www.opensource.org/licenses/MIT
*/
Expand Down
2 changes: 1 addition & 1 deletion release/modular/ct-ui-router-extras.previous.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion release/modular/ct-ui-router-extras.statevis.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* UI-Router Extras: Sticky states, Future States, Deep State Redirect, Transition promise
* Module: statevis
* @version 0.1.2
* @version 0.1.3
* @link http://christopherthielen.github.io/ui-router-extras/
* @license MIT License, http://www.opensource.org/licenses/MIT
*/
Expand Down
Loading

0 comments on commit 1a3d7c0

Please sign in to comment.