{"version":3,"sources":["angular-modal-service.min.js","angular-modal-service.js"],"names":["module","angular","factory","$document","$compile","$controller","$http","$rootScope","$q","$templateCache","ModalService","self","this","getTemplate","template","templateUrl","deferred","defer","resolve","get","cache","then","result","data","error","reject","promise","showModal","options","controllerName","controller","modalScope","$new","closeDeferred","inputs","$scope","close","delay","undefined","window","setTimeout","$destroy","modalElement","remove","modal","extend","linkFn","$element","modalController","controllerAs","appendElement","append","body","scope","element","find"],"mappings":"AAAA;AACA,CCKC,WAEC,YAEA,IAAIA,GAASC,QAAQD,OAAO,yBAE5BA,GAAOE,QAAQ,gBAAiB,YAAa,WAAY,cAAe,QAAS,aAAc,KAAM,iBACnG,SAASC,EAAWC,EAAUC,EAAaC,EAAOC,EAAYC,EAAIC,GAKlE,QAASC,KAEP,GAAIC,GAAOC,KAKPC,EAAc,SAASC,EAAUC,GACnC,GAAIC,GAAWR,EAAGS,OAclB,OAbGH,GACDE,EAASE,QAAQJ,GACTC,EAERT,EAAMa,IAAIJ,GAAcK,MAAOX,IAC5BY,KAAK,SAASC,GACbN,EAASE,QAAQI,EAAOC,OACvB,SAASC,GACVR,EAASS,OAAOD,KAGpBR,EAASS,OAAO,kDAEXT,EAASU,QAGlBf,GAAKgB,UAAY,SAASC,GAGxB,GAAIZ,GAAWR,EAAGS,QAGdY,EAAiBD,EAAQE,UAC7B,OAAID,IAMJhB,EAAYe,EAAQd,SAAUc,EAAQb,aACnCM,KAAK,SAASP,GAGb,GAAIiB,GAAaxB,EAAWyB,OAQxBC,EAAgBzB,EAAGS,QACnBiB,GACFC,OAAQJ,EACRK,MAAO,SAASd,EAAQe,IACTC,SAAVD,GAAiC,OAAVA,KAAgBA,EAAQ,GAClDE,OAAOC,WAAW,WAEhBP,EAAcf,QAAQI,GAGtBS,EAAWU,WACXC,EAAaC,SAKbT,EAAOE,MAAQ,KACfpB,EAAW,KACXiB,EAAgB,KAChBW,EAAQ,KACRV,EAAS,KACTQ,EAAe,KACfX,EAAa,MACZM,IAKJT,GAAQM,QAAQjC,QAAQ4C,OAAOX,EAAQN,EAAQM,OAIlD,IAAIY,GAAS1C,EAASU,GAClB4B,EAAeI,EAAOf,EAC1BG,GAAOa,SAAWL,CAGlB,IAAIM,GAAkB3C,EAAYuB,EAAQE,WAAYI,EAEnDN,GAAQqB,eACTlB,EAAWH,EAAQqB,cAAgBD,GAGjCpB,EAAQsB,cAEVtB,EAAQsB,cAAcC,OAAOT,GAG7BU,EAAKD,OAAOT,EAId,IAAIE,IACFd,WAAYkB,EACZK,MAAOtB,EACPuB,QAASZ,EACTN,MAAOH,EAAcP,QAIvBV,GAASE,QAAQ0B,KAGlBvB,KAAK,KAAM,SAASG,GACnBR,EAASS,OAAOD,KAGbR,EAASU,UApFdV,EAASS,OAAO,qCACTT,EAASU,UApCtB,GAAI0B,GAAOjD,EAAUoD,KAAK,OA4H1B,OAAO,IAAI7C","file":"angular-modal-service.min.js","sourcesContent":["/*angular-modal-service v0.6.7 - https://github.com/dwmkerr/angular-modal-service */\n!function(){\"use strict\";var e=angular.module(\"angularModalService\",[]);e.factory(\"ModalService\",[\"$document\",\"$compile\",\"$controller\",\"$http\",\"$rootScope\",\"$q\",\"$templateCache\",function(e,n,l,o,t,r,c){function a(){var e=this,a=function(e,n){var l=r.defer();return e?l.resolve(e):n?o.get(n,{cache:c}).then(function(e){l.resolve(e.data)},function(e){l.reject(e)}):l.reject(\"No template or templateUrl has been specified.\"),l.promise};e.showModal=function(e){var o=r.defer(),c=e.controller;return c?(a(e.template,e.templateUrl).then(function(c){var a=t.$new(),i=r.defer(),s={$scope:a,close:function(e,n){(void 0===n||null===n)&&(n=0),window.setTimeout(function(){i.resolve(e),a.$destroy(),d.remove(),s.close=null,o=null,i=null,m=null,s=null,d=null,a=null},n)}};e.inputs&&angular.extend(s,e.inputs);var p=n(c),d=p(a);s.$element=d;var f=l(e.controller,s);e.controllerAs&&(a[e.controllerAs]=f),e.appendElement?e.appendElement.append(d):u.append(d);var m={controller:f,scope:a,element:d,close:i.promise};o.resolve(m)}).then(null,function(e){o.reject(e)}),o.promise):(o.reject(\"No controller has been specified.\"),o.promise)}}var u=e.find(\"body\");return new a}])}();\n//# sourceMappingURL=angular-modal-service.min.js.map","// angularModalService.js\n//\n// Service for showing modal dialogs.\n\n/***** JSLint Config *****/\n/*global angular */\n(function() {\n\n 'use strict';\n\n var module = angular.module('angularModalService', []);\n\n module.factory('ModalService', ['$document', '$compile', '$controller', '$http', '$rootScope', '$q', '$templateCache',\n function($document, $compile, $controller, $http, $rootScope, $q, $templateCache) {\n\n // Get the body of the document, we'll add the modal to this.\n var body = $document.find('body');\n\n function ModalService() {\n\n var self = this;\n\n // Returns a promise which gets the template, either\n // from the template parameter or via a request to the\n // template url parameter.\n var getTemplate = function(template, templateUrl) {\n var deferred = $q.defer();\n if(template) {\n deferred.resolve(template);\n } else if(templateUrl) {\n // Get the template, using the $templateCache.\n $http.get(templateUrl, {cache: $templateCache})\n .then(function(result) {\n deferred.resolve(result.data);\n }, function(error) {\n deferred.reject(error);\n });\n } else {\n deferred.reject(\"No template or templateUrl has been specified.\");\n }\n return deferred.promise;\n };\n\n self.showModal = function(options) {\n\n // Create a deferred we'll resolve when the modal is ready.\n var deferred = $q.defer();\n\n // Validate the input parameters.\n var controllerName = options.controller;\n if(!controllerName) {\n deferred.reject(\"No controller has been specified.\");\n return deferred.promise;\n }\n\n // Get the actual html of the template.\n getTemplate(options.template, options.templateUrl)\n .then(function(template) {\n\n // Create a new scope for the modal.\n var modalScope = $rootScope.$new();\n\n // Create the inputs object to the controller - this will include\n // the scope, as well as all inputs provided.\n // We will also create a deferred that is resolved with a provided\n // close function. The controller can then call 'close(result)'.\n // The controller can also provide a delay for closing - this is\n // helpful if there are closing animations which must finish first.\n var closeDeferred = $q.defer();\n var inputs = {\n $scope: modalScope,\n close: function(result, delay) {\n if(delay === undefined || delay === null) delay = 0;\n window.setTimeout(function() {\n // Resolve the 'close' promise.\n closeDeferred.resolve(result);\n\n // We can now clean up the scope and remove the element from the DOM.\n modalScope.$destroy();\n modalElement.remove();\n\n // Unless we null out all of these objects we seem to suffer\n // from memory leaks, if anyone can explain why then I'd\n // be very interested to know.\n inputs.close = null;\n deferred = null;\n closeDeferred = null;\n modal = null;\n inputs = null;\n modalElement = null;\n modalScope = null;\n }, delay);\n }\n };\n\n // If we have provided any inputs, pass them to the controller.\n if(options.inputs) angular.extend(inputs, options.inputs);\n\n // Compile then link the template element, building the actual element.\n // Set the $element on the inputs so that it can be injected if required.\n var linkFn = $compile(template);\n var modalElement = linkFn(modalScope);\n inputs.$element = modalElement;\n\n // Create the controller, explicitly specifying the scope to use.\n var modalController = $controller(options.controller, inputs);\n\n if(options.controllerAs){\n modalScope[options.controllerAs] = modalController ;\n }\n // Finally, append the modal to the dom.\n if (options.appendElement) {\n // append to custom append element\n options.appendElement.append(modalElement);\n } else {\n // append to body when no custom append element is specified\n body.append(modalElement);\n }\n\n // We now have a modal object...\n var modal = {\n controller: modalController,\n scope: modalScope,\n element: modalElement,\n close: closeDeferred.promise\n };\n\n // ...which is passed to the caller via the promise.\n deferred.resolve(modal);\n\n })\n .then(null, function(error) { // 'catch' doesn't work in IE8.\n deferred.reject(error);\n });\n\n return deferred.promise;\n };\n\n }\n\n return new ModalService();\n }]);\n\n}());\n"],"sourceRoot":"/source/"}