MDL-69301 course: Remove custom keyboard navigation code
[moodle.git] / course / amd / build / copy_modal.min.js
1 define ("core_course/copy_modal",["jquery","core/str","core/modal_factory","core/modal_events","core/ajax","core/fragment","core/notification","core/config"],function(a,b,c,d,f,g,h,i){var m={},n,o,p,q="<p class=\"text-center\"><i class=\"fa fa-spinner fa-pulse fa-2x fa-fw\"></i></p>";function j(){b.get_string("loading").then(function(a){c.create({type:c.types.DEFAULT,title:a,body:q,large:!0}).done(function(a){p=a;p.getRoot().on("click","#id_submitreturn",l);p.getRoot().on("click","#id_submitdisplay",function(a){a.formredirect=!0;l(a)});p.getRoot().on("click","#id_cancel",function(a){a.preventDefault();p.setBody(q);p.hide()})})}).catch(function(){h.exception(new Error("Failed to load string: loading"))})}function k(a){if("undefined"==typeof a){a={}}var c={jsonformdata:JSON.stringify(a),courseid:o.id};p.setBody(q);b.get_string("copycoursetitle","backup",o.shortname).then(function(a){p.setTitle(a);p.setBody(g.loadFragment("course","new_base_form",n,c))}).catch(function(){h.exception(new Error("Failed to load string: copycoursetitle"))})}function l(b){b.preventDefault();var c=p.getRoot().find("form").serialize(),d=JSON.stringify(c),e=a.merge(p.getRoot().find("[aria-invalid=\"true\"]"),p.getRoot().find(".error"));if(e.length){e.first().focus();return}f.call([{methodname:"core_backup_submit_copy_form",args:{jsonformdata:d}}])[0].done(function(){p.setBody(q);p.hide();if(!0==b.formredirect){var a=i.wwwroot+"/backup/copyprogress.php?id="+o.id;window.location.assign(a)}}).fail(function(){k(c)})}m.init=function(b){n=b;j();a(".action-copy").on("click",function(a){a.preventDefault();var b=new URL(this.getAttribute("href")),c=new URLSearchParams(b.search),d=c.get("id");f.call([{methodname:"core_course_get_courses",args:{options:{ids:[d]}}}])[0].done(function(a){o=a[0];k()}).fail(function(){h.exception(new Error("Failed to load course"))});p.show()})};return m});
2 //# sourceMappingURL=copy_modal.min.js.map