From 70e43ac7adfb27ebebad4e4f5407e00ec8a4622e Mon Sep 17 00:00:00 2001 From: Adam Bradley Date: Sun, 16 Nov 2014 23:12:53 -0600 Subject: [PATCH] refactor(uiRouter): updates for Angular v1.3 --- config/lib/js/angular-ui/angular-ui-router.js | 421 +++++++++--------- .../js/angular-ui/angular-ui-router.min.js | 3 +- 2 files changed, 220 insertions(+), 204 deletions(-) diff --git a/config/lib/js/angular-ui/angular-ui-router.js b/config/lib/js/angular-ui/angular-ui-router.js index c8770993eb..bf8f0bcebb 100644 --- a/config/lib/js/angular-ui/angular-ui-router.js +++ b/config/lib/js/angular-ui/angular-ui-router.js @@ -1,6 +1,7 @@ /** * State-based routing for AngularJS * @version v0.2.10 + * Ionic fork, updated for Angular v1.3 * @link http://angular-ui.github.com/ * @license MIT License, http://www.opensource.org/licenses/MIT */ @@ -191,7 +192,7 @@ angular.module('ui.router.util', ['ng']); /** * @ngdoc overview * @name ui.router.router - * + * * @requires ui.router.util * * @description @@ -205,7 +206,7 @@ angular.module('ui.router.router', ['ui.router.util']); /** * @ngdoc overview * @name ui.router.state - * + * * @requires ui.router.router * @requires ui.router.util * @@ -214,7 +215,7 @@ angular.module('ui.router.router', ['ui.router.util']); * * This module is a dependency of the main ui.router module. Do not include this module as a dependency * in your angular app (use {@link ui.router} module instead). - * + * */ angular.module('ui.router.state', ['ui.router.router', 'ui.router.util']); @@ -226,17 +227,17 @@ angular.module('ui.router.state', ['ui.router.router', 'ui.router.util']); * * @description * # ui.router - * - * ## The main module for ui.router + * + * ## The main module for ui.router * There are several sub-modules included with the ui.router module, however only this module is needed - * as a dependency within your angular app. The other modules are for organization purposes. + * as a dependency within your angular app. The other modules are for organization purposes. * * The modules are: * * ui.router - the main "umbrella" module - * * ui.router.router - - * + * * ui.router.router - + * * *You'll need to include **only** this module as the dependency within your angular app.* - * + * *
  * 
  * 
@@ -270,14 +271,14 @@ angular.module('ui.router.compat', ['ui.router']);
  */
 $Resolve.$inject = ['$q', '$injector'];
 function $Resolve(  $q,    $injector) {
-  
+
   var VISIT_IN_PROGRESS = 1,
       VISIT_DONE = 2,
       NOTHING = {},
       NO_DEPENDENCIES = [],
       NO_LOCALS = NOTHING,
       NO_PARENT = extend($q.when(NOTHING), { $$promises: NOTHING, $$values: NOTHING });
-  
+
 
   /**
    * @ngdoc function
@@ -293,7 +294,7 @@ function $Resolve(  $q,    $injector) {
    * 
    * $resolve.resolve(invocables, locals, parent, self)
    * 
- * but the former is more efficient (in fact `resolve` just calls `study` + * but the former is more efficient (in fact `resolve` just calls `study` * internally). * * @param {object} invocables Invocable objects @@ -301,19 +302,19 @@ function $Resolve( $q, $injector) { */ this.study = function (invocables) { if (!isObject(invocables)) throw new Error("'invocables' must be an object"); - + // Perform a topological sort of invocables to build an ordered plan var plan = [], cycle = [], visited = {}; function visit(value, key) { if (visited[key] === VISIT_DONE) return; - + cycle.push(key); if (visited[key] === VISIT_IN_PROGRESS) { cycle.splice(0, cycle.indexOf(key)); throw new Error("Cyclic dependency: " + cycle.join(" -> ")); } visited[key] = VISIT_IN_PROGRESS; - + if (isString(value)) { plan.push(key, [ function() { return $injector.get(value); }], NO_DEPENDENCIES); } else { @@ -323,17 +324,17 @@ function $Resolve( $q, $injector) { }); plan.push(key, value, params); } - + cycle.pop(); visited[key] = VISIT_DONE; } forEach(invocables, visit); invocables = cycle = visited = null; // plan is all that's required - + function isResolve(value) { return isObject(value) && value.then && value.$$promises; } - + return function (locals, parent, self) { if (isResolve(locals) && self === undefined) { self = parent; parent = locals; locals = null; @@ -341,12 +342,12 @@ function $Resolve( $q, $injector) { if (!locals) locals = NO_LOCALS; else if (!isObject(locals)) { throw new Error("'locals' must be an object"); - } + } if (!parent) parent = NO_PARENT; else if (!isResolve(parent)) { throw new Error("'parent' must be a promise returned by $resolve.resolve()"); } - + // To complete the overall resolution, we have to wait for the parent // promise and for the promise for each invokable in our plan. var resolution = $q.defer(), @@ -355,28 +356,28 @@ function $Resolve( $q, $injector) { values = extend({}, locals), wait = 1 + plan.length/3, merged = false; - + function done() { // Merge parent values we haven't got yet and publish our own $$values if (!--wait) { - if (!merged) merge(values, parent.$$values); + if (!merged) merge(values, parent.$$values); result.$$values = values; result.$$promises = true; // keep for isResolve() resolution.resolve(values); } } - + function fail(reason) { result.$$failure = reason; resolution.reject(reason); } - + // Short-circuit if parent has already failed if (isDefined(parent.$$failure)) { fail(parent.$$failure); return result; } - + // Merge parent values if the parent has already resolved, or merge // parent promises and wait if the parent resolve is still in progress. if (parent.$$values) { @@ -386,13 +387,13 @@ function $Resolve( $q, $injector) { extend(promises, parent.$$promises); parent.then(done, fail); } - + // Process each invocable in the plan, but ignore any where a local of the same name exists. for (var i=0, ii=plan.length; i} The template html as a string, or a promise + * @return {string|Promise.} The template html as a string, or a promise * for that string. */ this.fromUrl = function (url, params) { @@ -600,9 +601,9 @@ function $TemplateFactory( $http, $templateCache, $injector) { * * @param {Function} provider Function to invoke via `$injector.invoke` * @param {Object} params Parameters for the template. - * @param {Object} locals Locals to pass to `invoke`. Defaults to + * @param {Object} locals Locals to pass to `invoke`. Defaults to * `{ params: params }`. - * @return {string|Promise.} The template html as a string, or a promise + * @return {string|Promise.} The template html as a string, or a promise * for that string. */ this.fromProvider = function (provider, params, locals) { @@ -622,7 +623,7 @@ angular.module('ui.router.util').service('$templateFactory', $TemplateFactory); * of search parameters. Multiple search parameter names are separated by '&'. Search parameters * do not influence whether or not a URL is matched, but their values are passed through into * the matched parameters returned by {@link ui.router.util.type:UrlMatcher#methods_exec exec}. - * + * * Path parameter placeholders can be specified using simple colon/catch-all syntax or curly brace * syntax, which optionally allows a regular expression for the parameter to be specified: * @@ -633,13 +634,13 @@ angular.module('ui.router.util').service('$templateFactory', $TemplateFactory); * curly braces, they must be in matched pairs or escaped with a backslash. * * Parameter names may contain only word characters (latin letters, digits, and underscore) and - * must be unique within the pattern (across both path and search parameters). For colon + * must be unique within the pattern (across both path and search parameters). For colon * placeholders or curly placeholders without an explicit regexp, a path parameter matches any * number of characters other than '/'. For catch-all placeholders the path parameter matches * any number of characters. - * + * * Examples: - * + * * * `'/hello/'` - Matches only if the path is exactly '/hello/'. There is no special treatment for * trailing slashes, and patterns have to match the entire path, not just a prefix. * * `'/user/:id'` - Matches '/user/bob' or '/user/1234!!!' or even '/user/' but not '/user' or @@ -664,7 +665,7 @@ angular.module('ui.router.util').service('$templateFactory', $TemplateFactory); * * @property {string} sourceSearch The search portion of the source property * - * @property {string} regex The constructed regex that will be used to match against the url when + * @property {string} regex The constructed regex that will be used to match against the url when * it is time to determine which url will match. * * @returns {Object} New UrlMatcher object @@ -814,7 +815,7 @@ UrlMatcher.prototype.exec = function (path, searchParams) { * * @description * Returns the names of all path and search parameters of this pattern in an unspecified order. - * + * * @returns {Array.} An array of parameter names. Must be treated as read-only. If the * pattern has no parameters, an empty array is returned. */ @@ -884,7 +885,7 @@ function $UrlMatcherFactory() { * * @description * Creates a {@link ui.router.util.type:UrlMatcher} for the specified pattern. - * + * * @param {string} pattern The URL pattern. * @returns {ui.router.util.type:UrlMatcher} The UrlMatcher. */ @@ -906,7 +907,7 @@ function $UrlMatcherFactory() { this.isMatcher = function (o) { return isObject(o) && isFunction(o.exec) && isFunction(o.format) && isFunction(o.concat); }; - + /* No need to document $get, since it returns this */ this.$get = function () { return this; @@ -923,9 +924,9 @@ angular.module('ui.router.util').provider('$urlMatcherFactory', $UrlMatcherFacto * @requires ui.router.util.$urlMatcherFactoryProvider * * @description - * `$urlRouterProvider` has the responsibility of watching `$location`. - * When `$location` changes it runs through a list of rules one by one until a - * match is found. `$urlRouterProvider` is used behind the scenes anytime you specify + * `$urlRouterProvider` has the responsibility of watching `$location`. + * When `$location` changes it runs through a list of rules one by one until a + * match is found. `$urlRouterProvider` is used behind the scenes anytime you specify * a url in a state configuration. All urls are compiled into a UrlMatcher object. * * There are several methods on `$urlRouterProvider` that make it useful to use directly @@ -933,7 +934,7 @@ angular.module('ui.router.util').provider('$urlMatcherFactory', $UrlMatcherFacto */ $UrlRouterProvider.$inject = ['$urlMatcherFactoryProvider']; function $UrlRouterProvider( $urlMatcherFactory) { - var rules = [], + var rules = [], otherwise = null; // Returns a string that is a prefix of all strings matching the RegExp @@ -1012,8 +1013,8 @@ function $UrlRouterProvider( $urlMatcherFactory) { * }); *
* - * @param {string|object} rule The url path you want to redirect to or a function - * rule that returns the url path. The function version is passed two params: + * @param {string|object} rule The url path you want to redirect to or a function + * rule that returns the url path. The function version is passed two params: * `$injector` and `$location` services. * * @return {object} $urlRouterProvider - $urlRouterProvider instance @@ -1131,8 +1132,8 @@ function $UrlRouterProvider( $urlMatcherFactory) { * */ this.$get = - [ '$location', '$rootScope', '$injector', - function ($location, $rootScope, $injector) { + [ '$location', '$rootScope', '$injector', '$log', + function ($location, $rootScope, $injector, $log) { // TODO: Optimize groups of rules with non-empty prefix into some sort of decision tree function update(evt) { if (evt && evt.defaultPrevented) return; @@ -1149,7 +1150,7 @@ function $UrlRouterProvider( $urlMatcherFactory) { if (check(rules[i])) return; } if($location.$$path && $location.$$path !== '/') { - console.warn('Routing: No route matched for', $location.$$path + '. Check your Ionic route definitions.'); + $log.warn('Routing: No route matched for', $location.$$path + '. Check your Ionic route definitions.'); } // always check otherwise last to allow dynamic updates to the set of rules if (otherwise) check(otherwise); @@ -1165,8 +1166,8 @@ function $UrlRouterProvider( $urlMatcherFactory) { * * @description * Triggers an update; the same update that happens when the address bar url changes, aka `$locationChangeSuccess`. - * This method is useful when you need to use `preventDefault()` on the `$locationChangeSuccess` event, - * perform some custom logic (route protection, auth, config, redirection, etc) and then finally proceed + * This method is useful when you need to use `preventDefault()` on the `$locationChangeSuccess` event, + * perform some custom logic (route protection, auth, config, redirection, etc) and then finally proceed * with the transition by calling `$urlRouter.sync()`. * * @example @@ -1465,9 +1466,9 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory, $ * @methodOf ui.router.state.$stateProvider * * @description - * Allows you to extend (carefully) or override (at your own peril) the - * `stateBuilder` object used internally by `$stateProvider`. This can be used - * to add custom functionality to ui-router, for example inferring templateUrl + * Allows you to extend (carefully) or override (at your own peril) the + * `stateBuilder` object used internally by `$stateProvider`. This can be used + * to add custom functionality to ui-router, for example inferring templateUrl * based on the state name. * * When passing only a name, it returns the current (original or decorated) builder @@ -1476,14 +1477,14 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory, $ * The builder functions that can be decorated are listed below. Though not all * necessarily have a good use case for decoration, that is up to you to decide. * - * In addition, users can attach custom decorators, which will generate new - * properties within the state's internal definition. There is currently no clear - * use-case for this beyond accessing internal states (i.e. $state.$current), - * however, expect this to become increasingly relevant as we introduce additional + * In addition, users can attach custom decorators, which will generate new + * properties within the state's internal definition. There is currently no clear + * use-case for this beyond accessing internal states (i.e. $state.$current), + * however, expect this to become increasingly relevant as we introduce additional * meta-programming features. * - * **Warning**: Decorators should not be interdependent because the order of - * execution of the builder functions in non-deterministic. Builder functions + * **Warning**: Decorators should not be interdependent because the order of + * execution of the builder functions in non-deterministic. Builder functions * should only be dependent on the state definition object and super function. * * @@ -1493,21 +1494,21 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory, $ * - **data** `{object}` - returns state data, including any inherited data that is not * overridden by own values (if any). * - **url** `{object}` - returns a {link ui.router.util.type:UrlMatcher} or null. - * - **navigable** `{object}` - returns closest ancestor state that has a URL (aka is + * - **navigable** `{object}` - returns closest ancestor state that has a URL (aka is * navigable). - * - **params** `{object}` - returns an array of state params that are ensured to + * - **params** `{object}` - returns an array of state params that are ensured to * be a super-set of parent's params. - * - **views** `{object}` - returns a views object where each key is an absolute view - * name (i.e. "viewName@stateName") and each value is the config object - * (template, controller) for the view. Even when you don't use the views object + * - **views** `{object}` - returns a views object where each key is an absolute view + * name (i.e. "viewName@stateName") and each value is the config object + * (template, controller) for the view. Even when you don't use the views object * explicitly on a state config, one is still created for you internally. - * So by decorating this builder function you have access to decorating template + * So by decorating this builder function you have access to decorating template * and controller properties. - * - **ownParams** `{object}` - returns an array of params that belong to the state, + * - **ownParams** `{object}` - returns an array of params that belong to the state, * not including any params defined by ancestor states. - * - **path** `{string}` - returns the full path from the root down to this state. + * - **path** `{string}` - returns the full path from the root down to this state. * Needed for state activation. - * - **includes** `{object}` - returns an object that includes every state that + * - **includes** `{object}` - returns an object that includes every state that * would pass a '$state.includes()' test. * * @example @@ -1540,8 +1541,8 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory, $ * // and /partials/home/contact/item.html, respectively. * * - * @param {string} name The name of the builder function to decorate. - * @param {object} func A function that is responsible for decorating the original + * @param {string} name The name of the builder function to decorate. + * @param {object} func A function that is responsible for decorating the original * builder function. The function receives two parameters: * * - `{object}` - state - The state config object. @@ -1577,9 +1578,9 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory, $ * * * - **`template`** - {string|function=} - html template as a string or a function that returns - * an html template as a string which should be used by the uiView directives. This property + * an html template as a string which should be used by the uiView directives. This property * takes precedence over templateUrl. - * + * * If `template` is a function, it will be called with the following parameters: * * - {array.<object>} - state parameters extracted from the current $location.path() by @@ -1587,12 +1588,12 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory, $ * * * - * - **`templateUrl`** - {string|function=} - path or function that returns a path to an html + * - **`templateUrl`** - {string|function=} - path or function that returns a path to an html * template that should be used by uiView. - * + * * If `templateUrl` is a function, it will be called with the following parameters: * - * - {array.<object>} - state parameters extracted from the current $location.path() by + * - {array.<object>} - state parameters extracted from the current $location.path() by * applying the current state * * @@ -1602,7 +1603,7 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory, $ * * * - * - **`controller`** - {string|function=} - Controller fn that should be associated with newly + * - **`controller`** - {string|function=} - Controller fn that should be associated with newly * related scope or the name of a registered controller if passed as a string. * * @@ -1611,35 +1612,35 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory, $ * the actual controller or string. * * - * - * - **`controllerAs`** – {string=} – A controller alias name. If present the controller will be + * + * - **`controllerAs`** – {string=} – A controller alias name. If present the controller will be * published to scope under the controllerAs name. * * * - * - **`resolve`** - {object.<string, function>=} - An optional map of dependencies which - * should be injected into the controller. If any of these dependencies are promises, - * the router will wait for them all to be resolved or one to be rejected before the - * controller is instantiated. If all the promises are resolved successfully, the values - * of the resolved promises are injected and $stateChangeSuccess event is fired. If any + * - **`resolve`** - {object.<string, function>=} - An optional map of dependencies which + * should be injected into the controller. If any of these dependencies are promises, + * the router will wait for them all to be resolved or one to be rejected before the + * controller is instantiated. If all the promises are resolved successfully, the values + * of the resolved promises are injected and $stateChangeSuccess event is fired. If any * of the promises are rejected the $stateChangeError event is fired. The map object is: - * + * * - key - {string}: name of dependency to be injected into controller - * - factory - {string|function}: If string then it is alias for service. Otherwise if function, - * it is injected and return value it treated as dependency. If result is a promise, it is + * - factory - {string|function}: If string then it is alias for service. Otherwise if function, + * it is injected and return value it treated as dependency. If result is a promise, it is * resolved before its value is injected into controller. * * * * - **`url`** - {string=} - A url with optional parameters. When a state is navigated or - * transitioned to, the `$stateParams` service will be populated with any + * transitioned to, the `$stateParams` service will be populated with any * parameters that were passed. * * * - * - **`params`** - {object=} - An array of parameter names or regular expressions. Only + * - **`params`** - {object=} - An array of parameter names or regular expressions. Only * use this within a state if you are not using url. Otherwise you can specify your - * parameters within the url. When a state is navigated or transitioned to, the + * parameters within the url. When a state is navigated or transitioned to, the * $stateParams service will be populated with any parameters that were passed. * * @@ -1649,7 +1650,7 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory, $ * * * - * - **`abstract`** - {boolean=} - An abstract state will never be directly activated, + * - **`abstract`** - {boolean=} - An abstract state will never be directly activated, * but can provide inherited properties to its common children states. * * @@ -1664,8 +1665,8 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory, $ * * * - * - **`reloadOnSearch = true`** - {boolean=} - If `false`, will not retrigger the same state - * just because a search/query parameter has changed (via $location.search() or $location.hash()). + * - **`reloadOnSearch = true`** - {boolean=} - If `false`, will not retrigger the same state + * just because a search/query parameter has changed (via $location.search() or $location.hash()). * Useful for when you'd like to modify $location.search() without triggering a reload. * * @@ -1679,7 +1680,7 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory, $ * // stateName can be a single top-level name (must be unique). * $stateProvider.state("home", {}); * - * // Or it can be a nested state name. This state is a child of the + * // Or it can be a nested state name. This state is a child of the * // above "home" state. * $stateProvider.state("home.newest", {}); * @@ -1693,7 +1694,7 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory, $ * .state("contacts", {}); * * - * @param {string} name A unique state name, e.g. "home", "about", "contacts". + * @param {string} name A unique state name, e.g. "home", "about", "contacts". * To create a parent/child state use a dot, e.g. "about.sales", "home.newest". * @param {object} definition State configuration object. */ @@ -1717,11 +1718,11 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory, $ * @requires ui.router.util.$resolve * @requires ui.router.state.$stateParams * - * @property {object} params A param object, e.g. {sectionId: section.id)}, that + * @property {object} params A param object, e.g. {sectionId: section.id)}, that * you'd like to test against the current active state. - * @property {object} current A reference to the state's config object. However + * @property {object} current A reference to the state's config object. However * you passed it in. Useful for accessing custom data. - * @property {object} transition Currently pending transition. A promise that'll + * @property {object} transition Currently pending transition. A promise that'll * resolve or reject. * * @description @@ -1762,7 +1763,7 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory, $ * @methodOf ui.router.state.$state * * @description - * A method that force reloads the current state. All resolves are re-resolved, events are not re-fired, + * A method that force reloads the current state. All resolves are re-resolved, events are not re-fired, * and controllers reinstantiated (bug with controllers reinstantiating right now, fixing soon). * * @example @@ -1778,8 +1779,8 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory, $ * * `reload()` is just an alias for: *
-     * $state.transitionTo($state.current, $stateParams, { 
-     *   reload: true, inherit: false, notify: false 
+     * $state.transitionTo($state.current, $stateParams, {
+     *   reload: true, inherit: false, notify: false
      * });
      * 
*/ @@ -1793,11 +1794,11 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory, $ * @methodOf ui.router.state.$state * * @description - * Convenience method for transitioning to a new state. `$state.go` calls - * `$state.transitionTo` internally but automatically sets options to - * `{ location: true, inherit: true, relative: $state.$current, notify: true }`. - * This allows you to easily use an absolute or relative to path and specify - * only the parameters you'd like to update (while letting unspecified parameters + * Convenience method for transitioning to a new state. `$state.go` calls + * `$state.transitionTo` internally but automatically sets options to + * `{ location: true, inherit: true, relative: $state.$current, notify: true }`. + * This allows you to easily use an absolute or relative to path and specify + * only the parameters you'd like to update (while letting unspecified parameters * inherit from the currently active ancestor states). * * @example @@ -1819,8 +1820,8 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory, $ * - `$state.go('^.sibling')` - will go to a sibling state * - `$state.go('.child.grandchild')` - will go to grandchild state * - * @param {object=} params A map of the parameters that will be sent to the state, - * will populate $stateParams. Any parameters that are not specified will be inherited from currently + * @param {object=} params A map of the parameters that will be sent to the state, + * will populate $stateParams. Any parameters that are not specified will be inherited from currently * defined parameters. This allows, for example, going to a sibling state that shares parameters * specified in a parent state. Parameter inheritance only works between common ancestor states, I.e. * transitioning to a sibling will get you the parameters for all parents, transitioning to a child @@ -1830,10 +1831,10 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory, $ * - **`location`** - {boolean=true|string=} - If `true` will update the url in the location bar, if `false` * will not. If string, must be `"replace"`, which will update url and also replace last history record. * - **`inherit`** - {boolean=true}, If `true` will inherit url parameters from current url. - * - **`relative`** - {object=$state.$current}, When transitioning with relative path (e.g '^'), + * - **`relative`** - {object=$state.$current}, When transitioning with relative path (e.g '^'), * defines which state to be relative from. * - **`notify`** - {boolean=true}, If `true` will broadcast $stateChangeStart and $stateChangeSuccess events. - * - **`reload`** (v0.2.5) - {boolean=false}, If `true` will force transition even if the state or params + * - **`reload`** (v0.2.5) - {boolean=false}, If `true` will force transition even if the state or params * have not changed, aka a reload of the same state. It differs from reloadOnSearch because you'd * use this when you want to force a reload when *everything* is the same, including search params. * @@ -1885,10 +1886,10 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory, $ * - **`location`** - {boolean=true|string=} - If `true` will update the url in the location bar, if `false` * will not. If string, must be `"replace"`, which will update url and also replace last history record. * - **`inherit`** - {boolean=false}, If `true` will inherit url parameters from current url. - * - **`relative`** - {object=}, When transitioning with relative path (e.g '^'), + * - **`relative`** - {object=}, When transitioning with relative path (e.g '^'), * defines which state to be relative from. * - **`notify`** - {boolean=true}, If `true` will broadcast $stateChangeStart and $stateChangeSuccess events. - * - **`reload`** (v0.2.5) - {boolean=false}, If `true` will force transition even if the state or params + * - **`reload`** (v0.2.5) - {boolean=false}, If `true` will force transition even if the state or params * have not changed, aka a reload of the same state. It differs from reloadOnSearch because you'd * use this when you want to force a reload when *everything* is the same, including search params. * @@ -2157,8 +2158,8 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory, $ * * @description * Similar to {@link ui.router.state.$state#methods_includes $state.includes}, - * but only checks for the full state name. If params is supplied then it will be - * tested for strict equality against the current active params object, so all params + * but only checks for the full state name. If params is supplied then it will be + * tested for strict equality against the current active params object, so all params * must match with none missing and no extras. * * @example @@ -2170,7 +2171,7 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory, $ * * * @param {string|object} stateName The state name or state object you'd like to check. - * @param {object=} params A param object, e.g. `{sectionId: section.id}`, that you'd like + * @param {object=} params A param object, e.g. `{sectionId: section.id}`, that you'd like * to test against the current active state. * @returns {boolean} Returns true if it is the state. */ @@ -2194,7 +2195,7 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory, $ * @methodOf ui.router.state.$state * * @description - * A method to determine if the current active state is equal to or is the child of the + * A method to determine if the current active state is equal to or is the child of the * state stateName. If any params are passed then they will be tested for a match as well. * Not all the parameters need to be passed, just the ones you'd like to test for equality. * @@ -2226,7 +2227,7 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory, $ * * * @param {string} stateOrName A partial name to be searched for within the current state name. - * @param {object} params A param object, e.g. `{sectionId: section.id}`, + * @param {object} params A param object, e.g. `{sectionId: section.id}`, * that you'd like to test against the current active state. * @returns {boolean} Returns true if it does include the state */ @@ -2280,10 +2281,10 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory, $ * first parameter, then the constructed href url will be built from the first navigable ancestor (aka * ancestor with a valid url). * - **`inherit`** - {boolean=false}, If `true` will inherit url parameters from current url. - * - **`relative`** - {object=$state.$current}, When transitioning with relative path (e.g '^'), + * - **`relative`** - {object=$state.$current}, When transitioning with relative path (e.g '^'), * defines which state to be relative from. * - **`absolute`** - {boolean=false}, If true will generate an absolute url, e.g. "http://www.example.com/fullurl". - * + * * @returns {string} compiled state url */ $state.href = function href(stateOrName, params, options) { @@ -2294,12 +2295,20 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory, $ params = inheritParams($stateParams, params || {}, $state.$current, state); var nav = (state && options.lossy) ? state.navigable : state; var url = (nav && nav.url) ? nav.url.format(normalize(state.params, params || {})) : null; - if (!$locationProvider.html5Mode() && url) { + + var isHtml5 = $locationProvider.html5Mode(); + + // Angular 1.3.X + + if (isObject(isHtml5)) { + isHtml5 = isHtml5.enabled; + } + + if (!isHtml5 && url) { url = "#" + $locationProvider.hashPrefix() + url; } if (baseHref !== '/') { - if ($locationProvider.html5Mode()) { + if (isHtml5) { url = baseHref.slice(0, -1) + url; } else if (options.absolute){ url = baseHref.slice(1) + url; @@ -2307,10 +2316,10 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory, $ } if (options.absolute && url) { - url = $location.protocol() + '://' + - $location.host() + - ($location.port() == 80 || $location.port() == 443 ? '' : ':' + $location.port()) + - (!$locationProvider.html5Mode() && url ? '/' : '') + + url = $location.protocol() + '://' + + $location.host() + + ($location.port() == 80 || $location.port() == 443 ? '' : ':' + $location.port()) + + (!isHtml5 && url ? '/' : '') + url; } return url; @@ -2551,26 +2560,26 @@ angular.module('ui.router.state').provider('$uiViewScroll', $ViewScrollProvider) * functionality, call `$uiViewScrollProvider.useAnchorScroll()`.* * * @param {string=} onload Expression to evaluate whenever the view updates. - * + * * @example - * A view can be unnamed or named. + * A view can be unnamed or named. *
  * 
- * 
- * + *
+ * * *
*
* - * You can only have one unnamed view within any template (or root html). If you are only using a + * You can only have one unnamed view within any template (or root html). If you are only using a * single view and it is unnamed then you can populate it like so: *
- * 
+ *
* $stateProvider.state("home", { * template: "

HELLO!

" * }) *
- * + * * The above is a convenient shortcut equivalent to specifying your view explicitly with the {@link ui.router.state.$stateProvider#views `views`} * config property, by name, in this case an empty name: *
@@ -2579,33 +2588,33 @@ angular.module('ui.router.state').provider('$uiViewScroll', $ViewScrollProvider)
  *     "": {
  *       template: "

HELLO!

" * } - * } + * } * }) *
- * - * But typically you'll only use the views property if you name your view or have more than one view - * in the same template. There's not really a compelling reason to name a view if its the only one, + * + * But typically you'll only use the views property if you name your view or have more than one view + * in the same template. There's not really a compelling reason to name a view if its the only one, * but you could if you wanted, like so: *
  * 
- *
+ * *
  * $stateProvider.state("home", {
  *   views: {
  *     "main": {
  *       template: "

HELLO!

" * } - * } + * } * }) *
- * + * * Really though, you'll use views to set up multiple views: *
  * 
- *
- *
+ *
+ *
*
- * + * *
  * $stateProvider.state("home", {
  *   views: {
@@ -2618,7 +2627,7 @@ angular.module('ui.router.state').provider('$uiViewScroll', $ViewScrollProvider)
  *     "data": {
  *       template: ""
  *     }
- *   }    
+ *   }
  * })
  * 
* @@ -2667,8 +2676,14 @@ function $ViewDirective( $state, $injector, $uiViewScroll) { if ($animate) { return { - enter: function(element, target, cb) { $animate.enter(element, null, target, cb); }, - leave: function(element, cb) { $animate.leave(element, cb); } + enter: function(element, target, cb) { + var promise = $animate.enter(element, null, target, cb); + if (promise && promise.then) promise.then(cb); + }, + leave: function(element, cb) { + var promise = $animate.leave(element, cb); + if (promise && promise.then) promise.then(cb); + } }; } @@ -2838,17 +2853,17 @@ function stateContext(el) { * @restrict A * * @description - * A directive that binds a link (`` tag) to a state. If the state has an associated - * URL, the directive will automatically generate & update the `href` attribute via - * the {@link ui.router.state.$state#methods_href $state.href()} method. Clicking - * the link will trigger a state transition with optional parameters. + * A directive that binds a link (`` tag) to a state. If the state has an associated + * URL, the directive will automatically generate & update the `href` attribute via + * the {@link ui.router.state.$state#methods_href $state.href()} method. Clicking + * the link will trigger a state transition with optional parameters. * - * Also middle-clicking, right-clicking, and ctrl-clicking on the link will be + * Also middle-clicking, right-clicking, and ctrl-clicking on the link will be * handled natively by the browser. * - * You can also use relative state paths within ui-sref, just like the relative + * You can also use relative state paths within ui-sref, just like the relative * paths passed to `$state.go()`. You just need to be aware that the path is relative - * to the state that the link lives in, in other words the state that loaded the + * to the state that the link lives in, in other words the state that loaded the * template containing the link. * * You can specify options to pass to {@link ui.router.state.$state#go $state.go()} @@ -2856,22 +2871,22 @@ function stateContext(el) { * and `reload`. * * @example - * Here's an example of how you'd use ui-sref and how it would compile. If you have the + * Here's an example of how you'd use ui-sref and how it would compile. If you have the * following template: *
  * Home | About
- * 
+ *
  * 
  * 
- * + * * Then the compiled html would be (assuming Html5Mode is off): *
  * Home | About
- * 
+ *
  * 
  * 
- * - * When the app state is "app.user", and contains the state parameter "user" with value "bilbobaggins", + * + * When the app state is "app.user", and contains the state parameter "user" with value "bilbobaggins", * the resulting HTML will appear as (note the 'active' class): *
  * 
  * 
- * - * The class name is interpolated **once** during the directives link time (any further changes to the - * interpolated value are ignored). - * + * + * The class name is interpolated **once** during the directives link time (any further changes to the + * interpolated value are ignored). + * * Multiple classes may be specified in a space-separated format: *
  *