angular.module("app").service("editWindow",["$compile","$rootScope","$controller","$timeout","state","core","bootstrap",function(n,o,t,i,e,s,d){e.editWindows||(e.editWindows=[]);var a=this;this.windows=e.editWindows,this.closeAll=function(n){for(var o=0;o<a.windows.length;o++){a.windows[o].close((function(){0==a.windows.length&&"function"==typeof n&&n()}),!0)}},this.show=function(e,a,l){var w=this;i((function(){var c=!!e,r=o.$new(!0);r.nested=c,angular.isString(a)&&(a={template:s.adminURL+"js/views/windows/"+a.toLowerCase()+".html.js?"+s.cacheID,controller:a+"Controller"}),r.options=a,r._loadListeners=[],r._load=function(n){r._loaded?n():r._loadListeners.push(n)},r.$on("$includeContentLoaded",(function(){r._loaded||(r._loaded=!0,i((function(){for(var n=0;n<r._loadListeners.length;n++)r._loadListeners[n]();r._loadListeners=[]})))}));if(r.dom=n('<div class="hero-unit edit-window" style="opacity: 0" ng-class="{\'actives\':isActive}" ng-click="activate($event)">\t\t\t\t\t\t\t\t<ng-include src="options.template" class="edit-window-content"></ng-include>\t\t\t\t\t\t\t</div>')(r),r.nested?w.windows.push(r):w.windows.unshift(r),a.controller){var f={$windowScope:r,$element:r.dom,useConditional:!0,nameBinding:null};angular.isObject(l)&&(f=angular.extend({},f,l)),t(a.controller,f)}if(r.close=function(n,o){var t=!(r.nested&&!o),e=t?300:400;t&&r.dom.addClass("fast"),r.dom.css({opacity:0,transform:"translateY(250px)"}),i((function(){r.dom.remove(),r.$destroy();var o=w.windows.indexOf(r);o>=0&&w.windows.splice(o,1);var t=o>0?w.windows[o-1]:null;t&&(t.activate(),t.$apply()),"function"==typeof n&&n(o)}),e+100)},r.activate=function(n){if(!r.isActive){var o=w.windows.indexOf(r);if(o>=0&&w.windows.length>o)for(var t=o+1;t<w.windows.length;t++)w.windows[t].close();for(var i=0;i<w.windows.length;i++)w.windows[i].isActive=!1;r.isActive=!0}},r._show=function(){r._load((function(){var n=w.windows.indexOf(r),o=0;if(n>0){for(var t=$("#edit-windows");"auto"!==t.css("overflow-y")&&"scroll"!==t.css("overflow-y")&&!t.is(document);)t=t.parent();o=Math.max(t.scrollTop(),80*n)}$("#edit-windows").append(r.dom),r.activate(),r.dom.css("width",720+30*w.windows.length-30/w.windows.length+"px");var e=!r.nested;i((function(){e&&r.dom.addClass("fast"),r.dom.addClass("actives").css({"margin-top":o+"px",transform:"unset",opacity:1})}),50),d.rebind()}))},c||1===w.windows.length)r._show();else for(var u=0;u<w.windows.length;u++){var v=w.windows[u];v!==r&&v.close((function(){1===w.windows.length&&r._show()}),!0)}}),10)}}]);