MDL-69166 pg_paypal: Support multiple currencies on the same page
[moodle.git] / payment / amd / build / gateways_modal.min.js
1 define ("core_payment/gateways_modal",["exports","core/modal_factory","core/templates","core/str","./repository","./selectors","core/modal_events","core/toast","core/notification"],function(a,b,c,d,e,f,g,h,i){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.registerEventListeners=a.registerEventListenersBySelector=void 0;b=j(b);c=j(c);f=j(f);g=j(g);i=j(i);var m="undefined"!=typeof window?window:"undefined"!=typeof self?self:"undefined"!=typeof global?global:{};function j(a){return a&&a.__esModule?a:{default:a}}function k(a,b,c,d,e,f,g){try{var h=a[f](g),i=h.value}catch(a){c(a);return}if(h.done){b(i)}else{Promise.resolve(i).then(d,e)}}function l(a){return function(){var b=this,c=arguments;return new Promise(function(d,e){var h=a.apply(b,c);function f(a){k(h,d,e,f,g,"next",a)}function g(a){k(h,d,e,f,g,"throw",a)}f(void 0)})}}a.registerEventListenersBySelector=function registerEventListenersBySelector(a){document.querySelectorAll(a).forEach(function(a){n(a)})};var n=function(a){a.addEventListener("click",function(b){b.preventDefault();o(a,{focusOnClose:b.target})})};a.registerEventListeners=n;var o=function(){var a=l(regeneratorRuntime.mark(function a(j){var k,l,m,n,o,q,r,s,t,u,v=arguments;return regeneratorRuntime.wrap(function(a){while(1){switch(a.prev=a.next){case 0:k=1<v.length&&v[1]!==void 0?v[1]:{},l=k.focusOnClose,m=void 0===l?null:l;a.t0=b.default;a.t1=b.default.types.SAVE_CANCEL;a.next=5;return(0,d.get_string)("selectpaymenttype","core_payment");case 5:a.t2=a.sent;a.next=8;return c.default.render("core_payment/gateways_modal",{});case 8:a.t3=a.sent;a.t4={type:a.t1,title:a.t2,body:a.t3};a.next=12;return a.t0.create.call(a.t0,a.t4);case 12:n=a.sent;(0,h.addToastRegion)(n.getRoot()[0]);n.show();n.getRoot().on(g.default.hidden,function(){n.destroy();try{m.focus()}catch(a){}});n.getRoot().on(g.default.save,function(a){var b=n.getRoot()[0],c=(b.querySelector(f.default.values.gateway)||{value:""}).value;if(c){p(c,j.dataset.amount,j.dataset.currency,j.dataset.component,j.dataset.componentid,j.dataset.description,function(a){var b=a.success,c=a.message,d=void 0===c?"":c;n.hide();if(b){i.default.addNotification({message:d,type:"success"});location.reload()}else{i.default.alert("",d)}})}else{(0,d.get_string)("nogatewayselected","core_payment").then(function(a){return(0,h.add)(a)})}a.preventDefault()});o=j.dataset.currency;a.next=20;return(0,e.getGatewaysSupportingCurrency)(o);case 20:q=a.sent;r={gateways:q};a.next=24;return c.default.renderForPromise("core_payment/gateways",r);case 24:s=a.sent;t=s.html;u=s.js;c.default.replaceNodeContents(n.getRoot().find(f.default.regions.gatewaysContainer),t,u);case 28:case"end":return a.stop();}}},a)}));return function(){return a.apply(this,arguments)}}(),p=function(){var a=l(regeneratorRuntime.mark(function a(b,c,d,e,f,g,h){var i;return regeneratorRuntime.wrap(function(a){while(1){switch(a.prev=a.next){case 0:a.next=2;return"function"==typeof m.define&&m.define.amd?new Promise(function(a,c){m.require(["pg_".concat(b,"/gateways_modal")],a,c)}):"undefined"!=typeof module&&module.exports&&"undefined"!=typeof require||"undefined"!=typeof module&&module.component&&m.require&&"component"===m.require.loader?Promise.resolve(require(("pg_".concat(b,"/gateways_modal")))):Promise.resolve(m["pg_".concat(b,"/gateways_modal")]);case 2:i=a.sent;i.process(c,d,e,f,g,h);case 4:case"end":return a.stop();}}},a)}));return function(){return a.apply(this,arguments)}}()});
2 //# sourceMappingURL=gateways_modal.min.js.map