Socket
Socket
Sign inDemoInstall

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.2.14 to 0.3.0

.editorconfig

2

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

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

@@ -26,3 +26,5 @@ /*

closeByEscape: true,
appendTo: false
appendTo: false,
preCloseCallback: false,
cache: true
};

@@ -71,4 +73,5 @@

closeDialog: function ($dialog, value) {
performCloseDialog: function ($dialog, value) {
var id = $dialog.attr('id');
if (typeof window.Hammer !== 'undefined') {

@@ -116,2 +119,29 @@ window.Hammer($dialog[0]).off('tap', closeByDocumentHandler);

}
},
closeDialog: function ($dialog, value) {
var preCloseCallback = $dialog.data('$ngDialogPreCloseCallback');
if (preCloseCallback && angular.isFunction(preCloseCallback)) {
var preCloseCallbackResult = preCloseCallback.call($dialog, value);
if (angular.isObject(preCloseCallbackResult)) {
if (preCloseCallbackResult.closePromise) {
preCloseCallbackResult.closePromise.then(function () {
privateMethods.performCloseDialog($dialog, value);
});
} else {
preCloseCallbackResult.then(function () {
privateMethods.performCloseDialog($dialog, value);
}, function () {
return;
});
}
} else if (preCloseCallbackResult !== false) {
privateMethods.performCloseDialog($dialog, value);
}
} else {
privateMethods.performCloseDialog($dialog, value);
}
}

@@ -132,2 +162,3 @@ };

* - closeByDocument {Boolean} - default true
* - preCloseCallback {String|Function} - user supplied function name/function called before closing dialog (if set)
*

@@ -168,3 +199,3 @@ * @return {Object} dialog

$dialog.html('<div class="ngdialog-overlay"></div><div class="ngdialog-content">' + template + '</div>');
if (options.data && angular.isString(options.data)) {

@@ -195,2 +226,24 @@ var firstLetter = options.data.replace(/^\s*/, '')[0];

if (options.preCloseCallback) {
var preCloseCallback;
if (angular.isFunction(options.preCloseCallback)) {
preCloseCallback = options.preCloseCallback;
} else if (angular.isString(options.preCloseCallback)) {
if (scope) {
if (angular.isFunction(scope[options.preCloseCallback])) {
preCloseCallback = scope[options.preCloseCallback];
} else if (scope.$parent && angular.isFunction(scope.$parent[options.preCloseCallback])) {
preCloseCallback = scope.$parent[options.preCloseCallback];
} else if ($rootScope && angular.isFunction($rootScope[options.preCloseCallback])) {
preCloseCallback = $rootScope[options.preCloseCallback];
}
}
}
if (preCloseCallback) {
$dialog.data('$ngDialogPreCloseCallback', preCloseCallback);
}
}
scope.closeThisDialog = function (value) {

@@ -210,3 +263,8 @@ privateMethods.closeDialog($dialog, value);

$dialogParent.append($dialog);
$rootScope.$broadcast('ngDialog.opened', $dialog);
if (options.name) {
$rootScope.$broadcast('ngDialog.opened', {dialog: $dialog, name: options.name});
} else {
$rootScope.$broadcast('ngDialog.opened', $dialog);
}
});

@@ -241,3 +299,3 @@

closePromise: defer.promise,
close: function(value) {
close: function (value) {
privateMethods.closeDialog($dialog, value);

@@ -256,3 +314,7 @@ }

return $templateCache.get(tmpl) || $http.get(tmpl, { cache: true });
if (typeof options.cache === 'boolean' && !options.cache) {
return $http.get(tmpl, {cache: false});
}
return $templateCache.get(tmpl) || $http.get(tmpl, {cache: true});
}

@@ -271,2 +333,3 @@ },

* - closeByDocument {Boolean} - default false
* - preCloseCallback {String|Function} - user supplied function name/function called before closing dialog (if set); not called on confirm
*

@@ -287,3 +350,4 @@ * @return {Object} dialog

defer.resolve(value);
openResult.close(value);
var $dialog = $el(document.getElementById(openResult.id));
privateMethods.performCloseDialog($dialog, value);
};

@@ -324,2 +388,6 @@

});
},
getDefaults: function () {
return defaults;
}

@@ -345,11 +413,14 @@ };

var defaults = ngDialog.getDefaults();
ngDialog.open({
template: attrs.ngDialog,
className: attrs.ngDialogClass,
className: attrs.ngDialogClass || defaults.className,
controller: attrs.ngDialogController,
scope: ngDialogScope ,
data: attrs.ngDialogData,
showClose: attrs.ngDialogShowClose === 'false' ? false : true,
closeByDocument: attrs.ngDialogCloseByDocument === 'false' ? false : true,
closeByEscape: attrs.ngDialogCloseByEscape === 'false' ? false : true
showClose: attrs.ngDialogShowClose === 'false' ? false : (attrs.ngDialogShowClose === 'true' ? true : defaults.showClose),
closeByDocument: attrs.ngDialogCloseByDocument === 'false' ? false : (attrs.ngDialogCloseByDocument === 'true' ? true : defaults.closeByDocument),
closeByEscape: attrs.ngDialogCloseByEscape === 'false' ? false : (attrs.ngDialogCloseByEscape === 'true' ? true : defaults.closeByEscape),
preCloseCallback: attrs.ngDialogPreCloseCallback || defaults.preCloseCallback
});

@@ -356,0 +427,0 @@ });

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

/*! ng-dialog - v0.2.14 (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",i=!1;c.provider("ngDialog",function(){var c=this.defaults={className:"ngdialog-theme-default",plain:!1,showClose:!0,closeByDocument:!0,closeByEscape:!0,appendTo:!1};this.setForceBodyReload=function(a){i=a||!1},this.setDefaults=function(a){b.extend(c,a)};var e,f=0,j=0,k={};this.$get=["$document","$templateCache","$compile","$q","$http","$rootScope","$timeout","$window","$controller",function(l,m,n,o,p,q,r,s,t){var u=l.find("body");i&&q.$on("$locationChangeSuccess",function(){u=l.find("body")});var v={onDocumentKeydown:function(a){27===a.keyCode&&w.close("$escape")},setBodyPadding:function(a){var b=parseInt(u.css("padding-right")||0,10);u.css("padding-right",b+a+"px"),u.data("ng-dialog-original-padding",b)},resetBodyPadding:function(){var a=u.data("ng-dialog-original-padding");a?u.css("padding-right",a+"px"):u.css("padding-right","")},closeDialog:function(b,c){var d=b.attr("id");"undefined"!=typeof a.Hammer?a.Hammer(b[0]).off("tap",e):b.unbind("click"),1===j&&u.unbind("keydown"),b.hasClass("ngdialog-closing")||(j-=1),g?b.unbind(h).bind(h,function(){b.scope().$destroy(),b.remove(),0===j&&(u.removeClass("ngdialog-open"),v.resetBodyPadding()),q.$broadcast("ngDialog.closed",b)}).addClass("ngdialog-closing"):(b.scope().$destroy(),b.remove(),0===j&&(u.removeClass("ngdialog-open"),v.resetBodyPadding()),q.$broadcast("ngDialog.closed",b)),k[d]&&(k[d].resolve({id:d,value:c,$dialog:b,remainingDialogs:j}),delete k[d])}},w={open:function(g){function h(a){return a?b.isString(a)&&l.plain?a:m.get(a)||p.get(a,{cache:!0}):"Empty template"}var i=this,l=b.copy(c);g=g||{},b.extend(l,g),f+=1,i.latestID="ngdialog"+f;var x;k[i.latestID]=x=o.defer();var y,z,A=b.isObject(l.scope)?l.scope.$new():q.$new();return o.when(h(l.template)).then(function(c){if(c=b.isString(c)?c:c.data&&b.isString(c.data)?c.data:"",m.put(l.template,c),l.showClose&&(c+='<div class="ngdialog-close"></div>'),i.$result=y=d('<div id="ngdialog'+f+'" class="ngdialog"></div>'),y.html('<div class="ngdialog-overlay"></div><div class="ngdialog-content">'+c+"</div>"),l.data&&b.isString(l.data)){var g=l.data.replace(/^\s*/,"")[0];A.ngDialogData="{"===g||"["===g?b.fromJson(l.data):l.data}else l.data&&b.isObject(l.data)&&(A.ngDialogData=b.fromJson(b.toJson(l.data)));if(l.controller&&(b.isString(l.controller)||b.isArray(l.controller)||b.isFunction(l.controller))){var h=t(l.controller,{$scope:A,$element:y});y.data("$ngDialogControllerController",h)}return l.className&&y.addClass(l.className),z=l.appendTo&&b.isString(l.appendTo)?b.element(document.querySelector(l.appendTo)):u,A.closeThisDialog=function(a){v.closeDialog(y,a)},r(function(){n(y)(A);var a=s.innerWidth-u.prop("clientWidth");u.addClass("ngdialog-open");var b=a-(s.innerWidth-u.prop("clientWidth"));b>0&&v.setBodyPadding(b),z.append(y),q.$broadcast("ngDialog.opened",y)}),l.closeByEscape&&u.bind("keydown",v.onDocumentKeydown),e=function(a){var b=l.closeByDocument?d(a.target).hasClass("ngdialog-overlay"):!1,c=d(a.target).hasClass("ngdialog-close");(b||c)&&w.close(y.attr("id"),c?"$closeButton":"$document")},"undefined"!=typeof a.Hammer?a.Hammer(y[0]).on("tap",e):y.bind("click",e),j+=1,w}),{id:"ngdialog"+f,closePromise:x.promise,close:function(a){v.closeDialog(y,a)}}},openConfirm:function(a){var c=o.defer(),d={closeByEscape:!1,closeByDocument:!1};b.extend(d,a),d.scope=b.isObject(d.scope)?d.scope.$new():q.$new(),d.scope.confirm=function(a){c.resolve(a),e.close(a)};var e=w.open(d);return e.closePromise.then(function(a){return a?c.reject(a.value):c.reject()}),c.promise},close:function(a,b){var c=d(document.getElementById(a));return c.length?v.closeDialog(c,b):w.closeAll(b),w},closeAll:function(a){var c=document.querySelectorAll(".ngdialog");b.forEach(c,function(b){v.closeDialog(d(b),a)})}};return w}]}),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);
/*! ng-dialog - v0.3.0 (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",i=!1;c.provider("ngDialog",function(){var c=this.defaults={className:"ngdialog-theme-default",plain:!1,showClose:!0,closeByDocument:!0,closeByEscape:!0,appendTo:!1,preCloseCallback:!1,cache:!0};this.setForceBodyReload=function(a){i=a||!1},this.setDefaults=function(a){b.extend(c,a)};var e,f=0,j=0,k={};this.$get=["$document","$templateCache","$compile","$q","$http","$rootScope","$timeout","$window","$controller",function(l,m,n,o,p,q,r,s,t){var u=l.find("body");i&&q.$on("$locationChangeSuccess",function(){u=l.find("body")});var v={onDocumentKeydown:function(a){27===a.keyCode&&w.close("$escape")},setBodyPadding:function(a){var b=parseInt(u.css("padding-right")||0,10);u.css("padding-right",b+a+"px"),u.data("ng-dialog-original-padding",b)},resetBodyPadding:function(){var a=u.data("ng-dialog-original-padding");a?u.css("padding-right",a+"px"):u.css("padding-right","")},performCloseDialog:function(b,c){var d=b.attr("id");"undefined"!=typeof a.Hammer?a.Hammer(b[0]).off("tap",e):b.unbind("click"),1===j&&u.unbind("keydown"),b.hasClass("ngdialog-closing")||(j-=1),g?b.unbind(h).bind(h,function(){b.scope().$destroy(),b.remove(),0===j&&(u.removeClass("ngdialog-open"),v.resetBodyPadding()),q.$broadcast("ngDialog.closed",b)}).addClass("ngdialog-closing"):(b.scope().$destroy(),b.remove(),0===j&&(u.removeClass("ngdialog-open"),v.resetBodyPadding()),q.$broadcast("ngDialog.closed",b)),k[d]&&(k[d].resolve({id:d,value:c,$dialog:b,remainingDialogs:j}),delete k[d])},closeDialog:function(a,c){var d=a.data("$ngDialogPreCloseCallback");if(d&&b.isFunction(d)){var e=d.call(a,c);b.isObject(e)?e.closePromise?e.closePromise.then(function(){v.performCloseDialog(a,c)}):e.then(function(){v.performCloseDialog(a,c)},function(){}):e!==!1&&v.performCloseDialog(a,c)}else v.performCloseDialog(a,c)}},w={open:function(g){function h(a){return a?b.isString(a)&&l.plain?a:"boolean"!=typeof l.cache||l.cache?m.get(a)||p.get(a,{cache:!0}):p.get(a,{cache:!1}):"Empty template"}var i=this,l=b.copy(c);g=g||{},b.extend(l,g),f+=1,i.latestID="ngdialog"+f;var x;k[i.latestID]=x=o.defer();var y,z,A=b.isObject(l.scope)?l.scope.$new():q.$new();return o.when(h(l.template)).then(function(c){if(c=b.isString(c)?c:c.data&&b.isString(c.data)?c.data:"",m.put(l.template,c),l.showClose&&(c+='<div class="ngdialog-close"></div>'),i.$result=y=d('<div id="ngdialog'+f+'" class="ngdialog"></div>'),y.html('<div class="ngdialog-overlay"></div><div class="ngdialog-content">'+c+"</div>"),l.data&&b.isString(l.data)){var g=l.data.replace(/^\s*/,"")[0];A.ngDialogData="{"===g||"["===g?b.fromJson(l.data):l.data}else l.data&&b.isObject(l.data)&&(A.ngDialogData=b.fromJson(b.toJson(l.data)));if(l.controller&&(b.isString(l.controller)||b.isArray(l.controller)||b.isFunction(l.controller))){var h=t(l.controller,{$scope:A,$element:y});y.data("$ngDialogControllerController",h)}if(l.className&&y.addClass(l.className),z=l.appendTo&&b.isString(l.appendTo)?b.element(document.querySelector(l.appendTo)):u,l.preCloseCallback){var k;b.isFunction(l.preCloseCallback)?k=l.preCloseCallback:b.isString(l.preCloseCallback)&&A&&(b.isFunction(A[l.preCloseCallback])?k=A[l.preCloseCallback]:A.$parent&&b.isFunction(A.$parent[l.preCloseCallback])?k=A.$parent[l.preCloseCallback]:q&&b.isFunction(q[l.preCloseCallback])&&(k=q[l.preCloseCallback])),k&&y.data("$ngDialogPreCloseCallback",k)}return A.closeThisDialog=function(a){v.closeDialog(y,a)},r(function(){n(y)(A);var a=s.innerWidth-u.prop("clientWidth");u.addClass("ngdialog-open");var b=a-(s.innerWidth-u.prop("clientWidth"));b>0&&v.setBodyPadding(b),z.append(y),l.name?q.$broadcast("ngDialog.opened",{dialog:y,name:l.name}):q.$broadcast("ngDialog.opened",y)}),l.closeByEscape&&u.bind("keydown",v.onDocumentKeydown),e=function(a){var b=l.closeByDocument?d(a.target).hasClass("ngdialog-overlay"):!1,c=d(a.target).hasClass("ngdialog-close");(b||c)&&w.close(y.attr("id"),c?"$closeButton":"$document")},"undefined"!=typeof a.Hammer?a.Hammer(y[0]).on("tap",e):y.bind("click",e),j+=1,w}),{id:"ngdialog"+f,closePromise:x.promise,close:function(a){v.closeDialog(y,a)}}},openConfirm:function(a){var c=o.defer(),e={closeByEscape:!1,closeByDocument:!1};b.extend(e,a),e.scope=b.isObject(e.scope)?e.scope.$new():q.$new(),e.scope.confirm=function(a){c.resolve(a);var b=d(document.getElementById(f.id));v.performCloseDialog(b,a)};var f=w.open(e);return f.closePromise.then(function(a){return a?c.reject(a.value):c.reject()}),c.promise},close:function(a,b){var c=d(document.getElementById(a));return c.length?v.closeDialog(c,b):w.closeAll(b),w},closeAll:function(a){var c=document.querySelectorAll(".ngdialog");b.forEach(c,function(b){v.closeDialog(d(b),a)})},getDefaults:function(){return c}};return w}]}),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);var g=a.getDefaults();a.open({template:e.ngDialog,className:e.ngDialogClass||g.className,controller:e.ngDialogController,scope:f,data:e.ngDialogData,showClose:"false"===e.ngDialogShowClose?!1:"true"===e.ngDialogShowClose?!0:g.showClose,closeByDocument:"false"===e.ngDialogCloseByDocument?!1:"true"===e.ngDialogCloseByDocument?!0:g.closeByDocument,closeByEscape:"false"===e.ngDialogCloseByEscape?!1:"true"===e.ngDialogCloseByEscape?!0:g.closeByEscape,preCloseCallback:e.ngDialogPreCloseCallback||g.preCloseCallback})})}}}])}(window,window.angular);
{
"name": "ng-dialog",
"version": "0.2.14",
"version": "0.3.0",
"homepage": "https://github.com/likeastore/ngDialog",

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

@@ -132,5 +132,5 @@ # ngDialog

This option allows to controll dialog look, you can use built-in [themes](https://github.com/likeastore/ngDialog#themes) or create your own styled modals.
This option allows you to control the dialog's look, you can use built-in [themes](https://github.com/likeastore/ngDialog#themes) or create your own styled modals.
This example enables one of built-in ngDialog themes - ``ngdialog-theme-default`` (do not forget to include necessary css files):
This example enables one of the built-in ngDialog themes - ``ngdialog-theme-default`` (do not forget to include necessary css files):

@@ -164,6 +164,56 @@ ```javascript

### Defaults
##### ``cache {Boolean}``
##### ``setDefaults(options)``
Pass ``false`` to disable template caching. Useful for developing purposes, default is ``true``.
##### ``name {String} | {Number}``
Give a name for a dialog instance. It is useful for identifying specific dialog if there are multiple dialog boxes opened.
##### ``preCloseCallback {String} | {Function}``
Provide either the name of a function or a function to be called before the dialog is closed. If the callback function specified in the option returns ``false`` then the dialog will not be closed. Alternatively, if the callback function returns a promise that gets resolved the dialog will be closed.
The ``preCloseCallback`` function receives as a parameter (``value``) which is the same value sent to ``.close(id, value)``.
The primary use case for this feature is a dialog which contains user actions (e.g. editing data) for which you want the ability to confirm whether to discard unsaved changes upon exiting the dialog (e.g. via the escape button).
This example uses an inline function with a ``window.confirm`` call in the ``preCloseCallback`` function:
```javascript
ngDialog.open({
preCloseCallback: function(value) {
if(confirm('Are you sure you want to close without saving your changes?')) {
return true;
}
return false;
}
});
```
In another example, a callback function with a nested confirm ngDialog is used:
```javascript
ngDialog.open({
preCloseCallback: function(value) {
var nestedConfirmDialog = ngDialog.openConfirm({
template:'\
<p>Are you sure you want to close the parent dialog?</p>\
<div class="ngdialog-buttons">\
<button type="button" class="ngdialog-button ngdialog-button-secondary" ng-click="closeThisDialog(0)">No</button>\
<button type="button" class="ngdialog-button ngdialog-button-primary" ng-click="confirm(1)">Yes</button>\
</div>',
plain: true
});
// NOTE: return the promise from openConfirm
return nestedConfirmDialog;
}
});
```
===
### ``.setDefaults(options)``
You're able to set default settings through ``ngDialogProvider``:

@@ -308,8 +358,8 @@

ngDialog is available for public on [cdnjs](http://cdnjs.com/libraries/ng-dialog). Please use following urls for version 0.1.6.
ngDialog is available for public on [cdnjs](http://cdnjs.com/libraries/ng-dialog). For example, please use following urls for version ``0.3.0``.
```html
//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
//cdnjs.cloudflare.com/ajax/libs/ng-dialog/0.3.0/ng-dialog.min.css
//cdnjs.cloudflare.com/ajax/libs/ng-dialog/0.3.0/ng-dialog-theme-plain.min.css
//cdnjs.cloudflare.com/ajax/libs/ng-dialog/0.3.0/ng-dialog.min.js
```

@@ -316,0 +366,0 @@

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