From dc74c8373f801be99a00cd02f4ada9268b3d77be Mon Sep 17 00:00:00 2001 From: Ricky Nguyen Date: Wed, 27 Sep 2017 16:42:46 +0700 Subject: [PATCH] add response object to templateLoaded event, allow user fast access and modify template --- js/ngDialog.js | 2 +- js/ngDialog.min.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/js/ngDialog.js b/js/ngDialog.js index ddd287c1..144b8f4a 100644 --- a/js/ngDialog.js +++ b/js/ngDialog.js @@ -746,7 +746,7 @@ $rootScope.$broadcast('ngDialog.templateLoading', tmpl); return $http.get(tmpl, config).then(function(res) { - $rootScope.$broadcast('ngDialog.templateLoaded', tmpl); + $rootScope.$broadcast('ngDialog.templateLoaded', tmpl, res); return res.data || ''; }); } diff --git a/js/ngDialog.min.js b/js/ngDialog.min.js index aa9cee34..37c3fc95 100644 --- a/js/ngDialog.min.js +++ b/js/ngDialog.min.js @@ -1,2 +1,2 @@ -/*! ng-dialog - v1.2.0 (https://github.com/likeastore/ngDialog) */ -!function(a,b){"undefined"!=typeof module&&module.exports?(b("undefined"==typeof angular?require("angular"):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=[],n=!1,o=!1,p=[],q="legacy",r="1.0.0+";return b.provider("ngDialog",function(){var b=this.defaults={className:"ngdialog-theme-default",appendClassName:"",disableAnimation:!1,plain:!1,showClose:!0,closeByDocument:!0,closeByEscape:!0,closeByNavigation:!1,appendTo:!1,preCloseCallback:!1,onOpenCallback:!1,overlay:!0,cache:!0,trapFocus:!0,preserveFocus:!0,ariaAuto:!0,ariaRole:null,ariaLabelledById:null,ariaLabelledBySelector:null,ariaDescribedById:null,ariaDescribedBySelector:null,bodyClassName:"ngdialog-open",width:null,height: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){o=a||!1};var d,e=0,s=0,t={};this.$get=["$document","$templateCache","$compile","$q","$http","$rootScope","$timeout","$window","$controller","$injector",function(u,v,w,x,y,z,A,B,C,D){var E=[],F={onDocumentKeydown:function(a){27===a.keyCode&&G.close("$escape")},activate:function(a){var b=a.data("$ngDialogOptions");b.trapFocus&&(a.on("keydown",F.onTrapFocusKeydown),E.body.on("keydown",F.onTrapFocusKeydown))},deactivate:function(a){a.off("keydown",F.onTrapFocusKeydown),E.body.off("keydown",F.onTrapFocusKeydown)},deactivateAll:function(b){a.forEach(b,function(b){var c=a.element(b);F.deactivate(c)})},setBodyPadding:function(a){var b=parseInt(E.body.css("padding-right")||0,10);E.body.css("padding-right",b+a+"px"),E.body.data("ng-dialog-original-padding",b),z.$broadcast("ngDialog.setPadding",a)},resetBodyPadding:function(){var a=E.body.data("ng-dialog-original-padding");a?E.body.css("padding-right",a+"px"):E.body.css("padding-right",""),z.$broadcast("ngDialog.setPadding",0)},performCloseDialog:function(a,b){var c=a.data("$ngDialogOptions"),e=a.attr("id"),h=k[e];if(F.deactivate(a),h){if("undefined"!=typeof B.Hammer){var i=h.hammerTime;i.off("tap",d),i.destroy&&i.destroy(),delete h.hammerTime}else a.unbind("click");1===s&&E.body.unbind("keydown",F.onDocumentKeydown),a.hasClass("ngdialog-closing")||(s-=1);var j=a.data("$ngDialogPreviousFocus");j&&j.focus&&j.focus(),z.$broadcast("ngDialog.closing",a,b),s=s<0?0:s,f&&!c.disableAnimation?(h.$destroy(),a.unbind(g).bind(g,function(){F.closeDialogElement(a,b)}).addClass("ngdialog-closing")):(h.$destroy(),F.closeDialogElement(a,b)),t[e]&&(t[e].resolve({id:e,value:b,$dialog:a,remainingDialogs:s}),delete t[e]),k[e]&&delete k[e],l.splice(l.indexOf(e),1),l.length||(E.body.unbind("keydown",F.onDocumentKeydown),n=!1),0==s&&(d=void 0)}},closeDialogElement:function(a,b){var c=a.data("$ngDialogOptions");a.remove(),m.splice(m.indexOf(c.bodyClassName),1),m.indexOf(c.bodyClassName)===-1&&(E.html.removeClass(c.bodyClassName),E.body.removeClass(c.bodyClassName)),0===s&&F.resetBodyPadding(),z.$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);if(a.isObject(e))e.closePromise?e.closePromise.then(function(){F.performCloseDialog(b,c)},function(){return!1}):e.then(function(){F.performCloseDialog(b,c)},function(){return!1});else{if(e===!1)return!1;F.performCloseDialog(b,c)}}else F.performCloseDialog(b,c)},onTrapFocusKeydown:function(b){var c,d=a.element(b.currentTarget);if(d.hasClass("ngdialog"))c=d;else if(c=F.getActiveDialog(),null===c)return;var e=9===b.keyCode,f=b.shiftKey===!0;e&&F.handleTab(c,b,f)},handleTab:function(a,b,c){var d=F.getFocusableElements(a);if(0===d.length)return void(document.activeElement&&document.activeElement.blur&&document.activeElement.blur());var e=document.activeElement,f=Array.prototype.indexOf.call(d,e),g=f===-1,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=F.getFocusableElements(a);if(e.length>0)return void e[0].focus();var f=F.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=F.filterTabbableElements(c);return F.filterVisibleElements(d)},filterTabbableElements:function(a){for(var b=[],d=0;d0||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=F.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),F.applyAriaAttribute(a,"aria-labelledby",b.ariaLabelledById,b.ariaLabelledBySelector),F.applyAriaAttribute(a,"aria-describedby",b.ariaDescribedById,b.ariaDescribedBySelector)},applyAriaAttribute:function(a,b,d,e){if(d)return void a.attr(b,d);if(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(){return D.has("$transitions")?r:!!D.has("$state")&&q},getRouterLocationEventName:function(){return F.detectUIRouter()?"$stateChangeStart":"$locationChangeStart"}},G={__PRIVATE__:F,open:function(f){function g(b,c){var c=c||{};return c.headers=c.headers||{},a.extend(c.headers,{Accept:"text/html"}),z.$broadcast("ngDialog.templateLoading",b),y.get(b,c).then(function(a){return z.$broadcast("ngDialog.templateLoaded",b),a.data||""})}function h(b){return b?a.isString(b)&&q.plain?b:"boolean"!=typeof q.cache||q.cache?g(b,{cache:v}):g(b,{cache:!1}):"Empty template"}var j=null;if(f=f||{},!(o&&f.name&&(j=f.name.toLowerCase().replace(/\s/g,"-")+"-dialog",this.isOpen(j)))){var q=a.copy(b),r=++e;j=j||"ngdialog"+r,l.push(j),"undefined"!=typeof q.data&&("undefined"==typeof f.data&&(f.data={}),f.data=a.merge(a.copy(q.data),f.data)),a.extend(q,f);var u;t[j]=u=x.defer();var H;k[j]=H=a.isObject(q.scope)?q.scope.$new():z.$new();var I,J,K,L=a.extend({},q.resolve);return a.forEach(L,function(b,c){L[c]=a.isString(b)?D.get(b):D.invoke(b,null,null,c)}),x.all({template:h(q.template||q.templateUrl),locals:x.all(L)}).then(function(b){var e=b.template,f=b.locals;q.showClose&&(e+='');var g=q.overlay?"":" ngdialog-no-overlay";if(I=c('
'),I.html(q.overlay?'
'+e+"
":'
'+e+"
"),I.data("$ngDialogOptions",q),H.ngDialogId=j,q.data&&a.isString(q.data)){var h=q.data.replace(/^\s*/,"")[0];H.ngDialogData="{"===h||"["===h?a.fromJson(q.data):new String(q.data),H.ngDialogData.ngDialogId=j}else q.data&&a.isObject(q.data)&&(H.ngDialogData=q.data,H.ngDialogData.ngDialogId=j);if(q.className&&I.addClass(q.className),q.appendClassName&&I.addClass(q.appendClassName),q.width&&(K=I[0].querySelector(".ngdialog-content"),a.isString(q.width)?K.style.width=q.width:K.style.width=q.width+"px"),q.height&&(K=I[0].querySelector(".ngdialog-content"),a.isString(q.height)?K.style.height=q.height:K.style.height=q.height+"px"),q.disableAnimation&&I.addClass(i),J=q.appendTo&&a.isString(q.appendTo)?a.element(document.querySelector(q.appendTo)):E.body,F.applyAriaAttributes(I,q),[{name:"$ngDialogPreCloseCallback",value:q.preCloseCallback},{name:"$ngDialogOnOpenCallback",value:q.onOpenCallback}].forEach(function(b){if(b.value){var c;a.isFunction(b.value)?c=b.value:a.isString(b.value)&&H&&(a.isFunction(H[b.value])?c=H[b.value]:H.$parent&&a.isFunction(H.$parent[b.value])?c=H.$parent[b.value]:z&&a.isFunction(z[b.value])&&(c=z[b.value])),c&&I.data(b.name,c)}}),H.closeThisDialog=function(a){F.closeDialog(I,a)},q.controller&&(a.isString(q.controller)||a.isArray(q.controller)||a.isFunction(q.controller))){var k;q.controllerAs&&a.isString(q.controllerAs)&&(k=q.controllerAs);var l=C(q.controller,a.extend(f,{$scope:H,$element:I}),!0,k);q.bindToController&&a.extend(l.instance,{ngDialogId:H.ngDialogId,ngDialogData:H.ngDialogData,closeThisDialog:H.closeThisDialog,confirm:H.confirm}),"function"==typeof l?I.data("$ngDialogControllerController",l()):I.data("$ngDialogControllerController",l)}if(A(function(){var b=document.querySelectorAll(".ngdialog");F.deactivateAll(b),w(I)(H);var c=B.innerWidth-E.body.prop("clientWidth");E.html.addClass(q.bodyClassName),E.body.addClass(q.bodyClassName),m.push(q.bodyClassName);var d=c-(B.innerWidth-E.body.prop("clientWidth"));d>0&&F.setBodyPadding(d),J.append(I),F.activate(I),q.trapFocus&&F.autoFocus(I),q.name?z.$broadcast("ngDialog.opened",{dialog:I,name:q.name}):z.$broadcast("ngDialog.opened",I);var e=I.data("$ngDialogOnOpenCallback");e&&a.isFunction(e)&&e.call(I)}),n||(E.body.bind("keydown",F.onDocumentKeydown),n=!0),q.closeByNavigation&&p.push(I),q.preserveFocus&&I.data("$ngDialogPreviousFocus",document.activeElement),d=function(a){var b=!!q.closeByDocument&&c(a.target).hasClass("ngdialog-overlay"),d=c(a.target).hasClass("ngdialog-close");(b||d)&&G.close(I.attr("id"),d?"$closeButton":"$document")},"undefined"!=typeof B.Hammer){var o=H.hammerTime=B.Hammer(I[0]);o.on("tap",d)}else I.bind("click",d);return s+=1,G}),{id:j,closePromise:u.promise,close:function(a){F.closeDialog(I,a)}}}},openConfirm:function(d){var e=x.defer(),f=a.copy(b);d=d||{},"undefined"!=typeof f.data&&("undefined"==typeof d.data&&(d.data={}),d.data=a.merge(a.copy(f.data),d.data)),a.extend(f,d),f.scope=a.isObject(f.scope)?f.scope.$new():z.$new(),f.scope.confirm=function(a){e.resolve(a);var b=c(document.getElementById(g.id));F.performCloseDialog(b,a)};var g=G.open(f);if(g)return g.closePromise.then(function(a){return a?e.reject(a.value):e.reject()}),e.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)F.closeDialog(d,b);else if("$escape"===a){var e=l[l.length-1];d=c(document.getElementById(e)),d.data("$ngDialogOptions").closeByEscape&&F.closeDialog(d,"$escape")}else G.closeAll(b);return G},closeAll:function(a){for(var b=document.querySelectorAll(".ngdialog"),d=b.length-1;d>=0;d--){var e=b[d];F.closeDialog(c(e),a)}},getOpenDialogs:function(){return l},getDefaults:function(){return b}};a.forEach(["html","body"],function(a){if(E[a]=u.find(a),j[a]){var b=F.getRouterLocationEventName();z.$on(b,function(){E[a]=u.find(a)})}});var H=F.detectUIRouter();if(H===r){var I=D.get("$transitions");I.onStart({},function(a){for(;p.length>0;){var b=p.pop();if(F.closeDialog(b)===!1)return!1}})}else{var J=H===q?"$stateChangeStart":"$locationChangeStart";z.$on(J,function(a){for(;p.length>0;){var b=p.pop();F.closeDialog(b)===!1&&a.preventDefault()}})}return G}]}),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,appendClassName:e.ngDialogAppendClass,controller:e.ngDialogController,controllerAs:e.ngDialogControllerAs,bindToController:e.ngDialogBindToController,disableAnimation:e.ngDialogDisableAnimation,scope:f,data:e.ngDialogData,showClose:"false"!==e.ngDialogShowClose&&("true"===e.ngDialogShowClose||g.showClose),closeByDocument:"false"!==e.ngDialogCloseByDocument&&("true"===e.ngDialogCloseByDocument||g.closeByDocument),closeByEscape:"false"!==e.ngDialogCloseByEscape&&("true"===e.ngDialogCloseByEscape||g.closeByEscape),overlay:"false"!==e.ngDialogOverlay&&("true"===e.ngDialogOverlay||g.overlay),preCloseCallback:e.ngDialogPreCloseCallback||g.preCloseCallback,onOpenCallback:e.ngDialogOnOpenCallback||g.onOpenCallback,bodyClassName:e.ngDialogBodyClass||g.bodyClassName})})}}}]),b}); \ No newline at end of file +/*! ng-dialog - v1.4.0 (https://github.com/likeastore/ngDialog) */ +!function(a,b){"undefined"!=typeof module&&module.exports?(b("undefined"==typeof angular?require("angular"):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={html:!1,body:!1},i={},j=[],k=[],l=!1,m=!1,n=[],o="legacy",p="1.0.0+";return b.provider("ngDialog",function(){var b=this.defaults={className:"ngdialog-theme-default",appendClassName:"",disableAnimation:!1,plain:!1,showClose:!0,closeByDocument:!0,closeByEscape:!0,closeByNavigation:!1,appendTo:!1,preCloseCallback:!1,onOpenCallback:!1,overlay:!0,cache:!0,trapFocus:!0,preserveFocus:!0,ariaAuto:!0,ariaRole:null,ariaLabelledById:null,ariaLabelledBySelector:null,ariaDescribedById:null,ariaDescribedBySelector:null,bodyClassName:"ngdialog-open",width:null,height:null};this.setForceHtmlReload=function(a){h.html=a||!1},this.setForceBodyReload=function(a){h.body=a||!1},this.setDefaults=function(c){a.extend(b,c)},this.setOpenOnePerName=function(a){m=a||!1};var d,e=0,q=0,r={};this.$get=["$document","$templateCache","$compile","$q","$http","$rootScope","$timeout","$window","$controller","$injector",function(s,t,u,v,w,x,y,z,A,B){var C=[],D={onDocumentKeydown:function(a){27===a.keyCode&&E.close("$escape")},activate:function(a){a.data("$ngDialogOptions").trapFocus&&(a.on("keydown",D.onTrapFocusKeydown),C.body.on("keydown",D.onTrapFocusKeydown))},deactivate:function(a){a.off("keydown",D.onTrapFocusKeydown),C.body.off("keydown",D.onTrapFocusKeydown)},deactivateAll:function(b){a.forEach(b,function(b){var c=a.element(b);D.deactivate(c)})},setBodyPadding:function(a){var b=parseInt(C.body.css("padding-right")||0,10);C.body.css("padding-right",b+a+"px"),C.body.data("ng-dialog-original-padding",b),x.$broadcast("ngDialog.setPadding",a)},resetBodyPadding:function(){var a=C.body.data("ng-dialog-original-padding");a?C.body.css("padding-right",a+"px"):C.body.css("padding-right",""),x.$broadcast("ngDialog.setPadding",0)},performCloseDialog:function(a,b){var c=a.data("$ngDialogOptions"),e=a.attr("id"),h=i[e];if(D.deactivate(a),h){if(void 0!==z.Hammer){var k=h.hammerTime;k.off("tap",d),k.destroy&&k.destroy(),delete h.hammerTime}else a.unbind("click");1===q&&C.body.unbind("keydown",D.onDocumentKeydown),a.hasClass("ngdialog-closing")||(q-=1);var m=a.data("$ngDialogPreviousFocus");m&&m.focus&&m.focus(),x.$broadcast("ngDialog.closing",a,b),q=q<0?0:q,f&&!c.disableAnimation?(h.$destroy(),a.unbind(g).bind(g,function(){D.closeDialogElement(a,b)}).addClass("ngdialog-closing")):(h.$destroy(),D.closeDialogElement(a,b)),r[e]&&(r[e].resolve({id:e,value:b,$dialog:a,remainingDialogs:q}),delete r[e]),i[e]&&delete i[e],j.splice(j.indexOf(e),1),j.length||(C.body.unbind("keydown",D.onDocumentKeydown),l=!1),0==q&&(d=void 0)}},closeDialogElement:function(a,b){var c=a.data("$ngDialogOptions");a.remove(),k.splice(k.indexOf(c.bodyClassName),1),-1===k.indexOf(c.bodyClassName)&&(C.html.removeClass(c.bodyClassName),C.body.removeClass(c.bodyClassName)),0===q&&D.resetBodyPadding(),x.$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);if(a.isObject(e))e.closePromise?e.closePromise.then(function(){D.performCloseDialog(b,c)},function(){return!1}):e.then(function(){D.performCloseDialog(b,c)},function(){return!1});else{if(!1===e)return!1;D.performCloseDialog(b,c)}}else D.performCloseDialog(b,c)},onTrapFocusKeydown:function(b){var c,d=a.element(b.currentTarget);if(d.hasClass("ngdialog"))c=d;else if(null===(c=D.getActiveDialog()))return;var e=9===b.keyCode,f=!0===b.shiftKey;e&&D.handleTab(c,b,f)},handleTab:function(a,b,c){var d=D.getFocusableElements(a);if(0===d.length)return void(document.activeElement&&document.activeElement.blur&&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=D.getFocusableElements(a);if(e.length>0)return void e[0].focus();var f=D.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("a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), iframe, object, embed, *[tabindex], *[contenteditable]"),d=D.filterTabbableElements(c);return D.filterVisibleElements(d)},filterTabbableElements:function(a){for(var b=[],d=0;d0||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=D.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),D.applyAriaAttribute(a,"aria-labelledby",b.ariaLabelledById,b.ariaLabelledBySelector),D.applyAriaAttribute(a,"aria-describedby",b.ariaDescribedById,b.ariaDescribedBySelector)},applyAriaAttribute:function(a,b,d,e){if(d)return void a.attr(b,d);if(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(){return B.has("$transitions")?p:!!B.has("$state")&&o},getRouterLocationEventName:function(){return D.detectUIRouter()?"$stateChangeStart":"$locationChangeStart"}},E={__PRIVATE__:D,open:function(f){function g(b,c){var c=c||{};return c.headers=c.headers||{},a.extend(c.headers,{Accept:"text/html"}),x.$broadcast("ngDialog.templateLoading",b),w.get(b,c).then(function(a){return x.$broadcast("ngDialog.templateLoaded",b,a),a.data||""})}function h(b){return b?a.isString(b)&&p.plain?b:"boolean"!=typeof p.cache||p.cache?g(b,{cache:t}):g(b,{cache:!1}):"Empty template"}var o=null;if(f=f||{},!(m&&f.name&&(o=f.name.toLowerCase().replace(/\s/g,"-")+"-dialog",this.isOpen(o)))){var p=a.copy(b),s=++e;o=o||"ngdialog"+s,j.push(o),void 0!==p.data&&(void 0===f.data&&(f.data={}),f.data=a.merge(a.copy(p.data),f.data)),a.extend(p,f);var F;r[o]=F=v.defer();var G;i[o]=G=a.isObject(p.scope)?p.scope.$new():x.$new();var H,I,J,K=a.extend({},p.resolve);return a.forEach(K,function(b,c){K[c]=a.isString(b)?B.get(b):B.invoke(b,null,null,c)}),v.all({template:h(p.template||p.templateUrl),locals:v.all(K)}).then(function(b){var e=b.template,f=b.locals;p.showClose&&(e+='');var g=p.overlay?"":" ngdialog-no-overlay";if(H=c('
'),H.html(p.overlay?'
'+e+"
":'
'+e+"
"),H.data("$ngDialogOptions",p),G.ngDialogId=o,p.data&&a.isString(p.data)){var h=p.data.replace(/^\s*/,"")[0];G.ngDialogData="{"===h||"["===h?a.fromJson(p.data):new String(p.data),G.ngDialogData.ngDialogId=o}else p.data&&a.isObject(p.data)&&(G.ngDialogData=p.data,G.ngDialogData.ngDialogId=o);if(p.className&&H.addClass(p.className),p.appendClassName&&H.addClass(p.appendClassName),p.width&&(J=H[0].querySelector(".ngdialog-content"),a.isString(p.width)?J.style.width=p.width:J.style.width=p.width+"px"),p.height&&(J=H[0].querySelector(".ngdialog-content"),a.isString(p.height)?J.style.height=p.height:J.style.height=p.height+"px"),p.disableAnimation&&H.addClass("ngdialog-disabled-animation"),I=p.appendTo&&a.isString(p.appendTo)?a.element(document.querySelector(p.appendTo)):C.body,D.applyAriaAttributes(H,p),[{name:"$ngDialogPreCloseCallback",value:p.preCloseCallback},{name:"$ngDialogOnOpenCallback",value:p.onOpenCallback}].forEach(function(b){if(b.value){var c;a.isFunction(b.value)?c=b.value:a.isString(b.value)&&G&&(a.isFunction(G[b.value])?c=G[b.value]:G.$parent&&a.isFunction(G.$parent[b.value])?c=G.$parent[b.value]:x&&a.isFunction(x[b.value])&&(c=x[b.value])),c&&H.data(b.name,c)}}),G.closeThisDialog=function(a){D.closeDialog(H,a)},p.controller&&(a.isString(p.controller)||a.isArray(p.controller)||a.isFunction(p.controller))){var i;p.controllerAs&&a.isString(p.controllerAs)&&(i=p.controllerAs);var j=A(p.controller,a.extend(f,{$scope:G,$element:H}),!0,i);p.bindToController&&a.extend(j.instance,{ngDialogId:G.ngDialogId,ngDialogData:G.ngDialogData,closeThisDialog:G.closeThisDialog,confirm:G.confirm}),"function"==typeof j?H.data("$ngDialogControllerController",j()):H.data("$ngDialogControllerController",j)}return y(function(){var b=document.querySelectorAll(".ngdialog");D.deactivateAll(b),u(H)(G);var c=z.innerWidth-C.body.prop("clientWidth");C.html.addClass(p.bodyClassName),C.body.addClass(p.bodyClassName),k.push(p.bodyClassName);var d=c-(z.innerWidth-C.body.prop("clientWidth"));d>0&&D.setBodyPadding(d),I.append(H),D.activate(H),p.trapFocus&&D.autoFocus(H),p.name?x.$broadcast("ngDialog.opened",{dialog:H,name:p.name}):x.$broadcast("ngDialog.opened",H);var e=H.data("$ngDialogOnOpenCallback");e&&a.isFunction(e)&&e.call(H)}),l||(C.body.bind("keydown",D.onDocumentKeydown),l=!0),p.closeByNavigation&&n.push(H),p.preserveFocus&&H.data("$ngDialogPreviousFocus",document.activeElement),d=function(a){var b=!!p.closeByDocument&&c(a.target).hasClass("ngdialog-overlay"),d=c(a.target).hasClass("ngdialog-close");(b||d)&&E.close(H.attr("id"),d?"$closeButton":"$document")},void 0!==z.Hammer?(G.hammerTime=z.Hammer(H[0])).on("tap",d):H.bind("click",d),q+=1,E}),{id:o,closePromise:F.promise,close:function(a){D.closeDialog(H,a)}}}},openConfirm:function(d){var e=v.defer(),f=a.copy(b);d=d||{},void 0!==f.data&&(void 0===d.data&&(d.data={}),d.data=a.merge(a.copy(f.data),d.data)),a.extend(f,d),f.scope=a.isObject(f.scope)?f.scope.$new():x.$new(),f.scope.confirm=function(a){e.resolve(a);var b=c(document.getElementById(g.id));D.performCloseDialog(b,a)};var g=E.open(f);if(g)return g.closePromise.then(function(a){return a?e.reject(a.value):e.reject()}),e.promise},isOpen:function(a){return c(document.getElementById(a)).length>0},close:function(a,b){var d=c(document.getElementById(a));if(d.length)D.closeDialog(d,b);else if("$escape"===a){var e=j[j.length-1];d=c(document.getElementById(e)),d.data("$ngDialogOptions").closeByEscape&&D.closeDialog(d,"$escape")}else E.closeAll(b);return E},closeAll:function(a){for(var b=document.querySelectorAll(".ngdialog"),d=b.length-1;d>=0;d--){var e=b[d];D.closeDialog(c(e),a)}},getOpenDialogs:function(){return j},getDefaults:function(){return b}};a.forEach(["html","body"],function(a){if(C[a]=s.find(a),h[a]){var b=D.getRouterLocationEventName();x.$on(b,function(){C[a]=s.find(a)})}});var F=D.detectUIRouter();if(F===p)B.get("$transitions").onStart({},function(a){for(;n.length>0;){var b=n.pop();if(!1===D.closeDialog(b))return!1}});else{var G=F===o?"$stateChangeStart":"$locationChangeStart";x.$on(G,function(a){for(;n.length>0;){var b=n.pop();!1===D.closeDialog(b)&&a.preventDefault()}})}return E}]}),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,appendClassName:e.ngDialogAppendClass,controller:e.ngDialogController,controllerAs:e.ngDialogControllerAs,bindToController:e.ngDialogBindToController,disableAnimation:e.ngDialogDisableAnimation,scope:f,data:e.ngDialogData,showClose:"false"!==e.ngDialogShowClose&&("true"===e.ngDialogShowClose||g.showClose),closeByDocument:"false"!==e.ngDialogCloseByDocument&&("true"===e.ngDialogCloseByDocument||g.closeByDocument),closeByEscape:"false"!==e.ngDialogCloseByEscape&&("true"===e.ngDialogCloseByEscape||g.closeByEscape),overlay:"false"!==e.ngDialogOverlay&&("true"===e.ngDialogOverlay||g.overlay),preCloseCallback:e.ngDialogPreCloseCallback||g.preCloseCallback,onOpenCallback:e.ngDialogOnOpenCallback||g.onOpenCallback,bodyClassName:e.ngDialogBodyClass||g.bodyClassName})})}}}]),b}); \ No newline at end of file