MDL-62497 javascript: add babel transpiling to Grunt for ES6 support
[moodle.git] / lib / amd / build / modal_factory.min.js
CommitLineData
c5681f7f 1define(["jquery","core/modal_events","core/modal_registry","core/modal","core/modal_save_cancel","core/modal_cancel","core/templates","core/notification","core/custom_interaction_events"],function(a,b,c,d,e,f,g,h,i){var j={DEFAULT:"core/modal",SAVE_CANCEL:"core/modal_save_cancel",CANCEL:"core/modal_cancel"},k={DEFAULT:"DEFAULT",SAVE_CANCEL:"SAVE_CANCEL",CANCEL:"CANCEL"};c.register(k.DEFAULT,d,j.DEFAULT),c.register(k.SAVE_CANCEL,e,j.SAVE_CANCEL),c.register(k.CANCEL,f,j.CANCEL);var l=function(c,d,e){var f=null,g="function"==typeof e.preShowCallback,h=function(b,d){f=a(b.currentTarget),c.then(function(a){return g&&e.preShowCallback(f,a),a.show(),a}),d.originalEvent.preventDefault()};if(Array.isArray(d)){var j=d[1];d=d[0],i.define(d,[i.events.activate]),d.on(i.events.activate,j,h)}else i.define(d,[i.events.activate]),d.on(i.events.activate,h);c.then(function(a){return a.getRoot().on(b.hidden,function(){null!==f&&f.focus()}),a})},m=function(b,c){c=a(c);var d=b.module,e=new d(c);return e},n=function(b,c){var d=b.template,e=g.render(d,c).then(function(c){var d=a(c);return m(b,d)}).fail(h.exception);return e},o=function(a,b){var d=a.type||k.DEFAULT,e=!!a.large,f=null,g={};f=c.get(d),f||h.exception({message:"Unable to find modal of type: "+d}),"undefined"!=typeof a.templateContext&&(g=a.templateContext);var i=n(f,g).then(function(b){return"undefined"!=typeof a.title&&b.setTitle(a.title),"undefined"!=typeof a.body&&b.setBody(a.body),"undefined"!=typeof a.footer&&b.setFooter(a.footer),e&&b.setLarge(),b});return"undefined"!=typeof b&&l(i,b,a),i};return{create:o,types:k}});