Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

angular-modal-service

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

angular-modal-service - npm Package Compare versions

Comparing version 0.12.3 to 0.13.0

4

CHANGELOG.md

@@ -0,1 +1,5 @@

## v0.7.12
* Support for configuration of the `$locationChangeSuccess` event. Thanks [smalbs](https://github.com/smalbs).
## v0.6.12

@@ -2,0 +6,0 @@

@@ -120,5 +120,20 @@ /******/ (function(modules) { // webpackBootstrap

// Create a new scope for the modal.
var modalScope = (options.scope || $rootScope).$new();
var rootScopeOnClose = $rootScope.$on('$locationChangeSuccess', cleanUpClose);
var modalScope = (options.scope || $rootScope).$new(),
rootScopeOnClose = null,
locationChangeSuccess = options.locationChangeSuccess;
// Allow locationChangeSuccess event registration to be configurable.
// True (default) = event registered immediately
// # (greater than 0) = event registered with delay
// False = disabled
if (locationChangeSuccess === false) {
rootScopeOnClose = angular.noop;
} else if (angular.isNumber(locationChangeSuccess) && locationChangeSuccess >= 0) {
$timeout(function () {
rootScopeOnClose = $rootScope.$on('$locationChangeSuccess', cleanUpClose);
}, locationChangeSuccess);
} else {
rootScopeOnClose = $rootScope.$on('$locationChangeSuccess', cleanUpClose);
}
// Create the inputs object to the controller - this will include

@@ -125,0 +140,0 @@ // the scope, as well as all inputs provided.

2

dst/angular-modal-service.min.js

@@ -1,2 +0,2 @@

!function(e){function o(l){if(n[l])return n[l].exports;var t=n[l]={exports:{},id:l,loaded:!1};return e[l].call(t.exports,t,t.exports,o),t.loaded=!0,t.exports}var n={};o.m=e,o.c=n,o.p="",o(0)}([function(e,o){"use strict";angular.module("angularModalService",[]).factory("ModalService",["$animate","$document","$compile","$controller","$http","$rootScope","$q","$templateRequest","$timeout",function(e,o,n,l,t,r,s,a,c){function u(){var t=this;t.openModals=[];var u=function(e,o){var n=s.defer();return e?n.resolve(e):o?a(o,!0).then(function(e){n.resolve(e)},function(e){n.reject(e)}):n.reject("No template or templateUrl has been specified."),n.promise},i=function(o,n){var l=o.children();return l.length>0?e.enter(n,o,l[l.length-1]):e.enter(n,o)};t.closeModals=function(e,o){for(;t.openModals.length;)t.openModals[0].close(e,o),t.openModals.splice(0,1)},t.showModal=function(a){var p=angular.element(o[0].body),d=s.defer();return a.controller?(u(a.template,a.templateUrl).then(function(o){function u(o){h.resolve(o),a.bodyClass&&p[0].classList.remove(a.bodyClass),e.leave(b).then(function(){$.resolve(o),m.$destroy();for(var e=0;e<t.openModals.length;e++)if(t.openModals[e].modal===f){t.openModals.splice(e,1);break}M.close=null,d=null,h=null,f=null,M=null,b=null,m=null}),v&&v()}var f={},m=(a.scope||r).$new(),v=r.$on("$locationChangeSuccess",u),h=s.defer(),$=s.defer(),M={$scope:m,close:function(e,o){"function"==typeof a.preClose&&a.preClose(f,e,o),void 0!==o&&null!==o||(o=0),c(function(){u(e)},o)}};a.inputs&&angular.extend(M,a.inputs);var g=n(o),b=g(m);M.$element=b;var y=m[a.controllerAs],x=l(a.controller,M,!1,a.controllerAs);a.controllerAs&&y&&angular.extend(x,y),a.appendElement?i(a.appendElement,b):i(p,b),a.bodyClass&&p[0].classList.add(a.bodyClass),f.controller=x,f.scope=m,f.element=b,f.close=h.promise,f.closed=$.promise,d.resolve(f),document.activeElement.blur(),t.openModals.push({modal:f,close:M.close})}).then(null,function(e){d.reject(e)}),d.promise):(d.reject("No controller has been specified."),d.promise)}}return new u}])}]);
!function(e){function o(l){if(n[l])return n[l].exports;var t=n[l]={exports:{},id:l,loaded:!1};return e[l].call(t.exports,t,t.exports,o),t.loaded=!0,t.exports}var n={};o.m=e,o.c=n,o.p="",o(0)}([function(e,o){"use strict";angular.module("angularModalService",[]).factory("ModalService",["$animate","$document","$compile","$controller","$http","$rootScope","$q","$templateRequest","$timeout",function(e,o,n,l,t,r,s,a,c){function u(){var t=this;t.openModals=[];var u=function(e,o){var n=s.defer();return e?n.resolve(e):o?a(o,!0).then(function(e){n.resolve(e)},function(e){n.reject(e)}):n.reject("No template or templateUrl has been specified."),n.promise},i=function(o,n){var l=o.children();return l.length>0?e.enter(n,o,l[l.length-1]):e.enter(n,o)};t.closeModals=function(e,o){for(;t.openModals.length;)t.openModals[0].close(e,o),t.openModals.splice(0,1)},t.showModal=function(a){var p=angular.element(o[0].body),d=s.defer();return a.controller?(u(a.template,a.templateUrl).then(function(o){function u(o){$.resolve(o),a.bodyClass&&p[0].classList.remove(a.bodyClass),e.leave(C).then(function(){g.resolve(o),m.$destroy();for(var e=0;e<t.openModals.length;e++)if(t.openModals[e].modal===f){t.openModals.splice(e,1);break}M.close=null,d=null,$=null,f=null,M=null,C=null,m=null}),v&&v()}var f={},m=(a.scope||r).$new(),v=null,h=a.locationChangeSuccess;h===!1?v=angular.noop:angular.isNumber(h)&&h>=0?c(function(){v=r.$on("$locationChangeSuccess",u)},h):v=r.$on("$locationChangeSuccess",u);var $=s.defer(),g=s.defer(),M={$scope:m,close:function(e,o){"function"==typeof a.preClose&&a.preClose(f,e,o),void 0!==o&&null!==o||(o=0),c(function(){u(e)},o)}};a.inputs&&angular.extend(M,a.inputs);var b=n(o),C=b(m);M.$element=C;var y=m[a.controllerAs],x=l(a.controller,M,!1,a.controllerAs);a.controllerAs&&y&&angular.extend(x,y),a.appendElement?i(a.appendElement,C):i(p,C),a.bodyClass&&p[0].classList.add(a.bodyClass),f.controller=x,f.scope=m,f.element=C,f.close=$.promise,f.closed=g.promise,d.resolve(f),document.activeElement.blur(),t.openModals.push({modal:f,close:M.close})}).then(null,function(e){d.reject(e)}),d.promise):(d.reject("No controller has been specified."),d.promise)}}return new u}])}]);
//# sourceMappingURL=./dst/angular-modal-service.min.js.map
{
"name": "angular-modal-service",
"version": "0.12.3",
"version": "0.13.0",
"description": "AngularJS Service for showing Modals and Popups",

@@ -5,0 +5,0 @@ "main": "./dst/angular-modal-service.js",

@@ -145,2 +145,3 @@ angular-modal-service

* `preClose`: Optional. A function which will be called before the process of closing a modal starts. The signature is `function preClose(modal, result, delay)`. It is provided the `modal` object, the `result` which was passed to `close` and the `delay` which was passed to close.
* `locationChangeSuccess`: Optional. Allows the closing of the modal when the location changes to be configured. If no value is set, the modal is closed immediately when the `$locationChangeSuccess` event fires. If `false` is set, event is not fired. If a number `n` is set, then the event fires after `n` milliseconds.

@@ -147,0 +148,0 @@ #### The Modal Object

@@ -77,5 +77,25 @@ 'use strict';

// Create a new scope for the modal.
var modalScope = (options.scope || $rootScope).$new();
var rootScopeOnClose = $rootScope.$on('$locationChangeSuccess', cleanUpClose);
var modalScope = (options.scope || $rootScope).$new(),
rootScopeOnClose = null,
locationChangeSuccess = options.locationChangeSuccess;
// Allow locationChangeSuccess event registration to be configurable.
// True (default) = event registered immediately
// # (greater than 0) = event registered with delay
// False = disabled
if (locationChangeSuccess === false){
rootScopeOnClose = angular.noop;
}
else if (angular.isNumber(locationChangeSuccess) && locationChangeSuccess >= 0) {
$timeout(function() {
rootScopeOnClose = $rootScope.$on('$locationChangeSuccess', cleanUpClose);
}, locationChangeSuccess);
}
else {
rootScopeOnClose = $rootScope.$on('$locationChangeSuccess', cleanUpClose);
}
// Create the inputs object to the controller - this will include

@@ -82,0 +102,0 @@ // the scope, as well as all inputs provided.

@@ -147,2 +147,80 @@ describe('dom', () => {

it('should leave the template html in the dom when the $locationChangeSuccess event is explicitly enabled', () => {
$httpBackend.expectGET('some/template2.html');
ModalService.showModal({
controller: "DomController",
templateUrl: "some/template2.html"
}).then((modal) => {
// We should be able to find the element that has been created in the dom.
expect(document.getElementById('template2')).not.toBeNull();
modal.close.then((result) => {
expect(document.getElementById('template2')).toBeNull();
});
$rootScope.$emit('$locationChangeSuccess');
});
$httpBackend.flush();
$timeout.flush();
});
it('should leave the template html in the dom when the $locationChangeSuccess event is explicitly disabled', (done) => {
$httpBackend.expectGET('some/template2.html');
ModalService.showModal({
controller: "DomController",
templateUrl: "some/template2.html",
locationChangeSuccess : false
}).then((modal) => {
// We should be able to find the element that has been created in the dom.
expect(document.getElementById('template2')).not.toBeNull();
$rootScope.$emit('$locationChangeSuccess');
setTimeout(() => {
expect(document.getElementById('template2')).not.toBeNull();
done();
}, 3);
});
$httpBackend.flush();
$timeout.flush();
});
it('should leave the template html in the dom when the $locationChangeSuccess event for the specified delay', () => {
$httpBackend.expectGET('some/template2.html');
ModalService.showModal({
controller: "DomController",
templateUrl: "some/template2.html",
locationChangeSuccess : 10
}).then((modal) => {
$rootScope.$emit('$locationChangeSuccess');
expect($timeout.verifyNoPendingTasks).toThrow();
expect(document.getElementById('template2')).not.toBeNull();
modal.close.then((result) => {
$timeout.verifyNoPendingTasks();
expect(document.getElementById('template2')).toBeNull();
});
$rootScope.$emit('$locationChangeSuccess');
});
$httpBackend.flush();
$timeout.flush();
});
});

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc