moodle/course/amd/build/copy_modal.min.js
Andrew Nicols e1b9d5f3cd MDL-73915 js: Drop support for IE and android
Moodle announced that support for IE would be dropped back in August
2020 with Moodle 3.9 but not active steps were taken at that time. That
decision was made in MDLSITE-6109 and this particular step was meant to
be taken in Moodle 3.10.

This is the first step taken to actively drop support for IE.

This commit also bumps the browser support pattern from 0.25% to 0.3%.
The percentage here includes any browser where at least this percentage
of users worldwide may be using a browser. In this case it causes
support for Android 4.3-4.4 to be dropped, which relate to Android
KitKat (released 2013).

This combination of changes means that all of the supported browsers in
our compatibility list support modern features including async,
for...of, classes, native Promises, and more which has a huge impact on
the ease of debugging code, and drastically reduces the minified file
size because a number of native Polyfills included by Babel are no
longer included.
2022-02-23 08:55:20 +08:00

13 lines
2.8 KiB
JavaScript

/**
* This module provides the course copy modal from the course and
* category management screen.
*
* @module core_course/copy_modal
* @copyright 2020 onward The Moodle Users Association <https://moodleassociation.org/>
* @author Matt Porritt <mattp@catalyst-au.net>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @since 3.9
*/
define("core_course/copy_modal",["jquery","core/str","core/modal_factory","core/modal_events","core/ajax","core/fragment","core/notification","core/config"],(function($,Str,ModalFactory,ModalEvents,ajax,Fragment,Notification,Config){var contextid,course,modalObj,CopyModal={},spinner='<p class="text-center"><i class="fa fa-spinner fa-pulse fa-2x fa-fw"></i></p>';function updateModalBody(formdata){void 0===formdata&&(formdata={});var params={jsonformdata:JSON.stringify(formdata),courseid:course.id};modalObj.setBody(spinner),Str.get_string("copycoursetitle","backup",course.shortname).then((function(title){modalObj.setTitle(title),modalObj.setBody(Fragment.loadFragment("course","new_base_form",contextid,params))})).catch((function(){Notification.exception(new Error("Failed to load string: copycoursetitle"))}))}function processModalForm(e){e.preventDefault();var copyform=modalObj.getRoot().find("form").serialize(),formjson=JSON.stringify(copyform),invalid=$.merge(modalObj.getRoot().find('[aria-invalid="true"]'),modalObj.getRoot().find(".error"));invalid.length?invalid.first().focus():ajax.call([{methodname:"core_backup_submit_copy_form",args:{jsonformdata:formjson}}])[0].done((function(){if(modalObj.setBody(spinner),modalObj.hide(),1==e.formredirect){let redirect=Config.wwwroot+"/backup/copyprogress.php?id="+course.id;window.location.assign(redirect)}})).fail((function(){updateModalBody(copyform)}))}return CopyModal.init=function(context){contextid=context,Str.get_string("loading").then((function(title){ModalFactory.create({type:ModalFactory.types.DEFAULT,title:title,body:spinner,large:!0}).done((function(modal){(modalObj=modal).getRoot().on("click","#id_submitreturn",processModalForm),modalObj.getRoot().on("click","#id_submitdisplay",(function(e){e.formredirect=!0,processModalForm(e)})),modalObj.getRoot().on("click","#id_cancel",(function(e){e.preventDefault(),modalObj.setBody(spinner),modalObj.hide()}))}))})).catch((function(){Notification.exception(new Error("Failed to load string: loading"))})),$(".action-copy").on("click",(function(e){e.preventDefault();let url=new URL(this.getAttribute("href")),courseid=new URLSearchParams(url.search).get("id");ajax.call([{methodname:"core_course_get_courses",args:{options:{ids:[courseid]}}}])[0].done((function(response){course=response[0],updateModalBody()})).fail((function(){Notification.exception(new Error("Failed to load course"))})),modalObj.show()}))},CopyModal}));
//# sourceMappingURL=copy_modal.min.js.map