A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://unpkg.com/@uirouter/angularjs@latest/release/angular-ui-router.js below:

} The template html as a string, or a promise * for that string. */ TemplateFactory.prototype.fromUrl = function (url, params) { if (isFunction(url)) url = url(params); if (url == null) return null; if (this._useHttp) { return this.$http .get(url, { cache: this.$templateCache, headers: { Accept: 'text/html' } }) .then(function (response) { return response.data; }); } return this.$templateRequest(url); }; /** * Creates a template by invoking an injectable provider function. * * @param provider Function to invoke via `locals` * @param {Function} injectFn a function used to invoke the template provider * @return {string|Promise. } The template html as a string, or a promise * for that string. */ TemplateFactory.prototype.fromProvider = function (provider, params, context) { var deps = services.$injector.annotate(provider); var providerFn = isArray(provider) ? tail(provider) : provider; var resolvable = new Resolvable('', providerFn, deps); return resolvable.get(context); }; /** * Creates a component's template by invoking an injectable provider function. * * @param provider Function to invoke via `locals` * @param {Function} injectFn a function used to invoke the template provider * @return {string} The template html as a string: " ". */ TemplateFactory.prototype.fromComponentProvider = function (provider, params, context) { var deps = services.$injector.annotate(provider); var providerFn = isArray(provider) ? tail(provider) : provider; var resolvable = new Resolvable('', providerFn, deps); return resolvable.get(context); }; /** * Creates a template from a component's name * * This implements route-to-component. * It works by retrieving the component (directive) metadata from the injector. * It analyses the component's bindings, then constructs a template that instantiates the component. * The template wires input and output bindings to resolves or from the parent component. * * @param uiView {object} The parent ui-view (for binding outputs to callbacks) * @param context The ResolveContext (for binding outputs to callbacks returned from resolves) * @param component {string} Component's name in camel case. * @param bindings An object defining the component's bindings: {foo: '<'} * @return {string} The template as a string: " ". */ TemplateFactory.prototype.makeComponentTemplate = function (uiView, context, component, bindings) { bindings = bindings || {}; // Bind once prefix var prefix = ng.version.minor >= 3 ? '::' : ''; // Convert to kebob name. Add x- prefix if the string starts with `x-` or `data-` var kebob = function (camelCase) { var kebobed = kebobString(camelCase); return /^(x|data)-/.exec(kebobed) ? "x-" + kebobed : kebobed; }; var attributeTpl = function (input) { var name = input.name, type = input.type; var attrName = kebob(name); // If the ui-view has an attribute which matches a binding on the routed component // then pass that attribute through to the routed component template. // Prefer ui-view wired mappings to resolve data, unless the resolve was explicitly bound using `bindings:` if (uiView.attr(attrName) && !bindings[name]) return attrName + "='" + uiView.attr(attrName) + "'"; var resolveName = bindings[name] || name; // Pre-evaluate the expression for "@" bindings by enclosing in {{ }} // some-attr="{{ ::$resolve.someResolveName }}" if (type === '@') return attrName + "='{{" + prefix + "$resolve." + resolveName + "}}'"; // Wire "&" callbacks to resolves that return a callback function // Get the result of the resolve (should be a function) and annotate it to get its arguments. // some-attr="$resolve.someResolveResultName(foo, bar)" if (type === '&') { var res = context.getResolvable(resolveName); var fn = res && res.data; var args = (fn && services.$injector.annotate(fn)) || []; // account for array style injection, i.e., ['foo', function(foo) {}] var arrayIdxStr = isArray(fn) ? "[" + (fn.length - 1) + "]" : ''; return attrName + "='$resolve." + resolveName + arrayIdxStr + "(" + args.join(',') + ")'"; } // some-attr="::$resolve.someResolveName" return attrName + "='" + prefix + "$resolve." + resolveName + "'"; }; var attrs = getComponentBindings(component).map(attributeTpl).join(' '); var kebobName = kebob(component); return "<" + kebobName + " " + attrs + ">"; }; return TemplateFactory; }()); // Gets all the directive(s)' inputs ('@', '=', and '<') and outputs ('&') function getComponentBindings(name) { var cmpDefs = services.$injector.get(name + 'Directive'); // could be multiple if (!cmpDefs || !cmpDefs.length) throw new Error("Unable to find component named '" + name + "'"); return cmpDefs.map(getBindings).reduce(unnestR, []); } // Given a directive definition, find its object input attributes // Use different properties, depending on the type of directive (component, bindToController, normal) var getBindings = function (def) { if (isObject(def.bindToController)) return scopeBindings(def.bindToController); return scopeBindings(def.scope); }; // for ng 1.2 style, process the scope: { input: "=foo" } // for ng 1.3 through ng 1.5, process the component's bindToController: { input: "=foo" } object var scopeBindings = function (bindingsObj) { return Object.keys(bindingsObj || {}) // [ 'input', [ '=foo', '=', 'foo' ] ] .map(function (key) { return [key, /^([=<@&])[?]?(.*)/.exec(bindingsObj[key])]; }) // skip malformed values .filter(function (tuple) { return isDefined(tuple) && isArray(tuple[1]); }) // { name: ('foo' || 'input'), type: '=' } .map(function (tuple) { return ({ name: tuple[1][2] || tuple[0], type: tuple[1][1] }); }); }; /** @publicapi @module ng1 */ /** */ /** * The Angular 1 `StateProvider` * * The `$stateProvider` works similar to Angular's v1 router, but it focuses purely * on state. * * A state corresponds to a "place" in the application in terms of the overall UI and * navigation. A state describes (via the controller / template / view properties) what * the UI looks like and does at that place. * * States often have things in common, and the primary way of factoring out these * commonalities in this model is via the state hierarchy, i.e. parent/child states aka * nested states. * * The `$stateProvider` provides interfaces to declare these states for your app. */ var StateProvider = /** @class */ (function () { function StateProvider(stateRegistry, stateService) { this.stateRegistry = stateRegistry; this.stateService = stateService; createProxyFunctions(val(StateProvider.prototype), this, val(this)); } /** * Decorates states when they are registered * * Allows you to extend (carefully) or override (at your own peril) the * `stateBuilder` object used internally by [[StateRegistry]]. * 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 * function that matches `name`. * * 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 * meta-programming features. * * **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. * * * Existing builder functions and current return values: * * - **parent** `{object}` - returns the parent state object. * - **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 UrlMatcher} * or `null`. * - **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 * 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 * explicitly on a state config, one is still created for you internally. * 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, * not including any params defined by ancestor states. * - **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 * would pass a `$state.includes()` test. * * #### Example: * Override the internal 'views' builder with a function that takes the state * definition, and a reference to the internal function being overridden: * ```js * $stateProvider.decorator('views', function (state, parent) { * let result = {}, * views = parent(state); * * angular.forEach(views, function (config, name) { * let autoName = (state.name + '.' + name).replace('.', '/'); * config.templateUrl = config.templateUrl || '/partials/' + autoName + '.html'; * result[name] = config; * }); * return result; * }); * * $stateProvider.state('home', { * views: { * 'contact.list': { controller: 'ListController' }, * 'contact.item': { controller: 'ItemController' } * } * }); * ``` * * * ```js * // Auto-populates list and item views with /partials/home/contact/list.html, * // and /partials/home/contact/item.html, respectively. * $state.go('home'); * ``` * * @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. * - `{object}` - super - The original builder function. * * @return {object} $stateProvider - $stateProvider instance */ StateProvider.prototype.decorator = function (name, func) { return this.stateRegistry.decorator(name, func) || this; }; StateProvider.prototype.state = function (name, definition) { if (isObject(name)) { definition = name; } else { definition.name = name; } this.stateRegistry.register(definition); return this; }; /** * Registers an invalid state handler * * This is a passthrough to [[StateService.onInvalid]] for ng1. */ StateProvider.prototype.onInvalid = function (callback) { return this.stateService.onInvalid(callback); }; return StateProvider; }()); /** @publicapi @module ng1 */ /** */ /** * This is a [[StateBuilder.builder]] function for angular1 `onEnter`, `onExit`, * `onRetain` callback hooks on a [[Ng1StateDeclaration]]. * * When the [[StateBuilder]] builds a [[StateObject]] object from a raw [[StateDeclaration]], this builder * ensures that those hooks are injectable for @uirouter/angularjs (ng1). * * @internalapi */ var getStateHookBuilder = function (hookName) { return function stateHookBuilder(stateObject) { var hook = stateObject[hookName]; var pathname = hookName === 'onExit' ? 'from' : 'to'; function decoratedNg1Hook(trans, state) { var resolveContext = new ResolveContext(trans.treeChanges(pathname)); var subContext = resolveContext.subContext(state.$$state()); var locals = extend(getLocals(subContext), { $state$: state, $transition$: trans }); return services.$injector.invoke(hook, this, locals); } return hook ? decoratedNg1Hook : undefined; }; }; /** @publicapi @module ng1 */ /** */ /** * Implements UI-Router LocationServices and LocationConfig using Angular 1's $location service * @internalapi */ var Ng1LocationServices = /** @class */ (function () { function Ng1LocationServices($locationProvider) { // .onChange() registry this._urlListeners = []; this.$locationProvider = $locationProvider; var _lp = val($locationProvider); createProxyFunctions(_lp, this, _lp, ['hashPrefix']); } /** * Applys ng1-specific path parameter encoding * * The Angular 1 `$location` service is a bit weird. * It doesn't allow slashes to be encoded/decoded bi-directionally. * * See the writeup at https://github.com/angular-ui/ui-router/issues/2598 * * This code patches the `path` parameter type so it encoded/decodes slashes as ~2F * * @param router */ Ng1LocationServices.monkeyPatchPathParameterType = function (router) { var pathType = router.urlMatcherFactory.type('path'); pathType.encode = function (x) { return x != null ? x.toString().replace(/(~|\/)/g, function (m) { return ({ '~': '~~', '/': '~2F' }[m]); }) : x; }; pathType.decode = function (x) { return x != null ? x.toString().replace(/(~~|~2F)/g, function (m) { return ({ '~~': '~', '~2F': '/' }[m]); }) : x; }; }; // eslint-disable-next-line @typescript-eslint/no-empty-function Ng1LocationServices.prototype.dispose = function () { }; Ng1LocationServices.prototype.onChange = function (callback) { var _this = this; this._urlListeners.push(callback); return function () { return removeFrom(_this._urlListeners)(callback); }; }; Ng1LocationServices.prototype.html5Mode = function () { var html5Mode = this.$locationProvider.html5Mode(); html5Mode = isObject(html5Mode) ? html5Mode.enabled : html5Mode; return html5Mode && this.$sniffer.history; }; Ng1LocationServices.prototype.baseHref = function () { return this._baseHref || (this._baseHref = this.$browser.baseHref() || this.$window.location.pathname); }; Ng1LocationServices.prototype.url = function (newUrl, replace, state) { if (replace === void 0) { replace = false; } if (isDefined(newUrl)) this.$location.url(newUrl); if (replace) this.$location.replace(); if (state) this.$location.state(state); return this.$location.url(); }; Ng1LocationServices.prototype._runtimeServices = function ($rootScope, $location, $sniffer, $browser, $window) { var _this = this; this.$location = $location; this.$sniffer = $sniffer; this.$browser = $browser; this.$window = $window; // Bind $locationChangeSuccess to the listeners registered in LocationService.onChange $rootScope.$on('$locationChangeSuccess', function (evt) { return _this._urlListeners.forEach(function (fn) { return fn(evt); }); }); var _loc = val($location); // Bind these LocationService functions to $location createProxyFunctions(_loc, this, _loc, ['replace', 'path', 'search', 'hash']); // Bind these LocationConfig functions to $location createProxyFunctions(_loc, this, _loc, ['port', 'protocol', 'host']); }; return Ng1LocationServices; }()); /** @publicapi @module url */ /** */ /** * Manages rules for client-side URL * * ### Deprecation warning: * This class is now considered to be an internal API * Use the [[UrlService]] instead. * For configuring URL rules, use the [[UrlRulesApi]] which can be found as [[UrlService.rules]]. * * This class manages the router rules for what to do when the URL changes. * * This provider remains for backwards compatibility. * * @internalapi * @deprecated */ var UrlRouterProvider = /** @class */ (function () { /** @hidden */ function UrlRouterProvider(/** @hidden */ router) { this.router = router; } UrlRouterProvider.injectableHandler = function (router, handler) { return function (match) { return services.$injector.invoke(handler, null, { $match: match, $stateParams: router.globals.params }); }; }; /** @hidden */ UrlRouterProvider.prototype.$get = function () { var urlService = this.router.urlService; this.router.urlRouter.update(true); if (!urlService.interceptDeferred) urlService.listen(); return this.router.urlRouter; }; /** * Registers a url handler function. * * Registers a low level url handler (a `rule`). * A rule detects specific URL patterns and returns a redirect, or performs some action. * * If a rule returns a string, the URL is replaced with the string, and all rules are fired again. * * #### Example: * ```js * var app = angular.module('app', ['ui.router.router']); * * app.config(function ($urlRouterProvider) { * // Here's an example of how you might allow case insensitive urls * $urlRouterProvider.rule(function ($injector, $location) { * var path = $location.path(), * normalized = path.toLowerCase(); * * if (path !== normalized) { * return normalized; * } * }); * }); * ``` * * @param ruleFn * Handler function that takes `$injector` and `$location` services as arguments. * You can use them to detect a url and return a different url as a string. * * @return [[UrlRouterProvider]] (`this`) */ UrlRouterProvider.prototype.rule = function (ruleFn) { var _this = this; if (!isFunction(ruleFn)) throw new Error("'rule' must be a function"); var match = function () { return ruleFn(services.$injector, _this.router.locationService); }; var rule = new BaseUrlRule(match, identity); this.router.urlService.rules.rule(rule); return this; }; /** * Defines the path or behavior to use when no url can be matched. * * #### Example: * ```js * var app = angular.module('app', ['ui.router.router']); * * app.config(function ($urlRouterProvider) { * // if the path doesn't match any of the urls you configured * // otherwise will take care of routing the user to the * // specified url * $urlRouterProvider.otherwise('/index'); * * // Example of using function rule as param * $urlRouterProvider.otherwise(function ($injector, $location) { * return '/a/valid/url'; * }); * }); * ``` * * @param rule * The url path you want to redirect to or a function rule that returns the url path or performs a `$state.go()`. * The function version is passed two params: `$injector` and `$location` services, and should return a url string. * * @return {object} `$urlRouterProvider` - `$urlRouterProvider` instance */ UrlRouterProvider.prototype.otherwise = function (rule) { var _this = this; var urlRules = this.router.urlService.rules; if (isString(rule)) { urlRules.otherwise(rule); } else if (isFunction(rule)) { urlRules.otherwise(function () { return rule(services.$injector, _this.router.locationService); }); } else { throw new Error("'rule' must be a string or function"); } return this; }; /** * Registers a handler for a given url matching. * * If the handler is a string, it is * treated as a redirect, and is interpolated according to the syntax of match * (i.e. like `String.replace()` for `RegExp`, or like a `UrlMatcher` pattern otherwise). * * If the handler is a function, it is injectable. * It gets invoked if `$location` matches. * You have the option of inject the match object as `$match`. * * The handler can return * * - **falsy** to indicate that the rule didn't match after all, then `$urlRouter` * will continue trying to find another one that matches. * - **string** which is treated as a redirect and passed to `$location.url()` * - **void** or any **truthy** value tells `$urlRouter` that the url was handled. * * #### Example: * ```js * var app = angular.module('app', ['ui.router.router']); * * app.config(function ($urlRouterProvider) { * $urlRouterProvider.when($state.url, function ($match, $stateParams) { * if ($state.$current.navigable !== state || * !equalForKeys($match, $stateParams) { * $state.transitionTo(state, $match, false); * } * }); * }); * ``` * * @param what A pattern string to match, compiled as a [[UrlMatcher]]. * @param handler The path (or function that returns a path) that you want to redirect your user to. * @param ruleCallback [optional] A callback that receives the `rule` registered with [[UrlMatcher.rule]] * * Note: the handler may also invoke arbitrary code, such as `$state.go()` */ UrlRouterProvider.prototype.when = function (what, handler) { if (isArray(handler) || isFunction(handler)) { handler = UrlRouterProvider.injectableHandler(this.router, handler); } this.router.urlService.rules.when(what, handler); return this; }; /** * Disables monitoring of the URL. * * Call this method before UI-Router has bootstrapped. * It will stop UI-Router from performing the initial url sync. * * This can be useful to perform some asynchronous initialization before the router starts. * Once the initialization is complete, call [[listen]] to tell UI-Router to start watching and synchronizing the URL. * * #### Example: * ```js * var app = angular.module('app', ['ui.router']); * * app.config(function ($urlRouterProvider) { * // Prevent $urlRouter from automatically intercepting URL changes; * $urlRouterProvider.deferIntercept(); * }) * * app.run(function (MyService, $urlRouter, $http) { * $http.get("/stuff").then(function(resp) { * MyService.doStuff(resp.data); * $urlRouter.listen(); * $urlRouter.sync(); * }); * }); * ``` * * @param defer Indicates whether to defer location change interception. * Passing no parameter is equivalent to `true`. */ UrlRouterProvider.prototype.deferIntercept = function (defer) { this.router.urlService.deferIntercept(defer); }; return UrlRouterProvider; }()); /* eslint-disable @typescript-eslint/no-empty-function */ ng.module('ui.router.angular1', []); var mod_init = ng.module('ui.router.init', ['ng']); var mod_util = ng.module('ui.router.util', ['ui.router.init']); var mod_rtr = ng.module('ui.router.router', ['ui.router.util']); var mod_state = ng.module('ui.router.state', ['ui.router.router', 'ui.router.util', 'ui.router.angular1']); var mod_main = ng.module('ui.router', ['ui.router.init', 'ui.router.state', 'ui.router.angular1']); var mod_cmpt = ng.module('ui.router.compat', ['ui.router']); var router = null; $uiRouterProvider.$inject = ['$locationProvider']; /** This angular 1 provider instantiates a Router and exposes its services via the angular injector */ function $uiRouterProvider($locationProvider) { // Create a new instance of the Router when the $uiRouterProvider is initialized router = this.router = new UIRouter(); router.stateProvider = new StateProvider(router.stateRegistry, router.stateService); // Apply ng1 specific StateBuilder code for `views`, `resolve`, and `onExit/Retain/Enter` properties router.stateRegistry.decorator('views', ng1ViewsBuilder); router.stateRegistry.decorator('onExit', getStateHookBuilder('onExit')); router.stateRegistry.decorator('onRetain', getStateHookBuilder('onRetain')); router.stateRegistry.decorator('onEnter', getStateHookBuilder('onEnter')); router.viewService._pluginapi._viewConfigFactory('ng1', getNg1ViewConfigFactory()); // Disable decoding of params by UrlMatcherFactory because $location already handles this router.urlService.config._decodeParams = false; var ng1LocationService = (router.locationService = router.locationConfig = new Ng1LocationServices($locationProvider)); Ng1LocationServices.monkeyPatchPathParameterType(router); // backwards compat: also expose router instance as $uiRouterProvider.router router['router'] = router; router['$get'] = $get; $get.$inject = ['$location', '$browser', '$window', '$sniffer', '$rootScope', '$http', '$templateCache']; function $get($location, $browser, $window, $sniffer, $rootScope, $http, $templateCache) { ng1LocationService._runtimeServices($rootScope, $location, $sniffer, $browser, $window); delete router['router']; delete router['$get']; return router; } return router; } var getProviderFor = function (serviceName) { return [ '$uiRouterProvider', function ($urp) { var service = $urp.router[serviceName]; service['$get'] = function () { return service; }; return service; }, ]; }; // This effectively calls $get() on `$uiRouterProvider` to trigger init (when ng enters runtime) runBlock.$inject = ['$injector', '$q', '$uiRouter']; function runBlock($injector, $q, $uiRouter) { services.$injector = $injector; services.$q = $q; // https://github.com/angular-ui/ui-router/issues/3678 if (!Object.prototype.hasOwnProperty.call($injector, 'strictDi')) { try { $injector.invoke(function (checkStrictDi) { }); } catch (error) { $injector.strictDi = !!/strict mode/.exec(error && error.toString()); } } // The $injector is now available. // Find any resolvables that had dependency annotation deferred $uiRouter.stateRegistry .get() .map(function (x) { return x.$$state().resolvables; }) .reduce(unnestR, []) .filter(function (x) { return x.deps === 'deferred'; }) .forEach(function (resolvable) { return (resolvable.deps = $injector.annotate(resolvable.resolveFn, $injector.strictDi)); }); } // $urlRouter service and $urlRouterProvider var getUrlRouterProvider = function (uiRouter) { return (uiRouter.urlRouterProvider = new UrlRouterProvider(uiRouter)); }; // $state service and $stateProvider // $urlRouter service and $urlRouterProvider var getStateProvider = function () { return extend(router.stateProvider, { $get: function () { return router.stateService; } }); }; watchDigests.$inject = ['$rootScope']; function watchDigests($rootScope) { $rootScope.$watch(function () { trace.approximateDigests++; }); } mod_init.provider('$uiRouter', $uiRouterProvider); mod_rtr.provider('$urlRouter', ['$uiRouterProvider', getUrlRouterProvider]); mod_util.provider('$urlService', getProviderFor('urlService')); mod_util.provider('$urlMatcherFactory', ['$uiRouterProvider', function () { return router.urlMatcherFactory; }]); mod_util.provider('$templateFactory', function () { return new TemplateFactory(); }); mod_state.provider('$stateRegistry', getProviderFor('stateRegistry')); mod_state.provider('$uiRouterGlobals', getProviderFor('globals')); mod_state.provider('$transitions', getProviderFor('transitionService')); mod_state.provider('$state', ['$uiRouterProvider', getStateProvider]); mod_state.factory('$stateParams', ['$uiRouter', function ($uiRouter) { return $uiRouter.globals.params; }]); mod_main.factory('$view', function () { return router.viewService; }); mod_main.service('$trace', function () { return trace; }); mod_main.run(watchDigests); mod_util.run(['$urlMatcherFactory', function ($urlMatcherFactory) { }]); mod_state.run(['$state', function ($state) { }]); mod_rtr.run(['$urlRouter', function ($urlRouter) { }]); mod_init.run(runBlock); /** @hidden TODO: find a place to move this */ var getLocals = function (ctx) { var tokens = ctx.getTokens().filter(isString); var tuples = tokens.map(function (key) { var resolvable = ctx.getResolvable(key); var waitPolicy = ctx.getPolicy(resolvable).async; return [key, waitPolicy === 'NOWAIT' ? resolvable.promise : resolvable.data]; }); return tuples.reduce(applyPairs, {}); }; /* eslint-disable @typescript-eslint/no-empty-interface */ /** @hidden */ function parseStateRef(ref) { var paramsOnly = ref.match(/^\s*({[^}]*})\s*$/); if (paramsOnly) ref = '(' + paramsOnly[1] + ')'; var parsed = ref.replace(/\n/g, ' ').match(/^\s*([^(]*?)\s*(\((.*)\))?\s*$/); if (!parsed || parsed.length !== 4) throw new Error("Invalid state ref '" + ref + "'"); return { state: parsed[1] || null, paramExpr: parsed[3] || null }; } /** @hidden */ function stateContext(el) { var $uiView = el.parent().inheritedData('$uiView'); var path = parse('$cfg.path')($uiView); return path ? tail(path).state.name : undefined; } /** @hidden */ function processedDef($state, $element, def) { var uiState = def.uiState || $state.current.name; var uiStateOpts = extend(defaultOpts($element, $state), def.uiStateOpts || {}); var href = $state.href(uiState, def.uiStateParams, uiStateOpts); return { uiState: uiState, uiStateParams: def.uiStateParams, uiStateOpts: uiStateOpts, href: href }; } /** @hidden */ function getTypeInfo(el) { // SVGAElement does not use the href attribute, but rather the 'xlinkHref' attribute. var isSvg = Object.prototype.toString.call(el.prop('href')) === '[object SVGAnimatedString]'; var isForm = el[0].nodeName === 'FORM'; return { attr: isForm ? 'action' : isSvg ? 'xlink:href' : 'href', isAnchor: el.prop('tagName').toUpperCase() === 'A', clickable: !isForm, }; } /** @hidden */ function clickHook(el, $state, $timeout, type, getDef) { return function (e) { var button = e.which || e.button, target = getDef(); if (!(button > 1 || e.ctrlKey || e.metaKey || e.shiftKey || e.altKey || el.attr('target'))) { // HACK: This is to allow ng-clicks to be processed before the transition is initiated: var transition_1 = $timeout(function () { if (!el.attr('disabled')) { $state.go(target.uiState, target.uiStateParams, target.uiStateOpts); } }); e.preventDefault(); // if the state has no URL, ignore one preventDefault from the directive. var ignorePreventDefaultCount_1 = type.isAnchor && !target.href ? 1 : 0; e.preventDefault = function () { if (ignorePreventDefaultCount_1-- <= 0) $timeout.cancel(transition_1); }; } }; } /** @hidden */ function defaultOpts(el, $state) { return { relative: stateContext(el) || $state.$current, inherit: true, source: 'sref', }; } /** @hidden */ function bindEvents(element, scope, hookFn, uiStateOpts) { var events; if (uiStateOpts) { events = uiStateOpts.events; } if (!isArray(events)) { events = ['click']; } var on = element.on ? 'on' : 'bind'; for (var _i = 0, events_1 = events; _i < events_1.length; _i++) { var event_1 = events_1[_i]; element[on](event_1, hookFn); } scope.$on('$destroy', function () { var off = element.off ? 'off' : 'unbind'; for (var _i = 0, events_2 = events; _i < events_2.length; _i++) { var event_2 = events_2[_i]; element[off](event_2, hookFn); } }); } /** * `ui-sref`: A directive for linking to a state * * A directive which links to a state (and optionally, parameters). * When clicked, this directive activates the linked state with the supplied parameter values. * * ### Linked State * The attribute value of the `ui-sref` is the name of the state to link to. * * #### Example: * This will activate the `home` state when the link is clicked. * ```html * Home * ``` * * ### Relative Links * You can also use relative state paths within `ui-sref`, just like a relative path passed to `$state.go()` ([[StateService.go]]). * You just need to be aware that the path is relative to the state that *created* the link. * This allows a state to create a relative `ui-sref` which always targets the same destination. * * #### Example: * Both these links are relative to the parent state, even when a child state is currently active. * ```html * child 1 state * child 2 state * ``` * * This link activates the parent state. * ```html * Return * ``` * * ### hrefs * If the linked state has a URL, the directive will automatically generate and * update the `href` attribute (using the [[StateService.href]] method). * * #### Example: * Assuming the `users` state has a url of `/users/` * ```html * Users * ``` * * ### Parameter Values * In addition to the state name, a `ui-sref` can include parameter values which are applied when activating the state. * Param values can be provided in the `ui-sref` value after the state name, enclosed by parentheses. * The content inside the parentheses is an expression, evaluated to the parameter values. * * #### Example: * This example renders a list of links to users. * The state's `userId` parameter value comes from each user's `user.id` property. * ```html *
  • * {{ user.displayName }} *
  • * ``` * * Note: * The parameter values expression is `$watch`ed for updates. * * ### Transition Options * You can specify [[TransitionOptions]] to pass to [[StateService.go]] by using the `ui-sref-opts` attribute. * Options are restricted to `location`, `inherit`, and `reload`. * * #### Example: * ```html * Home * ``` * * ### Other DOM Events * * You can also customize which DOM events to respond to (instead of `click`) by * providing an `events` array in the `ui-sref-opts` attribute. * * #### Example: * ```html * * ``` * * ### Highlighting the active link * This directive can be used in conjunction with [[uiSrefActive]] to highlight the active link. * * ### Examples * If you have the following template: * * ```html * Home * About * Next page * * * ``` * * Then (assuming the current state is `contacts`) the rendered html including hrefs would be: * * ```html * Home * About * Next page * * * * Home * ``` * * ### Notes * * - You can use `ui-sref` to change **only the parameter values** by omitting the state name and parentheses. * #### Example: * Sets the `lang` parameter to `en` and remains on the same state. * * ```html * English * ``` * * - A middle-click, right-click, or ctrl-click is handled (natively) by the browser to open the href in a new window, for example. * * - Unlike the parameter values expression, the state name is not `$watch`ed (for performance reasons). * If you need to dynamically update the state being linked to, use the fully dynamic [[uiState]] directive. */ var uiSrefDirective; uiSrefDirective = [ '$uiRouter', '$timeout', function $StateRefDirective($uiRouter, $timeout) { var $state = $uiRouter.stateService; return { restrict: 'A', require: ['?^uiSrefActive', '?^uiSrefActiveEq'], link: function (scope, element, attrs, uiSrefActive) { var type = getTypeInfo(element); var active = uiSrefActive[1] || uiSrefActive[0]; var unlinkInfoFn = null; var rawDef = {}; var getDef = function () { return processedDef($state, element, rawDef); }; var ref = parseStateRef(attrs.uiSref); rawDef.uiState = ref.state; rawDef.uiStateOpts = attrs.uiSrefOpts ? scope.$eval(attrs.uiSrefOpts) : {}; function update() { var def = getDef(); if (unlinkInfoFn) unlinkInfoFn(); if (active) unlinkInfoFn = active.$$addStateInfo(def.uiState, def.uiStateParams); if (def.href != null) attrs.$set(type.attr, def.href); } if (ref.paramExpr) { scope.$watch(ref.paramExpr, function (val) { rawDef.uiStateParams = extend({}, val); update(); }, true); rawDef.uiStateParams = extend({}, scope.$eval(ref.paramExpr)); } update(); scope.$on('$destroy', $uiRouter.stateRegistry.onStatesChanged(update)); scope.$on('$destroy', $uiRouter.transitionService.onSuccess({}, update)); if (!type.clickable) return; var hookFn = clickHook(element, $state, $timeout, type, getDef); bindEvents(element, scope, hookFn, rawDef.uiStateOpts); }, }; }, ]; /** * `ui-state`: A fully dynamic directive for linking to a state * * A directive which links to a state (and optionally, parameters). * When clicked, this directive activates the linked state with the supplied parameter values. * * **This directive is very similar to [[uiSref]], but it `$observe`s and `$watch`es/evaluates all its inputs.** * * A directive which links to a state (and optionally, parameters). * When clicked, this directive activates the linked state with the supplied parameter values. * * ### Linked State * The attribute value of `ui-state` is an expression which is `$watch`ed and evaluated as the state to link to. * **This is in contrast with `ui-sref`, which takes a state name as a string literal.** * * #### Example: * Create a list of links. * ```html *
  • * {{ link.displayName }} *
  • * ``` * * ### Relative Links * If the expression evaluates to a relative path, it is processed like [[uiSref]]. * You just need to be aware that the path is relative to the state that *created* the link. * This allows a state to create relative `ui-state` which always targets the same destination. * * ### hrefs * If the linked state has a URL, the directive will automatically generate and * update the `href` attribute (using the [[StateService.href]] method). * * ### Parameter Values * In addition to the state name expression, a `ui-state` can include parameter values which are applied when activating the state. * Param values should be provided using the `ui-state-params` attribute. * The `ui-state-params` attribute value is `$watch`ed and evaluated as an expression. * * #### Example: * This example renders a list of links with param values. * The state's `userId` parameter value comes from each user's `user.id` property. * ```html *
  • * {{ link.displayName }} *
  • * ``` * * ### Transition Options * You can specify [[TransitionOptions]] to pass to [[StateService.go]] by using the `ui-state-opts` attribute. * Options are restricted to `location`, `inherit`, and `reload`. * The value of the `ui-state-opts` is `$watch`ed and evaluated as an expression. * * #### Example: * ```html * Home * ``` * * ### Other DOM Events * * You can also customize which DOM events to respond to (instead of `click`) by * providing an `events` array in the `ui-state-opts` attribute. * * #### Example: * ```html * * ``` * * ### Highlighting the active link * This directive can be used in conjunction with [[uiSrefActive]] to highlight the active link. * * ### Notes * * - You can use `ui-params` to change **only the parameter values** by omitting the state name and supplying only `ui-state-params`. * However, it might be simpler to use [[uiSref]] parameter-only links. * * #### Example: * Sets the `lang` parameter to `en` and remains on the same state. * * ```html * English * ``` * * - A middle-click, right-click, or ctrl-click is handled (natively) by the browser to open the href in a new window, for example. * ``` */ var uiStateDirective; uiStateDirective = [ '$uiRouter', '$timeout', function $StateRefDynamicDirective($uiRouter, $timeout) { var $state = $uiRouter.stateService; return { restrict: 'A', require: ['?^uiSrefActive', '?^uiSrefActiveEq'], link: function (scope, element, attrs, uiSrefActive) { var type = getTypeInfo(element); var active = uiSrefActive[1] || uiSrefActive[0]; var unlinkInfoFn = null; var hookFn; var rawDef = {}; var getDef = function () { return processedDef($state, element, rawDef); }; var inputAttrs = ['uiState', 'uiStateParams', 'uiStateOpts']; var watchDeregFns = inputAttrs.reduce(function (acc, attr) { return ((acc[attr] = noop), acc); }, {}); function update() { var def = getDef(); if (unlinkInfoFn) unlinkInfoFn(); if (active) unlinkInfoFn = active.$$addStateInfo(def.uiState, def.uiStateParams); if (def.href != null) attrs.$set(type.attr, def.href); } inputAttrs.forEach(function (field) { rawDef[field] = attrs[field] ? scope.$eval(attrs[field]) : null; attrs.$observe(field, function (expr) { watchDeregFns[field](); watchDeregFns[field] = scope.$watch(expr, function (newval) { rawDef[field] = newval; update(); }, true); }); }); update(); scope.$on('$destroy', $uiRouter.stateRegistry.onStatesChanged(update)); scope.$on('$destroy', $uiRouter.transitionService.onSuccess({}, update)); if (!type.clickable) return; hookFn = clickHook(element, $state, $timeout, type, getDef); bindEvents(element, scope, hookFn, rawDef.uiStateOpts); }, }; }, ]; /** * `ui-sref-active` and `ui-sref-active-eq`: A directive that adds a CSS class when a `ui-sref` is active * * A directive working alongside [[uiSref]] and [[uiState]] to add classes to an element when the * related directive's state is active (and remove them when it is inactive). * * The primary use-case is to highlight the active link in navigation menus, * distinguishing it from the inactive menu items. * * ### Linking to a `ui-sref` or `ui-state` * `ui-sref-active` can live on the same element as `ui-sref`/`ui-state`, or it can be on a parent element. * If a `ui-sref-active` is a parent to more than one `ui-sref`/`ui-state`, it will apply the CSS class when **any of the links are active**. * * ### Matching * * The `ui-sref-active` directive applies the CSS class when the `ui-sref`/`ui-state`'s target state **or any child state is active**. * This is a "fuzzy match" which uses [[StateService.includes]]. * * The `ui-sref-active-eq` directive applies the CSS class when the `ui-sref`/`ui-state`'s target state is directly active (not when child states are active). * This is an "exact match" which uses [[StateService.is]]. * * ### Parameter values * If the `ui-sref`/`ui-state` includes parameter values, the current parameter values must match the link's values for the link to be highlighted. * This allows a list of links to the same state with different parameters to be rendered, and the correct one highlighted. * * #### Example: * ```html *
  • * {{ user.lastName }} *
  • * ``` * * ### Examples * * Given the following template: * #### Example: * ```html * * ``` * * When the app state is `app.user` (or any child state), * and contains the state parameter "user" with value "bilbobaggins", * the resulting HTML will appear as (note the 'active' class): * * ```html * * ``` * * ### Glob mode * * It is possible to pass `ui-sref-active` an expression that evaluates to an object. * The objects keys represent active class names and values represent the respective state names/globs. * `ui-sref-active` will match if the current active state **includes** any of * the specified state names/globs, even the abstract ones. * * #### Example: * Given the following template, with "admin" being an abstract state: * ```html * * ``` * * Arrays are also supported as values in the `ngClass`-like interface. * This allows multiple states to add `active` class. * * #### Example: * Given the following template, with "admin.roles" being the current state, the class will be added too: * ```html * * ``` * * When the current state is "admin.roles" the "active" class will be applied to both the `

    ` and `

    ` elements. * It is important to note that the state names/globs passed to `ui-sref-active` override any state provided by a linked `ui-sref`. * * ### Notes: * * - 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: `ui-sref-active='class1 class2 class3'` */ var uiSrefActiveDirective; uiSrefActiveDirective = [ '$state', '$stateParams', '$interpolate', '$uiRouter', function $StateRefActiveDirective($state, $stateParams, $interpolate, $uiRouter) { return { restrict: 'A', controller: [ '$scope', '$element', '$attrs', function ($scope, $element, $attrs) { var states = []; var activeEqClass; var uiSrefActive; // There probably isn't much point in $observing this // uiSrefActive and uiSrefActiveEq share the same directive object with some // slight difference in logic routing activeEqClass = $interpolate($attrs.uiSrefActiveEq || '', false)($scope); try { uiSrefActive = $scope.$eval($attrs.uiSrefActive); } catch (e) { // Do nothing. uiSrefActive is not a valid expression. // Fall back to using $interpolate below } uiSrefActive = uiSrefActive || $interpolate($attrs.uiSrefActive || '', false)($scope); setStatesFromDefinitionObject(uiSrefActive); // Allow uiSref to communicate with uiSrefActive[Equals] this.$$addStateInfo = function (newState, newParams) { // we already got an explicit state provided by ui-sref-active, so we // shadow the one that comes from ui-sref if (isObject(uiSrefActive) && states.length > 0) { return; } var deregister = addState(newState, newParams, uiSrefActive); update(); return deregister; }; function updateAfterTransition(trans) { trans.promise.then(update, noop); } $scope.$on('$destroy', setupEventListeners()); if ($uiRouter.globals.transition) { updateAfterTransition($uiRouter.globals.transition); } function setupEventListeners() { var deregisterStatesChangedListener = $uiRouter.stateRegistry.onStatesChanged(handleStatesChanged); var deregisterOnStartListener = $uiRouter.transitionService.onStart({}, updateAfterTransition); var deregisterStateChangeSuccessListener = $scope.$on('$stateChangeSuccess', update); return function cleanUp() { deregisterStatesChangedListener(); deregisterOnStartListener(); deregisterStateChangeSuccessListener(); }; } function handleStatesChanged() { setStatesFromDefinitionObject(uiSrefActive); } function setStatesFromDefinitionObject(statesDefinition) { if (isObject(statesDefinition)) { states = []; forEach(statesDefinition, function (stateOrName, activeClass) { // Helper function to abstract adding state. var addStateForClass = function (stateOrName, activeClass) { var ref = parseStateRef(stateOrName); addState(ref.state, $scope.$eval(ref.paramExpr), activeClass); }; if (isString(stateOrName)) { // If state is string, just add it. addStateForClass(stateOrName, activeClass); } else if (isArray(stateOrName)) { // If state is an array, iterate over it and add each array item individually. forEach(stateOrName, function (stateOrName) { addStateForClass(stateOrName, activeClass); }); } }); } } function addState(stateName, stateParams, activeClass) { var state = $state.get(stateName, stateContext($element)); var stateInfo = { state: state || { name: stateName }, params: stateParams, activeClass: activeClass, }; states.push(stateInfo); return function removeState() { removeFrom(states)(stateInfo); }; } // Update route state function update() { var splitClasses = function (str) { return str.split(/\s/).filter(identity); }; var getClasses = function (stateList) { return stateList .map(function (x) { return x.activeClass; }) .map(splitClasses) .reduce(unnestR, []); }; var allClasses = getClasses(states).concat(splitClasses(activeEqClass)).reduce(uniqR, []); var fuzzyClasses = getClasses(states.filter(function (x) { return $state.includes(x.state.name, x.params); })); var exactlyMatchesAny = !!states.filter(function (x) { return $state.is(x.state.name, x.params); }).length; var exactClasses = exactlyMatchesAny ? splitClasses(activeEqClass) : []; var addClasses = fuzzyClasses.concat(exactClasses).reduce(uniqR, []); var removeClasses = allClasses.filter(function (cls) { return !inArray(addClasses, cls); }); $scope.$evalAsync(function () { addClasses.forEach(function (className) { return $element.addClass(className); }); removeClasses.forEach(function (className) { return $element.removeClass(className); }); }); } update(); }, ], }; }, ]; ng .module('ui.router.state') .directive('uiSref', uiSrefDirective) .directive('uiSrefActive', uiSrefActiveDirective) .directive('uiSrefActiveEq', uiSrefActiveDirective) .directive('uiState', uiStateDirective); /** @publicapi @module ng1 */ /** */ /** * `isState` Filter: truthy if the current state is the parameter * * Translates to [[StateService.is]] `$state.is("stateName")`. * * #### Example: * ```html *

    show if state is 'stateName'

    * ``` */ $IsStateFilter.$inject = ['$state']; function $IsStateFilter($state) { var isFilter = function (state, params, options) { return $state.is(state, params, options); }; isFilter.$stateful = true; return isFilter; } /** * `includedByState` Filter: truthy if the current state includes the parameter * * Translates to [[StateService.includes]]` $state.is("fullOrPartialStateName")`. * * #### Example: * ```html *

    show if state includes 'fullOrPartialStateName'

    * ``` */ $IncludedByStateFilter.$inject = ['$state']; function $IncludedByStateFilter($state) { var includesFilter = function (state, params, options) { return $state.includes(state, params, options); }; includesFilter.$stateful = true; return includesFilter; } ng.module('ui.router.state').filter('isState', $IsStateFilter).filter('includedByState', $IncludedByStateFilter); /** @publicapi @module directives */ /** */ /** * `ui-view`: A viewport directive which is filled in by a view from the active state. * * ### Attributes * * - `name`: (Optional) A view name. * The name should be unique amongst the other views in the same state. * You can have views of the same name that live in different states. * The ui-view can be targeted in a View using the name ([[Ng1StateDeclaration.views]]). * * - `autoscroll`: an expression. When it evaluates to true, the `ui-view` will be scrolled into view when it is activated. * Uses [[$uiViewScroll]] to do the scrolling. * * - `onload`: Expression to evaluate whenever the view updates. * * #### Example: * A view can be unnamed or named. * ```html * * * * * * * * * ``` * * 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: * * ```html * * $stateProvider.state("home", { * template: " HELLO!" * }) * ``` * * The above is a convenient shortcut equivalent to specifying your view explicitly with the * [[Ng1StateDeclaration.views]] config property, by name, in this case an empty name: * * ```js * $stateProvider.state("home", { * views: { * "": { * 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 you could if you wanted, like so: * * ```html * * ``` * * ```js * $stateProvider.state("home", { * views: { * "main": { * template: " HELLO!" * } * } * }) * ``` * * Really though, you'll use views to set up multiple views: * * ```html * * * * ``` * * ```js * $stateProvider.state("home", { * views: { * "": { * template: " HELLO!" * }, * "chart": { * template: "" * }, * "data": { * template: "" * } * } * }) * ``` * * #### Examples for `autoscroll`: * ```html * * * * * * * * ``` * * Resolve data: * * The resolved data from the state's `resolve` block is placed on the scope as `$resolve` (this * can be customized using [[Ng1ViewDeclaration.resolveAs]]). This can be then accessed from the template. * * Note that when `controllerAs` is being used, `$resolve` is set on the controller instance *after* the * controller is instantiated. The `$onInit()` hook can be used to perform initialization code which * depends on `$resolve` data. * * #### Example: * ```js * $stateProvider.state('home', { * template: '', * resolve: { * user: function(UserService) { return UserService.fetchUser(); } * } * }); * ``` */ var uiView; // eslint-disable-next-line prefer-const uiView = [ '$view', '$animate', '$uiViewScroll', '$interpolate', '$q', function $ViewDirective($view, $animate, $uiViewScroll, $interpolate, $q) { function getRenderer() { return { enter: function (element, target, cb) { if (ng.version.minor > 2) { $animate.enter(element, null, target).then(cb); } else { $animate.enter(element, null, target, cb); } }, leave: function (element, cb) { if (ng.version.minor > 2) { $animate.leave(element).then(cb); } else { $animate.leave(element, cb); } }, }; } function configsEqual(config1, config2) { return config1 === config2; } var rootData = { $cfg: { viewDecl: { $context: $view._pluginapi._rootViewContext() } }, $uiView: {}, }; var directive = { count: 0, restrict: 'ECA', terminal: true, priority: 400, transclude: 'element', compile: function (tElement, tAttrs, $transclude) { return function (scope, $element, attrs) { var onloadExp = attrs['onload'] || '', autoScrollExp = attrs['autoscroll'], renderer = getRenderer(), inherited = $element.inheritedData('$uiView') || rootData, name = $interpolate(attrs['uiView'] || attrs['name'] || '')(scope) || '$default'; var previousEl, currentEl, currentScope, viewConfig; var activeUIView = { $type: 'ng1', id: directive.count++, name: name, fqn: inherited.$uiView.fqn ? inherited.$uiView.fqn + '.' + name : name, config: null, configUpdated: configUpdatedCallback, get creationContext() { // The context in which this ui-view "tag" was created var fromParentTagConfig = parse('$cfg.viewDecl.$context')(inherited); // Allow // See https://github.com/angular-ui/ui-router/issues/3355 var fromParentTag = parse('$uiView.creationContext')(inherited); return fromParentTagConfig || fromParentTag; }, }; trace.traceUIViewEvent('Linking', activeUIView); function configUpdatedCallback(config) { if (config && !(config instanceof Ng1ViewConfig)) return; if (configsEqual(viewConfig, config)) return; trace.traceUIViewConfigUpdated(activeUIView, config && config.viewDecl && config.viewDecl.$context); viewConfig = config; updateView(config); } $element.data('$uiView', { $uiView: activeUIView }); updateView(); var unregister = $view.registerUIView(activeUIView); scope.$on('$destroy', function () { trace.traceUIViewEvent('Destroying/Unregistering', activeUIView); unregister(); }); function cleanupLastView() { if (previousEl) { trace.traceUIViewEvent('Removing (previous) el', previousEl.data('$uiView')); previousEl.remove(); previousEl = null; } if (currentScope) { trace.traceUIViewEvent('Destroying scope', activeUIView); currentScope.$destroy(); currentScope = null; } if (currentEl) { var _viewData_1 = currentEl.data('$uiViewAnim'); trace.traceUIViewEvent('Animate out', _viewData_1); renderer.leave(currentEl, function () { _viewData_1.$$animLeave.resolve(); previousEl = null; }); previousEl = currentEl; currentEl = null; } } function updateView(config) { var newScope = scope.$new(); var animEnter = $q.defer(), animLeave = $q.defer(); var $uiViewData = { $cfg: config, $uiView: activeUIView, }; var $uiViewAnim = { $animEnter: animEnter.promise, $animLeave: animLeave.promise, $$animLeave: animLeave, }; /** * @ngdoc event * @name ui.router.state.directive:ui-view#$viewContentLoading * @eventOf ui.router.state.directive:ui-view * @eventType emits on ui-view directive scope * @description * * Fired once the view **begins loading**, *before* the DOM is rendered. * * @param {Object} event Event object. * @param {string} viewName Name of the view. */ newScope.$emit('$viewContentLoading', name); var cloned = $transclude(newScope, function (clone) { clone.data('$uiViewAnim', $uiViewAnim); clone.data('$uiView', $uiViewData); renderer.enter(clone, $element, function onUIViewEnter() { animEnter.resolve(); if (currentScope) currentScope.$emit('$viewContentAnimationEnded'); if ((isDefined(autoScrollExp) && !autoScrollExp) || scope.$eval(autoScrollExp)) { $uiViewScroll(clone); } }); cleanupLastView(); }); currentEl = cloned; currentScope = newScope; /** * @ngdoc event * @name ui.router.state.directive:ui-view#$viewContentLoaded * @eventOf ui.router.state.directive:ui-view * @eventType emits on ui-view directive scope * @description * * Fired once the view is **loaded**, *after* the DOM is rendered. * * @param {Object} event Event object. */ currentScope.$emit('$viewContentLoaded', config || viewConfig); currentScope.$eval(onloadExp); } }; }, }; return directive; }, ]; $ViewDirectiveFill.$inject = ['$compile', '$controller', '$transitions', '$view', '$q']; /** @hidden */ function $ViewDirectiveFill($compile, $controller, $transitions, $view, $q) { var getControllerAs = parse('viewDecl.controllerAs'); var getResolveAs = parse('viewDecl.resolveAs'); return { restrict: 'ECA', priority: -400, compile: function (tElement) { var initial = tElement.html(); tElement.empty(); return function (scope, $element) { var data = $element.data('$uiView'); if (!data) { $element.html(initial); $compile($element.contents())(scope); return; } var cfg = data.$cfg || { viewDecl: {}, getTemplate: noop }; var resolveCtx = cfg.path && new ResolveContext(cfg.path); $element.html(cfg.getTemplate($element, resolveCtx) || initial); trace.traceUIViewFill(data.$uiView, $element.html()); var link = $compile($element.contents()); var controller = cfg.controller; var controllerAs = getControllerAs(cfg); var resolveAs = getResolveAs(cfg); var locals = resolveCtx && getLocals(resolveCtx); scope[resolveAs] = locals; if (controller) { var controllerInstance = ($controller(controller, extend({}, locals, { $scope: scope, $element: $element }))); if (controllerAs) { scope[controllerAs] = controllerInstance; scope[controllerAs][resolveAs] = locals; } // TODO: Use $view service as a central point for registering component-level hooks // Then, when a component is created, tell the $view service, so it can invoke hooks // $view.componentLoaded(controllerInstance, { $scope: scope, $element: $element }); // scope.$on('$destroy', () => $view.componentUnloaded(controllerInstance, { $scope: scope, $element: $element })); $element.data('$ngControllerController', controllerInstance); $element.children().data('$ngControllerController', controllerInstance); registerControllerCallbacks($q, $transitions, controllerInstance, scope, cfg); } // Wait for the component to appear in the DOM if (isString(cfg.component)) { var kebobName = kebobString(cfg.component); var tagRegexp_1 = new RegExp("^(x-|data-)?" + kebobName + "$", 'i'); var getComponentController = function () { var directiveEl = [].slice .call($element[0].children) .filter(function (el) { return el && el.tagName && tagRegexp_1.exec(el.tagName); }); return directiveEl && ng.element(directiveEl).data("$" + cfg.component + "Controller"); }; var deregisterWatch_1 = scope.$watch(getComponentController, function (ctrlInstance) { if (!ctrlInstance) return; registerControllerCallbacks($q, $transitions, ctrlInstance, scope, cfg); deregisterWatch_1(); }); } link(scope); }; }, }; } /** @hidden */ var hasComponentImpl = typeof ng.module('ui.router')['component'] === 'function'; /** @hidden incrementing id */ var _uiCanExitId = 0; /** @hidden TODO: move these callbacks to $view and/or `/hooks/components.ts` or something */ function registerControllerCallbacks($q, $transitions, controllerInstance, $scope, cfg) { // Call $onInit() ASAP if (isFunction(controllerInstance.$onInit) && !((cfg.viewDecl.component || cfg.viewDecl.componentProvider) && hasComponentImpl)) { controllerInstance.$onInit(); } var viewState = tail(cfg.path).state.self; var hookOptions = { bind: controllerInstance }; // Add component-level hook for onUiParamsChanged if (isFunction(controllerInstance.uiOnParamsChanged)) { var resolveContext = new ResolveContext(cfg.path); var viewCreationTrans_1 = resolveContext.getResolvable('$transition$').data; // Fire callback on any successful transition var paramsUpdated = function ($transition$) { // Exit early if the $transition$ is the same as the view was created within. // Exit early if the $transition$ will exit the state the view is for. if ($transition$ === viewCreationTrans_1 || $transition$.exiting().indexOf(viewState) !== -1) return; var toParams = $transition$.params('to'); var fromParams = $transition$.params('from'); var getNodeSchema = function (node) { return node.paramSchema; }; var toSchema = $transition$.treeChanges('to').map(getNodeSchema).reduce(unnestR, []); var fromSchema = $transition$.treeChanges('from').map(getNodeSchema).reduce(unnestR, []); // Find the to params that have different values than the from params var changedToParams = toSchema.filter(function (param) { var idx = fromSchema.indexOf(param); return idx === -1 || !fromSchema[idx].type.equals(toParams[param.id], fromParams[param.id]); }); // Only trigger callback if a to param has changed or is new if (changedToParams.length) { var changedKeys_1 = changedToParams.map(function (x) { return x.id; }); // Filter the params to only changed/new to params. `$transition$.params()` may be used to get all params. var newValues = filter(toParams, function (val, key) { return changedKeys_1.indexOf(key) !== -1; }); controllerInstance.uiOnParamsChanged(newValues, $transition$); } }; $scope.$on('$destroy', $transitions.onSuccess({}, paramsUpdated, hookOptions)); } // Add component-level hook for uiCanExit if (isFunction(controllerInstance.uiCanExit)) { var id_1 = _uiCanExitId++; var cacheProp_1 = '_uiCanExitIds'; // Returns true if a redirect transition already answered truthy var prevTruthyAnswer_1 = function (trans) { return !!trans && ((trans[cacheProp_1] && trans[cacheProp_1][id_1] === true) || prevTruthyAnswer_1(trans.redirectedFrom())); }; // If a user answered yes, but the transition was later redirected, don't also ask for the new redirect transition var wrappedHook = function (trans) { var promise; var ids = (trans[cacheProp_1] = trans[cacheProp_1] || {}); if (!prevTruthyAnswer_1(trans)) { promise = $q.when(controllerInstance.uiCanExit(trans)); promise.then(function (val) { return (ids[id_1] = val !== false); }); } return promise; }; var criteria = { exiting: viewState.name }; $scope.$on('$destroy', $transitions.onBefore(criteria, wrappedHook, hookOptions)); } } ng.module('ui.router.state').directive('uiView', uiView); ng.module('ui.router.state').directive('uiView', $ViewDirectiveFill); /** @publicapi @module ng1 */ /** */ /** @hidden */ function $ViewScrollProvider() { var useAnchorScroll = false; this.useAnchorScroll = function () { useAnchorScroll = true; }; this.$get = [ '$anchorScroll', '$timeout', function ($anchorScroll, $timeout) { if (useAnchorScroll) { return $anchorScroll; } return function ($element) { return $timeout(function () { $element[0].scrollIntoView(); }, 0, false); }; }, ]; } ng.module('ui.router.state').provider('$uiViewScroll', $ViewScrollProvider); /** * Main entry point for angular 1.x build * @publicapi @module ng1 */ /** */ var index$1 = 'ui.router'; exports.$injector = $injector; exports.$q = $q; exports.BaseLocationServices = BaseLocationServices; exports.BaseUrlRule = BaseUrlRule; exports.BrowserLocationConfig = BrowserLocationConfig; exports.Glob = Glob; exports.HashLocationService = HashLocationService; exports.HookBuilder = HookBuilder; exports.MemoryLocationConfig = MemoryLocationConfig; exports.MemoryLocationService = MemoryLocationService; exports.NATIVE_INJECTOR_TOKEN = NATIVE_INJECTOR_TOKEN; exports.Ng1ViewConfig = Ng1ViewConfig; exports.Param = Param; exports.ParamFactory = ParamFactory; exports.ParamType = ParamType; exports.ParamTypes = ParamTypes; exports.PathNode = PathNode; exports.PathUtils = PathUtils; exports.PushStateLocationService = PushStateLocationService; exports.Queue = Queue; exports.RegisteredHook = RegisteredHook; exports.Rejection = Rejection; exports.Resolvable = Resolvable; exports.ResolveContext = ResolveContext; exports.StateBuilder = StateBuilder; exports.StateMatcher = StateMatcher; exports.StateObject = StateObject; exports.StateParams = StateParams; exports.StateProvider = StateProvider; exports.StateQueueManager = StateQueueManager; exports.StateRegistry = StateRegistry; exports.StateService = StateService; exports.TargetState = TargetState; exports.Trace = Trace; exports.Transition = Transition; exports.TransitionEventType = TransitionEventType; exports.TransitionHook = TransitionHook; exports.TransitionService = TransitionService; exports.UIRouter = UIRouter; exports.UIRouterGlobals = UIRouterGlobals; exports.UIRouterPluginBase = UIRouterPluginBase; exports.UrlConfig = UrlConfig; exports.UrlMatcher = UrlMatcher; exports.UrlMatcherFactory = UrlMatcherFactory; exports.UrlRouter = UrlRouter; exports.UrlRouterProvider = UrlRouterProvider; exports.UrlRuleFactory = UrlRuleFactory; exports.UrlRules = UrlRules; exports.UrlService = UrlService; exports.ViewService = ViewService; exports._extend = _extend; exports._inArray = _inArray; exports._pushTo = _pushTo; exports._removeFrom = _removeFrom; exports.all = all; exports.allTrueR = allTrueR; exports.ancestors = ancestors; exports.and = and; exports.any = any; exports.anyTrueR = anyTrueR; exports.applyPairs = applyPairs; exports.arrayTuples = arrayTuples; exports.assertFn = assertFn; exports.assertMap = assertMap; exports.assertPredicate = assertPredicate; exports.beforeAfterSubstr = beforeAfterSubstr; exports.buildUrl = buildUrl; exports.compose = compose; exports.copy = copy; exports.core = index; exports.createProxyFunctions = createProxyFunctions; exports.curry = curry; exports.default = index$1; exports.defaultResolvePolicy = defaultResolvePolicy; exports.defaultTransOpts = defaultTransOpts; exports.defaults = defaults; exports.deregAll = deregAll; exports.eq = eq; exports.equals = equals; exports.extend = extend; exports.filter = filter; exports.find = find; exports.flatten = flatten; exports.flattenR = flattenR; exports.fnToString = fnToString; exports.forEach = forEach; exports.fromJson = fromJson; exports.functionToString = functionToString; exports.getLocals = getLocals; exports.getNg1ViewConfigFactory = getNg1ViewConfigFactory; exports.getParams = getParams; exports.hashLocationPlugin = hashLocationPlugin; exports.hostRegex = hostRegex; exports.identity = identity; exports.inArray = inArray; exports.inherit = inherit; exports.invoke = invoke; exports.is = is; exports.isArray = isArray; exports.isDate = isDate; exports.isDefined = isDefined; exports.isFunction = isFunction; exports.isInjectable = isInjectable; exports.isNull = isNull; exports.isNullOrUndefined = isNullOrUndefined; exports.isNumber = isNumber; exports.isObject = isObject; exports.isPromise = isPromise; exports.isRegExp = isRegExp; exports.isString = isString; exports.isUndefined = isUndefined; exports.joinNeighborsR = joinNeighborsR; exports.kebobString = kebobString; exports.keyValsToObjectR = keyValsToObjectR; exports.locationPluginFactory = locationPluginFactory; exports.makeEvent = makeEvent; exports.makeStub = makeStub; exports.map = map; exports.mapObj = mapObj; exports.matchState = matchState; exports.maxLength = maxLength; exports.memoryLocationPlugin = memoryLocationPlugin; exports.mergeR = mergeR; exports.ng1ViewsBuilder = ng1ViewsBuilder; exports.noop = noop; exports.not = not; exports.omit = omit; exports.or = or; exports.padString = padString; exports.pairs = pairs; exports.parse = parse; exports.parseUrl = parseUrl$1; exports.pattern = pattern; exports.pick = pick; exports.pipe = pipe; exports.pluck = pluck; exports.prop = prop; exports.propEq = propEq; exports.pushR = pushR; exports.pushStateLocationPlugin = pushStateLocationPlugin; exports.pushTo = pushTo; exports.removeFrom = removeFrom; exports.resolvablesBuilder = resolvablesBuilder; exports.resolvePolicies = resolvePolicies; exports.root = root; exports.services = services; exports.servicesPlugin = servicesPlugin; exports.silenceUncaughtInPromise = silenceUncaughtInPromise; exports.silentRejection = silentRejection; exports.splitEqual = splitEqual; exports.splitHash = splitHash; exports.splitOnDelim = splitOnDelim; exports.splitQuery = splitQuery; exports.stringify = stringify; exports.stripLastPathElement = stripLastPathElement; exports.tail = tail; exports.toJson = toJson; exports.trace = trace; exports.trimHashVal = trimHashVal; exports.uniqR = uniqR; exports.unnest = unnest; exports.unnestR = unnestR; exports.val = val; exports.values = values; exports.watchDigests = watchDigests; Object.defineProperty(exports, '__esModule', { value: true }); }))); //# sourceMappingURL=angular-ui-router.js.map

    RetroSearch is an open source project built by @garambo | Open a GitHub Issue

    Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

    HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4