Comparing version 0.5.5 to 0.5.6
@@ -13,3 +13,3 @@ # Testing | ||
If your PR adds new behhaviour or modifies existing behaviour, the README should be updated. | ||
If your PR adds new behaviour or modifies existing behaviour, the README should be updated. | ||
@@ -20,3 +20,3 @@ # Coding style | ||
This section describes coding style guide of the repo. You might not agree with it and that's fine but if you're going to send PRs treat this guide as a law. | ||
This section describes the coding style guide of the repo. You might not agree with it and that's fine, but if you're going to send PRs, treat this guide as a law. | ||
@@ -26,3 +26,3 @@ ##### There are not too much of rules to follow: | ||
- indent style is 4 spaces | ||
- always use single quotes | ||
- always use single quotes | ||
- one space after `if`, `for`, `while`, etc. | ||
@@ -29,0 +29,0 @@ - no spaces between `(`,`)` and statement content |
@@ -11,11 +11,10 @@ /* | ||
if (typeof angular === 'undefined') { | ||
module.exports = factory(require('angular')); | ||
factory(require('angular')); | ||
} else { | ||
module.exports = factory(angular); | ||
factory(angular); | ||
} | ||
module.exports = 'ngDialog'; | ||
} else if (typeof define === 'function' && define.amd) { | ||
// AMD | ||
define(['ng-dialog'], function () { | ||
factory(root.angular); | ||
}); | ||
define(['angular'], factory); | ||
} else { | ||
@@ -443,2 +442,3 @@ // Global Variables | ||
var publicMethods = { | ||
__PRIVATE__: privateMethods, | ||
@@ -570,6 +570,11 @@ /* | ||
}), | ||
null, | ||
true, | ||
label | ||
); | ||
$dialog.data('$ngDialogControllerController', controllerInstance); | ||
if(options.bindToController) { | ||
angular.extend(controllerInstance.instance, {ngDialogId: scope.ngDialogId, ngDialogData: scope.ngDialogData, closeThisDialog: scope.closeThisDialog}); | ||
} | ||
$dialog.data('$ngDialogControllerController', controllerInstance()); | ||
} | ||
@@ -576,0 +581,0 @@ |
@@ -1,2 +0,2 @@ | ||
/*! ng-dialog - v0.5.4 (https://github.com/likeastore/ngDialog) */ | ||
!function(a,b){"undefined"!=typeof module&&module.exports?"undefined"==typeof angular?module.exports=b(require("angular")):module.exports=b(angular):"function"==typeof define&&define.amd?define(["ng-dialog"],function(c){b(a.angular)}):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={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}),null,l);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.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}); |
{ | ||
"name": "ng-dialog", | ||
"version": "0.5.5", | ||
"version": "0.5.6", | ||
"homepage": "https://github.com/likeastore/ngDialog", | ||
@@ -10,2 +10,3 @@ "description": "Modal dialogs and popups provider for Angular.js applications", | ||
"test": "./node_modules/karma/bin/karma start --single-run --browsers PhantomJS", | ||
"test-min": "./node_modules/karma/bin/karma start --single-run --browsers PhantomJS --min", | ||
"test-watch": "./node_modules/karma/bin/karma start --auto-watch --browsers PhantomJS", | ||
@@ -12,0 +13,0 @@ "serve": "node server", |
@@ -23,43 +23,54 @@ var args = process.argv.slice(2); | ||
} | ||
var multiCapabilities = [{ | ||
browserName: 'chrome' | ||
}, { | ||
browserName: 'firefox' | ||
}]; | ||
if (!useA11y) { | ||
multiCapabilities.push({ | ||
browserName: 'safari' | ||
}); | ||
} | ||
// if (process.env.TRAVIS_PULL_REQUEST === 'false') { | ||
// multiCapabilities.push({ | ||
// browserName: 'chrome' | ||
// }); | ||
// if (!useA11y) { | ||
// multiCapabilities.push({ | ||
// browserName: 'safari' | ||
// }); | ||
// } | ||
// if (!useA11y && !useConsole) { | ||
// multiCapabilities.push({ | ||
// browserName: 'internet explorer', | ||
// version: 10 | ||
// }); | ||
// multiCapabilities.push({ | ||
// browserName: 'internet explorer', | ||
// version: 11 | ||
// }); | ||
// } | ||
// multiCapabilities.forEach(function(capability) { | ||
// capability['tunnel-identifier'] = process.env.TRAVIS_JOB_NUMBER; | ||
// capability.name = 'ngDialog Protractor ' + process.env.TRAVIS_JOB_NUMBER; | ||
// }); | ||
// } | ||
if (!useA11y && !useConsole) { | ||
multiCapabilities.push({ | ||
browserName: 'internet explorer', | ||
version: 10 | ||
}); | ||
multiCapabilities.push({ | ||
browserName: 'internet explorer', | ||
version: 11 | ||
}); | ||
} | ||
multiCapabilities.forEach(function(capability) { | ||
capability['tunnel-identifier'] = process.env.TRAVIS_JOB_NUMBER; | ||
capability.name = 'ngDialog Protractor ' + process.env.TRAVIS_JOB_NUMBER; | ||
}); | ||
module.exports.config = { | ||
sauceUser: process.env.SAUCE_USERNAME, | ||
sauceKey: process.env.SAUCE_ACCESS_KEY, | ||
var config = { | ||
allScriptsTimeout: 11000, | ||
specs: ['tests/protractor/**/*.js'], | ||
multiCapabilities: multiCapabilities, | ||
framework: 'jasmine', | ||
framework: 'jasmine2', | ||
jasmineNodeOpts: { | ||
defaultTimeoutInterval: 30000 | ||
defaultTimeoutInterval: 30000 | ||
}, | ||
sauceSeleniumAddress: 'localhost:4445/wd/hub', | ||
plugins: plugins | ||
}; | ||
// if (process.env.TRAVIS_PULL_REQUEST === 'false') { | ||
// config.sauceUser = process.env.SAUCE_USERNAME; | ||
// config.sauceKey = process.env.SAUCE_ACCESS_KEY; | ||
// } | ||
console.log('TRAVIS_PULL_REQUEST', process.env.TRAVIS_PULL_REQUEST); | ||
console.log('protractor config: ', config); | ||
console.log('multiCapabilities: ', multiCapabilities); | ||
module.exports.config = config; |
111
README.md
@@ -10,5 +10,5 @@ <!-- ### LOOKING FOR MAINTAINER. PLEASE PING [@voronianski](https://twitter.com/voronianski)! --> | ||
> Modal dialogs and popups provider for [Angular.js](http://angularjs.org/) applications. | ||
> Modal dialogs and popups provider for [AngularJS](http://angularjs.org/) applications. | ||
ngDialog is ~10Kb, has minimalistic API, highly customizable through themes and has only Angular.js as dependency. | ||
ngDialog is ~10KB (minified), has minimalistic API, is highly customizable through themes and has only AngularJS as dependency. | ||
@@ -19,3 +19,3 @@ ### [Demo](http://likeastore.github.io/ngDialog) | ||
You can download all necessary ngDialog files manually or install it with bower: | ||
You can download all necessary ngDialog files manually, or install it with bower: | ||
@@ -34,3 +34,3 @@ ```bash | ||
You need only to include ``ngDialog.js`` and ``ngDialog.css`` (as minimal setup) to your project and then you can start using ``ngDialog`` provider in your directives, controllers and services. For example in controllers: | ||
You need only to include ``ngDialog.js``, ``ngDialog.css`` and ``ngDialog-theme-default.css`` (as minimal setup) to your project and then you can start using the ``ngDialog`` provider in your directives, controllers and services. For example in controllers: | ||
@@ -49,3 +49,3 @@ ```javascript | ||
Your help is appreciated! If you've found a bug or something is not clear, please raise an issue. | ||
Your help is appreciated! If you've found a bug or if something is not clear, please raise an issue. | ||
@@ -66,3 +66,3 @@ Ideally, if you've found an issue, you will submit a PR that meets our [contributor guidelines][contributor-guidelines]. | ||
### Options: | ||
#### Options: | ||
@@ -84,3 +84,3 @@ ##### ``template {String}`` | ||
Also it is possible to use simple string as template together with ``plain`` option. | ||
Also it is possible to use a simple string as template together with ``plain`` option. | ||
@@ -97,3 +97,3 @@ ##### Pro Tip about templates | ||
Then you it would be possible to include ``dialog.templates`` module into dependencies of your main module and start using this template as ``templateId``. | ||
Then it would be possible to include the ``dialog.templates`` module into the dependencies of your main module and start using this template as ``templateId``. | ||
@@ -123,3 +123,3 @@ There is no need to do these actions manually. | ||
Controller that will be used for dialog window if necessary. The controller can be specified either by referring it by name or directly inline. | ||
Controller that will be used for the dialog window if necessary. The controller can be specified either by referring it by name or directly inline. | ||
@@ -146,7 +146,8 @@ ```javascript | ||
You could optionally specify `controllerAs` parameter for your controller. Then inside your template it will be possible to refer this controller by value specified by `controllerAs`. | ||
You could optionally specify `controllerAs` parameter for your controller. Then inside your template it will be possible to refer this controller by the value specified by `controllerAs`. | ||
Usage of `controllerAs` syntax is currently recommended by Angular team. | ||
Usage of `controllerAs` syntax is currently recommended by the AngularJS team. | ||
##### ``resolve {Object.<string, function>=}`` | ||
##### ``resolve {Object.<String, Function>}`` | ||
An optional map of dependencies which should be injected into the controller. | ||
@@ -161,5 +162,5 @@ If any of these dependencies are promises, ngDialog will wait for them all to be resolved | ||
is: | ||
- `key` – `{string}`: a name of a dependency to be injected into the controller. | ||
- `factory` - `{string|function}`: If `string` then it is an alias for a service. | ||
Otherwise if function, then it is injected using `$injector.invoke` and the return | ||
- `key` – `{String}`: a name of a dependency to be injected into the controller. | ||
- `factory` - `{String | Function}`: If `String` then it is an alias for a service. | ||
Otherwise if `Function`, then it is injected using `$injector.invoke` and the return | ||
value is treated as the dependency. If the result is a promise, it is resolved | ||
@@ -182,3 +183,3 @@ before its value is injected into the controller. | ||
Scope object that will be passed to dialog. If you use controller with separate ``$scope`` service this object will be passed to ``$scope.$parent`` param: | ||
Scope object that will be passed to the dialog. If you use a controller with separate ``$scope`` service this object will be passed to the ``$scope.$parent`` param: | ||
@@ -203,3 +204,3 @@ ```javascript | ||
In addition ``.closeThisDialog(value)`` method gets injected to passed ``$scope``. This allows you to close dialog straight from handler in a popup element, for example: | ||
In addition ``.closeThisDialog(value)`` method gets injected to passed ``$scope``. This allows you to close the dialog straight from the handler in a popup element, for example: | ||
@@ -217,5 +218,5 @@ ```html | ||
Any serializable data that you want to be stored in controller's dialog scope. (``$scope.ngDialogData``). From version `0.3.6` `$scope.ngDialogData` keeps references to the objects instead of copying them. | ||
Any serializable data that you want to be stored in the controller's dialog scope. (``$scope.ngDialogData``). From version `0.3.6` `$scope.ngDialogData` keeps references to the objects instead of copying them. | ||
Additionally, you will have dialog id available as ``$scope.ngDialogId``. If you are using ``$scope.ngDialogData``, it'll be also available under ``$scope.ngDialogData.ngDialogId``. | ||
Additionally, you will have the dialog id available as ``$scope.ngDialogId``. If you are using ``$scope.ngDialogData``, it'll be also available under ``$scope.ngDialogData.ngDialogId``. | ||
@@ -243,13 +244,13 @@ ##### ``className {String}`` | ||
If ``false`` it allows to hide overlay div behind the modals, default ``true``. | ||
If ``false`` it allows to hide the overlay div behind the modals, default ``true``. | ||
##### ``showClose {Boolean}`` | ||
If ``false`` it allows to hide close button on modals, default ``true``. | ||
If ``false`` it allows to hide the close button on modals, default ``true``. | ||
##### ``closeByEscape {Boolean}`` | ||
It allows to close modals by clicking ``Esc`` button, default ``true``. | ||
It allows to close modals by clicking the ``Esc`` key, default ``true``. | ||
This will close all open modals if there several of them open at the same time. | ||
This will close all open modals if there are several of them opened at the same time. | ||
@@ -276,5 +277,5 @@ ##### ``closeByDocument {Boolean}`` | ||
The ``preCloseCallback`` function receives as a parameter (``value``) which is the same value sent to ``.close(id, value)``. | ||
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). | ||
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 key). | ||
@@ -286,3 +287,3 @@ This example uses an inline function with a ``window.confirm`` call in the ``preCloseCallback`` function: | ||
preCloseCallback: function(value) { | ||
if(confirm('Are you sure you want to close without saving your changes?')) { | ||
if (confirm('Are you sure you want to close without saving your changes?')) { | ||
return true; | ||
@@ -360,23 +361,4 @@ } | ||
=== | ||
#### Returns: | ||
### ``.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: | ||
The ``open()`` method returns an object with some useful properties. | ||
@@ -412,2 +394,21 @@ | ||
### ``.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 | ||
}); | ||
}]); | ||
``` | ||
=== | ||
### ``.openConfirm(options)`` | ||
@@ -417,3 +418,3 @@ | ||
### Options: | ||
#### Options: | ||
@@ -436,3 +437,3 @@ The options are the same as the regular [``.open()``](https://github.com/likeastore/ngDialog#options) method with an extra function added to the scope: | ||
### Returns: | ||
#### Returns: | ||
@@ -463,3 +464,3 @@ An Angular promise object that is resolved if the ``.confirm()`` function is used to close the dialog, otherwise the promise is rejected. The resolve value and the reject reason is defined by the value passed to the ``confirm()`` or ``closeThisDialog()`` call respectively. | ||
Method that returns array which includes ids of opened dialogs. | ||
Method that returns array which includes the ids of opened dialogs. | ||
@@ -470,3 +471,3 @@ === | ||
Adds additional listener on every ``$locationChangeSuccess`` event and gets update version of ``html`` 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: | ||
Adds an additional listener on every ``$locationChangeSuccess`` event and gets update version of ``html`` into dialog. May be useful in some rare cases when you're dependant on DOM changes, defaults to ``false``. Use it in module's config as provider instance: | ||
@@ -485,3 +486,3 @@ ```javascript | ||
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: | ||
Adds additional listener on every ``$locationChangeSuccess`` event and gets updated 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: | ||
@@ -498,3 +499,3 @@ ```javascript | ||
By default ngDialog module is served with ``ngDialog`` directive which can be used as attribute for buttons, links, etc. Almost all ``.open()`` options are available through tag attributes as well, the only difference is that ``ng-template`` id or path of template file is required. | ||
By default the ngDialog module is served with the ``ngDialog`` directive which can be used as attribute for buttons, links, etc. Almost all ``.open()`` options are available through tag attributes as well, the only difference is that ``ng-template`` id or path of template file is required. | ||
@@ -520,3 +521,3 @@ Some imaginary button, for example, will look like: | ||
Everytime when ngDialog is opened or closed we're broadcasting three events (dispatching events downwards to all child scopes): | ||
Everytime ngDialog is opened or closed we're broadcasting three events (dispatching events downwards to all child scopes): | ||
@@ -549,5 +550,5 @@ - ``ngDialog.opened`` | ||
- ``ngDialog.setpadding`` | ||
- ``ngDialog.setPadding`` | ||
The ``ngDialog.setpadding`` event will communicate the pixel value being added to the body tag so you can add it to any other elements in your layout at the same time (often fixed-position elements will need this). | ||
The ``ngDialog.setPadding`` event will communicate the pixel value being added to the body tag so you can add it to any other elements in your layout at the same time (often fixed-position elements will need this). | ||
@@ -554,0 +555,0 @@ |
@@ -9,2 +9,2 @@ var express = require('express'); | ||
http.createServer(app).listen(port); | ||
console.log('Server running on' + port); | ||
console.log('Server running on ' + port); |
@@ -174,2 +174,32 @@ describe('ngDialog', function () { | ||
}); | ||
describe('bindToController data checking', function () { | ||
var Ctrl; | ||
beforeEach(inject(function (ngDialog, $timeout) { | ||
Ctrl = spy('DialogCtrl'); | ||
ngDialog.open({ | ||
controller: Ctrl, | ||
controllerAs: 'CtrlVM', | ||
bindToController: true, | ||
data: { | ||
testData: 'testData' | ||
} | ||
}); | ||
$timeout.flush(); | ||
})); | ||
it('should have placed ngDialogId on the controller', function() { | ||
expect(Ctrl.calls.first().object.ngDialogId).toEqual('ngdialog1'); | ||
}); | ||
it('should have placed ngDialogData on the controller', function() { | ||
expect(Ctrl.calls.first().object.ngDialogData.testData).toEqual('testData'); | ||
}); | ||
it('should have placed closeThisDialog function on the controller', function() { | ||
expect(Ctrl.calls.first().object.closeThisDialog).toEqual(jasmine.any(Function)); | ||
}); | ||
}); | ||
}); |
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
158885
46
1958
592