angular.module("app").service("modal",["$compile","$rootScope","$controller","$timeout","core","bootstrap",function(o,a,e,n,l,t){var i=this;$.fn.modal.Constructor.prototype.enforceFocus=function(){},this.modals=[],this.closeAll=function(){for(var o=0;o<this.modals.length;o++){var a=this.modals[o];a&&angular.isFunction(a.close)&&a.close()}},this.show=function(s,r,c){this.closeAll();var d=a.$new(!0);d.isStatic=!1,d.delayShow=!1;var m=!1;i.modals.indexOf(d)<0&&i.modals.push(d),n((function(){if(angular.isString(s)){var a=s;s={template:l.adminURL+"js/views/modals/"+a.toLowerCase()+".html.js?"+l.cacheID,controller:a+"Controller"}}d.options=s;var n=o('<div class="modal hide fade" tabindex="-1" data-show="false" role="dialog"><ng-include src="options.template" onload="_show()"></ng-include></div>')(d);d.close=function(o){m=!0,$(n).modal("hide");var a=i.modals.indexOf(d);a>=0&&i.modals.splice(a,1),angular.isFunction(r)&&r(o)},d.show=function(){$(n).modal({show:!0,backdrop:!d.noBackdrop&&(!d.isStatic||"static"),keyboard:!d.isStatic}),t.rebind()},d._show=function(){if($(n).appendTo("#main-view"),s.controller){var o={$modalScope:d,$element:n};angular.isObject(c)&&(o=angular.extend({},o,c));e(s.controller,o)}d.delayShow||d.show(),$(n).on("hidden",(function(){d.$destroy(),$(n).remove(),m||d.close()}))}}))}}]);