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.5.6 to 0.5.7

5

bower.json

@@ -35,7 +35,10 @@ {

"dependencies": {
"angular": "^1.4.x"
"angular": "1.4.9"
},
"devDependencies": {
"angular-mocks": "^1.4.x"
},
"resolutions": {
"angular": "1.4.9"
}
}

45

js/ngDialog.js

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

var keydownIsBound = false;
var openOnePerName = false;
m.provider('ngDialog', function () {

@@ -76,2 +78,6 @@ var defaults = this.defaults = {

this.setOpenOnePerName = function (isOpenOne) {
openOnePerName = isOpenOne || false;
};
var globalID = 0, dialogsCount = 0, closeByDocumentHandler, defers = {};

@@ -458,12 +464,18 @@

* - preCloseCallback {String|Function} - user supplied function name/function called before closing dialog (if set)
*
* @return {Object} dialog
*/
open: function (opts) {
var dialogID = null;
opts = opts || {};
if (openOnePerName && opts.name) {
dialogID = opts.name+' dialog';
if (this.isOpen(dialogID)) {
return;
}
}
var options = angular.copy(defaults);
var localID = ++globalID;
var dialogID = 'ngdialog' + localID;
dialogID = dialogID || 'ngdialog' + localID;
openIdStack.push(dialogID);
opts = opts || {};
angular.extend(options, opts);

@@ -497,3 +509,3 @@

var hasOverlayClass = options.overlay ? '' : ' ngdialog-no-overlay';
$dialog = $el('<div id="ngdialog' + localID + '" class="ngdialog' + hasOverlayClass + '"></div>');
$dialog = $el('<div id="'+dialogID + '" class="ngdialog' + hasOverlayClass + '"></div>');
$dialog.html((options.overlay ?

@@ -509,3 +521,3 @@ '<div class="ngdialog-overlay"></div><div class="ngdialog-content" role="document">' + template + '</div>' :

var firstLetter = options.data.replace(/^\s*/, '')[0];
scope.ngDialogData = (firstLetter === '{' || firstLetter === '[') ? angular.fromJson(options.data) : options.data;
scope.ngDialogData = (firstLetter === '{' || firstLetter === '[') ? angular.fromJson(options.data) : new String(options.data);
scope.ngDialogData.ngDialogId = dialogID;

@@ -699,7 +711,5 @@ } else if (options.data && angular.isObject(options.data)) {

var defer = $q.defer();
var options = angular.copy(defaults);
var options = {
closeByEscape: false,
closeByDocument: false
};
opts = opts || {};
angular.extend(options, opts);

@@ -715,10 +725,11 @@

var openResult = publicMethods.open(options);
openResult.closePromise.then(function (data) {
if (data) {
return defer.reject(data.value);
}
return defer.reject();
});
return defer.promise;
if (openResult) {
openResult.closePromise.then(function (data) {
if (data) {
return defer.reject(data.value);
}
return defer.reject();
});
return defer.promise;
}
},

@@ -725,0 +736,0 @@

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

/*! ng-dialog - v0.5.5 (https://github.com/likeastore/ngDialog) */
!function(a,b){"undefined"!=typeof module&&module.exports?"undefined"==typeof angular?(b(require("angular")),module.exports="ngDialog"):(b(angular),module.exports="ngDialog"):"function"==typeof define&&define.amd?define(["angular"],b):b(a.angular)}(this,function(a){"use strict";var b=a.module("ngDialog",[]),c=a.element,d=a.isDefined,e=(document.body||document.documentElement).style,f=d(e.animation)||d(e.WebkitAnimation)||d(e.MozAnimation)||d(e.MsAnimation)||d(e.OAnimation),g="animationend webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend",h="a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), iframe, object, embed, *[tabindex], *[contenteditable]",i="ngdialog-disabled-animation",j={html:!1,body:!1},k={},l=[],m=!1;return b.provider("ngDialog",function(){var b=this.defaults={className:"ngdialog-theme-default",disableAnimation:!1,plain:!1,showClose:!0,closeByDocument:!0,closeByEscape:!0,closeByNavigation:!1,appendTo:!1,preCloseCallback:!1,overlay:!0,cache:!0,trapFocus:!0,preserveFocus:!0,ariaAuto:!0,ariaRole:null,ariaLabelledById:null,ariaLabelledBySelector:null,ariaDescribedById:null,ariaDescribedBySelector:null};this.setForceHtmlReload=function(a){j.html=a||!1},this.setForceBodyReload=function(a){j.body=a||!1},this.setDefaults=function(c){a.extend(b,c)};var d,e=0,n=0,o={};this.$get=["$document","$templateCache","$compile","$q","$http","$rootScope","$timeout","$window","$controller","$injector",function(p,q,r,s,t,u,v,w,x,y){var z=[],A={onDocumentKeydown:function(a){27===a.keyCode&&B.close("$escape")},activate:function(a){var b=a.data("$ngDialogOptions");b.trapFocus&&(a.on("keydown",A.onTrapFocusKeydown),z.body.on("keydown",A.onTrapFocusKeydown))},deactivate:function(a){a.off("keydown",A.onTrapFocusKeydown),z.body.off("keydown",A.onTrapFocusKeydown)},deactivateAll:function(b){a.forEach(b,function(b){var c=a.element(b);A.deactivate(c)})},setBodyPadding:function(a){var b=parseInt(z.body.css("padding-right")||0,10);z.body.css("padding-right",b+a+"px"),z.body.data("ng-dialog-original-padding",b),u.$broadcast("ngDialog.setPadding",a)},resetBodyPadding:function(){var a=z.body.data("ng-dialog-original-padding");a?z.body.css("padding-right",a+"px"):z.body.css("padding-right",""),u.$broadcast("ngDialog.setPadding",0)},performCloseDialog:function(a,b){var c=a.data("$ngDialogOptions"),e=a.attr("id"),h=k[e];if(h){if("undefined"!=typeof w.Hammer){var i=h.hammerTime;i.off("tap",d),i.destroy&&i.destroy(),delete h.hammerTime}else a.unbind("click");1===n&&z.body.unbind("keydown",A.onDocumentKeydown),a.hasClass("ngdialog-closing")||(n-=1);var j=a.data("$ngDialogPreviousFocus");j&&j.focus&&j.focus(),u.$broadcast("ngDialog.closing",a,b),n=0>n?0:n,f&&!c.disableAnimation?(h.$destroy(),a.unbind(g).bind(g,function(){A.closeDialogElement(a,b)}).addClass("ngdialog-closing")):(h.$destroy(),A.closeDialogElement(a,b)),o[e]&&(o[e].resolve({id:e,value:b,$dialog:a,remainingDialogs:n}),delete o[e]),k[e]&&delete k[e],l.splice(l.indexOf(e),1),l.length||(z.body.unbind("keydown",A.onDocumentKeydown),m=!1)}},closeDialogElement:function(a,b){a.remove(),0===n&&(z.html.removeClass("ngdialog-open"),z.body.removeClass("ngdialog-open"),A.resetBodyPadding()),u.$broadcast("ngDialog.closed",a,b)},closeDialog:function(b,c){var d=b.data("$ngDialogPreCloseCallback");if(d&&a.isFunction(d)){var e=d.call(b,c);a.isObject(e)?e.closePromise?e.closePromise.then(function(){A.performCloseDialog(b,c)}):e.then(function(){A.performCloseDialog(b,c)},function(){}):e!==!1&&A.performCloseDialog(b,c)}else A.performCloseDialog(b,c)},onTrapFocusKeydown:function(b){var c,d=a.element(b.currentTarget);if(d.hasClass("ngdialog"))c=d;else if(c=A.getActiveDialog(),null===c)return;var e=9===b.keyCode,f=b.shiftKey===!0;e&&A.handleTab(c,b,f)},handleTab:function(a,b,c){var d=A.getFocusableElements(a);if(0===d.length)return void(document.activeElement&&document.activeElement.blur());var e=document.activeElement,f=Array.prototype.indexOf.call(d,e),g=-1===f,h=0===f,i=f===d.length-1,j=!1;c?(g||h)&&(d[d.length-1].focus(),j=!0):(g||i)&&(d[0].focus(),j=!0),j&&(b.preventDefault(),b.stopPropagation())},autoFocus:function(a){var b=a[0],d=b.querySelector("*[autofocus]");if(null===d||(d.focus(),document.activeElement!==d)){var e=A.getFocusableElements(a);if(e.length>0)return void e[0].focus();var f=A.filterVisibleElements(b.querySelectorAll("h1,h2,h3,h4,h5,h6,p,span"));if(f.length>0){var g=f[0];c(g).attr("tabindex","-1").css("outline","0"),g.focus()}}},getFocusableElements:function(a){var b=a[0],c=b.querySelectorAll(h),d=A.filterTabbableElements(c);return A.filterVisibleElements(d)},filterTabbableElements:function(a){for(var b=[],d=0;d<a.length;d++){var e=a[d];"-1"!==c(e).attr("tabindex")&&b.push(e)}return b},filterVisibleElements:function(a){for(var b=[],c=0;c<a.length;c++){var d=a[c];(d.offsetWidth>0||d.offsetHeight>0)&&b.push(d)}return b},getActiveDialog:function(){var a=document.querySelectorAll(".ngdialog");return 0===a.length?null:c(a[a.length-1])},applyAriaAttributes:function(a,b){if(b.ariaAuto){if(!b.ariaRole){var c=A.getFocusableElements(a).length>0?"dialog":"alertdialog";b.ariaRole=c}b.ariaLabelledBySelector||(b.ariaLabelledBySelector="h1,h2,h3,h4,h5,h6"),b.ariaDescribedBySelector||(b.ariaDescribedBySelector="article,section,p")}b.ariaRole&&a.attr("role",b.ariaRole),A.applyAriaAttribute(a,"aria-labelledby",b.ariaLabelledById,b.ariaLabelledBySelector),A.applyAriaAttribute(a,"aria-describedby",b.ariaDescribedById,b.ariaDescribedBySelector)},applyAriaAttribute:function(a,b,d,e){if(d&&a.attr(b,d),e){var f=a.attr("id"),g=a[0].querySelector(e);if(!g)return;var h=f+"-"+b;return c(g).attr("id",h),a.attr(b,h),h}},detectUIRouter:function(){try{return a.module("ui.router"),!0}catch(b){return!1}},getRouterLocationEventName:function(){return A.detectUIRouter()?"$stateChangeSuccess":"$locationChangeSuccess"}},B={__PRIVATE__:A,open:function(f){function g(a,b){return u.$broadcast("ngDialog.templateLoading",a),t.get(a,b||{}).then(function(b){return u.$broadcast("ngDialog.templateLoaded",a),b.data||""})}function h(b){return b?a.isString(b)&&j.plain?b:"boolean"!=typeof j.cache||j.cache?g(b,{cache:q}):g(b,{cache:!1}):"Empty template"}var j=a.copy(b),p=++e,C="ngdialog"+p;l.push(C),f=f||{},a.extend(j,f);var D;o[C]=D=s.defer();var E;k[C]=E=a.isObject(j.scope)?j.scope.$new():u.$new();var F,G,H=a.extend({},j.resolve);return a.forEach(H,function(b,c){H[c]=a.isString(b)?y.get(b):y.invoke(b,null,null,c)}),s.all({template:h(j.template||j.templateUrl),locals:s.all(H)}).then(function(b){var e=b.template,f=b.locals;j.showClose&&(e+='<div class="ngdialog-close"></div>');var g=j.overlay?"":" ngdialog-no-overlay";if(F=c('<div id="ngdialog'+p+'" class="ngdialog'+g+'"></div>'),F.html(j.overlay?'<div class="ngdialog-overlay"></div><div class="ngdialog-content" role="document">'+e+"</div>":'<div class="ngdialog-content" role="document">'+e+"</div>"),F.data("$ngDialogOptions",j),E.ngDialogId=C,j.data&&a.isString(j.data)){var h=j.data.replace(/^\s*/,"")[0];E.ngDialogData="{"===h||"["===h?a.fromJson(j.data):j.data,E.ngDialogData.ngDialogId=C}else j.data&&a.isObject(j.data)&&(E.ngDialogData=j.data,E.ngDialogData.ngDialogId=C);if(j.className&&F.addClass(j.className),j.disableAnimation&&F.addClass(i),G=j.appendTo&&a.isString(j.appendTo)?a.element(document.querySelector(j.appendTo)):z.body,A.applyAriaAttributes(F,j),j.preCloseCallback){var k;a.isFunction(j.preCloseCallback)?k=j.preCloseCallback:a.isString(j.preCloseCallback)&&E&&(a.isFunction(E[j.preCloseCallback])?k=E[j.preCloseCallback]:E.$parent&&a.isFunction(E.$parent[j.preCloseCallback])?k=E.$parent[j.preCloseCallback]:u&&a.isFunction(u[j.preCloseCallback])&&(k=u[j.preCloseCallback])),k&&F.data("$ngDialogPreCloseCallback",k)}if(E.closeThisDialog=function(a){A.closeDialog(F,a)},j.controller&&(a.isString(j.controller)||a.isArray(j.controller)||a.isFunction(j.controller))){var l;j.controllerAs&&a.isString(j.controllerAs)&&(l=j.controllerAs);var o=x(j.controller,a.extend(f,{$scope:E,$element:F}),!0,l);j.bindToController&&a.extend(o.instance,{ngDialogId:E.ngDialogId,ngDialogData:E.ngDialogData,closeThisDialog:E.closeThisDialog}),F.data("$ngDialogControllerController",o())}if(v(function(){var a=document.querySelectorAll(".ngdialog");A.deactivateAll(a),r(F)(E);var b=w.innerWidth-z.body.prop("clientWidth");z.html.addClass("ngdialog-open"),z.body.addClass("ngdialog-open");var c=b-(w.innerWidth-z.body.prop("clientWidth"));c>0&&A.setBodyPadding(c),G.append(F),A.activate(F),j.trapFocus&&A.autoFocus(F),j.name?u.$broadcast("ngDialog.opened",{dialog:F,name:j.name}):u.$broadcast("ngDialog.opened",F)}),m||(z.body.bind("keydown",A.onDocumentKeydown),m=!0),j.closeByNavigation){var q=A.getRouterLocationEventName();u.$on(q,function(){A.closeDialog(F)})}if(j.preserveFocus&&F.data("$ngDialogPreviousFocus",document.activeElement),d=function(a){var b=j.closeByDocument?c(a.target).hasClass("ngdialog-overlay"):!1,d=c(a.target).hasClass("ngdialog-close");(b||d)&&B.close(F.attr("id"),d?"$closeButton":"$document")},"undefined"!=typeof w.Hammer){var s=E.hammerTime=w.Hammer(F[0]);s.on("tap",d)}else F.bind("click",d);return n+=1,B}),{id:C,closePromise:D.promise,close:function(a){A.closeDialog(F,a)}}},openConfirm:function(b){var d=s.defer(),e={closeByEscape:!1,closeByDocument:!1};a.extend(e,b),e.scope=a.isObject(e.scope)?e.scope.$new():u.$new(),e.scope.confirm=function(a){d.resolve(a);var b=c(document.getElementById(f.id));A.performCloseDialog(b,a)};var f=B.open(e);return f.closePromise.then(function(a){return a?d.reject(a.value):d.reject()}),d.promise},isOpen:function(a){var b=c(document.getElementById(a));return b.length>0},close:function(a,b){var d=c(document.getElementById(a));if(d.length)A.closeDialog(d,b);else if("$escape"===a){var e=l[l.length-1];d=c(document.getElementById(e)),d.data("$ngDialogOptions").closeByEscape&&A.closeDialog(d,"$escape")}else B.closeAll(b);return B},closeAll:function(a){for(var b=document.querySelectorAll(".ngdialog"),d=b.length-1;d>=0;d--){var e=b[d];A.closeDialog(c(e),a)}},getOpenDialogs:function(){return l},getDefaults:function(){return b}};return a.forEach(["html","body"],function(a){if(z[a]=p.find(a),j[a]){var b=A.getRouterLocationEventName();u.$on(b,function(){z[a]=p.find(a)})}}),B}]}),b.directive("ngDialog",["ngDialog",function(b){return{restrict:"A",scope:{ngDialogScope:"="},link:function(c,d,e){d.on("click",function(d){d.preventDefault();var f=a.isDefined(c.ngDialogScope)?c.ngDialogScope:"noScope";a.isDefined(e.ngDialogClosePrevious)&&b.close(e.ngDialogClosePrevious);var g=b.getDefaults();b.open({template:e.ngDialog,className:e.ngDialogClass||g.className,controller:e.ngDialogController,controllerAs:e.ngDialogControllerAs,bindToController:e.ngDialogBindToController,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,overlay:"false"===e.ngDialogOverlay?!1:"true"===e.ngDialogOverlay?!0:g.overlay,preCloseCallback:e.ngDialogPreCloseCallback||g.preCloseCallback})})}}}]),b});
/*! ng-dialog - v0.5.7 (https://github.com/likeastore/ngDialog) */
!function(a,b){"undefined"!=typeof module&&module.exports?("undefined"==typeof angular?b(require("angular")):b(angular),module.exports="ngDialog"):"function"==typeof define&&define.amd?define(["angular"],b):b(a.angular)}(this,function(a){"use strict";var b=a.module("ngDialog",[]),c=a.element,d=a.isDefined,e=(document.body||document.documentElement).style,f=d(e.animation)||d(e.WebkitAnimation)||d(e.MozAnimation)||d(e.MsAnimation)||d(e.OAnimation),g="animationend webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend",h="a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), iframe, object, embed, *[tabindex], *[contenteditable]",i="ngdialog-disabled-animation",j={html:!1,body:!1},k={},l=[],m=!1,n=!1;return b.provider("ngDialog",function(){var b=this.defaults={className:"ngdialog-theme-default",disableAnimation:!1,plain:!1,showClose:!0,closeByDocument:!0,closeByEscape:!0,closeByNavigation:!1,appendTo:!1,preCloseCallback:!1,overlay:!0,cache:!0,trapFocus:!0,preserveFocus:!0,ariaAuto:!0,ariaRole:null,ariaLabelledById:null,ariaLabelledBySelector:null,ariaDescribedById:null,ariaDescribedBySelector:null};this.setForceHtmlReload=function(a){j.html=a||!1},this.setForceBodyReload=function(a){j.body=a||!1},this.setDefaults=function(c){a.extend(b,c)},this.setOpenOnePerName=function(a){n=a||!1};var d,e=0,o=0,p={};this.$get=["$document","$templateCache","$compile","$q","$http","$rootScope","$timeout","$window","$controller","$injector",function(q,r,s,t,u,v,w,x,y,z){var A=[],B={onDocumentKeydown:function(a){27===a.keyCode&&C.close("$escape")},activate:function(a){var b=a.data("$ngDialogOptions");b.trapFocus&&(a.on("keydown",B.onTrapFocusKeydown),A.body.on("keydown",B.onTrapFocusKeydown))},deactivate:function(a){a.off("keydown",B.onTrapFocusKeydown),A.body.off("keydown",B.onTrapFocusKeydown)},deactivateAll:function(b){a.forEach(b,function(b){var c=a.element(b);B.deactivate(c)})},setBodyPadding:function(a){var b=parseInt(A.body.css("padding-right")||0,10);A.body.css("padding-right",b+a+"px"),A.body.data("ng-dialog-original-padding",b),v.$broadcast("ngDialog.setPadding",a)},resetBodyPadding:function(){var a=A.body.data("ng-dialog-original-padding");a?A.body.css("padding-right",a+"px"):A.body.css("padding-right",""),v.$broadcast("ngDialog.setPadding",0)},performCloseDialog:function(a,b){var c=a.data("$ngDialogOptions"),e=a.attr("id"),h=k[e];if(h){if("undefined"!=typeof x.Hammer){var i=h.hammerTime;i.off("tap",d),i.destroy&&i.destroy(),delete h.hammerTime}else a.unbind("click");1===o&&A.body.unbind("keydown",B.onDocumentKeydown),a.hasClass("ngdialog-closing")||(o-=1);var j=a.data("$ngDialogPreviousFocus");j&&j.focus&&j.focus(),v.$broadcast("ngDialog.closing",a,b),o=0>o?0:o,f&&!c.disableAnimation?(h.$destroy(),a.unbind(g).bind(g,function(){B.closeDialogElement(a,b)}).addClass("ngdialog-closing")):(h.$destroy(),B.closeDialogElement(a,b)),p[e]&&(p[e].resolve({id:e,value:b,$dialog:a,remainingDialogs:o}),delete p[e]),k[e]&&delete k[e],l.splice(l.indexOf(e),1),l.length||(A.body.unbind("keydown",B.onDocumentKeydown),m=!1)}},closeDialogElement:function(a,b){a.remove(),0===o&&(A.html.removeClass("ngdialog-open"),A.body.removeClass("ngdialog-open"),B.resetBodyPadding()),v.$broadcast("ngDialog.closed",a,b)},closeDialog:function(b,c){var d=b.data("$ngDialogPreCloseCallback");if(d&&a.isFunction(d)){var e=d.call(b,c);a.isObject(e)?e.closePromise?e.closePromise.then(function(){B.performCloseDialog(b,c)}):e.then(function(){B.performCloseDialog(b,c)},function(){}):e!==!1&&B.performCloseDialog(b,c)}else B.performCloseDialog(b,c)},onTrapFocusKeydown:function(b){var c,d=a.element(b.currentTarget);if(d.hasClass("ngdialog"))c=d;else if(c=B.getActiveDialog(),null===c)return;var e=9===b.keyCode,f=b.shiftKey===!0;e&&B.handleTab(c,b,f)},handleTab:function(a,b,c){var d=B.getFocusableElements(a);if(0===d.length)return document.activeElement&&document.activeElement.blur(),void 0;var e=document.activeElement,f=Array.prototype.indexOf.call(d,e),g=-1===f,h=0===f,i=f===d.length-1,j=!1;c?(g||h)&&(d[d.length-1].focus(),j=!0):(g||i)&&(d[0].focus(),j=!0),j&&(b.preventDefault(),b.stopPropagation())},autoFocus:function(a){var b=a[0],d=b.querySelector("*[autofocus]");if(null===d||(d.focus(),document.activeElement!==d)){var e=B.getFocusableElements(a);if(e.length>0)return e[0].focus(),void 0;var f=B.filterVisibleElements(b.querySelectorAll("h1,h2,h3,h4,h5,h6,p,span"));if(f.length>0){var g=f[0];c(g).attr("tabindex","-1").css("outline","0"),g.focus()}}},getFocusableElements:function(a){var b=a[0],c=b.querySelectorAll(h),d=B.filterTabbableElements(c);return B.filterVisibleElements(d)},filterTabbableElements:function(a){for(var b=[],d=0;d<a.length;d++){var e=a[d];"-1"!==c(e).attr("tabindex")&&b.push(e)}return b},filterVisibleElements:function(a){for(var b=[],c=0;c<a.length;c++){var d=a[c];(d.offsetWidth>0||d.offsetHeight>0)&&b.push(d)}return b},getActiveDialog:function(){var a=document.querySelectorAll(".ngdialog");return 0===a.length?null:c(a[a.length-1])},applyAriaAttributes:function(a,b){if(b.ariaAuto){if(!b.ariaRole){var c=B.getFocusableElements(a).length>0?"dialog":"alertdialog";b.ariaRole=c}b.ariaLabelledBySelector||(b.ariaLabelledBySelector="h1,h2,h3,h4,h5,h6"),b.ariaDescribedBySelector||(b.ariaDescribedBySelector="article,section,p")}b.ariaRole&&a.attr("role",b.ariaRole),B.applyAriaAttribute(a,"aria-labelledby",b.ariaLabelledById,b.ariaLabelledBySelector),B.applyAriaAttribute(a,"aria-describedby",b.ariaDescribedById,b.ariaDescribedBySelector)},applyAriaAttribute:function(a,b,d,e){if(d&&a.attr(b,d),e){var f=a.attr("id"),g=a[0].querySelector(e);if(!g)return;var h=f+"-"+b;return c(g).attr("id",h),a.attr(b,h),h}},detectUIRouter:function(){try{return a.module("ui.router"),!0}catch(b){return!1}},getRouterLocationEventName:function(){return B.detectUIRouter()?"$stateChangeSuccess":"$locationChangeSuccess"}},C={__PRIVATE__:B,open:function(f){function g(a,b){return v.$broadcast("ngDialog.templateLoading",a),u.get(a,b||{}).then(function(b){return v.$broadcast("ngDialog.templateLoaded",a),b.data||""})}function h(b){return b?a.isString(b)&&q.plain?b:"boolean"!=typeof q.cache||q.cache?g(b,{cache:r}):g(b,{cache:!1}):"Empty template"}var j=null;if(f=f||{},!(n&&f.name&&(j=f.name+" dialog",this.isOpen(j)))){var q=a.copy(b),D=++e;j=j||"ngdialog"+D,l.push(j),a.extend(q,f);var E;p[j]=E=t.defer();var F;k[j]=F=a.isObject(q.scope)?q.scope.$new():v.$new();var G,H,I=a.extend({},q.resolve);return a.forEach(I,function(b,c){I[c]=a.isString(b)?z.get(b):z.invoke(b,null,null,c)}),t.all({template:h(q.template||q.templateUrl),locals:t.all(I)}).then(function(b){var e=b.template,f=b.locals;q.showClose&&(e+='<div class="ngdialog-close"></div>');var g=q.overlay?"":" ngdialog-no-overlay";if(G=c('<div id="'+j+'" class="ngdialog'+g+'"></div>'),G.html(q.overlay?'<div class="ngdialog-overlay"></div><div class="ngdialog-content" role="document">'+e+"</div>":'<div class="ngdialog-content" role="document">'+e+"</div>"),G.data("$ngDialogOptions",q),F.ngDialogId=j,q.data&&a.isString(q.data)){var h=q.data.replace(/^\s*/,"")[0];F.ngDialogData="{"===h||"["===h?a.fromJson(q.data):new String(q.data),F.ngDialogData.ngDialogId=j}else q.data&&a.isObject(q.data)&&(F.ngDialogData=q.data,F.ngDialogData.ngDialogId=j);if(q.className&&G.addClass(q.className),q.disableAnimation&&G.addClass(i),H=q.appendTo&&a.isString(q.appendTo)?a.element(document.querySelector(q.appendTo)):A.body,B.applyAriaAttributes(G,q),q.preCloseCallback){var k;a.isFunction(q.preCloseCallback)?k=q.preCloseCallback:a.isString(q.preCloseCallback)&&F&&(a.isFunction(F[q.preCloseCallback])?k=F[q.preCloseCallback]:F.$parent&&a.isFunction(F.$parent[q.preCloseCallback])?k=F.$parent[q.preCloseCallback]:v&&a.isFunction(v[q.preCloseCallback])&&(k=v[q.preCloseCallback])),k&&G.data("$ngDialogPreCloseCallback",k)}if(F.closeThisDialog=function(a){B.closeDialog(G,a)},q.controller&&(a.isString(q.controller)||a.isArray(q.controller)||a.isFunction(q.controller))){var l;q.controllerAs&&a.isString(q.controllerAs)&&(l=q.controllerAs);var n=y(q.controller,a.extend(f,{$scope:F,$element:G}),!0,l);q.bindToController&&a.extend(n.instance,{ngDialogId:F.ngDialogId,ngDialogData:F.ngDialogData,closeThisDialog:F.closeThisDialog}),G.data("$ngDialogControllerController",n())}if(w(function(){var a=document.querySelectorAll(".ngdialog");B.deactivateAll(a),s(G)(F);var b=x.innerWidth-A.body.prop("clientWidth");A.html.addClass("ngdialog-open"),A.body.addClass("ngdialog-open");var c=b-(x.innerWidth-A.body.prop("clientWidth"));c>0&&B.setBodyPadding(c),H.append(G),B.activate(G),q.trapFocus&&B.autoFocus(G),q.name?v.$broadcast("ngDialog.opened",{dialog:G,name:q.name}):v.$broadcast("ngDialog.opened",G)}),m||(A.body.bind("keydown",B.onDocumentKeydown),m=!0),q.closeByNavigation){var p=B.getRouterLocationEventName();v.$on(p,function(){B.closeDialog(G)})}if(q.preserveFocus&&G.data("$ngDialogPreviousFocus",document.activeElement),d=function(a){var b=q.closeByDocument?c(a.target).hasClass("ngdialog-overlay"):!1,d=c(a.target).hasClass("ngdialog-close");(b||d)&&C.close(G.attr("id"),d?"$closeButton":"$document")},"undefined"!=typeof x.Hammer){var r=F.hammerTime=x.Hammer(G[0]);r.on("tap",d)}else G.bind("click",d);return o+=1,C}),{id:j,closePromise:E.promise,close:function(a){B.closeDialog(G,a)}}}},openConfirm:function(d){var e=t.defer(),f=a.copy(b);d=d||{},a.extend(f,d),f.scope=a.isObject(f.scope)?f.scope.$new():v.$new(),f.scope.confirm=function(a){e.resolve(a);var b=c(document.getElementById(g.id));B.performCloseDialog(b,a)};var g=C.open(f);return g?(g.closePromise.then(function(a){return a?e.reject(a.value):e.reject()}),e.promise):void 0},isOpen:function(a){var b=c(document.getElementById(a));return b.length>0},close:function(a,b){var d=c(document.getElementById(a));if(d.length)B.closeDialog(d,b);else if("$escape"===a){var e=l[l.length-1];d=c(document.getElementById(e)),d.data("$ngDialogOptions").closeByEscape&&B.closeDialog(d,"$escape")}else C.closeAll(b);return C},closeAll:function(a){for(var b=document.querySelectorAll(".ngdialog"),d=b.length-1;d>=0;d--){var e=b[d];B.closeDialog(c(e),a)}},getOpenDialogs:function(){return l},getDefaults:function(){return b}};return a.forEach(["html","body"],function(a){if(A[a]=q.find(a),j[a]){var b=B.getRouterLocationEventName();v.$on(b,function(){A[a]=q.find(a)})}}),C}]}),b.directive("ngDialog",["ngDialog",function(b){return{restrict:"A",scope:{ngDialogScope:"="},link:function(c,d,e){d.on("click",function(d){d.preventDefault();var f=a.isDefined(c.ngDialogScope)?c.ngDialogScope:"noScope";a.isDefined(e.ngDialogClosePrevious)&&b.close(e.ngDialogClosePrevious);var g=b.getDefaults();b.open({template:e.ngDialog,className:e.ngDialogClass||g.className,controller:e.ngDialogController,controllerAs:e.ngDialogControllerAs,bindToController:e.ngDialogBindToController,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,overlay:"false"===e.ngDialogOverlay?!1:"true"===e.ngDialogOverlay?!0:g.overlay,preCloseCallback:e.ngDialogPreCloseCallback||g.preCloseCallback})})}}}]),b});
{
"name": "ng-dialog",
"version": "0.5.6",
"version": "0.5.7",
"homepage": "https://github.com/likeastore/ngDialog",
"description": "Modal dialogs and popups provider for Angular.js applications",
"main": "./js/ngDialog.js",
"style": "./css/ngDialog.css",
"scripts": {

@@ -18,3 +19,4 @@ "pretest": "npm install && bower install --allow-root",

"protractor-a11y": "node_modules/.bin/protractor protractor.conf.js --a11y",
"protractor-console": "node_modules/.bin/protractor protractor.conf.js --console-error"
"protractor-console": "node_modules/.bin/protractor protractor.conf.js --console-error",
"build": "grunt build"
},

@@ -21,0 +23,0 @@ "directories": {

@@ -9,2 +9,4 @@ <!-- ### LOOKING FOR MAINTAINER. PLEASE PING [@voronianski](https://twitter.com/voronianski)! -->

[![Code Climate](https://codeclimate.com/github/likeastore/ngDialog/badges/gpa.svg)](https://codeclimate.com/github/likeastore/ngDialog)
[![Issue Stats](http://issuestats.com/github/likeastore/ngdialog/badge/pr?style=flat)](http://issuestats.com/github/likeastore/ngDialog)
[![Issue Stats](http://issuestats.com/github/likeastore/ngdialog/badge/issue?style=flat)](http://issuestats.com/github/likeastore/ngDialog)

@@ -51,4 +53,2 @@ > Modal dialogs and popups provider for [AngularJS](http://angularjs.org/) applications.

[![Throughput Graph](https://graphs.waffle.io/likeastore/ngDialog/throughput.svg)](https://waffle.io/likeastore/ngDialog/metrics)
## API

@@ -245,2 +245,11 @@

##### ``closeByNavigation {Boolean}``
It allows to close modals on state change (history.back, $state.go, etc.), default ``false``.
Compatible with ui-router and angular-router.
Set this value to true if you want your modal to close when you go back or change state.
Set this value to false if you want your modal to stay open when you change state within your app.
This will close all open modals if there are several of them opened at the same time.
##### ``closeByDocument {Boolean}``

@@ -477,2 +486,21 @@

===
### ``.setOpenOnePerName({Boolean})``
Default value: false
Define whether or not opening a dialog with the same name more than once simultaneously is allowed. Assigning true prevents opening a second dialog.
Setting it in the ngDialogProvider:
```javascript
var app = angular.module('exampleApp', ['ngDialog']);
app.config(function (ngDialogProvider) {
ngDialogProvider.setOpenOnePerName(true);
});
```
Make sure to remember to add a 'name' when opening a dialog.
**ngDialog 'open' and 'openConfirm' functions will return `undefined` if the dialog was not opened.**
## Directive

@@ -479,0 +507,0 @@

@@ -204,2 +204,53 @@ describe('ngDialog', function () {

describe('openOnePerName', function () {
var dialogOptions = {
name: 'do something'
};
describe('when feature is off - default', function () {
var ngDialog;
var $timeout;
beforeEach(inject(function (_ngDialog_, _$timeout_) {
ngDialog = _ngDialog_;
$timeout = _$timeout_;
}));
it('should allow opening 2 dialogs with the same name', function () {
var firstDialog = ngDialog.open(dialogOptions);
expect(firstDialog).not.toBeUndefined();
expect(firstDialog.id).toBe('ngdialog1');
var secondDialog = ngDialog.open(dialogOptions);
expect(secondDialog).not.toBeUndefined();
expect(secondDialog.id).toBe('ngdialog2');
$timeout.flush();
});
});
describe('when feature is on (openOnePerName = true)', function () {
var ngDialog;
var $timeout;
beforeEach(module(function (ngDialogProvider) {
ngDialogProvider.setOpenOnePerName(true);
}));
beforeEach(inject(function (_ngDialog_, _$timeout_) {
ngDialog = _ngDialog_;
$timeout = _$timeout_;
}));
it('should allow opening 2 dialogs with the same name', function () {
var firstDialog = ngDialog.open(dialogOptions);
expect(firstDialog).not.toBeUndefined();
expect(firstDialog.id).toBe('do something dialog');
$timeout.flush();
var secondDialog = ngDialog.open(dialogOptions);
expect(secondDialog).toBeUndefined();
});
});
});
});
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