Comparing version 0.2.6 to 0.2.10
{ | ||
"name": "ngDialog", | ||
"version": "0.2.6", | ||
"version": "0.2.10", | ||
"homepage": "https://github.com/likeastore/ngDialog", | ||
@@ -5,0 +5,0 @@ "description": "Modal dialogs and popups provider for Angular.js applications", |
@@ -17,2 +17,3 @@ /* | ||
var animationEndEvent = 'animationend webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend'; | ||
var forceBodyReload = false; | ||
@@ -26,5 +27,13 @@ module.provider('ngDialog', function () { | ||
closeByEscape: true, | ||
forceBodyReload: false | ||
appendTo: false | ||
}; | ||
this.setForceBodyReload = function (_useIt) { | ||
forceBodyReload = _useIt || false; | ||
}; | ||
this.setDefaults = function (newDefaults) { | ||
angular.extend(defaults, newDefaults); | ||
}; | ||
var globalID = 0, dialogsCount = 0, closeByDocumentHandler, defers = {}; | ||
@@ -35,3 +44,3 @@ | ||
var $body = $document.find('body'); | ||
if (defaults.forceBodyReload) { | ||
if (forceBodyReload) { | ||
$rootScope.$on('$locationChangeSuccess', function () { | ||
@@ -139,3 +148,3 @@ $body = $document.find('body'); | ||
var scope = angular.isObject(options.scope) ? options.scope.$new() : $rootScope.$new(); | ||
var $dialog; | ||
var $dialog, $dialogParent; | ||
@@ -170,2 +179,8 @@ $q.when(loadTemplate(options.template)).then(function (template) { | ||
if (options.appendTo && angular.isString(options.appendTo)) { | ||
$dialogParent = angular.element(document.querySelector(options.appendTo)); | ||
} else { | ||
$dialogParent = $body; | ||
} | ||
scope.closeThisDialog = function() { | ||
@@ -184,3 +199,3 @@ privateMethods.closeDialog($dialog); | ||
} | ||
$body.append($dialog); | ||
$dialogParent.append($dialog); | ||
@@ -187,0 +202,0 @@ $rootScope.$broadcast('ngDialog.opened', $dialog); |
@@ -1,2 +0,2 @@ | ||
/*! ng-dialog - v0.2.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 c,e=this.defaults={className:"ngdialog-theme-default",plain:!1,showClose:!0,closeByDocument:!0,closeByEscape:!0,forceBodyReload:!1},f=0,i=0,j={};this.$get=["$document","$templateCache","$compile","$q","$http","$rootScope","$timeout","$window",function(k,l,m,n,o,p,q,r){var s=k.find("body");e.forceBodyReload&&p.$on("$locationChangeSuccess",function(){s=k.find("body")});var t={onDocumentKeydown:function(a){27===a.keyCode&&u.close()},setBodyPadding:function(a){var b=parseInt(s.css("padding-right")||0,10);s.css("padding-right",b+a+"px"),s.data("ng-dialog-original-padding",b)},resetBodyPadding:function(){var a=s.data("ng-dialog-original-padding");a?s.css("padding-right",a+"px"):s.css("padding-right","")},closeDialog:function(b){var d=b.attr("id");"undefined"!=typeof a.Hammer?a.Hammer(b[0]).off("tap",c):b.unbind("click"),1===i&&s.unbind("keydown"),b.hasClass("ngdialog-closing")||(i-=1),g?b.unbind(h).bind(h,function(){b.scope().$destroy(),b.remove(),0===i&&(s.removeClass("ngdialog-open"),t.resetBodyPadding())}).addClass("ngdialog-closing"):(b.scope().$destroy(),b.remove(),0===i&&(s.removeClass("ngdialog-open"),t.resetBodyPadding())),j[d]&&(j[d].resolve({id:d,$dialog:b,remainingDialogs:i}),delete j[d]),p.$broadcast("ngDialog.closed",b)}},u={open:function(g){function h(a){return a?b.isString(a)&&v.plain?a:l.get(a)||o.get(a,{cache:!0}):"Empty template"}var k=this,v=b.copy(e);g=g||{},b.extend(v,g),f+=1,k.latestID="ngdialog"+f;var w;j[k.latestID]=w=n.defer();var x,y=b.isObject(v.scope)?v.scope.$new():p.$new();return n.when(h(v.template)).then(function(e){return e=b.isString(e)?e:e.data&&b.isString(e.data)?e.data:"",l.put(v.template,e),v.showClose&&(e+='<div class="ngdialog-close"></div>'),k.$result=x=d('<div id="ngdialog'+f+'" class="ngdialog"></div>'),x.html('<div class="ngdialog-overlay"></div><div class="ngdialog-content">'+e+"</div>"),v.controller&&b.isString(v.controller)&&x.attr("ng-controller",v.controller),v.className&&x.addClass(v.className),v.data&&b.isString(v.data)&&(y.ngDialogData="{"===v.data.replace(/^\s*/,"")[0]?b.fromJson(v.data):v.data),y.closeThisDialog=function(){t.closeDialog(x)},q(function(){m(x)(y);var a=r.innerWidth-s.prop("clientWidth");s.addClass("ngdialog-open");var b=a-(r.innerWidth-s.prop("clientWidth"));b>0&&t.setBodyPadding(b),s.append(x),p.$broadcast("ngDialog.opened",x)}),v.closeByEscape&&s.bind("keydown",t.onDocumentKeydown),c=function(a){var b=v.closeByDocument?d(a.target).hasClass("ngdialog-overlay"):!1,c=d(a.target).hasClass("ngdialog-close");(b||c)&&u.close(x.attr("id"))},"undefined"!=typeof a.Hammer?a.Hammer(x[0]).on("tap",c):x.bind("click",c),i+=1,u}),{id:"ngdialog"+f,closePromise:w.promise,close:function(){t.closeDialog(x)}}},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=u.open(d);return e.closePromise.then(function(){c.reject()}),c.promise},close:function(a){var b=d(document.getElementById(a));return b.length?t.closeDialog(b):u.closeAll(),u},closeAll:function(){var a=document.querySelectorAll(".ngdialog");b.forEach(a,function(a){t.closeDialog(d(a))})}};return u}]}),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.2.10 (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",function(l,m,n,o,p,q,r,s){var t=l.find("body");i&&q.$on("$locationChangeSuccess",function(){t=l.find("body")});var u={onDocumentKeydown:function(a){27===a.keyCode&&v.close()},setBodyPadding:function(a){var b=parseInt(t.css("padding-right")||0,10);t.css("padding-right",b+a+"px"),t.data("ng-dialog-original-padding",b)},resetBodyPadding:function(){var a=t.data("ng-dialog-original-padding");a?t.css("padding-right",a+"px"):t.css("padding-right","")},closeDialog:function(b){var c=b.attr("id");"undefined"!=typeof a.Hammer?a.Hammer(b[0]).off("tap",e):b.unbind("click"),1===j&&t.unbind("keydown"),b.hasClass("ngdialog-closing")||(j-=1),g?b.unbind(h).bind(h,function(){b.scope().$destroy(),b.remove(),0===j&&(t.removeClass("ngdialog-open"),u.resetBodyPadding())}).addClass("ngdialog-closing"):(b.scope().$destroy(),b.remove(),0===j&&(t.removeClass("ngdialog-open"),u.resetBodyPadding())),k[c]&&(k[c].resolve({id:c,$dialog:b,remainingDialogs:j}),delete k[c]),q.$broadcast("ngDialog.closed",b)}},v={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 w;k[i.latestID]=w=o.defer();var x,y,z=b.isObject(l.scope)?l.scope.$new():q.$new();return o.when(h(l.template)).then(function(c){return 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=x=d('<div id="ngdialog'+f+'" class="ngdialog"></div>'),x.html('<div class="ngdialog-overlay"></div><div class="ngdialog-content">'+c+"</div>"),l.controller&&b.isString(l.controller)&&x.attr("ng-controller",l.controller),l.className&&x.addClass(l.className),l.data&&b.isString(l.data)&&(z.ngDialogData="{"===l.data.replace(/^\s*/,"")[0]?b.fromJson(l.data):l.data),y=l.appendTo&&b.isString(l.appendTo)?b.element(document.querySelector(l.appendTo)):t,z.closeThisDialog=function(){u.closeDialog(x)},r(function(){n(x)(z);var a=s.innerWidth-t.prop("clientWidth");t.addClass("ngdialog-open");var b=a-(s.innerWidth-t.prop("clientWidth"));b>0&&u.setBodyPadding(b),y.append(x),q.$broadcast("ngDialog.opened",x)}),l.closeByEscape&&t.bind("keydown",u.onDocumentKeydown),e=function(a){var b=l.closeByDocument?d(a.target).hasClass("ngdialog-overlay"):!1,c=d(a.target).hasClass("ngdialog-close");(b||c)&&v.close(x.attr("id"))},"undefined"!=typeof a.Hammer?a.Hammer(x[0]).on("tap",e):x.bind("click",e),j+=1,v}),{id:"ngdialog"+f,closePromise:w.promise,close:function(){u.closeDialog(x)}}},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()};var e=v.open(d);return e.closePromise.then(function(){c.reject()}),c.promise},close:function(a){var b=d(document.getElementById(a));return b.length?u.closeDialog(b):v.closeAll(),v},closeAll:function(){var a=document.querySelectorAll(".ngdialog");b.forEach(a,function(a){u.closeDialog(d(a))})}};return v}]}),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.2.6", | ||
"version": "0.2.10", | ||
"homepage": "https://github.com/likeastore/ngDialog", | ||
@@ -5,0 +5,0 @@ "description": "Modal dialogs and popups provider for Angular.js applications", |
@@ -137,9 +137,27 @@ # ngDialog | ||
It allows to close modals by clicking on overlay background, default ``true``. | ||
If [Hammer.js](https://github.com/EightMedia/hammer.js) is loaded, it will listen for ``tap`` instead of ``click``. | ||
It allows to close modals by clicking on overlay background, default ``true``. If [Hammer.js](https://github.com/EightMedia/hammer.js) is loaded, it will listen for ``tap`` instead of ``click``. | ||
##### ``forceBodyReload {Boolean}`` | ||
##### ``appendTo {String}`` | ||
Adds additional listener on every ``$locationChangeSuccess`` event and gets update version of ``body`` into dialog. Maybe useful in some rare cases when you're dependant on DOM changes, defaults to ``false``. | ||
Specify your element where to append dialog instance, accepts selector string (e.g. ``#yourId``, ``.yourClass``). If not specified appends dialog to ``body`` as default behavior. | ||
### Defaults: | ||
##### ``setDefaults(options)`` | ||
You're able to set default settings through ``ngDialogProvider``: | ||
```javascript | ||
var app = angular.module('myApp', ['ngDialog']); | ||
app.config(['ngDialogProvider', function (ngDialogProvider) { | ||
ngDialogProvider.setDefaults({ | ||
className: 'ngdialog-theme-default', | ||
plain: true, | ||
showClose: true, | ||
closeByDocument: true, | ||
closeByEscape: true | ||
}); | ||
}]); | ||
``` | ||
### Returns: | ||
@@ -213,2 +231,16 @@ | ||
=== | ||
### ``.setForceBodyReload({Boolean})`` | ||
Adds additional listener on every ``$locationChangeSuccess`` event and gets update version of ``body`` into dialog. Maybe useful in some rare cases when you're dependant on DOM changes, defaults to ``false``. Use it in module's config as provider instance: | ||
```javascript | ||
var app = angular.module('exampleApp', ['ngDialog']); | ||
app.config(function (ngDialogProvider) { | ||
ngDialogProvider.setForceBodyReload(true); | ||
}); | ||
``` | ||
## Directive | ||
@@ -215,0 +247,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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
60925
1035
305