]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/web/js/ui/default/staff/extern/angular-location-update/angular-location-update.js
454f3cc9a27adb1bb2131238f18179d840372ddb
[working/Evergreen.git] / Open-ILS / web / js / ui / default / staff / extern / angular-location-update / angular-location-update.js
1 !function(angular, undefined) { 'use strict';
2
3   angular.module('ngLocationUpdate', [])
4       .run(['$route', '$rootScope', '$location', function ($route, $rootScope, $location) {
5         // todo: would be proper to change this to decorators of $location and $route
6         $location.update_path = function (path, keep_previous_path_in_history) {
7           if ($location.path() == path) return;
8
9           var routeToKeep = $route.current;
10           $rootScope.$on('$locationChangeSuccess', function () {
11             if (routeToKeep) {
12               $route.current = routeToKeep;
13               routeToKeep = null;
14             }
15           });
16
17           $location.path(path);
18           if (!keep_previous_path_in_history) $location.replace();
19         };
20       }]);
21
22 }(window.angular);