Sha256: d897e6c8958cd465790f76eba272109b11cc5eb0ac4a874f996421d77d102fdc
Contents?: true
Size: 1.13 KB
Versions: 32
Compression:
Stored size: 1.13 KB
Contents
!(angular => { 'use strict'; function NavigationGuardImports($window) { return class NavigationGuard { constructor($scope) { this._$scope = $scope; this._disabled = false; this._previousOnBeforeUnload = $window.onbeforeunload; $scope.$on('$destroy', () => { $window.onbeforeunload = this._previousOnBeforeUnload; }); } registerOnBeforeUnload(fn) { $window.onbeforeunload = () => { if(this._disabled) { return this._previousOnBeforeUnload(); } else { return fn(); } }; return this; } registerLocationChangeStart(fn) { this._$scope.$on('$locationChangeStart', (e) => { if (!this._disabled) { return fn(e); } }); return this; } disable() { this._disabled = true; } static defaultPreventer() { return e => { e.preventDefault(); }; } }; } NavigationGuardImports.$inject = ['$window']; angular.module('alephServices.navigationGuard', []).service('NavigationGuard', NavigationGuardImports); }(angular));
Version data entries
32 entries across 16 versions & 1 rubygems