From ad57c4c6499dc4112d30fbe3f7d79d35f00b5f6b Mon Sep 17 00:00:00 2001 From: Dave Kerr Date: Sun, 27 Sep 2015 01:15:14 +0700 Subject: [PATCH] Bumped up dependencies --- dst/angular-modal-service.js | 15 ++++++--------- dst/angular-modal-service.min.js | 2 +- dst/angular-modal-service.min.js.map | 2 +- package.json | 17 ++++++++--------- 4 files changed, 16 insertions(+), 20 deletions(-) diff --git a/dst/angular-modal-service.js b/dst/angular-modal-service.js index ff0a375..0adde59 100644 --- a/dst/angular-modal-service.js +++ b/dst/angular-modal-service.js @@ -53,12 +53,6 @@ return deferred.promise; } - // If a 'controllerAs' option has been provided, we change the controller - // name to use 'as' syntax. $controller will automatically handle this. - if(typeof controllerName === "string" && options.controllerAs) { - controllerName = controllerName + " as " + options.controllerAs; - } - // Get the actual html of the template. getTemplate(options.template, options.templateUrl) .then(function(template) { @@ -84,9 +78,9 @@ // We can now clean up the scope and remove the element from the DOM. modalScope.$destroy(); modalElement.remove(); - + // Unless we null out all of these objects we seem to suffer - // from memory leaks, if anyone can explain why then I'd + // from memory leaks, if anyone can explain why then I'd // be very interested to know. inputs.close = null; deferred = null; @@ -109,8 +103,11 @@ inputs.$element = modalElement; // Create the controller, explicitly specifying the scope to use. - var modalController = $controller(controllerName, inputs); + var modalController = $controller(options.controller, inputs); + if(options.controllerAs){ + modalScope[options.controllerAs] = modalController ; + } // Finally, append the modal to the dom. if (options.appendElement) { // append to custom append element diff --git a/dst/angular-modal-service.min.js b/dst/angular-modal-service.min.js index 808fcb2..78c00ac 100644 --- a/dst/angular-modal-service.min.js +++ b/dst/angular-modal-service.min.js @@ -1,3 +1,3 @@ /*angular-modal-service v0.6.7 - https://github.com/dwmkerr/angular-modal-service */ -!function(){"use strict";var e=angular.module("angularModalService",[]);e.factory("ModalService",["$document","$compile","$controller","$http","$rootScope","$q","$templateCache",function(e,n,t,l,o,r,c){function a(){var e=this,a=function(e,n){var t=r.defer();return e?t.resolve(e):n?l.get(n,{cache:c}).then(function(e){t.resolve(e.data)},function(e){t.reject(e)}):t.reject("No template or templateUrl has been specified."),t.promise};e.showModal=function(e){var l=r.defer(),c=e.controller;return c?(e.controllerAs&&(c=c+" as "+e.controllerAs),a(e.template,e.templateUrl).then(function(a){var i=o.$new(),s=r.defer(),p={$scope:i,close:function(e,n){(void 0===n||null===n)&&(n=0),window.setTimeout(function(){s.resolve(e),i.$destroy(),f.remove(),p.close=null,l=null,s=null,v=null,p=null,f=null,i=null},n)}};e.inputs&&angular.extend(p,e.inputs);var d=n(a),f=d(i);p.$element=f;var m=t(c,p);e.appendElement?e.appendElement.append(f):u.append(f);var v={controller:m,scope:i,element:f,close:s.promise};l.resolve(v)}).then(null,function(e){l.reject(e)}),l.promise):(l.reject("No controller has been specified."),l.promise)}}var u=e.find("body");return new a}])}(); +!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}])}(); //# sourceMappingURL=angular-modal-service.min.js.map \ No newline at end of file diff --git a/dst/angular-modal-service.min.js.map b/dst/angular-modal-service.min.js.map index d0b62c1..b5165f6 100644 --- a/dst/angular-modal-service.min.js.map +++ b/dst/angular-modal-service.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["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","controllerAs","modalScope","$new","closeDeferred","inputs","$scope","close","delay","undefined","window","setTimeout","$destroy","modalElement","remove","modal","extend","linkFn","$element","modalController","appendElement","append","body","scope","element","find"],"mappings":"CAMC,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,IAODD,EAAQG,eACTF,EAAiBA,EAAiB,OAASD,EAAQG,cAIrDlB,EAAYe,EAAQd,SAAUc,EAAQb,aACnCM,KAAK,SAASP,GAGb,GAAIkB,GAAazB,EAAW0B,OAQxBC,EAAgB1B,EAAGS,QACnBkB,GACFC,OAAQJ,EACRK,MAAO,SAASf,EAAQgB,IACTC,SAAVD,GAAiC,OAAVA,KAAgBA,EAAQ,GAClDE,OAAOC,WAAW,WAEhBP,EAAchB,QAAQI,GAGtBU,EAAWU,WACXC,EAAaC,SAKbT,EAAOE,MAAQ,KACfrB,EAAW,KACXkB,EAAgB,KAChBW,EAAQ,KACRV,EAAS,KACTQ,EAAe,KACfX,EAAa,MACZM,IAKJV,GAAQO,QAAQlC,QAAQ6C,OAAOX,EAAQP,EAAQO,OAIlD,IAAIY,GAAS3C,EAASU,GAClB6B,EAAeI,EAAOf,EAC1BG,GAAOa,SAAWL,CAGlB,IAAIM,GAAkB5C,EAAYwB,EAAgBM,EAG9CP,GAAQsB,cAEVtB,EAAQsB,cAAcC,OAAOR,GAG7BS,EAAKD,OAAOR,EAId,IAAIE,IACFf,WAAYmB,EACZI,MAAOrB,EACPsB,QAASX,EACTN,MAAOH,EAAcR,QAIvBV,GAASE,QAAQ2B,KAGlBxB,KAAK,KAAM,SAASG,GACnBR,EAASS,OAAOD,KAGbR,EAASU,UAvFdV,EAASS,OAAO,qCACTT,EAASU,UApCtB,GAAI0B,GAAOjD,EAAUoD,KAAK,OA+H1B,OAAO,IAAI7C","file":"angular-modal-service.min.js","sourcesContent":["// 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 // If a 'controllerAs' option has been provided, we change the controller\n // name to use 'as' syntax. $controller will automatically handle this.\n if(options.controllerAs) {\n controllerName = controllerName + \" as \" + options.controllerAs;\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(controllerName, inputs);\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/"} \ No newline at end of file +{"version":3,"sources":["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":"CAMC,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":["// 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/"} \ No newline at end of file diff --git a/package.json b/package.json index 2d548a4..b93bc8e 100644 --- a/package.json +++ b/package.json @@ -29,21 +29,20 @@ "express": "^4.12.0", "gulp": "^3.8.11", "gulp-jshint": "^1.9.2", - "gulp-open": "^0.3.2", - "jshint-stylish": "^1.0.1", - "karma": "^0.12.31", - "karma-chrome-launcher": "^0.1.3", - "karma-chrome-launcher": "^0.1.3", - "karma-coverage": "^0.2.1", + "gulp-open": "^1.0.0", + "jshint-stylish": "^2.0.0", + "karma": "^0.13.0", + "karma-chrome-launcher": "^0.2.3", + "karma-coverage": "^0.5.1", "karma-jasmine": "~0.3", - "karma-junit-reporter": "~0.2", - "karma-phantomjs-launcher": "^0.1.4", + "karma-junit-reporter": "~0.3", + "karma-phantomjs-launcher": "^0.2.4", "tiny-lr": "^0.1.5", "gulp-uglify": "^1.1.0", "gulp-rename": "^1.2.0", "gulp-sourcemaps": "^1.5.0", "connect-livereload": "^0.5.3", - "opn": "^1.0.1", + "opn": "^3.0.1", "gulp-header": "^1.2.2" } }