From 01bcaf740bef1d778befc3f3fd602fe54b09ab39 Mon Sep 17 00:00:00 2001 From: Stepan Riha Date: Tue, 11 Oct 2016 17:02:03 -0500 Subject: [PATCH] Bumped version number --- angular-ui-router-default.js | 145 ++++++++++++++++++----------------- bower.json | 2 +- package.json | 2 +- 3 files changed, 78 insertions(+), 71 deletions(-) diff --git a/angular-ui-router-default.js b/angular-ui-router-default.js index 4a06395..680deb7 100644 --- a/angular-ui-router-default.js +++ b/angular-ui-router-default.js @@ -3,83 +3,90 @@ * * @link https://github.com/nonplus/angular-ui-router-default * - * @license angular-ui-router-default v0.0.4 + * @license angular-ui-router-default v0.0.5 * (c) Copyright Stepan Riha * License MIT */ (function(angular) { -/* global angular */ "use strict"; +var moduleName = 'ui.router.default'; +if (typeof module !== "undefined" && typeof exports !== "undefined" && module.exports === exports) { + module.exports = moduleName; +} var max_redirects = 10; -angular.module('ui.router.default', ['ui.router']) - .config(['$provide', function($provide) { - $provide.decorator('$state', ['$delegate', '$injector', '$q', function($delegate, $injector, $q) { - var transitionTo = $delegate.transitionTo; - var pendingPromise; - $delegate.transitionTo = function(to, toParams, options) { - var numRedirects = 0; - var $state = this; - var nextState = to.name || to; - var nextParams = toParams; - var nextOptions = options; +angular.module(moduleName, ['ui.router']) + .config(['$provide', function ($provide) { + $provide.decorator('$state', ['$delegate', '$injector', '$q', function ($delegate, $injector, $q) { + var transitionTo = $delegate.transitionTo; + var pendingPromise; + $delegate.transitionTo = function (to, toParams, options) { + var numRedirects = 0; + var $state = this; + var nextState = to.name || to; + var nextParams = toParams; + var nextOptions = options; + return fetchTarget(); + function fetchTarget() { + var target = $state.get(nextState, $state.$current); + nextState = (target || {}).name; + var absRedirectPromise = getAbstractRedirect(target); + pendingPromise = absRedirectPromise; + return $q.when(absRedirectPromise) + .then(abstractTargetResolved); + function abstractTargetResolved(abstractTarget) { + if (absRedirectPromise !== pendingPromise) { + return $q.reject(new Error('transition superseded')); + } + // we didn't get anything from the abstract target + if (!abstractTarget) { + return transitionTo.call($delegate, nextState, nextParams, nextOptions); + } + checkForMaxRedirect(); + nextState = abstractTarget; + return fetchTarget(); + } + function checkForMaxRedirect() { + if (numRedirects === max_redirects) { + throw new Error('Too many abstract state default redirects'); + } + numRedirects += 1; + } + } + function getAbstractRedirect(state) { + if (!state || !state.abstract || (state.abstract === true && !state.default)) { + return null; + } + return invokeAbstract(state).then(abstractInvoked); + function abstractInvoked(newState) { + if (newState[0] === '.') { + return nextState + newState; + } + else { + return newState; + } + } + } + function invokeAbstract(state) { + var defaultState; + if (state.default) { + defaultState = state.default; + } + else { + defaultState = state.abstract; + } + if (defaultState instanceof Function || defaultState instanceof Array) { + return $q.when($injector.invoke(defaultState)); + } + else { + return $q.when(defaultState); + } + } + }; + return $delegate; + }]); + }]); - return fetchTarget(); - - function fetchTarget() { - var target = $state.get(nextState, $state.$current); - nextState = (target|| {}).name; - - var absRedirectPromise = getAbstractRedirect(target); - pendingPromise = absRedirectPromise; - return $q.when(absRedirectPromise, abstractTargetResolved); - - function abstractTargetResolved(abstractTarget) { - if(absRedirectPromise !== pendingPromise) { - return $q.reject(new Error('transition superseded')); - } - // we didn't get anything from the abstract target - if (!abstractTarget) { - return transitionTo.call($delegate, nextState, nextParams, nextOptions); - } - checkForMaxRedirect(); - nextState = abstractTarget; - return fetchTarget(); - } - - function checkForMaxRedirect() { - if (numRedirects === max_redirects) { - throw new Error('Too many abstract state default redirects'); - } - numRedirects += 1; - } - } - function getAbstractRedirect(state) { - if (!state || !state.abstract || state.abstract === true) { - return null; - } - return invokeAbstract(state.abstract).then(abstractInvoked); - function abstractInvoked(newState) { - if (newState[0] === '.') { - return nextState + newState; - } else { - return newState; - } - } - - } - function invokeAbstract(abstract) { - if (!angular.isString(abstract)) { - return $q.when($injector.invoke(abstract)); - } else { - return $q.when(abstract); - } - } - - }; - return $delegate; - }]); - }]); })(window.angular); \ No newline at end of file diff --git a/bower.json b/bower.json index 3b18634..3a48b1d 100644 --- a/bower.json +++ b/bower.json @@ -1,7 +1,7 @@ { "name": "angular-ui-router-default", "main": "angular-ui-router-default.js", - "version": "0.0.4", + "version": "0.0.5", "homepage": "https://github.com/nonplus/angular-ui-router-default", "authors": [ "Stepan Riha " diff --git a/package.json b/package.json index fc0febe..186b596 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "angular-ui-router-default", - "version": "0.0.4", + "version": "0.0.5", "description": "AngularJS module that adds support for specifying default child views for abstract states when using ui-router.", "main": "angular-ui-router-default.js", "types": "./index.d.ts",