Comparing version 0.2.3 to 0.2.6
{ | ||
"name": "ngDialog", | ||
"version": "0.2.3", | ||
"version": "0.2.6", | ||
"homepage": "https://github.com/likeastore/ngDialog", | ||
@@ -5,0 +5,0 @@ "description": "Modal dialogs and popups provider for Angular.js applications", |
var path = require('path'); | ||
var server = require('strata'); | ||
var address = require('network-address'); | ||
@@ -9,1 +10,2 @@ var root = path.resolve('../'); | ||
server.run(); | ||
console.log(address()); |
@@ -24,3 +24,4 @@ /* | ||
closeByDocument: true, | ||
closeByEscape: true | ||
closeByEscape: true, | ||
forceBodyReload: false | ||
}; | ||
@@ -30,5 +31,10 @@ | ||
this.$get = ['$document', '$templateCache', '$compile', '$q', '$http', '$rootScope', '$timeout', | ||
function ($document, $templateCache, $compile, $q, $http, $rootScope, $timeout) { | ||
this.$get = ['$document', '$templateCache', '$compile', '$q', '$http', '$rootScope', '$timeout', '$window', | ||
function ($document, $templateCache, $compile, $q, $http, $rootScope, $timeout, $window) { | ||
var $body = $document.find('body'); | ||
if (defaults.forceBodyReload) { | ||
$rootScope.$on('$locationChangeSuccess', function () { | ||
$body = $document.find('body'); | ||
}); | ||
} | ||
@@ -42,2 +48,17 @@ var privateMethods = { | ||
setBodyPadding: function (width) { | ||
var originalBodyPadding = parseInt(($body.css('padding-right') || 0), 10); | ||
$body.css('padding-right', (originalBodyPadding + width) + 'px'); | ||
$body.data('ng-dialog-original-padding', originalBodyPadding); | ||
}, | ||
resetBodyPadding: function () { | ||
var originalBodyPadding = $body.data('ng-dialog-original-padding'); | ||
if (originalBodyPadding) { | ||
$body.css('padding-right', originalBodyPadding + 'px'); | ||
} else { | ||
$body.css('padding-right', ''); | ||
} | ||
}, | ||
closeDialog: function ($dialog) { | ||
@@ -65,2 +86,3 @@ var id = $dialog.attr('id'); | ||
$body.removeClass('ngdialog-open'); | ||
privateMethods.resetBodyPadding(); | ||
} | ||
@@ -73,2 +95,3 @@ }).addClass('ngdialog-closing'); | ||
$body.removeClass('ngdialog-open'); | ||
privateMethods.resetBodyPadding(); | ||
} | ||
@@ -154,3 +177,11 @@ } | ||
$compile($dialog)(scope); | ||
$body.addClass('ngdialog-open').append($dialog); | ||
var widthDiffs = $window.innerWidth - $body.prop('clientWidth'); | ||
$body.addClass('ngdialog-open'); | ||
var scrollBarWidth = widthDiffs - ($window.innerWidth - $body.prop('clientWidth')); | ||
if (scrollBarWidth > 0) { | ||
privateMethods.setBodyPadding(scrollBarWidth); | ||
} | ||
$body.append($dialog); | ||
$rootScope.$broadcast('ngDialog.opened', $dialog); | ||
@@ -157,0 +188,0 @@ }); |
@@ -1,2 +0,2 @@ | ||
/*! ng-dialog - v0.2.3 (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),p.$broadcast("ngDialog.opened",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,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); | ||
/*! 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); |
{ | ||
"name": "ng-dialog", | ||
"version": "0.2.3", | ||
"version": "0.2.6", | ||
"homepage": "https://github.com/likeastore/ngDialog", | ||
@@ -31,8 +31,9 @@ "description": "Modal dialogs and popups provider for Angular.js applications", | ||
"devDependencies": { | ||
"myth": "~0.1.6", | ||
"grunt": "~0.4.2", | ||
"grunt-contrib-cssmin": "^0.9.0", | ||
"grunt-contrib-jshint": "~0.7.2", | ||
"grunt-contrib-uglify": "~0.2.7", | ||
"grunt-myth": "~0.1.0", | ||
"grunt-contrib-cssmin": "^0.9.0" | ||
"myth": "~0.1.6", | ||
"network-address": "0.0.4" | ||
}, | ||
@@ -39,0 +40,0 @@ "dependencies": { |
@@ -140,2 +140,6 @@ # ngDialog | ||
##### ``forceBodyReload {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``. | ||
### Returns: | ||
@@ -142,0 +146,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
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
Network access
Supply chain riskThis module accesses the network.
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
59168
1023
273
7
1