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

ng-dialog

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ng-dialog - npm Package Compare versions

Comparing version 0.1.6 to 0.2.2

2

bower.json
{
"name": "ngDialog",
"version": "0.1.6",
"version": "0.2.2",
"homepage": "https://github.com/likeastore/ngDialog",

@@ -5,0 +5,0 @@ "description": "Modal dialogs and popups provider for Angular.js applications",

@@ -9,3 +9,3 @@ module.exports = function (grunt) {

},
avgrund: {
ngDialog: {
files: {

@@ -12,0 +12,0 @@ './js/ngDialog.min.js': ['./js/ngDialog.js']

@@ -27,3 +27,3 @@ /*

var globalID = 0, dialogsCount = 0, closeByDocumentHandler;
var globalID = 0, dialogsCount = 0, closeByDocumentHandler, defers = {};

@@ -35,3 +35,3 @@ this.$get = ['$document', '$templateCache', '$compile', '$q', '$http', '$rootScope', '$timeout',

var privateMethods = {
onDocumentKeyup: function (event) {
onDocumentKeydown: function (event) {
if (event.keyCode === 27) {

@@ -43,4 +43,5 @@ publicMethods.close();

closeDialog: function ($dialog) {
if (typeof Hammer !== 'undefined') {
Hammer($dialog[0]).off('tap', closeByDocumentHandler);
var id = $dialog.attr('id');
if (typeof window.Hammer !== 'undefined') {
window.Hammer($dialog[0]).off('tap', closeByDocumentHandler);
} else {

@@ -51,6 +52,8 @@ $dialog.unbind('click');

if (dialogsCount === 1) {
$body.unbind('keyup').removeClass('ngdialog-open');
$body.unbind('keydown');
}
dialogsCount -= 1;
if (!$dialog.hasClass("ngdialog-closing")){
dialogsCount -= 1;
}

@@ -61,2 +64,5 @@ if (animationEndSupport) {

$dialog.remove();
if (dialogsCount === 0) {
$body.removeClass('ngdialog-open');
}
}).addClass('ngdialog-closing');

@@ -66,4 +72,14 @@ } else {

$dialog.remove();
if (dialogsCount === 0) {
$body.removeClass('ngdialog-open');
}
}
if (defers[id]) {
defers[id].resolve({
id: id,
$dialog: $dialog,
remainingDialogs: dialogsCount
});
delete defers[id];
}
$rootScope.$broadcast('ngDialog.closed', $dialog);

@@ -99,2 +115,5 @@ }

var defer;
defers[self.latestID] = defer = $q.defer();
var scope = angular.isObject(options.scope) ? options.scope.$new() : $rootScope.$new();

@@ -137,25 +156,22 @@ var $dialog;

$compile($dialog)(scope);
$body.addClass('ngdialog-open').append($dialog);
});
$body.addClass('ngdialog-open').append($dialog);
if (options.closeByEscape) {
$body.bind('keyup', privateMethods.onDocumentKeyup);
$body.bind('keydown', privateMethods.onDocumentKeydown);
}
if (options.closeByDocument) {
closeByDocumentHandler = function (event) {
var isOverlay = $el(event.target).hasClass('ngdialog-overlay');
var isCloseBtn = $el(event.target).hasClass('ngdialog-close');
closeByDocumentHandler = function (event) {
var isOverlay = options.closeByDocument ? $el(event.target).hasClass('ngdialog-overlay') : false;
var isCloseBtn = $el(event.target).hasClass('ngdialog-close');
if (isOverlay || isCloseBtn) {
publicMethods.close($dialog.attr('id'));
}
};
if (isOverlay || isCloseBtn) {
publicMethods.close($dialog.attr('id'));
}
};
if (typeof Hammer !== 'undefined') {
Hammer($dialog[0]).on('tap', closeByDocumentHandler);
} else {
$dialog.bind('click', closeByDocumentHandler);
}
if (typeof window.Hammer !== 'undefined') {
window.Hammer($dialog[0]).on('tap', closeByDocumentHandler);
} else {
$dialog.bind('click', closeByDocumentHandler);
}

@@ -170,2 +186,10 @@

return {
id: 'ngdialog' + globalID,
closePromise: defer.promise,
close: function() {
privateMethods.closeDialog($dialog);
}
};
function loadTemplate (tmpl) {

@@ -185,2 +209,38 @@ if (!tmpl) {

/*
* @param {Object} options:
* - template {String} - id of ng-template, url for partial, plain string (if enabled)
* - plain {Boolean} - enable plain string templates, default false
* - scope {Object}
* - controller {String}
* - className {String} - dialog theme class
* - showClose {Boolean} - show close button, default true
* - closeByEscape {Boolean} - default false
* - closeByDocument {Boolean} - default false
*
* @return {Object} dialog
*/
openConfirm: function (opts) {
var defer = $q.defer();
var options = {
closeByEscape: false,
closeByDocument: false
};
angular.extend(options, opts);
options.scope = angular.isObject(options.scope) ? options.scope.$new() : $rootScope.$new();
options.scope.confirm = function (value) {
defer.resolve(value);
openResult.close();
};
var openResult = publicMethods.open(options);
openResult.closePromise.then(function () {
defer.reject();
});
return defer.promise;
},
/*
* @param {String} id

@@ -217,2 +277,5 @@ * @return {Object} dialog

restrict: 'A',
scope : {
ngDialogScope : '='
},
link: function (scope, elem, attrs) {

@@ -222,2 +285,3 @@ elem.on('click', function (e) {

var ngDialogScope = angular.isDefined(scope.ngDialogScope) ? scope.ngDialogScope : 'noScope';
angular.isDefined(attrs.ngDialogClosePrevious) && ngDialog.close(attrs.ngDialogClosePrevious);

@@ -229,7 +293,7 @@

controller: attrs.ngDialogController,
scope: attrs.ngDialogScope,
scope: ngDialogScope ,
data: attrs.ngDialogData,
showClose: attrs.ngDialogShowClose === 'false' ? false : true,
closeByDocument: attrs.ngDialogCloseByDocument === 'false' ? false : true,
closeByEscape: attrs.ngDialogCloseByKeyup === 'false' ? false : true
closeByEscape: attrs.ngDialogCloseByEscape === 'false' ? false : true
});

@@ -236,0 +300,0 @@ });

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

/*! ngDialog - v0.1.6 (https://github.com/likeastore/ngDialog) */
!function(a,b){"use strict";var c=b.module("ngDialog",[]),d=b.element,e=b.isDefined,f=(document.body||document.documentElement).style,g=e(f.animation)||e(f.WebkitAnimation)||e(f.MozAnimation)||e(f.MsAnimation)||e(f.OAnimation),h="animationend webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend";c.provider("ngDialog",function(){var a,c=this.defaults={className:"ngdialog-theme-default",plain:!1,showClose:!0,closeByDocument:!0,closeByEscape:!0},e=0,f=0;this.$get=["$document","$templateCache","$compile","$q","$http","$rootScope","$timeout",function(i,j,k,l,m,n,o){var p=i.find("body"),q={onDocumentKeyup:function(a){27===a.keyCode&&r.close()},closeDialog:function(b){"undefined"!=typeof Hammer?Hammer(b[0]).off("tap",a):b.unbind("click"),1===f&&p.unbind("keyup").removeClass("ngdialog-open"),f-=1,g?b.unbind(h).bind(h,function(){b.scope().$destroy(),b.remove()}).addClass("ngdialog-closing"):(b.scope().$destroy(),b.remove()),n.$broadcast("ngDialog.closed",b)}},r={open:function(g){function h(a){return a?b.isString(a)&&s.plain?a:j.get(a)||m.get(a,{cache:!0}):"Empty template"}var i=this,s=b.copy(c);g=g||{},b.extend(s,g),e+=1,i.latestID="ngdialog"+e;var t,u=b.isObject(s.scope)?s.scope.$new():n.$new();l.when(h(s.template)).then(function(c){return c=b.isString(c)?c:c.data&&b.isString(c.data)?c.data:"",j.put(s.template,c),s.showClose&&(c+='<div class="ngdialog-close"></div>'),i.$result=t=d('<div id="ngdialog'+e+'" class="ngdialog"></div>'),t.html('<div class="ngdialog-overlay"></div><div class="ngdialog-content">'+c+"</div>"),s.controller&&b.isString(s.controller)&&t.attr("ng-controller",s.controller),s.className&&t.addClass(s.className),s.data&&b.isString(s.data)&&(u.ngDialogData="{"===s.data.replace(/^\s*/,"")[0]?b.fromJson(s.data):s.data),u.closeThisDialog=function(){q.closeDialog(t)},o(function(){k(t)(u)}),p.addClass("ngdialog-open").append(t),s.closeByEscape&&p.bind("keyup",q.onDocumentKeyup),s.closeByDocument&&(a=function(a){var b=d(a.target).hasClass("ngdialog-overlay"),c=d(a.target).hasClass("ngdialog-close");(b||c)&&r.close(t.attr("id"))},"undefined"!=typeof Hammer?Hammer(t[0]).on("tap",a):t.bind("click",a)),f+=1,n.$broadcast("ngDialog.opened",t),r})},close:function(a){var b=d(document.getElementById(a));return b.length?q.closeDialog(b):r.closeAll(),r},closeAll:function(){var a=document.querySelectorAll(".ngdialog");b.forEach(a,function(a){q.closeDialog(d(a))})}};return r}]}),c.directive("ngDialog",["ngDialog",function(a){return{restrict:"A",link:function(c,d,e){d.on("click",function(c){c.preventDefault(),b.isDefined(e.ngDialogClosePrevious)&&a.close(e.ngDialogClosePrevious),a.open({template:e.ngDialog,className:e.ngDialogClass,controller:e.ngDialogController,scope:e.ngDialogScope,data:e.ngDialogData,showClose:"false"===e.ngDialogShowClose?!1:!0,closeByDocument:"false"===e.ngDialogCloseByDocument?!1:!0,closeByEscape:"false"===e.ngDialogCloseByKeyup?!1:!0})})}}}])}(window,window.angular);
/*! ng-dialog - v0.2.2 (https://github.com/likeastore/ngDialog) */
!function(a,b){"use strict";var c=b.module("ngDialog",[]),d=b.element,e=b.isDefined,f=(document.body||document.documentElement).style,g=e(f.animation)||e(f.WebkitAnimation)||e(f.MozAnimation)||e(f.MsAnimation)||e(f.OAnimation),h="animationend webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend";c.provider("ngDialog",function(){var c,e=this.defaults={className:"ngdialog-theme-default",plain:!1,showClose:!0,closeByDocument:!0,closeByEscape:!0},f=0,i=0,j={};this.$get=["$document","$templateCache","$compile","$q","$http","$rootScope","$timeout",function(k,l,m,n,o,p,q){var r=k.find("body"),s={onDocumentKeydown:function(a){27===a.keyCode&&t.close()},closeDialog:function(b){var d=b.attr("id");"undefined"!=typeof a.Hammer?a.Hammer(b[0]).off("tap",c):b.unbind("click"),1===i&&r.unbind("keydown"),b.hasClass("ngdialog-closing")||(i-=1),g?b.unbind(h).bind(h,function(){b.scope().$destroy(),b.remove(),0===i&&r.removeClass("ngdialog-open")}).addClass("ngdialog-closing"):(b.scope().$destroy(),b.remove(),0===i&&r.removeClass("ngdialog-open")),j[d]&&(j[d].resolve({id:d,$dialog:b,remainingDialogs:i}),delete j[d]),p.$broadcast("ngDialog.closed",b)}},t={open:function(g){function h(a){return a?b.isString(a)&&u.plain?a:l.get(a)||o.get(a,{cache:!0}):"Empty template"}var k=this,u=b.copy(e);g=g||{},b.extend(u,g),f+=1,k.latestID="ngdialog"+f;var v;j[k.latestID]=v=n.defer();var w,x=b.isObject(u.scope)?u.scope.$new():p.$new();return n.when(h(u.template)).then(function(e){return e=b.isString(e)?e:e.data&&b.isString(e.data)?e.data:"",l.put(u.template,e),u.showClose&&(e+='<div class="ngdialog-close"></div>'),k.$result=w=d('<div id="ngdialog'+f+'" class="ngdialog"></div>'),w.html('<div class="ngdialog-overlay"></div><div class="ngdialog-content">'+e+"</div>"),u.controller&&b.isString(u.controller)&&w.attr("ng-controller",u.controller),u.className&&w.addClass(u.className),u.data&&b.isString(u.data)&&(x.ngDialogData="{"===u.data.replace(/^\s*/,"")[0]?b.fromJson(u.data):u.data),x.closeThisDialog=function(){s.closeDialog(w)},q(function(){m(w)(x),r.addClass("ngdialog-open").append(w)}),u.closeByEscape&&r.bind("keydown",s.onDocumentKeydown),c=function(a){var b=u.closeByDocument?d(a.target).hasClass("ngdialog-overlay"):!1,c=d(a.target).hasClass("ngdialog-close");(b||c)&&t.close(w.attr("id"))},"undefined"!=typeof a.Hammer?a.Hammer(w[0]).on("tap",c):w.bind("click",c),i+=1,p.$broadcast("ngDialog.opened",w),t}),{id:"ngdialog"+f,closePromise:v.promise,close:function(){s.closeDialog(w)}}},openConfirm:function(a){var c=n.defer(),d={closeByEscape:!1,closeByDocument:!1};b.extend(d,a),d.scope=b.isObject(d.scope)?d.scope.$new():p.$new(),d.scope.confirm=function(a){c.resolve(a),e.close()};var e=t.open(d);return e.closePromise.then(function(){c.reject()}),c.promise},close:function(a){var b=d(document.getElementById(a));return b.length?s.closeDialog(b):t.closeAll(),t},closeAll:function(){var a=document.querySelectorAll(".ngdialog");b.forEach(a,function(a){s.closeDialog(d(a))})}};return t}]}),c.directive("ngDialog",["ngDialog",function(a){return{restrict:"A",scope:{ngDialogScope:"="},link:function(c,d,e){d.on("click",function(d){d.preventDefault();var f=b.isDefined(c.ngDialogScope)?c.ngDialogScope:"noScope";b.isDefined(e.ngDialogClosePrevious)&&a.close(e.ngDialogClosePrevious),a.open({template:e.ngDialog,className:e.ngDialogClass,controller:e.ngDialogController,scope:f,data:e.ngDialogData,showClose:"false"===e.ngDialogShowClose?!1:!0,closeByDocument:"false"===e.ngDialogCloseByDocument?!1:!0,closeByEscape:"false"===e.ngDialogCloseByEscape?!1:!0})})}}}])}(window,window.angular);
{
"name": "ng-dialog",
"version": "0.1.6",
"version": "0.2.2",
"homepage": "https://github.com/likeastore/ngDialog",

@@ -5,0 +5,0 @@ "description": "Modal dialogs and popups provider for Angular.js applications",

@@ -35,2 +35,4 @@ # ngDialog

===
### ``.open(options)``

@@ -40,3 +42,3 @@

##### Options:
### Options:

@@ -103,3 +105,3 @@ ##### ``template {String}``

<input type="button" value="OK" ng-click="checkInput() && closeThisDialog()"/>
</button>
</div>
```

@@ -141,2 +143,60 @@

### Returns:
The ``open()`` method returns an object with some useful properties.
##### ``id {String}``
This is the ID of the dialog which was just created. It is the ID on the dialog's DOM element.
##### ``close() {Function}``
This is a function which will close the dialog which was opened by the current call to ``open()``.
##### ``closePromise {Promise}``
A promise which will resolve when the dialog is closed. It is resolved with an object containing: ``id`` - the ID of the closed dialog, ``$dialog`` - the dialog element which at this point has been removed from the DOM and ``remainingDialogs`` - the number of dialogs still open.
This allows you do to something like this:
```javascript
var dialog = ngDialog.open({
template: 'templateId'
});
dialog.closePromise.then(function (data) {
console.log(data.id + ' has been dismissed.');
});
```
===
### ``.openConfirm(options)``
Opens a dialog that by default does not close when hitting escape or clicking outside the dialog window. The function returns a promise that is either resolved or rejected depending on the way the dialog was closed.
### Options:
The options are the same as the regular [``.open()``](https://github.com/likeastore/ngDialog#options) method with an extra function added to the scope:
##### ``scope.confirm()``
In addition to the ``.closeThisDialog()`` method. The method ``.confirm()`` is also injected to passed ``$scope``. Use this method to close the dialog and ``resolve`` the promise that was returned when opening the modal.
The function accepts a single optional parameter which is used as the value of the resolved promise.
```html
<div class="dialog-contents">
Some message
<button ng-click="closeThisDialog()">Cancel</button>
<button ng-click="confirm()">Confirm</button>
</div>
```
### Returns:
An Angular promise object that is resolved if the ``.confirm()`` function is used to close the dialog, otherwise the promise is rejected.
===
### ``.close(id)``

@@ -146,2 +206,4 @@

===
### ``.closeAll()``

@@ -191,19 +253,15 @@

ngDialog is available for public on [cdnjs](http://cdnjs.com/). Please use following urls for version 0.1.5.
ngDialog is available for public on [cdnjs](http://cdnjs.com/libraries/ng-dialog). Please use following urls for version 0.1.6.
```html
//cdnjs.cloudflare.com/ajax/libs/ng-dialog/0.1.5/ng-dialog.min.css
//cdnjs.cloudflare.com/ajax/libs/ng-dialog/0.1.5/ng-dialog-theme-plain.min.css
//cdnjs.cloudflare.com/ajax/libs/ng-dialog/0.1.5/ng-dialog.min.js
//cdnjs.cloudflare.com/ajax/libs/ng-dialog/0.1.6/ng-dialog.min.css
//cdnjs.cloudflare.com/ajax/libs/ng-dialog/0.1.6/ng-dialog-theme-plain.min.css
//cdnjs.cloudflare.com/ajax/libs/ng-dialog/0.1.6/ng-dialog.min.js
```
## References
## License
Have a nice experience and use **ngDialog** in your project? Let us know! We appreciate any kind of feedback ;)
## Licence
MIT Licensed
Copyright (c) 2013, Likeastore.com <info@likeastore.com>
Copyright (c) 2013-2014, Likeastore.com <info@likeastore.com>

@@ -210,0 +268,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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