angular-modal-service
Advanced tools
Comparing version 0.14.2 to 0.15.1
@@ -0,1 +1,7 @@ | ||
## v0.15.0 | ||
* Support for a globally configurable close timeout. Thanks [decherneyge](https://github.com/decherneyge). | ||
* Support for selector for `appendElement`. Thanks [decherneyge](https://github.com/decherneyge). | ||
* Tooling version updates. | ||
## v0.7.12 | ||
@@ -2,0 +8,0 @@ |
@@ -1,2 +0,2 @@ | ||
!function(e){var n={};function o(t){if(n[t])return n[t].exports;var l=n[t]={i:t,l:!1,exports:{}};return e[t].call(l.exports,l,l.exports,o),l.l=!0,l.exports}o.m=e,o.c=n,o.d=function(e,n,t){o.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:t})},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(e,n){if(1&n&&(e=o(e)),8&n)return e;if(4&n&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(o.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var l in e)o.d(t,l,function(n){return e[n]}.bind(null,l));return t},o.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(n,"a",n),n},o.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},o.p="",o(o.s=0)}([function(e,n,o){"use strict";angular.module("angularModalService",[]).factory("ModalService",["$animate","$document","$compile","$controller","$http","$rootScope","$q","$templateRequest","$timeout",function(e,n,o,t,l,r,c,u,a){return new function(){var l=this;l.openModals=[];var s=function(n,o){var t=n.children();return t.length>0?e.enter(o,n,t[t.length-1]):e.enter(o,n)};l.closeModals=function(e,n){for(;l.openModals.length;)l.openModals[0].close(e,n),l.openModals.splice(0,1)},l.showModal=function(i){var p=angular.element(n[0].body),d=c.defer();return i.controller?(function(e,n){var o=c.defer();return e?o.resolve(e):n?u(n,!0).then(function(e){o.resolve(e)},function(e){o.reject(e)}):o.reject("No template or templateUrl has been specified."),o.promise}(i.template,i.templateUrl).then(function(n){var u={},f=(i.scope||r).$new(),m=null,v=i.locationChangeSuccess;!1===v?m=angular.noop:angular.isNumber(v)&&v>=0?a(function(){m=r.$on("$locationChangeSuccess",S)},v):m=r.$on("$locationChangeSuccess",S);var b=c.defer(),g=c.defer(),y=!1,h={$scope:f,close:function(e,n){"function"==typeof i.preClose&&i.preClose(u,e,n),void 0!==n&&null!==n||(n=0),y||(y=!0,a(function(){S(e)},n))}};i.inputs&&angular.extend(h,i.inputs);var $=o(n)(f);h.$element=$;var M=f[i.controllerAs],j=t(i.controller,h,!1,i.controllerAs);function S(n){b.resolve(n),i.bodyClass&&p[0].classList.remove(i.bodyClass),e.leave($).then(function(){if($){g.resolve(n),f.$destroy();for(var e=0;e<l.openModals.length;e++)if(l.openModals[e].modal===u){l.openModals.splice(e,1);break}h.close=null,d=null,b=null,u=null,h=null,$=null,f=null}}),m&&m()}i.controllerAs&&M&&angular.extend(j,M),i.appendElement?s(i.appendElement,$):s(p,$),i.bodyClass&&p[0].classList.add(i.bodyClass),u.controller=j,u.scope=f,u.element=$,u.close=b.promise,u.closed=g.promise,d.resolve(u),document.activeElement.blur(),l.openModals.push({modal:u,close:h.close})}).then(null,function(e){d.reject(e)}),d.promise):(d.reject("No controller has been specified."),d.promise)}}}])}]); | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly8vd2VicGFjay9ib290c3RyYXAiLCJ3ZWJwYWNrOi8vLy4vc3JjL2FuZ3VsYXItbW9kYWwtc2VydmljZS5qcyJdLCJuYW1lcyI6WyJpbnN0YWxsZWRNb2R1bGVzIiwiX193ZWJwYWNrX3JlcXVpcmVfXyIsIm1vZHVsZUlkIiwiZXhwb3J0cyIsIm1vZHVsZSIsImkiLCJsIiwibW9kdWxlcyIsImNhbGwiLCJtIiwiYyIsImQiLCJuYW1lIiwiZ2V0dGVyI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oZSBib2R5XG4gICAgICAgICAgICBpZihvcHRpb25zLmJvZHlDbGFzcykge1xuICAgICAgICAgICAgICAgIGJvZHlbMF0uY2xhc3NMaXN0LnJlbW92ZShvcHRpb25zLmJvZHlDbGFzcyk7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIC8vICBMZXQgYW5ndWxhciByZW1vdmUgdGhlIGVsZW1lbnQgYW5kIHdhaXQgZm9yIGFuaW1hdGlvbnMgdG8gZmluaXNoLlxuICAgICAgICAgICAgJGFuaW1hdGUubGVhdmUobW9kYWxFbGVtZW50KVxuICAgICAgICAgICAgICAgICAgICAudGhlbihmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICAgICAgICAgICAgLy8gcHJldmVudCBlcnJvciBpZiBtb2RhbCBpcyBhbHJlYWR5IGRlc3Ryb3llZFxuICAgICAgICAgICAgICAgICAgICAgIGlmICghbW9kYWxFbGVtZW50KSB7XG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgICAgICAgLy8gIFJlc29sdmUgdGhlICdjbG9zZWQnIHByb21pc2UuXG4gICAgICAgICAgICAgICAgICAgICAgY2xvc2VkRGVmZXJyZWQucmVzb2x2ZShyZXN1bHQpO1xuXG4gICAgICAgICAgICAgICAgICAgICAgLy8gIFdlIGNhbiBub3cgY2xlYW4gdXAgdGhlIHNjb3BlXG4gICAgICAgICAgICAgICAgICAgICAgbW9kYWxTY29wZS4kZGVzdHJveSgpO1xuXG4gICAgICAgICAgICAgICAgICAgICAgLy8gIFJlbW92ZSB0aGUgbW9kYWwgZnJvbSB0aGUgc2V0IG9mIG9wZW4gbW9kYWxzLlxuICAgICAgICAgICAgICAgICAgICAgIGZvciAodmFyIGk9MDsgaTxzZWxmLm9wZW5Nb2RhbHMubGVuZ3RoOyBpKyspIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzZWxmLm9wZW5Nb2RhbHNbaV0ubW9kYWwgPT09IG1vZGFsKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgIHNlbGYub3Blbk1vZGFscy5zcGxpY2UoaSwgMSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgICAgICAgIC8vICBVbmxlc3Mgd2UgbnVsbCBvdXQgYWxsIG9mIHRoZXNlIG9iamVjdHMgd2Ugc2VlbSB0byBzdWZmZXJcbiAgICAgICAgICAgICAgICAgICAgICAvLyAgZnJvbSBtZW1vcnkgbGVha3MsIGlmIGFueW9uZSBjYW4gZXhwbGFpbiB3aHkgdGhlbiBJJ2RcbiAgICAgICAgICAgICAgICAgICAgICAvLyAgYmUgdmVyeSBpbnRlcmVzdGVkIHRvIGtub3cuXG4gICAgICAgICAgICAgICAgICAgICAgaW5wdXRzLmNsb3NlID0gbnVsbDtcbiAgICAgICAgICAgICAgICAgICAgICBkZWZlcnJlZCA9IG51bGw7XG4gICAgICAgICAgICAgICAgICAgICAgY2xvc2VEZWZlcnJlZCA9IG51bGw7XG4gICAgICAgICAgICAgICAgICAgICAgbW9kYWwgPSBudWxsO1xuICAgICAgICAgICAgICAgICAgICAgIGlucHV0cyA9IG51bGw7XG4gICAgICAgICAgICAgICAgICAgICAgbW9kYWxFbGVtZW50ID0gbnVsbDtcbiAgICAgICAgICAgICAgICAgICAgICBtb2RhbFNjb3BlID0gbnVsbDtcblxuICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAvLyByZW1vdmUgZXZlbnQgd2F0Y2hlclxuICAgICAgICAgICAgcm9vdFNjb3BlT25DbG9zZSAmJiByb290U2NvcGVPbkNsb3NlKCk7XG4gICAgICAgICAgfVxuXG4gICAgICAgIH0pXG4gICAgICAgIC50aGVuKG51bGwsIGZ1bmN0aW9uKGVycm9yKSB7IC8vICdjYXRjaCcgZG9lc24ndCB3b3JrIGluIElFOC5cbiAgICAgICAgICBkZWZlcnJlZC5yZWplY3QoZXJyb3IpO1xuICAgICAgICB9KTtcblxuICAgICAgcmV0dXJuIGRlZmVycmVkLnByb21pc2U7XG4gICAgfTtcblxuICB9XG5cbiAgcmV0dXJuIG5ldyBNb2RhbFNlcnZpY2UoKTtcbn1dKTtcbiJdLCJzb3VyY2VSb290IjoiIn0= | ||
!function(e){var n={};function o(t){if(n[t])return n[t].exports;var l=n[t]={i:t,l:!1,exports:{}};return e[t].call(l.exports,l,l.exports,o),l.l=!0,l.exports}o.m=e,o.c=n,o.d=function(e,n,t){o.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:t})},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(e,n){if(1&n&&(e=o(e)),8&n)return e;if(4&n&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(o.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var l in e)o.d(t,l,function(n){return e[n]}.bind(null,l));return t},o.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(n,"a",n),n},o.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},o.p="",o(o.s=0)}([function(e,n,o){"use strict";angular.module("angularModalService",[]).provider("ModalService",function(){var e={closeDelay:0};this.configureOptions=function(n){angular.extend(e,n)},this.$get=["$animate","$document","$compile","$controller","$http","$rootScope","$q","$templateRequest","$timeout",function(n,o,t,l,r,c,a,i,s){return new function(e){var r=this;r.configOptions=e,r.openModals=[],r.closeModals=function(e,n){for(n=n||r.configOptions.closeDelay;r.openModals.length;)r.openModals[0].close(e,n),r.openModals.splice(0,1)},r.showModal=function(e){var u=angular.element(o[0].body),p=a.defer();return e.controller?(function(e,n){var o=a.defer();return e?o.resolve(e):n?i(n,!0).then(function(e){o.resolve(e)},function(e){o.reject(e)}):o.reject("No template or templateUrl has been specified."),o.promise}(e.template,e.templateUrl).then(function(i){var f={},d=(e.scope||c).$new(),m=null,g=e.locationChangeSuccess;!1===g?m=angular.noop:angular.isNumber(g)&&g>=0?s(function(){m=c.$on("$locationChangeSuccess",j)},g):s(function(){m=c.$on("$locationChangeSuccess",j)},r.configOptions.closeDelay);var v=a.defer(),y=a.defer(),b=!1,h={$scope:d,close:function(n,o){o=o||r.configOptions.closeDelay,"function"==typeof e.preClose&&e.preClose(f,n,o),void 0!==o&&null!==o||(o=0),b||(b=!0,s(function(){j(n)},o))}};e.inputs&&angular.extend(h,e.inputs);var $=t(i)(d);h.$element=$;var M=d[e.controllerAs],S=l(e.controller,h,!1,e.controllerAs);e.controllerAs&&M&&angular.extend(S,M);var O=u;function j(o){v.resolve(o),e.bodyClass&&u[0].classList.remove(e.bodyClass),n.leave($).then(function(){if($){y.resolve(o),d.$destroy();for(var e=0;e<r.openModals.length;e++)if(r.openModals[e].modal===f){r.openModals.splice(e,1);break}h.close=null,p=null,v=null,f=null,h=null,$=null,d=null}}),m&&m()}angular.isString(e.appendElement)?O=angular.element(o[0].querySelector(e.appendElement)):e.appendElement&&(O=e.appendElement),function(e,o){var t=e.children();t.length>0?n.enter(o,e,t[t.length-1]):n.enter(o,e)}(O,$),e.bodyClass&&u[0].classList.add(e.bodyClass),f.controller=S,f.scope=d,f.element=$,f.close=v.promise,f.closed=y.promise,angular.isFunction(f.controller.$onInit)&&f.controller.$onInit(),p.resolve(f),document.activeElement.blur(),r.openModals.push({modal:f,close:h.close})}).then(null,function(e){p.reject(e)}),p.promise):(p.reject("No controller has been specified."),p.promise)}}(e)}]})}]); | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly8vd2VicGFjay9ib290c3RyYXAiLCJ3ZWJwYWNrOi8vLy4vc3JjL2FuZ3VsYXItbW9kYWwtc2VydmljZS5qcyJdLC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AgICAgICBmdW5jdGlvbiBNb2RhbFNlcnZpY2UoY29uZmlnT3B0aW9ucykge1xuXG4gICAgICAgICAgICAgICAgdmFyIHNlbGYgPSB0aGlzO1xuXG4gICAgICAgICAgICAgICAgLy9zdGFzaCBjb25maWdPcHRpb25zXG4gICAgICAgICAgICAgICAgc2VsZi5jb25maWdPcHRpb25zID0gY29uZmlnT3B0aW9ucztcblxuICAgICAgICAgICAgICAgIC8vICBUcmFjayBvcGVuIG1vZGFscy5cbiAgICAgICAgICAgICAgICBzZWxmLm9wZW5Nb2RhbHMgPSBbXTtcblxuICAgICAgICAgICAgICAgIC8vICBSZXR1cm5zIGEgcHJvbWlzZSB3aGljaCBnZXRzIHRoZSB0ZW1wbGF0ZSwgZWl0aGVyXG4gICAgICAgICAgICAgICAgLy8gIGZyb20gdGhlIHRlbXBsYXRlIHBhcmFtZXRlciBvciB2aWEgYSByZXF1ZXN0IHRvIHRoZVxuICAgICAgICAgICAgICAgIC8vICB0ZW1wbGF0ZSB1cmwgcGFyYW1ldGVyLlxuICAgICAgICAgICAgICAgIHZhciBnZXRUZW1wbGF0ZSA9IGZ1bmN0aW9uICh0ZW1wbGF0ZSwgdGVtcGxhdGVVcmwpIHtcbiAgICAgICAgICAgICAgICAgICAgdmFyIGRlZmVycmVkID0gJHEuZGVmZXIoKTtcbiAgICAgICAgICAgICAgICAgICAgaWYgKHRlbXBsYXRlKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBkZWZlcnJlZC5yZXNvbHZlKHRlbXBsYXRlKTtcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmICh0ZW1wbGF0ZVVybCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgJHRlbXBsYXRlUmVxdWVzdCh0ZW1wbGF0ZVVybCwgdHJ1ZSlcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAudGhlbihmdW5jdGlvbiAodGVtcGxhdGUpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVmZXJyZWQucmVzb2x2ZSh0ZW1wbGF0ZSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSwgZnVuY3Rpb24gKGVycm9yKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlZmVycmVkLnJlamVjdChlcnJvcik7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBkZWZlcnJlZC5yZWplY3QoXCJObyB0ZW1wbGF0ZSBvciB0ZW1wbGF0ZVVybCBoYXMgYmVlbiBzcGVjaWZpZWQuXCIpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBkZWZlcnJlZC5wcm9taXNlO1xuICAgICAgICAgICAgICAgIH07XG5cbiAgICAgICAgICAgICAgICAvLyAgQWRkcyBhbiBlbGVtZW50IHRvIHRoZSBET00gYXMgdGhlIGxhc3QgY2hpbGQgb2YgaXRzIGNvbnRhaW5lclxuICAgICAgICAgICAgICAgIC8vICBsaWtlIGFwcGVuZCwgYnV0IHVzZXMgJGFuaW1hdGUgdG8gaGFuZGxlIGFuaW1hdGlvbnMuIFJldHVybnMgYVxuICAgICAgICAgICAgICAgIC8vICBwcm9taXNlIHRoYXQgaXMgcmVzb2x2ZWQgb25jZSBhbGwgYW5pbWF0aW9uIGlzIGNvbXBsZXRlLlxuICAgICAgICAgICAgICAgIHZhciBhcHBlbmRDaGlsZCA9IGZ1bmN0aW9uIChwYXJlbnQsIGNoaWxkKSB7XG4gICAgICAgICAgICAgICAgICAgIHZhciBjaGlsZHJlbiA9IHBhcmVudC5jaGlsZHJlbigpO1xuICAgICAgICAgICAgICAgICAgICBpZiAoY2hpbGRyZW4ubGVuZ3RoID4gMCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICRhbmltYXRlLmVudGVyKGNoaWxkLCBwYXJlbnQsIGNoaWxkcmVuW2NoaWxkcmVuLmxlbmd0aCAtIDFdKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gJGFuaW1hdGUuZW50ZXIoY2hpbGQsIHBhcmVudCk7XG4gICAgICAgICAgICAgICAgfTtcblxuICAgICAgICAgICAgICAgIC8vICBDbG9zZSBhbGwgbW9kYWxzLCBwcm92aWRpbmcgdGhlIGdpdmVuIHJlc3VsdCB0byB0aGUgY2xvc2UgcHJvbWlzZS5cbiAgICAgICAgICAgICAgICBzZWxmLmNsb3NlTW9kYWxzID0gZnVuY3Rpb24gKHJlc3VsdCwgZGVsYXkpIHtcbiAgICAgICAgICAgICAgICAgICAgZGVsYXkgPSBkZWxheSB8fCBzZWxmLmNvbmZpZ09wdGlvbnMuY2xvc2VEZWxheTtcbiAgICAgICAgICAgICAgICAgICAgd2hpbGUgKHNlbGYub3Blbk1vZGFscy5sZW5ndGgpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHNlbGYub3Blbk1vZGFsc1swXS5jbG9zZShyZXN1bHQsIGRlbGF5KTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHNlbGYub3Blbk1vZGFscy5zcGxpY2UoMCwgMSk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9O1xuXG4gICAgICAgICAgICAgICAgc2VsZi5zaG93TW9kYWwgPSBmdW5jdGlvbiAob3B0aW9ucykge1xuXG4gICAgICAgICAgICAgICAgICAgIC8vICBHZXQgdGhlIGJvZHkgb2YgdGhlIGRvY3VtZW50LCB3ZSdsbCBhZGQgdGhlIG1vZGFsIHRvIHRoaXMuXG4gICAgICAgICAgICAgICAgICAgIHZhciBib2R5ID0gYW5ndWxhci5lbGVtZW50KCRkb2N1bWVudFswXS5ib2R5KTtcblxuICAgICAgICAgICAgICAgICAgICAvLyAgQ3JlYXRlIGEgZGVmZXJyZWQgd2UnbGwgcmVzb2x2ZSB3aGVuIHRoZSBtb2RhbCBpcyByZWFkeS5cbiAgICAgICAgICAgICAgICAgICAgdmFyIGRlZmVycmVkID0gJHEuZGVmZXIoKTtcblxuICAgICAgICAgICAgICAgICAgICAvLyAgVmFsaWRhdGUgdGhlIGlucHV0IHBhcmFtZXRlcnMuXG4gICAgICAgICAgICAgICAgICAgIHZhciBjb250cm9sbGVyTmFtZSA9IG9wdGlvbnMuY29udHJvbGxlcjtcbiAgICAgICAgICAgICAgICAgICAgaWYgKCFjb250cm9sbGVyTmFtZSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgZGVmZXJyZWQucmVqZWN0KFwiTm8gY29udHJvbGxlciBoYXMgYmVlbiBzcGVjaWZpZWQuXCIpO1xuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGRlZmVycmVkLnByb21pc2U7XG4gICAgICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgICAgICAvLyAgR2V0IHRoZSBhY3R1YWwgaHRtbCBvZiB0aGUgdGVtcGxhdGUuXG4gICAgICAgICAgICAgICAgICAgIGdldFRlbXBsYXRlKG9wdGlvbnMudGVtcGxhdGUsIG9wdGlvbnMudGVtcGxhdGVVcmwpXG4gICAgICAgICAgICAgICAgICAgICAgICAudGhlbihmdW5jdGlvbiAodGVtcGxhdGUpIHtcblxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vICBUaGUgbWFpbiBtb2RhbCBvYmplY3Qgd2Ugd2lsbCBidWlsZC5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgbW9kYWwgPSB7fTtcblxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vICBDcmVhdGUgYSBuZXcgc2NvcGUgZm9yIHRoZSBtb2RhbC5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgbW9kYWxTY29wZSA9IChvcHRpb25zLnNjb3BlIHx8ICRyb290U2NvcGUpLiRuZXcoKSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcm9vdFNjb3BlT25DbG9zZSA9IG51bGwsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxvY2F0aW9uQ2hhbmdlU3VjY2VzcyA9IG9wdGlvbnMubG9jYXRpb25DaGFuZ2VTdWNjZXNzO1xuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gIEFsbG93IGxvY2F0aW9uQ2hhbmdlU3VjY2VzcyBldmVudCByZWdpc3RyYXRpb24gdG8gYmUgY29uZmlndXJhYmxlLlxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vICBUcnVlIChkZWZhdWx0KSA9IGV2ZW50IHJlZ2lzdGVyZWQgd2l0aCBkZWZhdWx0Q2xvc2VEZWxheVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vICAjIChncmVhdGVyIHRoYW4gMCkgPSBldmVudCByZWdpc3RlcmVkIHdpdGggZGVsYXlcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyAgRmFsc2UgPSBkaXNhYmxlZFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChsb2NhdGlvbkNoYW5nZVN1Y2Nlc3MgPT09IGZhbHNlKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJvb3RTY29wZU9uQ2xvc2UgPSBhbmd1bGFyLm5vb3A7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsc2UgaWYgKGFuZ3VsYXIuaXNOdW1iZXIobG9jYXRpb25DaGFuZ2VTdWNjZXNzKSAmJiBsb2NhdGlvbkNoYW5nZVN1Y2Nlc3MgPj0gMCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAkdGltZW91dChmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByb290U2NvcGVPbkNsb3NlID0gJHJvb3RTY29wZS4kb24oJyRsb2NhdGlvbkNoYW5nZVN1Y2Nlc3MnLCBjbGVhblVwQ2xvc2UpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LCBsb2NhdGlvbkNoYW5nZVN1Y2Nlc3MpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgJHRpbWVvdXQoZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcm9vdFNjb3BlT25DbG9zZSA9ICRyb290U2NvcGUuJG9uKCckbG9jYXRpb25DaGFuZ2VTdWNjZXNzJywgY2xlYW5VcENsb3NlKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSwgc2VsZi5jb25maWdPcHRpb25zLmNsb3NlRGVsYXkpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cblxuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gIENyZWF0ZSB0aGUgaW5wdXRzIG9iamVjdCB0byB0aGUgY29udHJvbGxlciAtIHRoaXMgd2lsbCBpbmNsdWRlXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gIHRoZSBzY29wZSwgYXMgd2VsbCBhcyBhbGwgaW5wdXRzIHByb3ZpZGVkLlxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vICBXZSB3aWxsIGFsc28gY3JlYXRlIGEgZGVmZXJyZWQgdGhhdCBpcyByZXNvbHZlZCB3aXRoIGEgcHJvdmlkZWRcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyAgY2xvc2UgZnVuY3Rpb24uIFRoZSBjb250cm9sbGVyIGNhbiB0aGVuIGNhbGwgJ2Nsb3NlKHJlc3VsdCknLlxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vICBUaGUgY29udHJvbGxlciBjYW4gYWxzbyBwcm92aWRlIGEgZGVsYXkgZm9yIGNsb3NpbmcgLSB0aGlzIGlzXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gIGhlbHBmdWwgaWYgdGhlcmUgYXJlIGNsb3NpbmcgYW5pbWF0aW9ucyB3aGljaCBtdXN0IGZpbmlzaCBmaXJzdC5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgY2xvc2VEZWZlcnJlZCA9ICRxLmRlZmVyKCk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGNsb3NlZERlZmVycmVkID0gJHEuZGVmZXIoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgaGFzQWxyZWFkeUJlZW5DbG9zZWQgPSBmYWxzZTtcblxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBpbnB1dHMgPSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICRzY29wZTogbW9kYWxTY29wZSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvc2U6IGZ1bmN0aW9uIChyZXN1bHQsIGRlbGF5KSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWxheSA9IGRlbGF5IHx8IHNlbGYuY29uZmlnT3B0aW9ucy5jbG9zZURlbGF5O1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gIElmIHdlIGhhdmUgYSBwcmUtY2xvc2UgZnVuY3Rpb24sIGNhbGwgaXQuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIG9wdGlvbnMucHJlQ2xvc2UgPT09ICdmdW5jdGlvbicpIG9wdGlvbnMucHJlQ2xvc2UobW9kYWwsIHJlc3VsdCwgZGVsYXkpO1xuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZGVsYXkgPT09IHVuZGVmaW5lZCB8fCBkZWxheSA9PT0gbnVsbCkgZGVsYXkgPSAwO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGhhc0FscmVhZHlCZWVuQ2xvc2VkKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaGFzQWxyZWFkeUJlZW5DbG9zZWQgPSB0cnVlO1xuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAkdGltZW91dChmdW5jdGlvbiAoKSB7XG5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbGVhblVwQ2xvc2UocmVzdWx0KTtcblxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSwgZGVsYXkpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfTtcblxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vICBJZiB3ZSBoYXZlIHByb3ZpZGVkIGFueSBpbnB1dHMsIHBhc3MgdGhlbSB0byB0aGUgY29udHJvbGxlci5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAob3B0aW9ucy5pbnB1dHMpIGFuZ3VsYXIuZXh0ZW5kKGlucHV0cywgb3B0aW9ucy5pbnB1dHMpO1xuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gIENvbXBpbGUgdGhlbiBsaW5rIHRoZSB0ZW1wbGF0ZSBlbGVtZW50LCBidWlsZGluZyB0aGUgYWN0dWFsIGVsZW1lbnQuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gIFNldCB0aGUgJGVsZW1lbnQgb24gdGhlIGlucHV0cyBzbyB0aGF0IGl0IGNhbiBiZSBpbmplY3RlZCBpZiByZXF1aXJlZC5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgbGlua0ZuID0gJGNvbXBpbGUodGVtcGxhdGUpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBtb2RhbEVsZW1lbnQgPSBsaW5rRm4obW9kYWxTY29wZSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaW5wdXRzLiRlbGVtZW50ID0gbW9kYWxFbGVtZW50O1xuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gIENyZWF0ZSB0aGUgY29udHJvbGxlciwgZXhwbGljaXRseSBzcGVjaWZ5aW5nIHRoZSBzY29wZSB0byB1c2UuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGNvbnRyb2xsZXJPYmpCZWZvcmUgPSBtb2RhbFNjb3BlW29wdGlvbnMuY29udHJvbGxlckFzXTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgbW9kYWxDb250cm9sbGVyID0gJGNvbnRyb2xsZXIob3B0aW9ucy5jb250cm9sbGVyLCBpbnB1dHMsIGZhbHNlLCBvcHRpb25zLmNvbnRyb2xsZXJBcyk7XG5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAob3B0aW9ucy5jb250cm9sbGVyQXMgJiYgY29udHJvbGxlck9iakJlZm9yZSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbmd1bGFyLmV4dGVuZChtb2RhbENvbnRyb2xsZXIsIGNvbnRyb2xsZXJPYmpCZWZvcmUpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vICBUaGVuLCBhcHBlbmQgdGhlIG1vZGFsIHRvIHRoZSBkb20uXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGFwcGVuZFRhcmdldCA9IGJvZHk7IC8vIGFwcGVuZCB0byBib2R5IHdoZW4gbm8gY3VzdG9tIGFwcGVuZCBlbGVtZW50IGlzIHNwZWNpZmllZFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChhbmd1bGFyLmlzU3RyaW5nKG9wdGlvbnMuYXBwZW5kRWxlbWVudCkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gcXVlcnkgdGhlIGRvY3VtZW50IGZvciB0aGUgZmlyc3QgZWxlbWVudCB0aGF0IG1hdGNoZXMgdGhlIHNlbGVjdG9yXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gYW5kIGNyZWF0ZSBhbiBhbmd1bGFyIGVsZW1lbnQgb3V0IG9mIGl0LlxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhcHBlbmRUYXJnZXQgPSBhbmd1bGFyLmVsZW1lbnQoJGRvY3VtZW50WzBdLnF1ZXJ5U2VsZWN0b3Iob3B0aW9ucy5hcHBlbmRFbGVtZW50KSk7XG5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKG9wdGlvbnMuYXBwZW5kRWxlbWVudCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBhcHBlbmQgdG8gY3VzdG9tIGFwcGVuZCBlbGVtZW50XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFwcGVuZFRhcmdldCA9IG9wdGlvbnMuYXBwZW5kRWxlbWVudDtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhcHBlbmRDaGlsZChhcHBlbmRUYXJnZXQsIG1vZGFsRWxlbWVudCk7XG5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBGaW5hbGx5LCBhcHBlbmQgYW55IGN1c3RvbSBjbGFzc2VzIHRvIHRoZSBib2R5XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG9wdGlvbnMuYm9keUNsYXNzKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJvZHlbMF0uY2xhc3NMaXN0LmFkZChvcHRpb25zLmJvZHlDbGFzcyk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gIFBvcHVsYXRlIHRoZSBtb2RhbCBvYmplY3QuLi5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtb2RhbC5jb250cm9sbGVyID0gbW9kYWxDb250cm9sbGVyO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1vZGFsLnNjb3BlID0gbW9kYWxTY29wZTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtb2RhbC5lbGVtZW50ID0gbW9kYWxFbGVtZW50O1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1vZGFsLmNsb3NlID0gY2xvc2VEZWZlcnJlZC5wcm9taXNlO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1vZGFsLmNsb3NlZCA9IGNsb3NlZERlZmVycmVkLnByb21pc2U7XG5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyAkb25Jbml0IGlzIHBhcnQgb2YgdGhlIGNvbXBvbmVudCBsaWZlY3ljbGUgaW50cm9kdWNlZCBpbiBBbmd1bGFySlMgMS42LnhcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBCZWNhdXNlIGl0IG1heSBub3QgYmUgZGVmaW5lZCBvbiBhbGwgY29udHJvbGxlcnMsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gd2UgbXVzdCBjaGVjayBmb3IgaXQgYmVmb3JlIGF0dGVtcHRpbmcgdG8gaW52b2tlIGl0LlxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIGh0dHBzOi8vZG9jcy5hbmd1bGFyanMub3JnL2d1aWRlL2NvbXBvbmVudCNjb21wb25lbnQtYmFzZWQtYXBwbGljYXRpb24tYXJjaGl0ZWN0dXJlXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGFuZ3VsYXIuaXNGdW5jdGlvbihtb2RhbC5jb250cm9sbGVyLiRvbkluaXQpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1vZGFsLmNvbnRyb2xsZXIuJG9uSW5pdCgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vICAuLi53aGljaCBpcyBwYXNzZWQgdG8gdGhlIGNhbGxlciB2aWEgdGhlIHByb21pc2UuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVmZXJyZWQucmVzb2x2ZShtb2RhbCk7XG5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBDbGVhciBwcmV2aW91cyBpbnB1dCBmb2N1cyB0byBhdm9pZCBvcGVuIG11bHRpcGxlIG1vZGFscyBvbiBlbnRlclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvY3VtZW50LmFjdGl2ZUVsZW1lbnQuYmx1cigpO1xuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gIFdlIGNhbiB0cmFjayB0aGlzIG1vZGFsIGluIG91ciBvcGVuIG1vZGFscy5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxmLm9wZW5Nb2RhbHMucHVzaCh7bW9kYWw6IG1vZGFsLCBjbG9zZTogaW5wdXRzLmNsb3NlfSk7XG5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmdW5jdGlvbiBjbGVhblVwQ2xvc2UocmVzdWx0KSB7XG5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gIFJlc29sdmUgdGhlICdjbG9zZScgcHJvbWlzZS5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvc2VEZWZlcnJlZC5yZXNvbHZlKHJlc3VsdCk7XG5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gIFJlbW92ZSB0aGUgY3VzdG9tIGNsYXNzIGZyb20gdGhlIGJvZHlcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG9wdGlvbnMuYm9keUNsYXNzKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBib2R5WzBdLmNsYXNzTGlzdC5yZW1vdmUob3B0aW9ucy5ib2R5Q2xhc3MpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gIExldCBhbmd1bGFyIHJlbW92ZSB0aGUgZWxlbWVudCBhbmQgd2FpdCBmb3IgYW5pbWF0aW9ucyB0byBmaW5pc2guXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICRhbmltYXRlLmxlYXZlKG1vZGFsRWxlbWVudClcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC50aGVuKGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBwcmV2ZW50IGVycm9yIGlmIG1vZGFsIGlzIGFscmVhZHkgZGVzdHJveWVkXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFtb2RhbEVsZW1lbnQpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vICBSZXNvbHZlIHRoZSAnY2xvc2VkJyBwcm9taXNlLlxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsb3NlZERlZmVycmVkLnJlc29sdmUocmVzdWx0KTtcblxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vICBXZSBjYW4gbm93IGNsZWFuIHVwIHRoZSBzY29wZVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1vZGFsU2NvcGUuJGRlc3Ryb3koKTtcblxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vICBSZW1vdmUgdGhlIG1vZGFsIGZyb20gdGhlIHNldCBvZiBvcGVuIG1vZGFscy5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKHZhciBpID0gMDsgaSA8IHNlbGYub3Blbk1vZGFscy5sZW5ndGg7IGkrKykge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoc2VsZi5vcGVuTW9kYWxzW2ldLm1vZGFsID09PSBtb2RhbCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VsZi5vcGVuTW9kYWxzLnNwbGljZShpLCAxKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gIFVubGVzcyB3ZSBudWxsIG91dCBhbGwgb2YgdGhlc2Ugb2JqZWN0cyB3ZSBzZWVtIHRvIHN1ZmZlclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vICBmcm9tIG1lbW9yeSBsZWFrcywgaWYgYW55b25lIGNhbiBleHBsYWluIHdoeSB0aGVuIEknZFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vICBiZSB2ZXJ5IGludGVyZXN0ZWQgdG8ga25vdy5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnB1dHMuY2xvc2UgPSBudWxsO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlZmVycmVkID0gbnVsbDtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9zZURlZmVycmVkID0gbnVsbDtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtb2RhbCA9IG51bGw7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW5wdXRzID0gbnVsbDtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtb2RhbEVsZW1lbnQgPSBudWxsO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1vZGFsU2NvcGUgPSBudWxsO1xuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gcmVtb3ZlIGV2ZW50IHdhdGNoZXJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcm9vdFNjb3BlT25DbG9zZSAmJiByb290U2NvcGVPbkNsb3NlKCk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgICAgICAgICB9KVxuICAgICAgICAgICAgICAgICAgICAgICAgLnRoZW4obnVsbCwgZnVuY3Rpb24gKGVycm9yKSB7IC8vICdjYXRjaCcgZG9lc24ndCB3b3JrIGluIElFOC5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZlcnJlZC5yZWplY3QoZXJyb3IpO1xuICAgICAgICAgICAgICAgICAgICAgICAgfSk7XG5cbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGRlZmVycmVkLnByb21pc2U7XG4gICAgICAgICAgICAgICAgfTtcblxuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICByZXR1cm4gbmV3IE1vZGFsU2VydmljZShfb3B0aW9ucyk7XG4gICAgICAgIH1dO1xuICAgIH0pO1xuIl0sInNvdXJjZVJvb3QiOiIifQ== |
@@ -1,1 +0,1 @@ | ||
!function(o){var t={};function r(e){if(t[e])return t[e].exports;var n=t[e]={i:e,l:!1,exports:{}};return o[e].call(n.exports,n,n.exports,r),n.l=!0,n.exports}r.m=o,r.c=t,r.d=function(e,n,o){r.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:o})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(n,e){if(1&e&&(n=r(n)),8&e)return n;if(4&e&&"object"==typeof n&&n&&n.__esModule)return n;var o=Object.create(null);if(r.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:n}),2&e&&"string"!=typeof n)for(var t in n)r.d(o,t,function(e){return n[e]}.bind(null,t));return o},r.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(n,"a",n),n},r.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},r.p="",r(r.s=0)}([function(e,n,o){"use strict";angular.module("angularModalService",[]).factory("ModalService",["$animate","$document","$compile","$controller","$http","$rootScope","$q","$templateRequest","$timeout",function(y,t,h,$,e,M,j,r,S){return new function(){var b=this;b.openModals=[];var g=function(e,n){var o=e.children();return 0<o.length?y.enter(n,e,o[o.length-1]):y.enter(n,e)};b.closeModals=function(e,n){for(;b.openModals.length;)b.openModals[0].close(e,n),b.openModals.splice(0,1)},b.showModal=function(f){var e,n,o,m=angular.element(t[0].body),v=j.defer();return f.controller?(e=f.template,n=f.templateUrl,o=j.defer(),e?o.resolve(e):n?r(n,!0).then(function(e){o.resolve(e)},function(e){o.reject(e)}):o.reject("No template or templateUrl has been specified."),o.promise).then(function(e){var o={},t=(f.scope||M).$new(),r=null,n=f.locationChangeSuccess;!1===n?r=angular.noop:angular.isNumber(n)&&0<=n?S(function(){r=M.$on("$locationChangeSuccess",d)},n):r=M.$on("$locationChangeSuccess",d);var l=j.defer(),c=j.defer(),a=!1,s={$scope:t,close:function(e,n){"function"==typeof f.preClose&&f.preClose(o,e,n),null!=n||(n=0),a||(a=!0,S(function(){d(e)},n))}};f.inputs&&angular.extend(s,f.inputs);var u=h(e)(t);s.$element=u;var i=t[f.controllerAs],p=$(f.controller,s,!1,f.controllerAs);function d(n){l.resolve(n),f.bodyClass&&m[0].classList.remove(f.bodyClass),y.leave(u).then(function(){if(u){c.resolve(n),t.$destroy();for(var e=0;e<b.openModals.length;e++)if(b.openModals[e].modal===o){b.openModals.splice(e,1);break}s.close=null,t=u=s=o=l=v=null}}),r&&r()}f.controllerAs&&i&&angular.extend(p,i),f.appendElement?g(f.appendElement,u):g(m,u),f.bodyClass&&m[0].classList.add(f.bodyClass),o.controller=p,o.scope=t,o.element=u,o.close=l.promise,o.closed=c.promise,v.resolve(o),document.activeElement.blur(),b.openModals.push({modal:o,close:s.close})}).then(null,function(e){v.reject(e)}):v.reject("No controller has been specified."),v.promise}}}])}]); | ||
!function(o){var t={};function l(e){if(t[e])return t[e].exports;var n=t[e]={i:e,l:!1,exports:{}};return o[e].call(n.exports,n,n.exports,l),n.l=!0,n.exports}l.m=o,l.c=t,l.d=function(e,n,o){l.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:o})},l.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},l.t=function(n,e){if(1&e&&(n=l(n)),8&e)return n;if(4&e&&"object"==typeof n&&n&&n.__esModule)return n;var o=Object.create(null);if(l.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:n}),2&e&&"string"!=typeof n)for(var t in n)l.d(o,t,function(e){return n[e]}.bind(null,t));return o},l.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return l.d(n,"a",n),n},l.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},l.p="",l(l.s=0)}([function(e,n,o){"use strict";angular.module("angularModalService",[]).provider("ModalService",function(){var n={closeDelay:0};this.configureOptions=function(e){angular.extend(n,e)},this.$get=["$animate","$document","$compile","$controller","$http","$rootScope","$q","$templateRequest","$timeout",function(M,S,O,j,e,C,x,t,_){return new function(e){var $=this;$.configOptions=e,$.openModals=[],$.closeModals=function(e,n){for(n=n||$.configOptions.closeDelay;$.openModals.length;)$.openModals[0].close(e,n),$.openModals.splice(0,1)},$.showModal=function(y){var e,n,o,b=angular.element(S[0].body),h=x.defer();return y.controller?(e=y.template,n=y.templateUrl,o=x.defer(),e?o.resolve(e):n?t(n,!0).then(function(e){o.resolve(e)},function(e){o.reject(e)}):o.reject("No template or templateUrl has been specified."),o.promise).then(function(e){var o={},t=(y.scope||C).$new(),l=null,n=y.locationChangeSuccess;!1===n?l=angular.noop:angular.isNumber(n)&&0<=n?_(function(){l=C.$on("$locationChangeSuccess",v)},n):_(function(){l=C.$on("$locationChangeSuccess",v)},$.configOptions.closeDelay);var r=x.defer(),c=x.defer(),a=!1,s={$scope:t,close:function(e,n){n=n||$.configOptions.closeDelay,"function"==typeof y.preClose&&y.preClose(o,e,n),null!=n||(n=0),a||(a=!0,_(function(){v(e)},n))}};y.inputs&&angular.extend(s,y.inputs);var i=O(e)(t);s.$element=i;var u=t[y.controllerAs],p=j(y.controller,s,!1,y.controllerAs);y.controllerAs&&u&&angular.extend(p,u);var f,d,m,g=b;function v(n){r.resolve(n),y.bodyClass&&b[0].classList.remove(y.bodyClass),M.leave(i).then(function(){if(i){c.resolve(n),t.$destroy();for(var e=0;e<$.openModals.length;e++)if($.openModals[e].modal===o){$.openModals.splice(e,1);break}s.close=null,t=i=s=o=r=h=null}}),l&&l()}angular.isString(y.appendElement)?g=angular.element(S[0].querySelector(y.appendElement)):y.appendElement&&(g=y.appendElement),d=i,0<(m=(f=g).children()).length?M.enter(d,f,m[m.length-1]):M.enter(d,f),y.bodyClass&&b[0].classList.add(y.bodyClass),o.controller=p,o.scope=t,o.element=i,o.close=r.promise,o.closed=c.promise,angular.isFunction(o.controller.$onInit)&&o.controller.$onInit(),h.resolve(o),document.activeElement.blur(),$.openModals.push({modal:o,close:s.close})}).then(null,function(e){h.reject(e)}):h.reject("No controller has been specified."),h.promise}}(n)}]})}]); |
{ | ||
"name": "angular-modal-service", | ||
"version": "0.14.2", | ||
"version": "0.15.1", | ||
"description": "AngularJS Service for showing Modals and Popups", | ||
@@ -36,3 +36,3 @@ "main": "./index.js", | ||
"istanbul-instrumenter-loader": "^3.0.1", | ||
"karma": "^2.0.5", | ||
"karma": "^3.1.0", | ||
"karma-chai": "^0.1.0", | ||
@@ -39,0 +39,0 @@ "karma-chrome-launcher": "^2.2.0", |
@@ -11,8 +11,21 @@ # angular-modal-service | ||
1. [Usage](#usage) | ||
2. [Developing](#developing) | ||
3. [Tests](#tests) | ||
4. [FAQ & Troubleshooting](#faq) | ||
5. [Thanks](#thanks) | ||
<!-- vim-markdown-toc GFM --> | ||
* [Usage](#usage) | ||
* [ShowModal Options](#showmodal-options) | ||
* [The Modal Object](#the-modal-object) | ||
* [The Modal Controller](#the-modal-controller) | ||
* [Closing All Modals](#closing-all-modals) | ||
* [Animation](#animation) | ||
* [Error Handing](#error-handing) | ||
* [Global Options Configuration](#global-options-configuration) | ||
* [Developing](#developing) | ||
* [Tests](#tests) | ||
* [Releasing](#releasing) | ||
* [FAQ](#faq) | ||
* [Thanks](#thanks) | ||
<!-- vim-markdown-toc --> | ||
## Usage | ||
@@ -91,3 +104,3 @@ | ||
DOM element. This is so that you can have a delay before destroying the DOM element if you | ||
are animating the closure. | ||
are animating the closure. See [Global Config](#global-options-configuration) for setting a default delay. | ||
@@ -131,5 +144,7 @@ Now just make sure the `close` function is called by your modal controller when the modal | ||
}) | ||
``` | ||
#### ShowModal Options | ||
### ShowModal Options | ||
The `showModal` function takes an object with these fields: | ||
@@ -144,3 +159,3 @@ | ||
is injected into the controller constructor. | ||
* `appendElement`: The custom angular element to append the modal to instead of default `body` element. | ||
* `appendElement`: The custom angular element or selector (such as `#element-id`) to append the modal to instead of default `body` element. | ||
* `scope`: Optional. If provided, the modal controller will use a new scope as a child of `scope` (created by calling `scope.$new()`) rather than a new scope created as a child of `$rootScope`. | ||
@@ -151,3 +166,3 @@ * `bodyClass`: Optional. The custom css class to append to the body while the modal is open (optional, useful when not using Bootstrap). | ||
#### The Modal Object | ||
### The Modal Object | ||
@@ -164,3 +179,3 @@ The `modal` object returned by `showModal` has this structure: | ||
#### The Modal Controller | ||
### The Modal Controller | ||
@@ -224,2 +239,17 @@ The controller that is used for the modal always has one extra parameter injected, a function | ||
### Global Options Configuration | ||
To configure the default options that will apply to all modals call `configureOptions` on the `ModalServiceProvider`. | ||
```js | ||
app.config(["ModalServiceProvider", function(ModalServiceProvider) { | ||
ModalServiceProvider.configureOptions({closeDelay:500}); | ||
}]); | ||
``` | ||
Here are the available global options: | ||
* `closeDelay` - This sets the default number of milliseconds to use in the close handler. This delay will also be used in the `closeModals` method and as the default for `locationChangeSuccess`. | ||
## Developing | ||
@@ -270,3 +300,3 @@ | ||
#### I'm using a Bootstrap Modal and the backdrop doesn't fade away | ||
**I'm using a Bootstrap Modal and the backdrop doesn't fade away** | ||
@@ -293,3 +323,3 @@ This can happen if your modal template contains more than one top level element. | ||
#### The backdrop STILL does not fade away after I call `close` OR I don't want to use the 'data-dismiss' attribute on a button, how can I close a modal manually? | ||
**The backdrop STILL does not fade away after I call `close` OR I don't want to use the 'data-dismiss' attribute on a button, how can I close a modal manually?** | ||
@@ -328,3 +358,3 @@ You can check the 'Complex' sample ([complexcontroller.js](samples/complex/complexcontroller.js)). The 'Cancel' button closes without using the `data-dismiss` attribute. In this case, just use the `preClose` option to ensure the bootstrap modal is removed: | ||
#### I'm using a Bootstrap Modal and the dialog doesn't show up | ||
**I'm using a Bootstrap Modal and the dialog doesn't show up** | ||
@@ -339,3 +369,3 @@ Code is entered exactly as shown the example but when the showAModal() function fires the modal template html is appended to the body while the console outputs: | ||
#### How can I prevent a Bootstrap modal from being closed? | ||
**How can I prevent a Bootstrap modal from being closed?** | ||
@@ -367,3 +397,3 @@ If you are using a bootstrap modal and want to make sure that only the `close` function will close the modal (not a click outside or escape), use the following attributes: | ||
#### Problems with Nested Modals | ||
**Problems with Nested Modals** | ||
@@ -391,1 +421,2 @@ If you are trying to nest Bootstrap modals, you will run into issues. From Bootstrap: | ||
* [stormpooper](https://github.com/StormPooper) - The new `bodyClass` feature. | ||
* [decherneyge](https://github.com/decherneyge) - Provider features, global configuration, `appendElement` improvements. |
var app = angular.module('sampleapp'); | ||
app.controller('ComplexController', [ | ||
'$scope', '$element', 'title', 'close', | ||
function($scope, $element, title, close) { | ||
'$scope', '$element', 'title', 'close', | ||
function ($scope, $element, title, close) { | ||
$scope.name = null; | ||
$scope.age = null; | ||
$scope.title = title; | ||
// This close function doesn't need to use jQuery or bootstrap, because | ||
// the button has the 'data-dismiss' attribute. | ||
$scope.close = function() { | ||
close({ | ||
name: $scope.name, | ||
age: $scope.age | ||
}, 500); // close, but give 500ms for bootstrap to animate | ||
}; | ||
$scope.name = null; | ||
$scope.age = null; | ||
$scope.title = title; | ||
// This cancel function must use the bootstrap, 'modal' function because | ||
// the doesn't have the 'data-dismiss' attribute. | ||
$scope.cancel = function() { | ||
$scope.wasClosed = false; | ||
// Manually hide the modal. | ||
$element.modal('hide'); | ||
// Now call close, returning control to the caller. | ||
close({ | ||
name: $scope.name, | ||
age: $scope.age | ||
}, 500); // close, but give 500ms for bootstrap to animate | ||
}; | ||
// This close function doesn't need to use jQuery or bootstrap, because | ||
// the button has the 'data-dismiss' attribute. | ||
$scope.close = function () { | ||
}]); | ||
//mark the modal as handled | ||
$scope.wasClosed = true; | ||
close({ | ||
name: $scope.name, | ||
age: $scope.age, | ||
source: 'Ok\'ed' | ||
}, 500); // close, but give 500ms for bootstrap to animate | ||
}; | ||
// This cancel function must use the bootstrap, 'modal' function because | ||
// the doesn't have the 'data-dismiss' attribute. | ||
$scope.cancel = function () { | ||
//mark the modal as handled | ||
$scope.wasClosed = true; | ||
// Manually hide the modal. | ||
$element.modal('hide'); | ||
// Now call close, returning control to the caller. | ||
close({ | ||
name: $scope.name, | ||
age: $scope.age, | ||
source: 'Cancelled' | ||
}, 500); // close, but give 500ms for bootstrap to animate | ||
}; | ||
// The abort function doesn't need to use jQuery or bootstrap, because | ||
// the backdrop click already dismisses the modal and the X has the 'data-dismiss' attribute. | ||
$scope.abort = function () { | ||
//mark the modal as handled | ||
$scope.wasClosed = true; | ||
close({ | ||
name: $scope.name, | ||
age: $scope.age, | ||
source: 'Aborted' | ||
}, 500); // close, but give 500ms for bootstrap to animate | ||
}; | ||
var backgroundClickHandler = function (e) { | ||
//if the modal was already closed short circuit | ||
if ($scope.wasClosed) return; | ||
//call the close functionality | ||
$scope.abort(); | ||
//remove the listener | ||
$element.off('hidden.bs.modal', backgroundClickHandler); | ||
}; | ||
//listen for when the modal is dismissed and close it | ||
$element.on('hidden.bs.modal', backgroundClickHandler); | ||
}]); |
// Build our app module, with a dependency on the angular modal service. | ||
var app = angular.module('sampleapp', ['angularModalService', 'ngAnimate']); | ||
app.config(["ModalServiceProvider", function(ModalServiceProvider) { | ||
//uncomment this line to set a default close delay | ||
//ModalServiceProvider.configureOptions({closeDelay:500}); | ||
}]); | ||
app.controller('SampleController', ['$scope', 'ModalService', function($scope, ModalService) { | ||
@@ -36,2 +42,3 @@ | ||
modal.element.modal(); | ||
modal.close.then(function(result) { | ||
@@ -41,3 +48,3 @@ if (!result) { | ||
} else { | ||
$scope.complexResult = "Name: " + result.name + ", age: " + result.age; | ||
$scope.complexResult = "Name: " + result.name + ", age: " + result.age + ", source: " + result.source; | ||
} | ||
@@ -44,0 +51,0 @@ }); |
@@ -5,233 +5,260 @@ 'use strict'; | ||
module.factory('ModalService', ['$animate', '$document', '$compile', '$controller', '$http', '$rootScope', '$q', '$templateRequest', '$timeout', | ||
function($animate, $document, $compile, $controller, $http, $rootScope, $q, $templateRequest, $timeout) { | ||
module.provider('ModalService', function ModalServiceProvider() { | ||
var _options = { | ||
closeDelay: 0 | ||
}; | ||
function ModalService() { | ||
this.configureOptions = function (config) { | ||
angular.extend(_options, config); | ||
}; | ||
this.$get = ['$animate', '$document', '$compile', '$controller', '$http', '$rootScope', '$q', '$templateRequest', '$timeout', | ||
function ($animate, $document, $compile, $controller, $http, $rootScope, $q, $templateRequest, $timeout) { | ||
var self = this; | ||
function ModalService(configOptions) { | ||
// Track open modals. | ||
self.openModals = []; | ||
var self = this; | ||
// Returns a promise which gets the template, either | ||
// from the template parameter or via a request to the | ||
// template url parameter. | ||
var getTemplate = function(template, templateUrl) { | ||
var deferred = $q.defer(); | ||
if (template) { | ||
deferred.resolve(template); | ||
} else if (templateUrl) { | ||
$templateRequest(templateUrl, true) | ||
.then(function(template) { | ||
deferred.resolve(template); | ||
}, function(error) { | ||
deferred.reject(error); | ||
}); | ||
} else { | ||
deferred.reject("No template or templateUrl has been specified."); | ||
} | ||
return deferred.promise; | ||
}; | ||
//stash configOptions | ||
self.configOptions = configOptions; | ||
// Adds an element to the DOM as the last child of its container | ||
// like append, but uses $animate to handle animations. Returns a | ||
// promise that is resolved once all animation is complete. | ||
var appendChild = function(parent, child) { | ||
var children = parent.children(); | ||
if (children.length > 0) { | ||
return $animate.enter(child, parent, children[children.length - 1]); | ||
} | ||
return $animate.enter(child, parent); | ||
}; | ||
// Track open modals. | ||
self.openModals = []; | ||
// Close all modals, providing the given result to the close promise. | ||
self.closeModals = function(result, delay) { | ||
while (self.openModals.length) { | ||
self.openModals[0].close(result, delay); | ||
self.openModals.splice(0, 1); | ||
} | ||
}; | ||
// Returns a promise which gets the template, either | ||
// from the template parameter or via a request to the | ||
// template url parameter. | ||
var getTemplate = function (template, templateUrl) { | ||
var deferred = $q.defer(); | ||
if (template) { | ||
deferred.resolve(template); | ||
} else if (templateUrl) { | ||
$templateRequest(templateUrl, true) | ||
.then(function (template) { | ||
deferred.resolve(template); | ||
}, function (error) { | ||
deferred.reject(error); | ||
}); | ||
} else { | ||
deferred.reject("No template or templateUrl has been specified."); | ||
} | ||
return deferred.promise; | ||
}; | ||
self.showModal = function(options) { | ||
// Adds an element to the DOM as the last child of its container | ||
// like append, but uses $animate to handle animations. Returns a | ||
// promise that is resolved once all animation is complete. | ||
var appendChild = function (parent, child) { | ||
var children = parent.children(); | ||
if (children.length > 0) { | ||
return $animate.enter(child, parent, children[children.length - 1]); | ||
} | ||
return $animate.enter(child, parent); | ||
}; | ||
// Get the body of the document, we'll add the modal to this. | ||
var body = angular.element($document[0].body); | ||
// Close all modals, providing the given result to the close promise. | ||
self.closeModals = function (result, delay) { | ||
delay = delay || self.configOptions.closeDelay; | ||
while (self.openModals.length) { | ||
self.openModals[0].close(result, delay); | ||
self.openModals.splice(0, 1); | ||
} | ||
}; | ||
// Create a deferred we'll resolve when the modal is ready. | ||
var deferred = $q.defer(); | ||
self.showModal = function (options) { | ||
// Validate the input parameters. | ||
var controllerName = options.controller; | ||
if (!controllerName) { | ||
deferred.reject("No controller has been specified."); | ||
return deferred.promise; | ||
} | ||
// Get the body of the document, we'll add the modal to this. | ||
var body = angular.element($document[0].body); | ||
// Get the actual html of the template. | ||
getTemplate(options.template, options.templateUrl) | ||
.then(function(template) { | ||
// Create a deferred we'll resolve when the modal is ready. | ||
var deferred = $q.defer(); | ||
// The main modal object we will build. | ||
var modal = {}; | ||
// Validate the input parameters. | ||
var controllerName = options.controller; | ||
if (!controllerName) { | ||
deferred.reject("No controller has been specified."); | ||
return deferred.promise; | ||
} | ||
// Create a new scope for the modal. | ||
var modalScope = (options.scope || $rootScope).$new(), | ||
rootScopeOnClose = null, | ||
locationChangeSuccess = options.locationChangeSuccess; | ||
// Get the actual html of the template. | ||
getTemplate(options.template, options.templateUrl) | ||
.then(function (template) { | ||
// Allow locationChangeSuccess event registration to be configurable. | ||
// True (default) = event registered immediately | ||
// # (greater than 0) = event registered with delay | ||
// False = disabled | ||
if (locationChangeSuccess === false){ | ||
rootScopeOnClose = angular.noop; | ||
} | ||
else if (angular.isNumber(locationChangeSuccess) && locationChangeSuccess >= 0) { | ||
$timeout(function() { | ||
rootScopeOnClose = $rootScope.$on('$locationChangeSuccess', cleanUpClose); | ||
}, locationChangeSuccess); | ||
} | ||
else { | ||
rootScopeOnClose = $rootScope.$on('$locationChangeSuccess', cleanUpClose); | ||
} | ||
// The main modal object we will build. | ||
var modal = {}; | ||
// Create a new scope for the modal. | ||
var modalScope = (options.scope || $rootScope).$new(), | ||
rootScopeOnClose = null, | ||
locationChangeSuccess = options.locationChangeSuccess; | ||
// Allow locationChangeSuccess event registration to be configurable. | ||
// True (default) = event registered with defaultCloseDelay | ||
// # (greater than 0) = event registered with delay | ||
// False = disabled | ||
if (locationChangeSuccess === false) { | ||
rootScopeOnClose = angular.noop; | ||
} | ||
else if (angular.isNumber(locationChangeSuccess) && locationChangeSuccess >= 0) { | ||
$timeout(function () { | ||
rootScopeOnClose = $rootScope.$on('$locationChangeSuccess', cleanUpClose); | ||
}, locationChangeSuccess); | ||
} | ||
else { | ||
$timeout(function () { | ||
rootScopeOnClose = $rootScope.$on('$locationChangeSuccess', cleanUpClose); | ||
}, self.configOptions.closeDelay); | ||
} | ||
// Create the inputs object to the controller - this will include | ||
// the scope, as well as all inputs provided. | ||
// We will also create a deferred that is resolved with a provided | ||
// close function. The controller can then call 'close(result)'. | ||
// The controller can also provide a delay for closing - this is | ||
// helpful if there are closing animations which must finish first. | ||
var closeDeferred = $q.defer(); | ||
var closedDeferred = $q.defer(); | ||
var hasAlreadyBeenClosed = false; | ||
// Create the inputs object to the controller - this will include | ||
// the scope, as well as all inputs provided. | ||
// We will also create a deferred that is resolved with a provided | ||
// close function. The controller can then call 'close(result)'. | ||
// The controller can also provide a delay for closing - this is | ||
// helpful if there are closing animations which must finish first. | ||
var closeDeferred = $q.defer(); | ||
var closedDeferred = $q.defer(); | ||
var hasAlreadyBeenClosed = false; | ||
var inputs = { | ||
$scope: modalScope, | ||
close: function(result, delay) { | ||
// If we have a pre-close function, call it. | ||
if (typeof options.preClose === 'function') options.preClose(modal, result, delay); | ||
var inputs = { | ||
$scope: modalScope, | ||
close: function (result, delay) { | ||
delay = delay || self.configOptions.closeDelay; | ||
// If we have a pre-close function, call it. | ||
if (typeof options.preClose === 'function') options.preClose(modal, result, delay); | ||
if (delay === undefined || delay === null) delay = 0; | ||
if (hasAlreadyBeenClosed) { | ||
return; | ||
} | ||
hasAlreadyBeenClosed = true; | ||
if (delay === undefined || delay === null) delay = 0; | ||
if (hasAlreadyBeenClosed) { | ||
return; | ||
} | ||
hasAlreadyBeenClosed = true; | ||
$timeout(function() { | ||
$timeout(function () { | ||
cleanUpClose(result); | ||
cleanUpClose(result); | ||
}, delay); | ||
} | ||
}; | ||
}, delay); | ||
} | ||
}; | ||
// If we have provided any inputs, pass them to the controller. | ||
if (options.inputs) angular.extend(inputs, options.inputs); | ||
// If we have provided any inputs, pass them to the controller. | ||
if (options.inputs) angular.extend(inputs, options.inputs); | ||
// Compile then link the template element, building the actual element. | ||
// Set the $element on the inputs so that it can be injected if required. | ||
var linkFn = $compile(template); | ||
var modalElement = linkFn(modalScope); | ||
inputs.$element = modalElement; | ||
// Compile then link the template element, building the actual element. | ||
// Set the $element on the inputs so that it can be injected if required. | ||
var linkFn = $compile(template); | ||
var modalElement = linkFn(modalScope); | ||
inputs.$element = modalElement; | ||
// Create the controller, explicitly specifying the scope to use. | ||
var controllerObjBefore = modalScope[options.controllerAs]; | ||
var modalController = $controller(options.controller, inputs, false, options.controllerAs); | ||
// Create the controller, explicitly specifying the scope to use. | ||
var controllerObjBefore = modalScope[options.controllerAs]; | ||
var modalController = $controller(options.controller, inputs, false, options.controllerAs); | ||
if (options.controllerAs && controllerObjBefore) { | ||
angular.extend(modalController, controllerObjBefore); | ||
} | ||
if (options.controllerAs && controllerObjBefore) { | ||
angular.extend(modalController, controllerObjBefore); | ||
} | ||
// Then, append the modal to the dom. | ||
if (options.appendElement) { | ||
// append to custom append element | ||
appendChild(options.appendElement, modalElement); | ||
} else { | ||
// append to body when no custom append element is specified | ||
appendChild(body, modalElement); | ||
} | ||
// Then, append the modal to the dom. | ||
var appendTarget = body; // append to body when no custom append element is specified | ||
if (angular.isString(options.appendElement)) { | ||
// query the document for the first element that matches the selector | ||
// and create an angular element out of it. | ||
appendTarget = angular.element($document[0].querySelector(options.appendElement)); | ||
// Finally, append any custom classes to the body | ||
if(options.bodyClass) { | ||
body[0].classList.add(options.bodyClass); | ||
} | ||
} else if (options.appendElement) { | ||
// append to custom append element | ||
appendTarget = options.appendElement; | ||
} | ||
// Populate the modal object... | ||
modal.controller = modalController; | ||
modal.scope = modalScope; | ||
modal.element = modalElement; | ||
modal.close = closeDeferred.promise; | ||
modal.closed = closedDeferred.promise; | ||
appendChild(appendTarget, modalElement); | ||
// ...which is passed to the caller via the promise. | ||
deferred.resolve(modal); | ||
// Finally, append any custom classes to the body | ||
if (options.bodyClass) { | ||
body[0].classList.add(options.bodyClass); | ||
} | ||
// Clear previous input focus to avoid open multiple modals on enter | ||
document.activeElement.blur(); | ||
// Populate the modal object... | ||
modal.controller = modalController; | ||
modal.scope = modalScope; | ||
modal.element = modalElement; | ||
modal.close = closeDeferred.promise; | ||
modal.closed = closedDeferred.promise; | ||
// We can track this modal in our open modals. | ||
self.openModals.push({ modal: modal, close: inputs.close }); | ||
// $onInit is part of the component lifecycle introduced in AngularJS 1.6.x | ||
// Because it may not be defined on all controllers, | ||
// we must check for it before attempting to invoke it. | ||
// https://docs.angularjs.org/guide/component#component-based-application-architecture | ||
if (angular.isFunction(modal.controller.$onInit)) { | ||
modal.controller.$onInit(); | ||
} | ||
function cleanUpClose(result) { | ||
// ...which is passed to the caller via the promise. | ||
deferred.resolve(modal); | ||
// Resolve the 'close' promise. | ||
closeDeferred.resolve(result); | ||
// Clear previous input focus to avoid open multiple modals on enter | ||
document.activeElement.blur(); | ||
// Remove the custom class from the body | ||
if(options.bodyClass) { | ||
body[0].classList.remove(options.bodyClass); | ||
} | ||
// We can track this modal in our open modals. | ||
self.openModals.push({modal: modal, close: inputs.close}); | ||
// Let angular remove the element and wait for animations to finish. | ||
$animate.leave(modalElement) | ||
.then(function () { | ||
// prevent error if modal is already destroyed | ||
if (!modalElement) { | ||
return; | ||
} | ||
function cleanUpClose(result) { | ||
// Resolve the 'closed' promise. | ||
closedDeferred.resolve(result); | ||
// Resolve the 'close' promise. | ||
closeDeferred.resolve(result); | ||
// We can now clean up the scope | ||
modalScope.$destroy(); | ||
// Remove the custom class from the body | ||
if (options.bodyClass) { | ||
body[0].classList.remove(options.bodyClass); | ||
} | ||
// Remove the modal from the set of open modals. | ||
for (var i=0; i<self.openModals.length; i++) { | ||
if (self.openModals[i].modal === modal) { | ||
self.openModals.splice(i, 1); | ||
break; | ||
} | ||
} | ||
// Let angular remove the element and wait for animations to finish. | ||
$animate.leave(modalElement) | ||
.then(function () { | ||
// prevent error if modal is already destroyed | ||
if (!modalElement) { | ||
return; | ||
} | ||
// Unless we null out all of these objects we seem to suffer | ||
// from memory leaks, if anyone can explain why then I'd | ||
// be very interested to know. | ||
inputs.close = null; | ||
deferred = null; | ||
closeDeferred = null; | ||
modal = null; | ||
inputs = null; | ||
modalElement = null; | ||
modalScope = null; | ||
// Resolve the 'closed' promise. | ||
closedDeferred.resolve(result); | ||
}); | ||
// remove event watcher | ||
rootScopeOnClose && rootScopeOnClose(); | ||
} | ||
// We can now clean up the scope | ||
modalScope.$destroy(); | ||
}) | ||
.then(null, function(error) { // 'catch' doesn't work in IE8. | ||
deferred.reject(error); | ||
}); | ||
// Remove the modal from the set of open modals. | ||
for (var i = 0; i < self.openModals.length; i++) { | ||
if (self.openModals[i].modal === modal) { | ||
self.openModals.splice(i, 1); | ||
break; | ||
} | ||
} | ||
return deferred.promise; | ||
}; | ||
// Unless we null out all of these objects we seem to suffer | ||
// from memory leaks, if anyone can explain why then I'd | ||
// be very interested to know. | ||
inputs.close = null; | ||
deferred = null; | ||
closeDeferred = null; | ||
modal = null; | ||
inputs = null; | ||
modalElement = null; | ||
modalScope = null; | ||
} | ||
}); | ||
// remove event watcher | ||
rootScopeOnClose && rootScopeOnClose(); | ||
} | ||
return new ModalService(); | ||
}]); | ||
}) | ||
.then(null, function (error) { // 'catch' doesn't work in IE8. | ||
deferred.reject(error); | ||
}); | ||
return deferred.promise; | ||
}; | ||
} | ||
return new ModalService(_options); | ||
}]; | ||
}); |
@@ -0,1 +1,3 @@ | ||
var sinon = require('sinon'); | ||
describe('controller', () => { | ||
@@ -27,2 +29,5 @@ | ||
$scope.getElement = () => { return $element; }; | ||
}) | ||
.controller('OnInitController', function() { | ||
this.$onInit = sinon.spy(); | ||
}); | ||
@@ -221,2 +226,14 @@ | ||
it('should run the controller\'s $onInit function if specified', () => { | ||
$httpBackend.expectGET('some/controllertemplate.html'); | ||
ModalService.showModal({ | ||
controller: 'OnInitController', | ||
templateUrl: 'some/controllertemplate.html' | ||
}).then((modal) => { | ||
sinon.assert.calledOnce(modal.controller.$onInit); | ||
}); | ||
$httpBackend.flush(); | ||
}); | ||
}); |
@@ -63,3 +63,3 @@ describe('dom', () => { | ||
}).then((modal) => { | ||
// We should be able to find the lement that has been created in the custom dom element | ||
// We should be able to find the element that has been created in the custom dom element | ||
expect(angular.element(document.querySelector('#fake-dom-element')).find('div')).not.to.equal(null); | ||
@@ -71,2 +71,24 @@ }); | ||
it('should add the template html to the custom selector', () => { | ||
$httpBackend.expectGET('some/template1.html'); | ||
// create fake element | ||
let fakeDomElement = document.createElement('div'); | ||
fakeDomElement.id = 'fake-dom-element'; | ||
// insert fakeDomElement into the document to test against | ||
document.body.insertBefore(fakeDomElement, null); | ||
ModalService.showModal({ | ||
controller: "DomController", | ||
templateUrl: "some/template1.html", | ||
appendElement: '#fake-dom-element' | ||
}).then((modal) => { | ||
// We should be able to find the element that has been created in the custom dom element | ||
expect(angular.element(document.querySelector('#fake-dom-element')).find('div')).not.to.equal(null); | ||
}); | ||
$httpBackend.flush(); | ||
}); | ||
it('should close the template html to the custom dom element', () => { | ||
@@ -87,3 +109,3 @@ $httpBackend.expectGET('some/template1.html'); | ||
}).then((modal) => { | ||
// We should be able to find the lement that has been created in the custom dom element | ||
// We should be able to find the element that has been created in the custom dom element | ||
expect(angular.element(document.querySelector('#fake-dom-element')).find('div')).not.to.equal(null); | ||
@@ -90,0 +112,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1514957
46
18974
410