diff --git a/CHANGELOG.md b/CHANGELOG.md index 55c1a95..8ff787e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,16 @@ + +### 0.0.13 (2015-02-02) + +This release comes 2 days after 0.0.12 and fixes a couple of bugs + +#### Bug Fixes + +* **future:** fix modular build of futurestates ([abfdc34d](https://github.com/christopherthielen/ui-router-extras/commit/abfdc34d41afea34ca8cccd3db5f81bb3a856eb4), closes [#151](https://github.com/christopherthielen/ui-router-extras/issues/151)) +* **statevis:** add dep from statevis to sticky ([1a488d84](https://github.com/christopherthielen/ui-router-extras/commit/1a488d84257060868f3c70b6ef7305f4936212eb), closes [#153](https://github.com/christopherthielen/ui-router-extras/issues/153)) +* **sticky:** Fix modular sticky states build ([21d1d129](https://github.com/christopherthielen/ui-router-extras/commit/21d1d129963b8bfc724823f93ca0efc32868ec77), closes [#154](https://github.com/christopherthielen/ui-router-extras/issues/154)) +* **transition:** transition promise now resolved correctly ([598452ed](https://github.com/christopherthielen/ui-router-extras/commit/598452ed5bae76b8add8707794740993d3242011), closes [#152](https://github.com/christopherthielen/ui-router-extras/issues/152)) + + ### 0.0.12 (2015-01-31) diff --git a/banners.json b/banners.json new file mode 100644 index 0000000..41d2948 --- /dev/null +++ b/banners.json @@ -0,0 +1,14 @@ +{ + "banner": [ + "/**\n", + " * UI-Router Extras: Sticky states, Future States, Deep State Redirect, Transition promise", + " * <%= module %>", + " * @version <%= pkg.version %>", + " * @link http://christopherthielen.github.io/ui-router-extras/", + " * @license MIT License, http://www.opensource.org/licenses/MIT", + " */" + ], + "minbanner": [ + "/** UI-Router Extras v.<%= pkg.version %> <%= module %> http://christopherthielen.github.io/ui-router-extras/ - MIT License */" + ] +} \ No newline at end of file diff --git a/bower.json b/bower.json index e29b7b1..063a586 100644 --- a/bower.json +++ b/bower.json @@ -1,8 +1,8 @@ { "name": "ui-router-extras", - "version": "0.0.12", + "version": "0.0.13", "authors": [ - "Chris Thielen " + "Chris Thielen " ], "description": "Extras for UI-Router including: Sticky States (a.k.a. parallel states), Deep State Redirect (for tab-like navigation), Future States (async state definition), Previous State ", "keywords": [ diff --git a/files.js b/files.js index 319dd94..f58a437 100644 --- a/files.js +++ b/files.js @@ -20,10 +20,9 @@ var modules = _(moduleNames) // sticky states has two src files modules.sticky.src = ['src/stickyProvider.js'].concat(modules.sticky.src); modules.core.src.push('src/util.js'); + modules.future.test.push('src/fsfactories/ngload.js'); modules.future.test.push('src/fsfactories/iframe.js'); -modules.statevis.test.push('build/modular/ct-ui-router-extras.sticky.js'); -modules.previous.test.push('build/modular/ct-ui-router-extras.transition.js'); // Build the monolithic module 'all' which sucks in all the others modules.all = { @@ -38,6 +37,9 @@ modules.all = { dest: 'build' }; +modules.statevis.test.push('build/modular/ct-ui-router-extras.sticky.js'); +modules.previous.test.push('build/modular/ct-ui-router-extras.transition.js'); + var otherFiles = { testUtil: [ 'test/testUtil.js', 'bower_components/lodash/dist/lodash.js'], diff --git a/gulpfile.js b/gulpfile.js index 1e2984b..2c26110 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -8,18 +8,9 @@ var gulp = require('gulp'), _ = require('lodash'), notify = require('gulp-notify'), uirExtrasModules = require('./files'), + banners = require('./banners.json'), pkg = require('./package.json'); - -var banner = "" + - "/**\n" + - " * UI-Router Extras: Sticky states, Future States, Deep State Redirect, Transition promise\n" + - " * <%= module %>\n" + - " * @version <%= pkg.version %>\n" + - " * @link http://christopherthielen.github.io/ui-router-extras/\n" + - " * @license MIT License, http://www.opensource.org/licenses/MIT\n" + - " */"; -var minbanner = "/** UI-Router Extras v.<%= pkg.version %> <%= module %> http://christopherthielen.github.io/ui-router-extras/ - MIT License */\n"; // Scripts gulp.task('scripts', ['clean'], function() { var jshint = require('gulp-jshint'), @@ -35,12 +26,12 @@ gulp.task('scripts', ['clean'], function() { .pipe(jshint.reporter('default')) .pipe(concat(module.dist)) .pipe(wrap('(function(angular, undefined){\n"use strict";\n<%= contents %>\n})(angular);')) - .pipe(wrap(banner + '\n<%= contents %>\n', { pkg: pkg, module: description })) + .pipe(wrap(banners.banner.join("\n") + '\n<%= contents %>\n', { pkg: pkg, module: description })) // .pipe(wrap('/* ' + module.dist + ' v.' + pkg.version + '*/\n<%= contents %>\n', { pkg: pkg, module: module })) .pipe(gulp.dest(module.dest)) .pipe(rename({ suffix: '.min' })) .pipe(uglify()) - .pipe(wrap(minbanner + '\n<%= contents %>\n', { pkg: pkg, module: description })) + .pipe(wrap(banners.minbanner.join("\n") + '\n<%= contents %>\n', { pkg: pkg, module: description })) .pipe(gulp.dest(module.dest)) .pipe(notify({message: 'built ' + module.module})) ; diff --git a/package.json b/package.json index e53aa2c..7e21642 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "author": "Christopher Thielen", "name": "ui-router-extras", - "version": "0.0.12", + "version": "0.0.13", "description": "UI-Router Extras: Sticky states, Future States, Deep State Redirect, Transition promise", "homepage": "http://christopherthielen.github.io/ui-router-extras/", "dependencies": {}, diff --git a/release/ct-ui-router-extras.js b/release/ct-ui-router-extras.js index 0490e34..7252502 100644 --- a/release/ct-ui-router-extras.js +++ b/release/ct-ui-router-extras.js @@ -1,3 +1,11 @@ +/** + + * UI-Router Extras: Sticky states, Future States, Deep State Redirect, Transition promise + * Monolithic build (all modules) + * @version 0.0.13 + * @link http://christopherthielen.github.io/ui-router-extras/ + * @license MIT License, http://www.opensource.org/licenses/MIT + */ (function(angular, undefined){ "use strict"; var mod_core = angular.module("ct.ui.router.extras.core", [ "ui.router" ]); @@ -337,8 +345,13 @@ angular.module("ct.ui.router.extras.sticky", [ 'ct.ui.router.extras.core' ]); var mod_sticky = angular.module("ct.ui.router.extras.sticky"); -$StickyStateProvider.$inject = [ '$stateProvider' ]; -function $StickyStateProvider($stateProvider) { +$StickyStateProvider.$inject = [ '$stateProvider', 'uirextras_coreProvider' ]; +function $StickyStateProvider($stateProvider, uirextras_coreProvider) { + var core = uirextras_coreProvider; + var inheritParams = core.inheritParams; + var protoKeys = core.protoKeys; + var map = core.map; + // Holds all the states which are inactivated. Inactivated states can be either sticky states, or descendants of sticky states. var inactiveStates = {}; // state.name -> (state) var stickyStates = {}; // state.name -> true @@ -721,7 +734,12 @@ angular.module("ct.ui.router.extras.sticky").run(["$stickyState", function ($sti angular.module("ct.ui.router.extras.sticky").config( [ "$provide", "$stateProvider", '$stickyStateProvider', '$urlMatcherFactoryProvider', 'uirextras_coreProvider', function ($provide, $stateProvider, $stickyStateProvider, $urlMatcherFactoryProvider, uirextras_coreProvider) { - var internalStates = uirextras_coreProvider.internalStates; + var core = uirextras_coreProvider; + var internalStates = core.internalStates; + var inherit = core.inherit; + var inheritParams = core.inheritParams; + var map = core.map; + var filterObj = core.filterObj; versionHeuristics.hasParamSet = !!$urlMatcherFactoryProvider.ParamSet; // inactivePseudoState (__inactives) holds all the inactive locals which includes resolved states data, i.e., views, scope, etc @@ -1085,76 +1103,83 @@ angular.module("ct.ui.router.extras.sticky").config( }; return $state; }]); - } - ] -); -function debugTransition($log, currentTransition, stickyTransition) { - function message(path, index, state) { - return (path[index] ? path[index].toUpperCase() + ": " + state.self.name : "(" + state.self.name + ")"); - } - var inactiveLogVar = map(stickyTransition.inactives, function (state) { - return state.self.name; - }); - var enterLogVar = map(currentTransition.toState.path, function (state, index) { - return message(stickyTransition.enter, index, state); - }); - var exitLogVar = map(currentTransition.fromState.path, function (state, index) { - return message(stickyTransition.exit, index, state); - }); - var transitionMessage = currentTransition.fromState.self.name + ": " + - angular.toJson(currentTransition.fromParams) + ": " + - " -> " + - currentTransition.toState.self.name + ": " + - angular.toJson(currentTransition.toParams); - - $log.debug(" Current transition: ", transitionMessage); - $log.debug("Before transition, inactives are: : ", map(_StickyState.getInactiveStates(), function (s) { - return s.self.name; - })); - $log.debug("After transition, inactives will be: ", inactiveLogVar); - $log.debug("Transition will exit: ", exitLogVar); - $log.debug("Transition will enter: ", enterLogVar); -} + function debugTransition($log, currentTransition, stickyTransition) { + function message(path, index, state) { + return (path[index] ? path[index].toUpperCase() + ": " + state.self.name : "(" + state.self.name + ")"); + } -function debugViewsAfterSuccess($log, currentState, $state) { - $log.debug("Current state: " + currentState.self.name + ", inactive states: ", map(_StickyState.getInactiveStates(), function (s) { - return s.self.name; - })); + var inactiveLogVar = map(stickyTransition.inactives, function (state) { + return state.self.name; + }); + var enterLogVar = map(currentTransition.toState.path, function (state, index) { + return message(stickyTransition.enter, index, state); + }); + var exitLogVar = map(currentTransition.fromState.path, function (state, index) { + return message(stickyTransition.exit, index, state); + }); - 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 transitionMessage = currentTransition.fromState.self.name + ": " + + angular.toJson(currentTransition.fromParams) + ": " + + " -> " + + currentTransition.toState.self.name + ": " + + angular.toJson(currentTransition.toParams); + + $log.debug(" Current transition: ", transitionMessage); + $log.debug("Before transition, inactives are: : ", map(_StickyState.getInactiveStates(), function (s) { + return s.self.name; + })); + $log.debug("After transition, inactives will be: ", inactiveLogVar); + $log.debug("Transition will exit: ", exitLogVar); + $log.debug("Transition will enter: ", enterLogVar); + } - var message = 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; - currentState = parent; - parent = currentState.parent; - } + function debugViewsAfterSuccess($log, currentState, $state) { + $log.debug("Current state: " + currentState.self.name + ", inactive states: ", map(_StickyState.getInactiveStates(), function (s) { + 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 message = 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; + currentState = parent; + parent = currentState.parent; + } + + $log.debug("Views: " + message); + } - $log.debug("Views: " + message); -} + } + ] +); + (function(angular, undefined) { var app = angular.module('ct.ui.router.extras.future', [ 'ct.ui.router.extras.core' ]); - function _futureStateProvider($stateProvider, $urlRouterProvider, $urlMatcherFactory) { + _futureStateProvider.$inject = [ '$stateProvider', '$urlRouterProvider', '$urlMatcherFactoryProvider', 'uirextras_coreProvider' ]; + function _futureStateProvider($stateProvider, $urlRouterProvider, $urlMatcherFactory, uirextras_coreProvider) { + var core = uirextras_coreProvider; + var internalStates = core.internalStates; var stateFactories = {}, futureStates = {}; var lazyloadInProgress = false, resolveFunctions = [], initPromise, initDone = false; var provider = this; @@ -1418,7 +1443,7 @@ function debugViewsAfterSuccess($log, currentState, $state) { ]; } - app.provider('$futureState', [ '$stateProvider', '$urlRouterProvider', '$urlMatcherFactoryProvider', _futureStateProvider]); + app.provider('$futureState', _futureStateProvider); var statesAddedQueue = { state: function(state) { @@ -1541,7 +1566,8 @@ angular.module("ct.ui.router.extras.transition", [ 'ct.ui.router.extras.core' ]) return function successFn(data) { popStack(); $rootScope.$broadcast("$transitionSuccess", tSuccess); - return deferred.resolve(data); + deferred.resolve(data); // $transition$ deferred + return data; }; } @@ -1551,7 +1577,8 @@ angular.module("ct.ui.router.extras.transition", [ 'ct.ui.router.extras.core' ]) return function failureFn(error) { popStack(); $rootScope.$broadcast("$transitionError", tFail, error); - return deferred.reject(error); + deferred.reject(error); // $transition$ deferred + return $q.reject(error); }; } @@ -1596,7 +1623,7 @@ angular.module("ct.ui.router.extras.transition", [ 'ct.ui.router.extras.core' ]) // statevis requires d3. (function () { "use strict"; - var app = angular.module("ct.ui.router.extras.statevis", [ 'ct.ui.router.extras.core' ]); + var app = angular.module("ct.ui.router.extras.statevis", [ 'ct.ui.router.extras.core', 'ct.ui.router.extras.sticky' ]); app.directive('stateVis', [ '$state', '$timeout', '$interval', stateVisDirective ]); diff --git a/release/ct-ui-router-extras.min.js b/release/ct-ui-router-extras.min.js index 3c707df..0319870 100644 --- a/release/ct-ui-router-extras.min.js +++ b/release/ct-ui-router-extras.min.js @@ -1 +1,2 @@ -!function(t,e){"use strict";function r(t,e){var r=[];for(var n in t.path){if(t.path[n]!==e.path[n])break;r.push(t.path[n])}return r}function n(e){if(Object.keys)return Object.keys(e);var r=[];return t.forEach(e,function(t,e){r.push(e)}),r}function a(t,e){var r=[];for(var n in t)e&&-1!==e.indexOf(n)||r.push(n);return r}function o(t,e){if(Array.prototype.indexOf)return t.indexOf(e,Number(arguments[2])||0);var r=t.length>>>0,n=Number(arguments[2])||0;for(n=0>n?Math.ceil(n):Math.floor(n),0>n&&(n+=r);r>n;n++)if(n in t&&t[n]===e)return n;return-1}function i(t,e,a,i){var u,s=r(a,i),c={},f=[];for(var l in s)if(s[l].params&&(u=x(s[l].params)?s[l].params:n(s[l].params),u.length))for(var v in u)o(f,u[v])>=0||(f.push(u[v]),c[u[v]]=t[u[v]]);return $({},c,e)}function u(t,e){return $(new($(function(){},{prototype:t})),e)}function s(t){h.push(t)}function c(){P=e}function f(){var e={},r={},n=!1;this.registerStickyState=function(t){r[t.name]=t},this.enableDebug=this.debugMode=function(e){return t.isDefined(e)&&(n=e),n},this.$get=["$rootScope","$state","$stateParams","$injector","$log",function(r,o,u,s,c){function f(){var r={};return t.forEach(e,function(t){for(var e=l(t),n=0;n "+r.toState.self.name+": "+t.toJson(r.toParams);e.debug(" Current transition: ",s),e.debug("Before transition, inactives are: : ",y(w.getInactiveStates(),function(t){return t.self.name})),e.debug("After transition, inactives will be: ",o),e.debug("Transition will exit: ",u),e.debug("Transition will enter: ",i)}function p(t,e,r){t.debug("Current state: "+e.self.name+", inactive states: ",y(w.getInactiveStates(),function(t){return t.self.name}));for(var n=function(t,e){return"'"+e+"' ("+t.$$state.name+")"},a=function(t,e){return"globals"!=e&&"resolve"!=e},o=function(t){var e=y(b(t.locals,a),n).join(", ");return"("+(t.self.name?t.self.name:"root")+".locals"+(e.length?": "+e:"")+")"},i=o(e),u=e.parent;u&&u!==e;)""===u.self.name&&(i=o(r.$current.path[0])+" / "+i),i=o(u)+" / "+i,e=u,u=e.parent;t.debug("Views: "+i)}var d=t.module("ct.ui.router.extras.core",["ui.router"]),m={},h=[];d.config(["$stateProvider","$injector",function(e){e.decorator("parent",function(e,r){return m[e.self.name]=e,e.self.$$state=function(){return m[e.self.name]},t.forEach(h,function(t){t(e)}),r(e)})}]);var g=t.forEach,$=t.extend,x=t.isArray,y=function(t,e){var r=[];return g(t,function(t,n){r.push(e(t,n))}),r},S=function(t){return y(t,function(t,e){return e})},E=function(t,e){var r=[];return g(t,function(t,n){e(t,n)&&r.push(t)}),r},b=function(t,e){var r={};return g(t,function(t,n){e(t,n)&&(r[n]=t)}),r};d.provider("uirextras_core",function(){var e={internalStates:m,onStateRegistered:s,forEach:g,extend:$,isArray:x,map:y,keys:S,filter:E,filterObj:b,ancestors:r,objectKeys:n,protoKeys:a,arraySearch:o,inheritParams:i,inherit:u};t.extend(this,e),this.$get=function(){return e}});var P;t.module("ct.ui.router.extras.dsr",["ct.ui.router.extras.core"]).config(["$provide",function(t){var e;t.decorator("$state",["$delegate","$q",function(t,r){return e=t.transitionTo,t.transitionTo=function(n,a,o){return o.ignoreDsr&&(P=o.ignoreDsr),e.apply(t,arguments).then(function(t){return c(),t},function(t){return c(),r.reject(t)})},t}])}]),t.module("ct.ui.router.extras.dsr").service("$deepStateRedirect",["$rootScope","$state","$injector",function(r,n,a){function o(t){var e=t.name;return l.hasOwnProperty(e)?l[e]:void u(e)}function i(e){var r=e.deepStateRedirect||e.dsr;if(!r)return{dsr:!1};var n={dsr:!0};return t.isFunction(r)?n.fn=r:t.isObject(r)&&(n=t.extend(n,r)),t.isString(n["default"])&&(n["default"]={state:n["default"]}),n.fn||(n.fn=["$dsr$",function(t){return t.redirect.state!=t.to.state}]),n}function u(t){var r=n.get(t);if(!r)return!1;var a=i(r);a.dsr&&(l[r.name]=v,f[t]===e&&(f[t]={}));var o=r.$$state&&r.$$state().parent;if(o){var s=u(o.self.name);s&&l[r.name]===e&&(l[r.name]=p)}return l[r.name]||!1}function s(r,n){n===!0&&(n=Object.keys(r)),(null===n||n===e)&&(n=[]);var a={};return t.forEach(n.sort(),function(t){a[t]=r[t]}),a}function c(e,r){function n(t){return t?t.toString():t}var a=s(e,r),o={};return t.forEach(a,function(t,e){o[e]=n(t)}),t.toJson(o)}var f={},l={},v="Redirect",p="AncestorRedirect";return r.$on("$stateChangeStart",function(e,r,u){var l=i(r);if(!P&&(o(r)===v||l["default"])){var p=c(u,l.params),d=f[r.name][p]||l["default"];if(d){var m={redirect:{state:d.state,params:d.params},to:{state:r.name,params:u}},h=a.invoke(l.fn,r,{$dsr$:m});if(h){h.state&&(d=h),e.preventDefault();var g=s(u,l.params);n.go(d.state,t.extend(g,d.params))}}}}),r.$on("$stateChangeSuccess",function(e,r,a){var u=o(r);if(u){var s=r.name;t.forEach(f,function(e,r){var o=i(n.get(r)),u=c(a,o.params);(s==r||-1!=s.indexOf(r+"."))&&(f[r][u]={state:s,params:t.copy(a)})})}}),{reset:function(e,r){if(e){var a=n.get(e);if(!a)throw new Error("Unknown state: "+e);if(f[a.name])if(r){var o=c(r,i(a).params);delete f[a.name][o]}else f[a.name]={}}else t.forEach(f,function(t,e){f[e]={}})}}}]),t.module("ct.ui.router.extras.dsr").run(["$deepStateRedirect",function(){}]),t.module("ct.ui.router.extras.sticky",["ct.ui.router.extras.core"]);var k=t.module("ct.ui.router.extras.sticky");f.$inject=["$stateProvider"],k.provider("$stickyState",f);var w,F,R,j,m={},O=[],A={hasParamSet:!1};t.module("ct.ui.router.extras.sticky").run(["$stickyState",function(t){w=t}]),t.module("ct.ui.router.extras.sticky").config(["$provide","$stateProvider","$stickyStateProvider","$urlMatcherFactoryProvider","uirextras_coreProvider",function(r,n,a,o,i){var s=i.internalStates;A.hasParamSet=!!o.ParamSet,j=t.extend(new l("__inactives"),{self:{name:"__inactives"}}),F=R=e,O=[],i.onStateRegistered(function(t){t.self.sticky===!0&&a.registerStickyState(t.self)});var c;r.decorator("$state",["$delegate","$log","$q",function(r,n,i){return F=r.$current,s[""]=F,F.parent=j,j.parent=e,F.locals=u(j.locals,F.locals),delete j.locals.globals,c=r.transitionTo,r.transitionTo=function(e,u,f){function d(e){var r=t.extend(new l("reactivate_phase1"),{locals:e.locals});return r.self=t.extend({},e.self),r}function m(e){var r=t.extend(new l("reactivate_phase2"),e),n=r.self.onEnter;return r.resolve={},r.views={},r.self.onEnter=function(){r.locals=e.locals,w.stateReactivated(e)},J.addRestoreFunction(function(){e.self.onEnter=n}),r}function h(t){var e=new l("inactivate");e.self=t.self;var r=t.self.onExit;return e.self.onExit=function(){w.stateInactivated(t)},J.addRestoreFunction(function(){t.self.onExit=r}),e}function g(t,e){var r=t.self.onEnter;return t.self.onEnter=function(){w.stateEntering(t,e,r)},J.addRestoreFunction(function(){t.self.onEnter=r}),t}function $(t,e){var r=t.self.onEnter;return t.self.onEnter=function(){w.stateEntering(t,e,r,!0)},J.addRestoreFunction(function(){t.self.onEnter=r}),t}function x(t){var e=t.self.onExit;return t.self.onExit=function(){w.stateExiting(t,N,e)},J.addRestoreFunction(function(){t.self.onExit=e}),t}var S=a.debugMode();j.locals||(j.locals=F.locals);var E=O.length;R&&(R(),S&&n.debug("Restored paths from pending transition"));var b,P,k,T,I=r.$current,C=r.params,M=f&&f.relative||r.$current,_=r.get(e,M),D=[],N=[];u=u||{},arguments[1]=u;var q=function(){},J=function(){b&&(z.path=b,b=null),P&&(I.path=P,P=null),t.forEach(J.restoreFunctions,function(t){t()}),J=q,R=null,O.splice(E,1)};if(J.restoreFunctions=[],J.addRestoreFunction=function(t){this.restoreFunctions.push(t)},_){var z=s[_.name];if(z){b=z.path,P=I.path;var K=f&&f.reload||!1,U=K&&(K===!0?b[0].self:r.get(K,M));f&&K&&K!==!0&&delete f.reload;var B={toState:z,toParams:u||{},fromState:I,fromParams:C||{},options:f,reloadStateTree:U};if(O.push(B),R=J,U){B.toParams.$$uirouterextrasreload=Math.random();var H=U.$$state().params,V=U.$$state().ownParams;if(A.hasParamSet){var W=new o.Param("$$uirouterextrasreload");H.$$uirouterextrasreload=V.$$uirouterextrasreload=W,J.restoreFunctions.push(function(){delete H.$$uirouterextrasreload,delete V.$$uirouterextrasreload})}else H.push("$$uirouterextrasreload"),V.push("$$uirouterextrasreload"),J.restoreFunctions.push(function(){H.length=H.length-1,V.length=V.length-1})}k=w.processTransition(B),S&&v(n,B,k);var L=z.path.slice(0,k.keep),Y=I.path.slice(0,k.keep);t.forEach(j.locals,function(t,e){-1!=e.indexOf("@")&&delete j.locals[e]});for(var G=0;G=0;s--)for(var c=0;c",link:function(r,a){function o(e){e=e.map(function(e){return""===e.name?l:t.copy(e)}),t.extend(u,e.reduce(function(t,e){return t[e.name]=e,t},{})),e.forEach(function(t){var e=t.name.split(/\./).slice(0,-1).join("."),r=t.name!=e&&u[e];r&&((r.children||(r.children=[])).push(t),t.px=r.px,t.py=r.py,v.push(t))})}function i(){function t(t){var e=t.name.split(".").pop();return t.sticky&&(e+=" (STICKY)"),t.deepStateRedirect&&(e+=" (DSR)"),e}h=h.data(f.nodes(l),function(t){return t.name}),g=g.data(f.links(v),function(t){return t.target.name}),$=$.data(p),v.forEach(function(t){t.y=70*t.depth});var e=h.enter();$.enter().append("circle").attr("class","active").attr("r",13).attr("cx",function(t){return t.parent.px||100}).attr("cy",function(t){return t.parent.py||100}),e.append("circle").attr("class","node").attr("r",9).attr("cx",function(t){return t.parent.px}).attr("cy",function(t){return t.parent.py}),e.append("text").attr("class","label").attr("x",function(t){return t.parent.px}).attr("y",function(t){return t.parent.py}).attr("text-anchor",function(){return"middle"}).text(t).style("fill-opacity",1),g.enter().insert("path",".node").attr("class","link").attr("d",function(t){var e={x:t.source.px,y:t.source.py};return d({source:e,target:e})});var r=m.transition().duration(y);r.selectAll(".link").attr("d",d);var n={entered:"#AF0",exited:"#777",active:"#0f0",inactive:"#55F",future:"#009"};r.selectAll(".node").attr("cx",function(t){return t.px=t.x}).attr("cy",function(t){return t.py=t.y}).attr("r",function(t){return"active"===t.status?15:10}).style("fill",function(t){return n[t.status]||"#FFF"}),r.selectAll(".label").attr("x",function(t){return t.px=t.x}).attr("y",function(t){return t.py=t.y-15}).attr("transform",function(t){return"rotate(-25 "+t.x+" "+t.y+")"}),r.selectAll(".active").attr("x",function(t){return t.px=t.x}).attr("y",function(t){return t.py=t.y-15})}var u={},s=r.width||400,c=r.height||400,f=d3.layout.tree().size([s-20,c-20]).separation(function(t,e){return t.parent==e.parent?10:25}),l=e.get().filter(function(t){return""===t.name})[0],v=f(l);l.parent=l,l.px=l.x=s/2,l.py=l.y=c/2;var p={};p.px=p.x=l.px,p.py=p.y=l.py;{var d=d3.svg.diagonal(),m=d3.select(a.find("svg")[0]).attr("width",s).attr("height",c).append("g").attr("transform","translate(10, 10)"),h=m.selectAll(".node"),g=m.selectAll(".link"),$=m.selectAll(".active"),x=200,y=200;setInterval(i,x)}n(function(){r.states=e.get(),t.forEach(v,function(t){var r=e.get(t.name);r&&(t.status=r.status||"exited")})},250),r.$watchCollection("states",function(t,e){var r=(e||[]).map(function(t){return t.name});o((t||[]).filter(function(t){return-1==r.indexOf(t.name)}))}),i(x)}}}var r=t.module("ct.ui.router.extras.statevis",["ct.ui.router.extras.core"]);r.directive("stateVis",["$state","$timeout","$interval",e])}(),t.module("ct.ui.router.extras",["ct.ui.router.extras.core","ct.ui.router.extras.dsr","ct.ui.router.extras.future","ct.ui.router.extras.previous","ct.ui.router.extras.statevis","ct.ui.router.extras.sticky","ct.ui.router.extras.transition"])}(angular); \ No newline at end of file +/** UI-Router Extras v.0.0.13 Monolithic build (all modules) http://christopherthielen.github.io/ui-router-extras/ - MIT License */ +!function(t,e){"use strict";function r(t,e){var r=[];for(var n in t.path){if(t.path[n]!==e.path[n])break;r.push(t.path[n])}return r}function n(e){if(Object.keys)return Object.keys(e);var r=[];return t.forEach(e,function(t,e){r.push(e)}),r}function a(t,e){var r=[];for(var n in t)e&&-1!==e.indexOf(n)||r.push(n);return r}function o(t,e){if(Array.prototype.indexOf)return t.indexOf(e,Number(arguments[2])||0);var r=t.length>>>0,n=Number(arguments[2])||0;for(n=0>n?Math.ceil(n):Math.floor(n),0>n&&(n+=r);r>n;n++)if(n in t&&t[n]===e)return n;return-1}function i(t,e,a,i){var u,s=r(a,i),c={},f=[];for(var l in s)if(s[l].params&&(u=g(s[l].params)?s[l].params:n(s[l].params),u.length))for(var v in u)o(f,u[v])>=0||(f.push(u[v]),c[u[v]]=t[u[v]]);return h({},c,e)}function u(t,e){return h(new(h(function(){},{prototype:t})),e)}function s(t){d.push(t)}function c(){b=e}function f(e,r){var n=r,a=n.inheritParams,o=n.protoKeys,i=n.map,u={},s={},c=!1;this.registerStickyState=function(t){s[t.name]=t},this.enableDebug=this.debugMode=function(e){return t.isDefined(e)&&(c=e),c},this.$get=["$rootScope","$state","$stateParams","$injector","$log",function(e,r,n,s,f){function l(){var e={};return t.forEach(u,function(t){for(var r=v(t),n=0;n "+r.toState.self.name+": "+t.toJson(r.toParams);e.debug(" Current transition: ",s),e.debug("Before transition, inactives are: : ",p(P.getInactiveStates(),function(t){return t.self.name})),e.debug("After transition, inactives will be: ",o),e.debug("Transition will exit: ",u),e.debug("Transition will enter: ",i)}function s(t,e,r){t.debug("Current state: "+e.self.name+", inactive states: ",p(P.getInactiveStates(),function(t){return t.self.name}));for(var n=function(t,e){return"'"+e+"' ("+t.$$state.name+")"},a=function(t,e){return"globals"!=e&&"resolve"!=e},o=function(t){var e=p(d(t.locals,a),n).join(", ");return"("+(t.self.name?t.self.name:"root")+".locals"+(e.length?": "+e:"")+")"},i=o(e),u=e.parent;u&&u!==e;)""===u.self.name&&(i=o(r.$current.path[0])+" / "+i),i=o(u)+" / "+i,e=u,u=e.parent;t.debug("Views: "+i)}var c=i,f=c.internalStates,v=c.inherit,p=(c.inheritParams,c.map),d=c.filterObj;R.hasParamSet=!!o.ParamSet,j=t.extend(new l("__inactives"),{self:{name:"__inactives"}}),k=w=e,F=[],i.onStateRegistered(function(t){t.self.sticky===!0&&a.registerStickyState(t.self)});var m;r.decorator("$state",["$delegate","$log","$q",function(r,n,i){return k=r.$current,f[""]=k,k.parent=j,j.parent=e,k.locals=v(j.locals,k.locals),delete j.locals.globals,m=r.transitionTo,r.transitionTo=function(e,c,v){function d(e){var r=t.extend(new l("reactivate_phase1"),{locals:e.locals});return r.self=t.extend({},e.self),r}function h(e){var r=t.extend(new l("reactivate_phase2"),e),n=r.self.onEnter;return r.resolve={},r.views={},r.self.onEnter=function(){r.locals=e.locals,P.stateReactivated(e)},J.addRestoreFunction(function(){e.self.onEnter=n}),r}function g(t){var e=new l("inactivate");e.self=t.self;var r=t.self.onExit;return e.self.onExit=function(){P.stateInactivated(t)},J.addRestoreFunction(function(){t.self.onExit=r}),e}function $(t,e){var r=t.self.onEnter;return t.self.onEnter=function(){P.stateEntering(t,e,r)},J.addRestoreFunction(function(){t.self.onEnter=r}),t}function x(t,e){var r=t.self.onEnter;return t.self.onEnter=function(){P.stateEntering(t,e,r,!0)},J.addRestoreFunction(function(){t.self.onEnter=r}),t}function y(t){var e=t.self.onExit;return t.self.onExit=function(){P.stateExiting(t,N,e)},J.addRestoreFunction(function(){t.self.onExit=e}),t}var S=a.debugMode();j.locals||(j.locals=k.locals);var b=F.length;w&&(w(),S&&n.debug("Restored paths from pending transition"));var E,O,A,T,_=r.$current,I=r.params,C=v&&v.relative||r.$current,M=r.get(e,C),D=[],N=[];c=c||{},arguments[1]=c;var q=function(){},J=function(){E&&(K.path=E,E=null),O&&(_.path=O,O=null),t.forEach(J.restoreFunctions,function(t){t()}),J=q,w=null,F.splice(b,1)};if(J.restoreFunctions=[],J.addRestoreFunction=function(t){this.restoreFunctions.push(t)},M){var K=f[M.name];if(K){E=K.path,O=_.path;var z=v&&v.reload||!1,U=z&&(z===!0?E[0].self:r.get(z,C));v&&z&&z!==!0&&delete v.reload;var B={toState:K,toParams:c||{},fromState:_,fromParams:I||{},options:v,reloadStateTree:U};if(F.push(B),w=J,U){B.toParams.$$uirouterextrasreload=Math.random();var H=U.$$state().params,V=U.$$state().ownParams;if(R.hasParamSet){var W=new o.Param("$$uirouterextrasreload");H.$$uirouterextrasreload=V.$$uirouterextrasreload=W,J.restoreFunctions.push(function(){delete H.$$uirouterextrasreload,delete V.$$uirouterextrasreload})}else H.push("$$uirouterextrasreload"),V.push("$$uirouterextrasreload"),J.restoreFunctions.push(function(){H.length=H.length-1,V.length=V.length-1})}A=P.processTransition(B),S&&u(n,B,A);var L=K.path.slice(0,A.keep),Y=_.path.slice(0,A.keep);t.forEach(j.locals,function(t,e){-1!=e.indexOf("@")&&delete j.locals[e]});for(var G=0;G=0;s--)for(var c=0;c",link:function(r,a){function o(e){e=e.map(function(e){return""===e.name?l:t.copy(e)}),t.extend(u,e.reduce(function(t,e){return t[e.name]=e,t},{})),e.forEach(function(t){var e=t.name.split(/\./).slice(0,-1).join("."),r=t.name!=e&&u[e];r&&((r.children||(r.children=[])).push(t),t.px=r.px,t.py=r.py,v.push(t))})}function i(){function t(t){var e=t.name.split(".").pop();return t.sticky&&(e+=" (STICKY)"),t.deepStateRedirect&&(e+=" (DSR)"),e}h=h.data(f.nodes(l),function(t){return t.name}),g=g.data(f.links(v),function(t){return t.target.name}),$=$.data(p),v.forEach(function(t){t.y=70*t.depth});var e=h.enter();$.enter().append("circle").attr("class","active").attr("r",13).attr("cx",function(t){return t.parent.px||100}).attr("cy",function(t){return t.parent.py||100}),e.append("circle").attr("class","node").attr("r",9).attr("cx",function(t){return t.parent.px}).attr("cy",function(t){return t.parent.py}),e.append("text").attr("class","label").attr("x",function(t){return t.parent.px}).attr("y",function(t){return t.parent.py}).attr("text-anchor",function(){return"middle"}).text(t).style("fill-opacity",1),g.enter().insert("path",".node").attr("class","link").attr("d",function(t){var e={x:t.source.px,y:t.source.py};return d({source:e,target:e})});var r=m.transition().duration(y);r.selectAll(".link").attr("d",d);var n={entered:"#AF0",exited:"#777",active:"#0f0",inactive:"#55F",future:"#009"};r.selectAll(".node").attr("cx",function(t){return t.px=t.x}).attr("cy",function(t){return t.py=t.y}).attr("r",function(t){return"active"===t.status?15:10}).style("fill",function(t){return n[t.status]||"#FFF"}),r.selectAll(".label").attr("x",function(t){return t.px=t.x}).attr("y",function(t){return t.py=t.y-15}).attr("transform",function(t){return"rotate(-25 "+t.x+" "+t.y+")"}),r.selectAll(".active").attr("x",function(t){return t.px=t.x}).attr("y",function(t){return t.py=t.y-15})}var u={},s=r.width||400,c=r.height||400,f=d3.layout.tree().size([s-20,c-20]).separation(function(t,e){return t.parent==e.parent?10:25}),l=e.get().filter(function(t){return""===t.name})[0],v=f(l);l.parent=l,l.px=l.x=s/2,l.py=l.y=c/2;var p={};p.px=p.x=l.px,p.py=p.y=l.py;{var d=d3.svg.diagonal(),m=d3.select(a.find("svg")[0]).attr("width",s).attr("height",c).append("g").attr("transform","translate(10, 10)"),h=m.selectAll(".node"),g=m.selectAll(".link"),$=m.selectAll(".active"),x=200,y=200;setInterval(i,x)}n(function(){r.states=e.get(),t.forEach(v,function(t){var r=e.get(t.name);r&&(t.status=r.status||"exited")})},250),r.$watchCollection("states",function(t,e){var r=(e||[]).map(function(t){return t.name});o((t||[]).filter(function(t){return-1==r.indexOf(t.name)}))}),i(x)}}}var r=t.module("ct.ui.router.extras.statevis",["ct.ui.router.extras.core","ct.ui.router.extras.sticky"]);r.directive("stateVis",["$state","$timeout","$interval",e])}(),t.module("ct.ui.router.extras",["ct.ui.router.extras.core","ct.ui.router.extras.dsr","ct.ui.router.extras.future","ct.ui.router.extras.previous","ct.ui.router.extras.statevis","ct.ui.router.extras.sticky","ct.ui.router.extras.transition"])}(angular); \ No newline at end of file diff --git a/release/modular/ct-ui-router-extras.core.js b/release/modular/ct-ui-router-extras.core.js index 616da4d..d24eb64 100644 --- a/release/modular/ct-ui-router-extras.core.js +++ b/release/modular/ct-ui-router-extras.core.js @@ -1,3 +1,11 @@ +/** + + * UI-Router Extras: Sticky states, Future States, Deep State Redirect, Transition promise + * Module: core + * @version 0.0.13 + * @link http://christopherthielen.github.io/ui-router-extras/ + * @license MIT License, http://www.opensource.org/licenses/MIT + */ (function(angular, undefined){ "use strict"; var mod_core = angular.module("ct.ui.router.extras.core", [ "ui.router" ]); diff --git a/release/modular/ct-ui-router-extras.core.min.js b/release/modular/ct-ui-router-extras.core.min.js index 54d135c..17014b2 100644 --- a/release/modular/ct-ui-router-extras.core.min.js +++ b/release/modular/ct-ui-router-extras.core.min.js @@ -1 +1,2 @@ +/** UI-Router Extras v.0.0.13 Module: core http://christopherthielen.github.io/ui-router-extras/ - MIT License */ !function(r){"use strict";function n(r,n){var t=[];for(var e in r.path){if(r.path[e]!==n.path[e])break;t.push(r.path[e])}return t}function t(n){if(Object.keys)return Object.keys(n);var t=[];return r.forEach(n,function(r,n){t.push(n)}),t}function e(r,n){var t=[];for(var e in r)n&&-1!==n.indexOf(e)||t.push(e);return t}function u(r,n){if(Array.prototype.indexOf)return r.indexOf(n,Number(arguments[2])||0);var t=r.length>>>0,e=Number(arguments[2])||0;for(e=0>e?Math.ceil(e):Math.floor(e),0>e&&(e+=t);t>e;e++)if(e in r&&r[e]===n)return e;return-1}function a(r,e,a,i){var o,f=n(a,i),c={},s=[];for(var h in f)if(f[h].params&&(o=v(f[h].params)?f[h].params:t(f[h].params),o.length))for(var m in o)u(s,o[m])>=0||(s.push(o[m]),c[o[m]]=r[o[m]]);return p({},c,e)}function i(r,n){return p(new(p(function(){},{prototype:r})),n)}function o(r){s.push(r)}var f=r.module("ct.ui.router.extras.core",["ui.router"]),c={},s=[];f.config(["$stateProvider","$injector",function(n){n.decorator("parent",function(n,t){return c[n.self.name]=n,n.self.$$state=function(){return c[n.self.name]},r.forEach(s,function(r){r(n)}),t(n)})}]);var h=r.forEach,p=r.extend,v=r.isArray,m=function(r,n){var t=[];return h(r,function(r,e){t.push(n(r,e))}),t},l=function(r){return m(r,function(r,n){return n})},d=function(r,n){var t=[];return h(r,function(r,e){n(r,e)&&t.push(r)}),t},y=function(r,n){var t={};return h(r,function(r,e){n(r,e)&&(t[e]=r)}),t};f.provider("uirextras_core",function(){var f={internalStates:c,onStateRegistered:o,forEach:h,extend:p,isArray:v,map:m,keys:l,filter:d,filterObj:y,ancestors:n,objectKeys:t,protoKeys:e,arraySearch:u,inheritParams:a,inherit:i};r.extend(this,f),this.$get=function(){return f}})}(angular); \ No newline at end of file diff --git a/release/modular/ct-ui-router-extras.dsr.js b/release/modular/ct-ui-router-extras.dsr.js index c282f10..0a24397 100644 --- a/release/modular/ct-ui-router-extras.dsr.js +++ b/release/modular/ct-ui-router-extras.dsr.js @@ -1,3 +1,11 @@ +/** + + * UI-Router Extras: Sticky states, Future States, Deep State Redirect, Transition promise + * Module: dsr + * @version 0.0.13 + * @link http://christopherthielen.github.io/ui-router-extras/ + * @license MIT License, http://www.opensource.org/licenses/MIT + */ (function(angular, undefined){ "use strict"; var ignoreDsr; diff --git a/release/modular/ct-ui-router-extras.dsr.min.js b/release/modular/ct-ui-router-extras.dsr.min.js index 41836cd..c2a283e 100644 --- a/release/modular/ct-ui-router-extras.dsr.min.js +++ b/release/modular/ct-ui-router-extras.dsr.min.js @@ -1 +1,2 @@ +/** UI-Router Extras v.0.0.13 Module: dsr http://christopherthielen.github.io/ui-router-extras/ - MIT License */ !function(t,e){"use strict";function r(){n=e}var n;t.module("ct.ui.router.extras.dsr",["ct.ui.router.extras.core"]).config(["$provide",function(t){var e;t.decorator("$state",["$delegate","$q",function(t,a){return e=t.transitionTo,t.transitionTo=function(o,i,u){return u.ignoreDsr&&(n=u.ignoreDsr),e.apply(t,arguments).then(function(t){return r(),t},function(t){return r(),a.reject(t)})},t}])}]),t.module("ct.ui.router.extras.dsr").service("$deepStateRedirect",["$rootScope","$state","$injector",function(r,a,o){function i(t){var e=t.name;return v.hasOwnProperty(e)?v[e]:void s(e)}function u(e){var r=e.deepStateRedirect||e.dsr;if(!r)return{dsr:!1};var n={dsr:!0};return t.isFunction(r)?n.fn=r:t.isObject(r)&&(n=t.extend(n,r)),t.isString(n["default"])&&(n["default"]={state:n["default"]}),n.fn||(n.fn=["$dsr$",function(t){return t.redirect.state!=t.to.state}]),n}function s(t){var r=a.get(t);if(!r)return!1;var n=u(r);n.dsr&&(v[r.name]=m,d[t]===e&&(d[t]={}));var o=r.$$state&&r.$$state().parent;if(o){var i=s(o.self.name);i&&v[r.name]===e&&(v[r.name]=$)}return v[r.name]||!1}function c(r,n){n===!0&&(n=Object.keys(r)),(null===n||n===e)&&(n=[]);var a={};return t.forEach(n.sort(),function(t){a[t]=r[t]}),a}function f(e,r){function n(t){return t?t.toString():t}var a=c(e,r),o={};return t.forEach(a,function(t,e){o[e]=n(t)}),t.toJson(o)}var d={},v={},m="Redirect",$="AncestorRedirect";return r.$on("$stateChangeStart",function(e,r,s){var v=u(r);if(!n&&(i(r)===m||v["default"])){var $=f(s,v.params),p=d[r.name][$]||v["default"];if(p){var l={redirect:{state:p.state,params:p.params},to:{state:r.name,params:s}},g=o.invoke(v.fn,r,{$dsr$:l});if(g){g.state&&(p=g),e.preventDefault();var h=c(s,v.params);a.go(p.state,t.extend(h,p.params))}}}}),r.$on("$stateChangeSuccess",function(e,r,n){var o=i(r);if(o){var s=r.name;t.forEach(d,function(e,r){var o=u(a.get(r)),i=f(n,o.params);(s==r||-1!=s.indexOf(r+"."))&&(d[r][i]={state:s,params:t.copy(n)})})}}),{reset:function(e,r){if(e){var n=a.get(e);if(!n)throw new Error("Unknown state: "+e);if(d[n.name])if(r){var o=f(r,u(n).params);delete d[n.name][o]}else d[n.name]={}}else t.forEach(d,function(t,e){d[e]={}})}}}]),t.module("ct.ui.router.extras.dsr").run(["$deepStateRedirect",function(){}])}(angular); \ No newline at end of file diff --git a/release/modular/ct-ui-router-extras.future.js b/release/modular/ct-ui-router-extras.future.js index d58100b..1049427 100644 --- a/release/modular/ct-ui-router-extras.future.js +++ b/release/modular/ct-ui-router-extras.future.js @@ -1,9 +1,20 @@ +/** + + * UI-Router Extras: Sticky states, Future States, Deep State Redirect, Transition promise + * Module: future + * @version 0.0.13 + * @link http://christopherthielen.github.io/ui-router-extras/ + * @license MIT License, http://www.opensource.org/licenses/MIT + */ (function(angular, undefined){ "use strict"; (function(angular, undefined) { var app = angular.module('ct.ui.router.extras.future', [ 'ct.ui.router.extras.core' ]); - function _futureStateProvider($stateProvider, $urlRouterProvider, $urlMatcherFactory) { + _futureStateProvider.$inject = [ '$stateProvider', '$urlRouterProvider', '$urlMatcherFactoryProvider', 'uirextras_coreProvider' ]; + function _futureStateProvider($stateProvider, $urlRouterProvider, $urlMatcherFactory, uirextras_coreProvider) { + var core = uirextras_coreProvider; + var internalStates = core.internalStates; var stateFactories = {}, futureStates = {}; var lazyloadInProgress = false, resolveFunctions = [], initPromise, initDone = false; var provider = this; @@ -267,7 +278,7 @@ ]; } - app.provider('$futureState', [ '$stateProvider', '$urlRouterProvider', '$urlMatcherFactoryProvider', _futureStateProvider]); + app.provider('$futureState', _futureStateProvider); var statesAddedQueue = { state: function(state) { diff --git a/release/modular/ct-ui-router-extras.future.min.js b/release/modular/ct-ui-router-extras.future.min.js index 58d1f81..248605e 100644 --- a/release/modular/ct-ui-router-extras.future.min.js +++ b/release/modular/ct-ui-router-extras.future.min.js @@ -1 +1,2 @@ -!function(t){"use strict";!function(t,e){function r(e,r,n){function a(e,r){var n=t.isObject(e)?e.name:e;return r?s[n]:internalStates[n]}function o(t,e){if(e.name){var r=e.name.split(/\./);for("."===e.name.charAt(0)&&(r[0]=t.current.name);r.length;){var n=r.join(".");if(t.get(n,{relative:t.current}))return null;if(s[n])return s[n];r.pop()}}if(e.url){var a=[];for(var o in s){var u=s[o].urlMatcher;u&&u.exec(e.url)&&a.push(s[o])}for(var i=a.slice(0),c=a.length-1;c>=0;c--)for(var f=0;f=0;c--)for(var f=0;f",link:function(e,a){function i(n){n=n.map(function(n){return""===n.name?p:t.copy(n)}),t.extend(u,n.reduce(function(t,n){return t[n.name]=n,t},{})),n.forEach(function(t){var n=t.name.split(/\./).slice(0,-1).join("."),e=t.name!=n&&u[n];e&&((e.children||(e.children=[])).push(t),t.px=e.px,t.py=e.py,f.push(t))})}function c(){function t(t){var n=t.name.split(".").pop();return t.sticky&&(n+=" (STICKY)"),t.deepStateRedirect&&(n+=" (DSR)"),n}v=v.data(l.nodes(p),function(t){return t.name}),h=h.data(l.links(f),function(t){return t.target.name}),m=m.data(d),f.forEach(function(t){t.y=70*t.depth});var n=v.enter();m.enter().append("circle").attr("class","active").attr("r",13).attr("cx",function(t){return t.parent.px||100}).attr("cy",function(t){return t.parent.py||100}),n.append("circle").attr("class","node").attr("r",9).attr("cx",function(t){return t.parent.px}).attr("cy",function(t){return t.parent.py}),n.append("text").attr("class","label").attr("x",function(t){return t.parent.px}).attr("y",function(t){return t.parent.py}).attr("text-anchor",function(){return"middle"}).text(t).style("fill-opacity",1),h.enter().insert("path",".node").attr("class","link").attr("d",function(t){var n={x:t.source.px,y:t.source.py};return x({source:n,target:n})});var e=y.transition().duration(A);e.selectAll(".link").attr("d",x);var r={entered:"#AF0",exited:"#777",active:"#0f0",inactive:"#55F",future:"#009"};e.selectAll(".node").attr("cx",function(t){return t.px=t.x}).attr("cy",function(t){return t.py=t.y}).attr("r",function(t){return"active"===t.status?15:10}).style("fill",function(t){return r[t.status]||"#FFF"}),e.selectAll(".label").attr("x",function(t){return t.px=t.x}).attr("y",function(t){return t.py=t.y-15}).attr("transform",function(t){return"rotate(-25 "+t.x+" "+t.y+")"}),e.selectAll(".active").attr("x",function(t){return t.px=t.x}).attr("y",function(t){return t.py=t.y-15})}var u={},o=e.width||400,s=e.height||400,l=d3.layout.tree().size([o-20,s-20]).separation(function(t,n){return t.parent==n.parent?10:25}),p=n.get().filter(function(t){return""===t.name})[0],f=l(p);p.parent=p,p.px=p.x=o/2,p.py=p.y=s/2;var d={};d.px=d.x=p.px,d.py=d.y=p.py;{var x=d3.svg.diagonal(),y=d3.select(a.find("svg")[0]).attr("width",o).attr("height",s).append("g").attr("transform","translate(10, 10)"),v=y.selectAll(".node"),h=y.selectAll(".link"),m=y.selectAll(".active"),g=200,A=200;setInterval(c,g)}r(function(){e.states=n.get(),t.forEach(f,function(t){var e=n.get(t.name);e&&(t.status=e.status||"exited")})},250),e.$watchCollection("states",function(t,n){var e=(n||[]).map(function(t){return t.name});i((t||[]).filter(function(t){return-1==e.indexOf(t.name)}))}),c(g)}}}var e=t.module("ct.ui.router.extras.statevis",["ct.ui.router.extras.core"]);e.directive("stateVis",["$state","$timeout","$interval",n])}()}(angular); \ No newline at end of file +/** UI-Router Extras v.0.0.13 Module: statevis http://christopherthielen.github.io/ui-router-extras/ - MIT License */ +!function(t){"use strict";!function(){function e(e,n,r){return{scope:{width:"@",height:"@"},restrict:"AE",template:"",link:function(n,a){function i(e){e=e.map(function(e){return""===e.name?p:t.copy(e)}),t.extend(u,e.reduce(function(t,e){return t[e.name]=e,t},{})),e.forEach(function(t){var e=t.name.split(/\./).slice(0,-1).join("."),n=t.name!=e&&u[e];n&&((n.children||(n.children=[])).push(t),t.px=n.px,t.py=n.py,f.push(t))})}function c(){function t(t){var e=t.name.split(".").pop();return t.sticky&&(e+=" (STICKY)"),t.deepStateRedirect&&(e+=" (DSR)"),e}v=v.data(l.nodes(p),function(t){return t.name}),h=h.data(l.links(f),function(t){return t.target.name}),m=m.data(d),f.forEach(function(t){t.y=70*t.depth});var e=v.enter();m.enter().append("circle").attr("class","active").attr("r",13).attr("cx",function(t){return t.parent.px||100}).attr("cy",function(t){return t.parent.py||100}),e.append("circle").attr("class","node").attr("r",9).attr("cx",function(t){return t.parent.px}).attr("cy",function(t){return t.parent.py}),e.append("text").attr("class","label").attr("x",function(t){return t.parent.px}).attr("y",function(t){return t.parent.py}).attr("text-anchor",function(){return"middle"}).text(t).style("fill-opacity",1),h.enter().insert("path",".node").attr("class","link").attr("d",function(t){var e={x:t.source.px,y:t.source.py};return x({source:e,target:e})});var n=y.transition().duration(A);n.selectAll(".link").attr("d",x);var r={entered:"#AF0",exited:"#777",active:"#0f0",inactive:"#55F",future:"#009"};n.selectAll(".node").attr("cx",function(t){return t.px=t.x}).attr("cy",function(t){return t.py=t.y}).attr("r",function(t){return"active"===t.status?15:10}).style("fill",function(t){return r[t.status]||"#FFF"}),n.selectAll(".label").attr("x",function(t){return t.px=t.x}).attr("y",function(t){return t.py=t.y-15}).attr("transform",function(t){return"rotate(-25 "+t.x+" "+t.y+")"}),n.selectAll(".active").attr("x",function(t){return t.px=t.x}).attr("y",function(t){return t.py=t.y-15})}var u={},o=n.width||400,s=n.height||400,l=d3.layout.tree().size([o-20,s-20]).separation(function(t,e){return t.parent==e.parent?10:25}),p=e.get().filter(function(t){return""===t.name})[0],f=l(p);p.parent=p,p.px=p.x=o/2,p.py=p.y=s/2;var d={};d.px=d.x=p.px,d.py=d.y=p.py;{var x=d3.svg.diagonal(),y=d3.select(a.find("svg")[0]).attr("width",o).attr("height",s).append("g").attr("transform","translate(10, 10)"),v=y.selectAll(".node"),h=y.selectAll(".link"),m=y.selectAll(".active"),g=200,A=200;setInterval(c,g)}r(function(){n.states=e.get(),t.forEach(f,function(t){var n=e.get(t.name);n&&(t.status=n.status||"exited")})},250),n.$watchCollection("states",function(t,e){var n=(e||[]).map(function(t){return t.name});i((t||[]).filter(function(t){return-1==n.indexOf(t.name)}))}),c(g)}}}var n=t.module("ct.ui.router.extras.statevis",["ct.ui.router.extras.core","ct.ui.router.extras.sticky"]);n.directive("stateVis",["$state","$timeout","$interval",e])}()}(angular); \ No newline at end of file diff --git a/release/modular/ct-ui-router-extras.sticky.js b/release/modular/ct-ui-router-extras.sticky.js index 10086a5..10c8186 100644 --- a/release/modular/ct-ui-router-extras.sticky.js +++ b/release/modular/ct-ui-router-extras.sticky.js @@ -1,11 +1,24 @@ +/** + + * UI-Router Extras: Sticky states, Future States, Deep State Redirect, Transition promise + * Module: sticky + * @version 0.0.13 + * @link http://christopherthielen.github.io/ui-router-extras/ + * @license MIT License, http://www.opensource.org/licenses/MIT + */ (function(angular, undefined){ "use strict"; angular.module("ct.ui.router.extras.sticky", [ 'ct.ui.router.extras.core' ]); var mod_sticky = angular.module("ct.ui.router.extras.sticky"); -$StickyStateProvider.$inject = [ '$stateProvider' ]; -function $StickyStateProvider($stateProvider) { +$StickyStateProvider.$inject = [ '$stateProvider', 'uirextras_coreProvider' ]; +function $StickyStateProvider($stateProvider, uirextras_coreProvider) { + var core = uirextras_coreProvider; + var inheritParams = core.inheritParams; + var protoKeys = core.protoKeys; + var map = core.map; + // Holds all the states which are inactivated. Inactivated states can be either sticky states, or descendants of sticky states. var inactiveStates = {}; // state.name -> (state) var stickyStates = {}; // state.name -> true @@ -388,7 +401,12 @@ angular.module("ct.ui.router.extras.sticky").run(["$stickyState", function ($sti angular.module("ct.ui.router.extras.sticky").config( [ "$provide", "$stateProvider", '$stickyStateProvider', '$urlMatcherFactoryProvider', 'uirextras_coreProvider', function ($provide, $stateProvider, $stickyStateProvider, $urlMatcherFactoryProvider, uirextras_coreProvider) { - var internalStates = uirextras_coreProvider.internalStates; + var core = uirextras_coreProvider; + var internalStates = core.internalStates; + var inherit = core.inherit; + var inheritParams = core.inheritParams; + var map = core.map; + var filterObj = core.filterObj; versionHeuristics.hasParamSet = !!$urlMatcherFactoryProvider.ParamSet; // inactivePseudoState (__inactives) holds all the inactive locals which includes resolved states data, i.e., views, scope, etc @@ -752,70 +770,74 @@ angular.module("ct.ui.router.extras.sticky").config( }; return $state; }]); - } - ] -); -function debugTransition($log, currentTransition, stickyTransition) { - function message(path, index, state) { - return (path[index] ? path[index].toUpperCase() + ": " + state.self.name : "(" + state.self.name + ")"); - } - - var inactiveLogVar = map(stickyTransition.inactives, function (state) { - return state.self.name; - }); - var enterLogVar = map(currentTransition.toState.path, function (state, index) { - return message(stickyTransition.enter, index, state); - }); - var exitLogVar = map(currentTransition.fromState.path, function (state, index) { - return message(stickyTransition.exit, index, state); - }); - - var transitionMessage = currentTransition.fromState.self.name + ": " + - angular.toJson(currentTransition.fromParams) + ": " + - " -> " + - currentTransition.toState.self.name + ": " + - angular.toJson(currentTransition.toParams); - - $log.debug(" Current transition: ", transitionMessage); - $log.debug("Before transition, inactives are: : ", map(_StickyState.getInactiveStates(), function (s) { - return s.self.name; - })); - $log.debug("After transition, inactives will be: ", inactiveLogVar); - $log.debug("Transition will exit: ", exitLogVar); - $log.debug("Transition will enter: ", enterLogVar); -} -function debugViewsAfterSuccess($log, currentState, $state) { - $log.debug("Current state: " + currentState.self.name + ", inactive states: ", map(_StickyState.getInactiveStates(), function (s) { - 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 : "") + ")"; - }; + function debugTransition($log, currentTransition, stickyTransition) { + function message(path, index, state) { + return (path[index] ? path[index].toUpperCase() + ": " + state.self.name : "(" + state.self.name + ")"); + } - var message = 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; - currentState = parent; - parent = currentState.parent; - } + var inactiveLogVar = map(stickyTransition.inactives, function (state) { + return state.self.name; + }); + var enterLogVar = map(currentTransition.toState.path, function (state, index) { + return message(stickyTransition.enter, index, state); + }); + var exitLogVar = map(currentTransition.fromState.path, function (state, index) { + return message(stickyTransition.exit, index, state); + }); + + var transitionMessage = currentTransition.fromState.self.name + ": " + + angular.toJson(currentTransition.fromParams) + ": " + + " -> " + + currentTransition.toState.self.name + ": " + + angular.toJson(currentTransition.toParams); + + $log.debug(" Current transition: ", transitionMessage); + $log.debug("Before transition, inactives are: : ", map(_StickyState.getInactiveStates(), function (s) { + return s.self.name; + })); + $log.debug("After transition, inactives will be: ", inactiveLogVar); + $log.debug("Transition will exit: ", exitLogVar); + $log.debug("Transition will enter: ", enterLogVar); + } + + function debugViewsAfterSuccess($log, currentState, $state) { + $log.debug("Current state: " + currentState.self.name + ", inactive states: ", map(_StickyState.getInactiveStates(), function (s) { + 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 message = 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; + currentState = parent; + parent = currentState.parent; + } + + $log.debug("Views: " + message); + } - $log.debug("Views: " + message); -} + } + ] +); + })(angular); \ No newline at end of file diff --git a/release/modular/ct-ui-router-extras.sticky.min.js b/release/modular/ct-ui-router-extras.sticky.min.js index a281f40..8a0bd3d 100644 --- a/release/modular/ct-ui-router-extras.sticky.min.js +++ b/release/modular/ct-ui-router-extras.sticky.min.js @@ -1 +1,2 @@ -!function(e,t){"use strict";function a(){var t={},a={},n=!1;this.registerStickyState=function(e){a[e.name]=e},this.enableDebug=this.debugMode=function(t){return e.isDefined(t)&&(n=t),n},this.$get=["$rootScope","$state","$stateParams","$injector","$log",function(a,r,s,o,i){function u(){var a={};return e.forEach(t,function(e){for(var t=l(e),n=0;n "+a.toState.self.name+": "+e.toJson(a.toParams);t.debug(" Current transition: ",l),t.debug("Before transition, inactives are: : ",map(i.getInactiveStates(),function(e){return e.self.name})),t.debug("After transition, inactives will be: ",s),t.debug("Transition will exit: ",u),t.debug("Transition will enter: ",o)}function s(e,t,a){e.debug("Current state: "+t.self.name+", inactive states: ",map(i.getInactiveStates(),function(e){return e.self.name}));for(var n=function(e,t){return"'"+t+"' ("+e.$$state.name+")"},r=function(e,t){return"globals"!=t&&"resolve"!=t},s=function(e){var t=map(filterObj(e.locals,r),n).join(", ");return"("+(e.self.name?e.self.name:"root")+".locals"+(t.length?": "+t:"")+")"},o=s(t),u=t.parent;u&&u!==t;)""===u.self.name&&(o=s(a.$current.path[0])+" / "+o),o=s(u)+" / "+o,t=u,u=t.parent;e.debug("Views: "+o)}e.module("ct.ui.router.extras.sticky",["ct.ui.router.extras.core"]);var o=e.module("ct.ui.router.extras.sticky");a.$inject=["$stateProvider"],o.provider("$stickyState",a);var i,u,l,c,f=[],v={hasParamSet:!1};e.module("ct.ui.router.extras.sticky").run(["$stickyState",function(e){i=e}]),e.module("ct.ui.router.extras.sticky").config(["$provide","$stateProvider","$stickyStateProvider","$urlMatcherFactoryProvider","uirextras_coreProvider",function(a,o,d,m,p){var h=p.internalStates;v.hasParamSet=!!m.ParamSet,c=e.extend(new n("__inactives"),{self:{name:"__inactives"}}),u=l=t,f=[],p.onStateRegistered(function(e){e.self.sticky===!0&&d.registerStickyState(e.self)});var g;a.decorator("$state",["$delegate","$log","$q",function(a,o,p){return u=a.$current,h[""]=u,u.parent=c,c.parent=t,u.locals=inherit(c.locals,u.locals),delete c.locals.globals,g=a.transitionTo,a.transitionTo=function(t,$,x){function S(t){var a=e.extend(new n("reactivate_phase1"),{locals:t.locals});return a.self=e.extend({},t.self),a}function E(t){var a=e.extend(new n("reactivate_phase2"),t),r=a.self.onEnter;return a.resolve={},a.views={},a.self.onEnter=function(){a.locals=t.locals,i.stateReactivated(t)},D.addRestoreFunction(function(){t.self.onEnter=r}),a}function P(e){var t=new n("inactivate");t.self=e.self;var a=e.self.onExit;return t.self.onExit=function(){i.stateInactivated(e)},D.addRestoreFunction(function(){e.self.onExit=a}),t}function b(e,t){var a=e.self.onEnter;return e.self.onEnter=function(){i.stateEntering(e,t,a)},D.addRestoreFunction(function(){e.self.onEnter=a}),e}function k(e,t){var a=e.self.onEnter;return e.self.onEnter=function(){i.stateEntering(e,t,a,!0)},D.addRestoreFunction(function(){e.self.onEnter=a}),e}function y(e){var t=e.self.onExit;return e.self.onExit=function(){i.stateExiting(e,A,t)},D.addRestoreFunction(function(){e.self.onExit=t}),e}var w=d.debugMode();c.locals||(c.locals=u.locals);var F=f.length;l&&(l(),w&&o.debug("Restored paths from pending transition"));var R,T,I,_,O=a.$current,j=a.params,C=x&&x.relative||a.$current,M=a.get(t,C),q=[],A=[];$=$||{},arguments[1]=$;var B=function(){},D=function(){R&&(J.path=R,R=null),T&&(O.path=T,T=null),e.forEach(D.restoreFunctions,function(e){e()}),D=B,l=null,f.splice(F,1)};if(D.restoreFunctions=[],D.addRestoreFunction=function(e){this.restoreFunctions.push(e)},M){var J=h[M.name];if(J){R=J.path,T=O.path;var K=x&&x.reload||!1,L=K&&(K===!0?R[0].self:a.get(K,C));x&&K&&K!==!0&&delete x.reload;var U={toState:J,toParams:$||{},fromState:O,fromParams:j||{},options:x,reloadStateTree:L};if(f.push(U),l=D,L){U.toParams.$$uirouterextrasreload=Math.random();var V=L.$$state().params,z=L.$$state().ownParams;if(v.hasParamSet){var G=new m.Param("$$uirouterextrasreload");V.$$uirouterextrasreload=z.$$uirouterextrasreload=G,D.restoreFunctions.push(function(){delete V.$$uirouterextrasreload,delete z.$$uirouterextrasreload})}else V.push("$$uirouterextrasreload"),z.push("$$uirouterextrasreload"),D.restoreFunctions.push(function(){V.length=V.length-1,z.length=z.length-1})}I=i.processTransition(U),w&&r(o,U,I);var H=J.path.slice(0,I.keep),N=O.path.slice(0,I.keep);e.forEach(c.locals,function(e,t){-1!=t.indexOf("@")&&delete c.locals[t]});for(var Q=0;Q "+n.toState.self.name+": "+e.toJson(n.toParams);t.debug(" Current transition: ",l),t.debug("Before transition, inactives are: : ",x(s.getInactiveStates(),function(e){return e.self.name})),t.debug("After transition, inactives will be: ",o),t.debug("Transition will exit: ",u),t.debug("Transition will enter: ",i)}function h(e,t,n){e.debug("Current state: "+t.self.name+", inactive states: ",x(s.getInactiveStates(),function(e){return e.self.name}));for(var a=function(e,t){return"'"+t+"' ("+e.$$state.name+")"},r=function(e,t){return"globals"!=t&&"resolve"!=t},o=function(e){var t=x(P(e.locals,r),a).join(", ");return"("+(e.self.name?e.self.name:"root")+".locals"+(t.length?": "+t:"")+")"},i=o(t),u=t.parent;u&&u!==t;)""===u.self.name&&(i=o(n.$current.path[0])+" / "+i),i=o(u)+" / "+i,t=u,u=t.parent;e.debug("Views: "+i)}var p=d,g=p.internalStates,$=p.inherit,x=(p.inheritParams,p.map),P=p.filterObj;c.hasParamSet=!!v.ParamSet,u=e.extend(new a("__inactives"),{self:{name:"__inactives"}}),o=i=t,l=[],d.onStateRegistered(function(e){e.self.sticky===!0&&f.registerStickyState(e.self)});var S;n.decorator("$state",["$delegate","$log","$q",function(n,r,d){return o=n.$current,g[""]=o,o.parent=u,u.parent=t,o.locals=$(u.locals,o.locals),delete u.locals.globals,S=n.transitionTo,n.transitionTo=function(t,p,$){function P(t){var n=e.extend(new a("reactivate_phase1"),{locals:t.locals});return n.self=e.extend({},t.self),n}function E(t){var n=e.extend(new a("reactivate_phase2"),t),r=n.self.onEnter;return n.resolve={},n.views={},n.self.onEnter=function(){n.locals=t.locals,s.stateReactivated(t)},J.addRestoreFunction(function(){t.self.onEnter=r}),n}function b(e){var t=new a("inactivate");t.self=e.self;var n=e.self.onExit;return t.self.onExit=function(){s.stateInactivated(e)},J.addRestoreFunction(function(){e.self.onExit=n}),t}function k(e,t){var n=e.self.onEnter;return e.self.onEnter=function(){s.stateEntering(e,t,n)},J.addRestoreFunction(function(){e.self.onEnter=n}),e}function y(e,t){var n=e.self.onEnter;return e.self.onEnter=function(){s.stateEntering(e,t,n,!0)},J.addRestoreFunction(function(){e.self.onEnter=n}),e}function w(e){var t=e.self.onExit;return e.self.onExit=function(){s.stateExiting(e,B,t)},J.addRestoreFunction(function(){e.self.onExit=t}),e}var F=f.debugMode();u.locals||(u.locals=o.locals);var R=l.length;i&&(i(),F&&r.debug("Restored paths from pending transition"));var T,_,I,O,j=n.$current,C=n.params,M=$&&$.relative||n.$current,q=n.get(t,M),A=[],B=[];p=p||{},arguments[1]=p;var D=function(){},J=function(){T&&(K.path=T,T=null),_&&(j.path=_,_=null),e.forEach(J.restoreFunctions,function(e){e()}),J=D,i=null,l.splice(R,1)};if(J.restoreFunctions=[],J.addRestoreFunction=function(e){this.restoreFunctions.push(e)},q){var K=g[q.name];if(K){T=K.path,_=j.path;var L=$&&$.reload||!1,U=L&&(L===!0?T[0].self:n.get(L,M));$&&L&&L!==!0&&delete $.reload;var V={toState:K,toParams:p||{},fromState:j,fromParams:C||{},options:$,reloadStateTree:U};if(l.push(V),i=J,U){V.toParams.$$uirouterextrasreload=Math.random();var z=U.$$state().params,G=U.$$state().ownParams;if(c.hasParamSet){var H=new v.Param("$$uirouterextrasreload");z.$$uirouterextrasreload=G.$$uirouterextrasreload=H,J.restoreFunctions.push(function(){delete z.$$uirouterextrasreload,delete G.$$uirouterextrasreload})}else z.push("$$uirouterextrasreload"),G.push("$$uirouterextrasreload"),J.restoreFunctions.push(function(){z.length=z.length-1,G.length=G.length-1})}I=s.processTransition(V),F&&m(r,V,I);var N=K.path.slice(0,I.keep),Q=j.path.slice(0,I.keep);e.forEach(u.locals,function(e,t){-1!=t.indexOf("@")&&delete u.locals[t]});for(var W=0;W