diff options
author | Emmanuel ROHEE <erohee@amdocs.com> | 2014-09-10 18:35:05 +0200 |
---|---|---|
committer | Emmanuel ROHEE <erohee@amdocs.com> | 2014-09-10 18:35:05 +0200 |
commit | 44998ca4508c9ed13e563383f1209e7be6ee2e56 (patch) | |
tree | 90870576ecb61d488efb0d9c9ec7697d46ab98a1 /webclient/js/angular-route.js | |
parent | Show echoed emote with transparency (diff) | |
parent | Animation on call end icon. (diff) | |
download | synapse-44998ca4508c9ed13e563383f1209e7be6ee2e56.tar.xz |
Merge remote-tracking branch 'origin/develop' into webclient_initialSync
Diffstat (limited to 'webclient/js/angular-route.js')
-rw-r--r-- | webclient/js/angular-route.js | 61 |
1 files changed, 45 insertions, 16 deletions
diff --git a/webclient/js/angular-route.js b/webclient/js/angular-route.js index c4da03a645..305d92e855 100644 --- a/webclient/js/angular-route.js +++ b/webclient/js/angular-route.js @@ -1,5 +1,5 @@ /** - * @license AngularJS v1.2.20 + * @license AngularJS v1.3.0-rc.1 * (c) 2010-2014 Google, Inc. http://angularjs.org * License: MIT */ @@ -22,12 +22,12 @@ */ /* global -ngRouteModule */ var ngRouteModule = angular.module('ngRoute', ['ng']). - provider('$route', $RouteProvider); + provider('$route', $RouteProvider), + $routeMinErr = angular.$$minErr('ngRoute'); /** * @ngdoc provider * @name $routeProvider - * @kind function * * @description * @@ -216,10 +216,14 @@ function $RouteProvider(){ * Sets route definition that will be used on route change when no other route definition * is matched. * - * @param {Object} params Mapping information to be assigned to `$route.current`. + * @param {Object|string} params Mapping information to be assigned to `$route.current`. + * If called with a string, the value maps to `redirectTo`. * @returns {Object} self */ this.otherwise = function(params) { + if (typeof params === 'string') { + params = {redirectTo: params}; + } this.when(null, params); return this; }; @@ -230,10 +234,9 @@ function $RouteProvider(){ '$routeParams', '$q', '$injector', - '$http', - '$templateCache', + '$templateRequest', '$sce', - function($rootScope, $location, $routeParams, $q, $injector, $http, $templateCache, $sce) { + function($rootScope, $location, $routeParams, $q, $injector, $templateRequest, $sce) { /** * @ngdoc service @@ -441,6 +444,36 @@ function $RouteProvider(){ reload: function() { forceReload = true; $rootScope.$evalAsync(updateRoute); + }, + + /** + * @ngdoc method + * @name $route#updateParams + * + * @description + * Causes `$route` service to update the current URL, replacing + * current route parameters with those specified in `newParams`. + * Provided property names that match the route's path segment + * definitions will be interpolated into the location's path, while + * remaining properties will be treated as query params. + * + * @param {Object} newParams mapping of URL parameter names to values + */ + updateParams: function(newParams) { + if (this.current && this.current.$$route) { + var searchParams = {}, self=this; + + angular.forEach(Object.keys(newParams), function(key) { + if (!self.current.pathParams[key]) searchParams[key] = newParams[key]; + }); + + newParams = angular.extend({}, this.current.params, newParams); + $location.path(interpolate(this.current.$$route.originalPath, newParams)); + $location.search(angular.extend({}, $location.search(), searchParams)); + } + else { + throw $routeMinErr('norout', 'Tried updating route when with no current route'); + } } }; @@ -473,9 +506,7 @@ function $RouteProvider(){ for (var i = 1, len = m.length; i < len; ++i) { var key = keys[i - 1]; - var val = 'string' == typeof m[i] - ? decodeURIComponent(m[i]) - : m[i]; + var val = m[i]; if (key && val) { params[key.name] = val; @@ -518,7 +549,7 @@ function $RouteProvider(){ angular.forEach(locals, function(value, key) { locals[key] = angular.isString(value) ? - $injector.get(value) : $injector.invoke(value); + $injector.get(value) : $injector.invoke(value, null, null, key); }); if (angular.isDefined(template = next.template)) { @@ -532,8 +563,7 @@ function $RouteProvider(){ templateUrl = $sce.getTrustedResourceUrl(templateUrl); if (angular.isDefined(templateUrl)) { next.loadedTemplateUrl = templateUrl; - template = $http.get(templateUrl, {cache: $templateCache}). - then(function(response) { return response.data; }); + template = $templateRequest(templateUrl); } } if (angular.isDefined(template)) { @@ -695,7 +725,6 @@ ngRouteModule.directive('ngView', ngViewFillContentFactory); <pre>$location.path() = {{main.$location.path()}}</pre> <pre>$route.current.templateUrl = {{main.$route.current.templateUrl}}</pre> <pre>$route.current.params = {{main.$route.current.params}}</pre> - <pre>$route.current.scope.name = {{main.$route.current.scope.name}}</pre> <pre>$routeParams = {{main.$routeParams}}</pre> </div> </file> @@ -846,7 +875,7 @@ function ngViewFactory( $route, $anchorScroll, $animate) { currentScope = null; } if(currentElement) { - $animate.leave(currentElement, function() { + $animate.leave(currentElement).then(function() { previousElement = null; }); previousElement = currentElement; @@ -869,7 +898,7 @@ function ngViewFactory( $route, $anchorScroll, $animate) { // function is called before linking the content, which would apply child // directives to non existing elements. var clone = $transclude(newScope, function(clone) { - $animate.enter(clone, null, currentElement || $element, function onNgViewEnter () { + $animate.enter(clone, null, currentElement || $element).then(function onNgViewEnter () { if (angular.isDefined(autoScrollExp) && (!autoScrollExp || scope.$eval(autoScrollExp))) { $anchorScroll(); |