mirror of
https://github.com/moodle/moodle.git
synced 2025-01-17 21:49:15 +01:00
MDL-69918 core: Update uses of legacy form change checker
This commit is contained in:
parent
cbe19158e9
commit
530322e2ce
@ -158,9 +158,7 @@ echo $outputhtml;
|
||||
echo html_writer::end_tag('fieldset');
|
||||
echo html_writer::end_tag('form');
|
||||
|
||||
$PAGE->requires->yui_module('moodle-core-formchangechecker', 'M.core_formchangechecker.init', [[
|
||||
'formid' => 'adminsettings'
|
||||
]]);
|
||||
$PAGE->requires->string_for_js('changesmadereallygoaway', 'moodle');
|
||||
// Add the form change checker.
|
||||
$PAGE->requires->js_call_amd('core_form/changechecker', 'watchFormById', ['adminsettings']);
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
|
@ -148,13 +148,8 @@ if (empty($SITE->fullname)) {
|
||||
echo $OUTPUT->render_from_template('core_admin/settings', $context);
|
||||
}
|
||||
|
||||
$PAGE->requires->yui_module('moodle-core-formchangechecker',
|
||||
'M.core_formchangechecker.init',
|
||||
array(array(
|
||||
'formid' => 'adminsettings'
|
||||
))
|
||||
);
|
||||
$PAGE->requires->string_for_js('changesmadereallygoaway', 'moodle');
|
||||
// Add the form change checker.
|
||||
$PAGE->requires->js_call_amd('core_form/changechecker', 'watchFormById', ['adminsettings']);
|
||||
|
||||
if ($settingspage->has_dependencies()) {
|
||||
$opts = [
|
||||
|
@ -1,2 +1,2 @@
|
||||
define ("tool_dataprivacy/add_category",["jquery","core/str","core/ajax","core/notification","core/modal_factory","core/modal_events","core/fragment"],function(a,b,c,d,e,f,g){var h={CATEGORY_LINK:"[data-add-element=\"category\"]"},i=function(a){this.contextId=a;this.strings=b.get_strings([{key:"addcategory",component:"tool_dataprivacy"},{key:"save",component:"admin"}]);this.registerEventListeners()};i.prototype.contextId=0;i.prototype.strings=0;i.prototype.registerEventListeners=function(){var b=a(h.CATEGORY_LINK);b.on("click",function(){return this.strings.then(function(a){e.create({type:e.types.SAVE_CANCEL,title:a[0],body:""},b).done(function(b){this.setupFormModal(b,a[1])}.bind(this))}.bind(this)).fail(d.exception)}.bind(this))};i.prototype.getBody=function(a){var b=null;if("undefined"!=typeof a){b={jsonformdata:JSON.stringify(a)}}return g.loadFragment("tool_dataprivacy","addcategory_form",this.contextId,b)};i.prototype.setupFormModal=function(a,b){a.setLarge();a.setSaveButtonText(b);a.getRoot().on(f.hidden,this.destroy.bind(this));a.setBody(this.getBody());a.getRoot().on(f.save,this.submitForm.bind(this));a.getRoot().on("submit","form",this.submitFormAjax.bind(this));this.modal=a;a.show()};i.prototype.submitForm=function(a){a.preventDefault();this.modal.getRoot().find("form").submit()};i.prototype.submitFormAjax=function(a){a.preventDefault();var b=this.modal.getRoot().find("form").serialize();c.call([{methodname:"tool_dataprivacy_create_category_form",args:{jsonformdata:JSON.stringify(b)},done:function(a){if(a.validationerrors){this.modal.setBody(this.getBody(b))}else{this.close()}}.bind(this),fail:d.exception}])};i.prototype.close=function(){this.destroy();document.location.reload()};i.prototype.destroy=function(){Y.use("moodle-core-formchangechecker",function(){M.core_formchangechecker.reset_form_dirty_state()});this.modal.destroy()};i.prototype.removeListeners=function(){a(h.CATEGORY_LINK).off("click")};return{getInstance:function getInstance(a){return new i(a)}}});
|
||||
define ("tool_dataprivacy/add_category",["jquery","core/str","core/ajax","core/notification","core/modal_factory","core/modal_events","core/fragment","core_form/changechecker"],function(a,b,c,d,e,f,g,h){var i={CATEGORY_LINK:"[data-add-element=\"category\"]"},j=function(a){this.contextId=a;this.strings=b.get_strings([{key:"addcategory",component:"tool_dataprivacy"},{key:"save",component:"admin"}]);this.registerEventListeners()};j.prototype.contextId=0;j.prototype.strings=0;j.prototype.registerEventListeners=function(){var b=a(i.CATEGORY_LINK);b.on("click",function(){return this.strings.then(function(a){e.create({type:e.types.SAVE_CANCEL,title:a[0],body:""},b).done(function(b){this.setupFormModal(b,a[1])}.bind(this))}.bind(this)).fail(d.exception)}.bind(this))};j.prototype.getBody=function(a){var b=null;if("undefined"!=typeof a){b={jsonformdata:JSON.stringify(a)}}return g.loadFragment("tool_dataprivacy","addcategory_form",this.contextId,b)};j.prototype.setupFormModal=function(a,b){a.setLarge();a.setSaveButtonText(b);a.getRoot().on(f.hidden,this.destroy.bind(this));a.setBody(this.getBody());a.getRoot().on(f.save,this.submitForm.bind(this));a.getRoot().on("submit","form",this.submitFormAjax.bind(this));this.modal=a;a.show()};j.prototype.submitForm=function(a){a.preventDefault();this.modal.getRoot().find("form").submit()};j.prototype.submitFormAjax=function(a){a.preventDefault();var b=this.modal.getRoot().find("form").serialize();c.call([{methodname:"tool_dataprivacy_create_category_form",args:{jsonformdata:JSON.stringify(b)},done:function(a){if(a.validationerrors){this.modal.setBody(this.getBody(b))}else{this.close()}}.bind(this),fail:d.exception}])};j.prototype.close=function(){this.destroy();document.location.reload()};j.prototype.destroy=function(){h.resetAllFormDirtyStates();this.modal.destroy()};j.prototype.removeListeners=function(){a(i.CATEGORY_LINK).off("click")};return{getInstance:function getInstance(a){return new j(a)}}});
|
||||
//# sourceMappingURL=add_category.min.js.map
|
||||
|
File diff suppressed because one or more lines are too long
@ -1,2 +1,2 @@
|
||||
define ("tool_dataprivacy/add_purpose",["jquery","core/str","core/ajax","core/notification","core/modal_factory","core/modal_events","core/fragment"],function(a,b,c,d,e,f,g){var h={PURPOSE_LINK:"[data-add-element=\"purpose\"]"},i=function(a){this.contextId=a;this.strings=b.get_strings([{key:"addpurpose",component:"tool_dataprivacy"},{key:"save",component:"admin"}]);this.registerEventListeners()};i.prototype.contextId=0;i.prototype.strings=0;i.prototype.registerEventListeners=function(){var b=a(h.PURPOSE_LINK);b.on("click",function(){return this.strings.then(function(a){e.create({type:e.types.SAVE_CANCEL,title:a[0],body:""},b).done(function(b){this.setupFormModal(b,a[1])}.bind(this))}.bind(this)).fail(d.exception)}.bind(this))};i.prototype.getBody=function(a){var b=null;if("undefined"!=typeof a){b={jsonformdata:JSON.stringify(a)}}return g.loadFragment("tool_dataprivacy","addpurpose_form",this.contextId,b)};i.prototype.setupFormModal=function(a,b){a.setLarge();a.setSaveButtonText(b);a.getRoot().on(f.hidden,this.destroy.bind(this));a.setBody(this.getBody());a.getRoot().on(f.save,this.submitForm.bind(this));a.getRoot().on("submit","form",this.submitFormAjax.bind(this));this.modal=a;a.show()};i.prototype.submitForm=function(a){a.preventDefault();this.modal.getRoot().find("form").submit()};i.prototype.submitFormAjax=function(a){a.preventDefault();var b=this.modal.getRoot().find("form").serialize();c.call([{methodname:"tool_dataprivacy_create_purpose_form",args:{jsonformdata:JSON.stringify(b)},done:function(a){if(a.validationerrors){this.modal.setBody(this.getBody(b))}else{this.close()}}.bind(this),fail:d.exception}])};i.prototype.close=function(){this.destroy();document.location.reload()};i.prototype.destroy=function(){Y.use("moodle-core-formchangechecker",function(){M.core_formchangechecker.reset_form_dirty_state()});this.modal.destroy()};i.prototype.removeListeners=function(){a(h.PURPOSE_LINK).off("click")};return{getInstance:function getInstance(a){return new i(a)}}});
|
||||
define ("tool_dataprivacy/add_purpose",["jquery","core/str","core/ajax","core/notification","core/modal_factory","core/modal_events","core/fragment","core_form/changechecker"],function(a,b,c,d,e,f,g,h){var i={PURPOSE_LINK:"[data-add-element=\"purpose\"]"},j=function(a){this.contextId=a;this.strings=b.get_strings([{key:"addpurpose",component:"tool_dataprivacy"},{key:"save",component:"admin"}]);this.registerEventListeners()};j.prototype.contextId=0;j.prototype.strings=0;j.prototype.registerEventListeners=function(){var b=a(i.PURPOSE_LINK);b.on("click",function(){return this.strings.then(function(a){e.create({type:e.types.SAVE_CANCEL,title:a[0],body:""},b).done(function(b){this.setupFormModal(b,a[1])}.bind(this))}.bind(this)).fail(d.exception)}.bind(this))};j.prototype.getBody=function(a){var b=null;if("undefined"!=typeof a){b={jsonformdata:JSON.stringify(a)}}return g.loadFragment("tool_dataprivacy","addpurpose_form",this.contextId,b)};j.prototype.setupFormModal=function(a,b){a.setLarge();a.setSaveButtonText(b);a.getRoot().on(f.hidden,this.destroy.bind(this));a.setBody(this.getBody());a.getRoot().on(f.save,this.submitForm.bind(this));a.getRoot().on("submit","form",this.submitFormAjax.bind(this));this.modal=a;a.show()};j.prototype.submitForm=function(a){a.preventDefault();this.modal.getRoot().find("form").submit()};j.prototype.submitFormAjax=function(a){a.preventDefault();var b=this.modal.getRoot().find("form").serialize();c.call([{methodname:"tool_dataprivacy_create_purpose_form",args:{jsonformdata:JSON.stringify(b)},done:function(a){if(a.validationerrors){this.modal.setBody(this.getBody(b))}else{this.close()}}.bind(this),fail:d.exception}])};j.prototype.close=function(){this.destroy();document.location.reload()};j.prototype.destroy=function(){h.resetAllFormDirtyStates();this.modal.destroy()};j.prototype.removeListeners=function(){a(i.PURPOSE_LINK).off("click")};return{getInstance:function getInstance(a){return new j(a)}}});
|
||||
//# sourceMappingURL=add_purpose.min.js.map
|
||||
|
File diff suppressed because one or more lines are too long
@ -1,2 +1,2 @@
|
||||
define ("tool_dataprivacy/data_registry",["jquery","core/str","core/ajax","core/notification","core/templates","core/modal_factory","core/modal_events","core/fragment","tool_dataprivacy/add_purpose","tool_dataprivacy/add_category"],function(a,b,c,d,e,f,g,h,i,j){var k={TREE_NODES:"[data-context-tree-node=1]",FORM_CONTAINER:"#context-form-container"},l=function(a,b,c){this.systemContextId=a;this.currentContextLevel=b;this.currentContextId=c;this.init()};l.prototype.systemContextId=0;l.prototype.currentContextLevel=0;l.prototype.currentContextId=0;l.prototype.addpurpose=null;l.prototype.addcategory=null;l.prototype.init=function(){this.addpurpose=i.getInstance(this.systemContextId);this.addcategory=j.getInstance(this.systemContextId);this.strings=b.get_strings([{key:"changessaved",component:"moodle"},{key:"contextpurposecategorysaved",component:"tool_dataprivacy"},{key:"noblockstoload",component:"tool_dataprivacy"},{key:"noactivitiestoload",component:"tool_dataprivacy"},{key:"nocoursestoload",component:"tool_dataprivacy"}]);this.registerEventListeners();if(this.currentContextId){this.loadForm("context_form",[this.currentContextId],this.submitContextFormAjax.bind(this))}else{this.loadForm("contextlevel_form",[this.currentContextLevel],this.submitContextLevelFormAjax.bind(this))}};l.prototype.registerEventListeners=function(){a(k.TREE_NODES).on("click",function(b){b.preventDefault();var c=a(b.currentTarget);a(k.TREE_NODES).removeClass("active");c.addClass("active");var d=c.data("contextlevel"),e=c.data("contextid");if(d){window.history.pushState({},null,"?contextlevel="+d);this.addpurpose.removeListeners();this.addcategory.removeListeners();this.currentContextLevel=d;this.loadForm("contextlevel_form",[this.currentContextLevel],this.submitContextLevelFormAjax.bind(this))}else if(e){window.history.pushState({},null,"?contextid="+e);this.addpurpose.removeListeners();this.addcategory.removeListeners();this.currentContextId=e;this.loadForm("context_form",[this.currentContextId],this.submitContextFormAjax.bind(this))}else{var f=c.data("expandcontextid"),g=c.data("expandelement"),h=c.data("expanded");if(g){if(!h){if(c.data("loaded")||!f||!g){this.expand(c)}else{c.find("> i").removeClass("fa-plus");c.find("> i").addClass("fa-circle-o-notch fa-spin");this.loadExtra(c,f,g)}}else{this.collapse(c)}}}}.bind(this))};l.prototype.removeListeners=function(){a(k.TREE_NODES).off("click")};l.prototype.loadForm=function(b,c,f){this.clearForm();var g=h.loadFragment("tool_dataprivacy",b,this.systemContextId,c);g.done(function(b,c){a(k.FORM_CONTAINER).html(b);e.runTemplateJS(c);this.addpurpose.registerEventListeners();this.addcategory.registerEventListeners();a(k.FORM_CONTAINER).on("submit","form",f)}.bind(this)).fail(d.exception)};l.prototype.clearForm=function(){Y.use("moodle-core-formchangechecker",function(){M.core_formchangechecker.reset_form_dirty_state()});a(k.FORM_CONTAINER).off("submit","form")};l.prototype.submitForm=function(b){b.preventDefault();a(k.FORM_CONTAINER).find("form").submit()};l.prototype.submitContextLevelFormAjax=function(a){this.submitFormAjax(a,"tool_dataprivacy_set_contextlevel_form")};l.prototype.submitContextFormAjax=function(a){this.submitFormAjax(a,"tool_dataprivacy_set_context_form")};l.prototype.submitFormAjax=function(b,e){b.preventDefault();var f=a(k.FORM_CONTAINER).find("form").serialize();return this.strings.then(function(a){c.call([{methodname:e,args:{jsonformdata:JSON.stringify(f)},done:function done(){d.alert(a[0],a[1])},fail:d.exception}])}).catch(d.exception)};l.prototype.loadExtra=function(a,b,f){c.call([{methodname:"tool_dataprivacy_tree_extra_branches",args:{contextid:b,element:f},done:function(b){if(0==b.branches.length){this.noElements(a,f);return}e.render("tool_dataprivacy/context_tree_branches",b).then(function(b){a.after(b);this.removeListeners();this.registerEventListeners();this.expand(a);a.data("loaded",1)}.bind(this)).fail(d.exception)}.bind(this),fail:d.exception}])};l.prototype.noElements=function(a,b){a.data("expandcontextid","");a.data("expandelement","");this.strings.then(function(c){var d=2;if("module"==b){d=3}else if("course"==b){d=4}a.text(c[d])}).fail(d.exception)};l.prototype.collapse=function(a){a.data("expanded",0);a.siblings("nav").addClass("hidden");a.find("> i").removeClass("fa-minus");a.find("> i").addClass("fa-plus")};l.prototype.expand=function(a){a.data("expanded",1);a.siblings("nav").removeClass("hidden");a.find("> i").removeClass("fa-plus");a.find("> i").removeClass("fa-circle-o-notch fa-spin");a.find("> i").addClass("fa-minus")};return{init:function init(a,b,c){return new l(a,b,c)}}});
|
||||
define ("tool_dataprivacy/data_registry",["jquery","core/str","core/ajax","core/notification","core/templates","core/modal_factory","core/modal_events","core/fragment","tool_dataprivacy/add_purpose","tool_dataprivacy/add_category"],function(a,b,c,d,e,f,g,h,i,j){var k={TREE_NODES:"[data-context-tree-node=1]",FORM_CONTAINER:"#context-form-container"},l=function(a,b,c){this.systemContextId=a;this.currentContextLevel=b;this.currentContextId=c;this.init()};l.prototype.systemContextId=0;l.prototype.currentContextLevel=0;l.prototype.currentContextId=0;l.prototype.addpurpose=null;l.prototype.addcategory=null;l.prototype.init=function(){this.addpurpose=i.getInstance(this.systemContextId);this.addcategory=j.getInstance(this.systemContextId);this.strings=b.get_strings([{key:"changessaved",component:"moodle"},{key:"contextpurposecategorysaved",component:"tool_dataprivacy"},{key:"noblockstoload",component:"tool_dataprivacy"},{key:"noactivitiestoload",component:"tool_dataprivacy"},{key:"nocoursestoload",component:"tool_dataprivacy"}]);this.registerEventListeners();if(this.currentContextId){this.loadForm("context_form",[this.currentContextId],this.submitContextFormAjax.bind(this))}else{this.loadForm("contextlevel_form",[this.currentContextLevel],this.submitContextLevelFormAjax.bind(this))}};l.prototype.registerEventListeners=function(){a(k.TREE_NODES).on("click",function(b){b.preventDefault();var c=a(b.currentTarget);a(k.TREE_NODES).removeClass("active");c.addClass("active");var d=c.data("contextlevel"),e=c.data("contextid");if(d){window.history.pushState({},null,"?contextlevel="+d);this.addpurpose.removeListeners();this.addcategory.removeListeners();this.currentContextLevel=d;this.loadForm("contextlevel_form",[this.currentContextLevel],this.submitContextLevelFormAjax.bind(this))}else if(e){window.history.pushState({},null,"?contextid="+e);this.addpurpose.removeListeners();this.addcategory.removeListeners();this.currentContextId=e;this.loadForm("context_form",[this.currentContextId],this.submitContextFormAjax.bind(this))}else{var f=c.data("expandcontextid"),g=c.data("expandelement"),h=c.data("expanded");if(g){if(!h){if(c.data("loaded")||!f||!g){this.expand(c)}else{c.find("> i").removeClass("fa-plus");c.find("> i").addClass("fa-circle-o-notch fa-spin");this.loadExtra(c,f,g)}}else{this.collapse(c)}}}}.bind(this))};l.prototype.removeListeners=function(){a(k.TREE_NODES).off("click")};l.prototype.loadForm=function(b,c,f){this.clearForm();var g=h.loadFragment("tool_dataprivacy",b,this.systemContextId,c);g.done(function(b,c){a(k.FORM_CONTAINER).html(b);e.runTemplateJS(c);this.addpurpose.registerEventListeners();this.addcategory.registerEventListeners();a(k.FORM_CONTAINER).on("submit","form",f)}.bind(this)).fail(d.exception)};l.prototype.clearForm=function(){a(k.FORM_CONTAINER).off("submit","form")};l.prototype.submitForm=function(b){b.preventDefault();a(k.FORM_CONTAINER).find("form").submit()};l.prototype.submitContextLevelFormAjax=function(a){this.submitFormAjax(a,"tool_dataprivacy_set_contextlevel_form")};l.prototype.submitContextFormAjax=function(a){this.submitFormAjax(a,"tool_dataprivacy_set_context_form")};l.prototype.submitFormAjax=function(b,e){b.preventDefault();var f=a(k.FORM_CONTAINER).find("form").serialize();return this.strings.then(function(a){c.call([{methodname:e,args:{jsonformdata:JSON.stringify(f)},done:function done(){d.alert(a[0],a[1])},fail:d.exception}])}).catch(d.exception)};l.prototype.loadExtra=function(a,b,f){c.call([{methodname:"tool_dataprivacy_tree_extra_branches",args:{contextid:b,element:f},done:function(b){if(0==b.branches.length){this.noElements(a,f);return}e.render("tool_dataprivacy/context_tree_branches",b).then(function(b){a.after(b);this.removeListeners();this.registerEventListeners();this.expand(a);a.data("loaded",1)}.bind(this)).fail(d.exception)}.bind(this),fail:d.exception}])};l.prototype.noElements=function(a,b){a.data("expandcontextid","");a.data("expandelement","");this.strings.then(function(c){var d=2;if("module"==b){d=3}else if("course"==b){d=4}a.text(c[d])}).fail(d.exception)};l.prototype.collapse=function(a){a.data("expanded",0);a.siblings("nav").addClass("hidden");a.find("> i").removeClass("fa-minus");a.find("> i").addClass("fa-plus")};l.prototype.expand=function(a){a.data("expanded",1);a.siblings("nav").removeClass("hidden");a.find("> i").removeClass("fa-plus");a.find("> i").removeClass("fa-circle-o-notch fa-spin");a.find("> i").addClass("fa-minus")};return{init:function init(a,b,c){return new l(a,b,c)}}});
|
||||
//# sourceMappingURL=data_registry.min.js.map
|
||||
|
File diff suppressed because one or more lines are too long
@ -20,8 +20,25 @@
|
||||
* @copyright 2018 David Monllao
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
define(['jquery', 'core/str', 'core/ajax', 'core/notification', 'core/modal_factory', 'core/modal_events', 'core/fragment'],
|
||||
function($, Str, Ajax, Notification, ModalFactory, ModalEvents, Fragment) {
|
||||
define([
|
||||
'jquery',
|
||||
'core/str',
|
||||
'core/ajax',
|
||||
'core/notification',
|
||||
'core/modal_factory',
|
||||
'core/modal_events',
|
||||
'core/fragment',
|
||||
'core_form/changechecker',
|
||||
], function(
|
||||
$,
|
||||
Str,
|
||||
Ajax,
|
||||
Notification,
|
||||
ModalFactory,
|
||||
ModalEvents,
|
||||
Fragment,
|
||||
FormChangeChecker
|
||||
) {
|
||||
|
||||
var SELECTORS = {
|
||||
CATEGORY_LINK: '[data-add-element="category"]',
|
||||
@ -151,9 +168,7 @@ define(['jquery', 'core/str', 'core/ajax', 'core/notification', 'core/modal_fact
|
||||
};
|
||||
|
||||
AddCategory.prototype.destroy = function() {
|
||||
Y.use('moodle-core-formchangechecker', function() {
|
||||
M.core_formchangechecker.reset_form_dirty_state();
|
||||
});
|
||||
FormChangeChecker.resetAllFormDirtyStates();
|
||||
this.modal.destroy();
|
||||
};
|
||||
|
||||
|
@ -20,8 +20,25 @@
|
||||
* @copyright 2018 David Monllao
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
define(['jquery', 'core/str', 'core/ajax', 'core/notification', 'core/modal_factory', 'core/modal_events', 'core/fragment'],
|
||||
function($, Str, Ajax, Notification, ModalFactory, ModalEvents, Fragment) {
|
||||
define([
|
||||
'jquery',
|
||||
'core/str',
|
||||
'core/ajax',
|
||||
'core/notification',
|
||||
'core/modal_factory',
|
||||
'core/modal_events',
|
||||
'core/fragment',
|
||||
'core_form/changechecker',
|
||||
], function(
|
||||
$,
|
||||
Str,
|
||||
Ajax,
|
||||
Notification,
|
||||
ModalFactory,
|
||||
ModalEvents,
|
||||
Fragment,
|
||||
FormChangeChecker
|
||||
) {
|
||||
|
||||
var SELECTORS = {
|
||||
PURPOSE_LINK: '[data-add-element="purpose"]',
|
||||
@ -152,9 +169,7 @@ define(['jquery', 'core/str', 'core/ajax', 'core/notification', 'core/modal_fact
|
||||
};
|
||||
|
||||
AddPurpose.prototype.destroy = function() {
|
||||
Y.use('moodle-core-formchangechecker', function() {
|
||||
M.core_formchangechecker.reset_form_dirty_state();
|
||||
});
|
||||
FormChangeChecker.resetAllFormDirtyStates();
|
||||
this.modal.destroy();
|
||||
};
|
||||
|
||||
|
@ -189,11 +189,6 @@ define(['jquery', 'core/str', 'core/ajax', 'core/notification', 'core/templates'
|
||||
};
|
||||
|
||||
DataRegistry.prototype.clearForm = function() {
|
||||
// For the previously loaded form.
|
||||
Y.use('moodle-core-formchangechecker', function() {
|
||||
M.core_formchangechecker.reset_form_dirty_state();
|
||||
});
|
||||
|
||||
// Remove previous listeners.
|
||||
$(SELECTORS.FORM_CONTAINER).off('submit', 'form');
|
||||
};
|
||||
|
@ -1,2 +1,2 @@
|
||||
define ("tool_policy/acceptmodal",["jquery","core/str","core/modal_factory","core/modal_events","core/notification","core/fragment","core/ajax","core/yui"],function(a,b,c,d,f,g,h,i){"use strict";var e=function(a){this.contextid=a;this.init()};e.prototype.modal=null;e.prototype.contextid=-1;e.prototype.currentTrigger=null;e.prototype.triggers={SINGLE:"a[data-action=acceptmodal]",BULK:"input[data-action=acceptmodal]"};e.prototype.init=function(){a(this.triggers.SINGLE).on("click",function(b){b.preventDefault();this.currentTrigger=a(b.currentTarget);var c=a(b.currentTarget).attr("href"),d=c.slice(c.indexOf("?")+1);this.showFormModal(d)}.bind(this));a(this.triggers.BULK).on("click",function(c){c.preventDefault();this.currentTrigger=a(c.currentTarget);var d=a(c.currentTarget).closest("form");if(d.find("input[type=checkbox][name=\"userids[]\"]:checked").length){var e=d.serialize();this.showFormModal(e)}else{b.get_strings([{key:"notice"},{key:"selectusersforconsent",component:"tool_policy"},{key:"ok"}]).then(function(a){f.alert(a[0],a[1],a[2])}).fail(f.exception)}}.bind(this))};e.prototype.showFormModal=function(a){for(var d,e=a.split("&"),g=0,h;g<e.length;g++){h=e[g].split("=");if("action"==h[0]){d=h[1]}}b.get_strings([{key:"statusformtitleaccept",component:"tool_policy"},{key:"iagreetothepolicy",component:"tool_policy"},{key:"statusformtitlerevoke",component:"tool_policy"},{key:"irevokethepolicy",component:"tool_policy"},{key:"statusformtitledecline",component:"tool_policy"},{key:"declinethepolicy",component:"tool_policy"}]).then(function(b){var e,f;if("accept"==d){e=b[0];f=b[1]}else if("revoke"==d){e=b[2];f=b[3]}else if("decline"==d){e=b[4];f=b[5]}return c.create({type:c.types.SAVE_CANCEL,title:e,body:""}).done(function(b){this.modal=b;this.setupFormModal(a,f)}.bind(this))}.bind(this)).catch(f.exception)};e.prototype.setupFormModal=function(a,b){var c=this.modal;c.setLarge();c.setSaveButtonText(b);c.getRoot().on(d.hidden,this.destroy.bind(this));c.setBody(this.getBody(a));c.getRoot().on(d.save,this.submitForm.bind(this));c.getRoot().on("submit","form",this.submitFormAjax.bind(this));c.show()};e.prototype.getBody=function(a){if("undefined"==typeof a){a={}}var b={jsonformdata:JSON.stringify(a)};return g.loadFragment("tool_policy","accept_on_behalf",this.contextid,b)};e.prototype.submitFormAjax=function(a){a.preventDefault();var b=this.modal.getRoot().find("form").serialize(),c=h.call([{methodname:"tool_policy_submit_accept_on_behalf",args:{jsonformdata:JSON.stringify(b)}}]);c[0].done(function(a){if(a.validationerrors){this.modal.setBody(this.getBody(b))}else{this.close()}}.bind(this)).fail(f.exception)};e.prototype.submitForm=function(a){a.preventDefault();this.modal.getRoot().find("form").submit()};e.prototype.close=function(){this.destroy();document.location.reload()};e.prototype.destroy=function(){i.use("moodle-core-formchangechecker",function(){M.core_formchangechecker.reset_form_dirty_state()});this.modal.destroy();this.currentTrigger.focus()};return{getInstance:function getInstance(a){return new e(a)}}});
|
||||
define ("tool_policy/acceptmodal",["jquery","core/str","core/modal_factory","core/modal_events","core/notification","core/fragment","core/ajax","core_form/changechecker"],function(a,b,c,d,f,g,h,i){"use strict";var j=function(a){this.contextid=a;this.init()};j.prototype.modal=null;j.prototype.contextid=-1;j.prototype.currentTrigger=null;j.prototype.triggers={SINGLE:"a[data-action=acceptmodal]",BULK:"input[data-action=acceptmodal]"};j.prototype.init=function(){a(this.triggers.SINGLE).on("click",function(b){b.preventDefault();this.currentTrigger=a(b.currentTarget);var c=a(b.currentTarget).attr("href"),d=c.slice(c.indexOf("?")+1);this.showFormModal(d)}.bind(this));a(this.triggers.BULK).on("click",function(c){c.preventDefault();this.currentTrigger=a(c.currentTarget);var d=a(c.currentTarget).closest("form");if(d.find("input[type=checkbox][name=\"userids[]\"]:checked").length){var e=d.serialize();this.showFormModal(e)}else{b.get_strings([{key:"notice"},{key:"selectusersforconsent",component:"tool_policy"},{key:"ok"}]).then(function(a){f.alert(a[0],a[1],a[2])}).fail(f.exception)}}.bind(this))};j.prototype.showFormModal=function(a){for(var d,e=a.split("&"),g=0,h;g<e.length;g++){h=e[g].split("=");if("action"==h[0]){d=h[1]}}b.get_strings([{key:"statusformtitleaccept",component:"tool_policy"},{key:"iagreetothepolicy",component:"tool_policy"},{key:"statusformtitlerevoke",component:"tool_policy"},{key:"irevokethepolicy",component:"tool_policy"},{key:"statusformtitledecline",component:"tool_policy"},{key:"declinethepolicy",component:"tool_policy"}]).then(function(b){var e,f;if("accept"==d){e=b[0];f=b[1]}else if("revoke"==d){e=b[2];f=b[3]}else if("decline"==d){e=b[4];f=b[5]}return c.create({type:c.types.SAVE_CANCEL,title:e,body:""}).done(function(b){this.modal=b;this.setupFormModal(a,f)}.bind(this))}.bind(this)).catch(f.exception)};j.prototype.setupFormModal=function(a,b){var c=this.modal;c.setLarge();c.setSaveButtonText(b);c.getRoot().on(d.hidden,this.destroy.bind(this));c.setBody(this.getBody(a));c.getRoot().on(d.save,this.submitForm.bind(this));c.getRoot().on("submit","form",this.submitFormAjax.bind(this));c.show()};j.prototype.getBody=function(a){if("undefined"==typeof a){a={}}var b={jsonformdata:JSON.stringify(a)};return g.loadFragment("tool_policy","accept_on_behalf",this.contextid,b)};j.prototype.submitFormAjax=function(a){a.preventDefault();var b=this.modal.getRoot().find("form").serialize(),c=h.call([{methodname:"tool_policy_submit_accept_on_behalf",args:{jsonformdata:JSON.stringify(b)}}]);c[0].done(function(a){if(a.validationerrors){this.modal.setBody(this.getBody(b))}else{this.close()}}.bind(this)).fail(f.exception)};j.prototype.submitForm=function(a){a.preventDefault();this.modal.getRoot().find("form").submit()};j.prototype.close=function(){this.destroy();document.location.reload()};j.prototype.destroy=function(){i.resetAllFormDirtyStates();this.modal.destroy();this.currentTrigger.focus()};return{getInstance:function getInstance(a){return new j(a)}}});
|
||||
//# sourceMappingURL=acceptmodal.min.js.map
|
||||
|
File diff suppressed because one or more lines are too long
@ -20,9 +20,25 @@
|
||||
* @copyright 2018 Marina Glancy
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
define(['jquery', 'core/str', 'core/modal_factory', 'core/modal_events', 'core/notification', 'core/fragment',
|
||||
'core/ajax', 'core/yui'],
|
||||
function($, Str, ModalFactory, ModalEvents, Notification, Fragment, Ajax, Y) {
|
||||
define([
|
||||
'jquery',
|
||||
'core/str',
|
||||
'core/modal_factory',
|
||||
'core/modal_events',
|
||||
'core/notification',
|
||||
'core/fragment',
|
||||
'core/ajax',
|
||||
'core_form/changechecker',
|
||||
], function(
|
||||
$,
|
||||
Str,
|
||||
ModalFactory,
|
||||
ModalEvents,
|
||||
Notification,
|
||||
Fragment,
|
||||
Ajax,
|
||||
FormChangeChecker
|
||||
) {
|
||||
|
||||
"use strict";
|
||||
|
||||
@ -244,9 +260,7 @@ define(['jquery', 'core/str', 'core/modal_factory', 'core/modal_events', 'core/n
|
||||
* Destroy the modal
|
||||
*/
|
||||
AcceptOnBehalf.prototype.destroy = function() {
|
||||
Y.use('moodle-core-formchangechecker', function() {
|
||||
M.core_formchangechecker.reset_form_dirty_state();
|
||||
});
|
||||
FormChangeChecker.resetAllFormDirtyStates();
|
||||
this.modal.destroy();
|
||||
this.currentTrigger.focus();
|
||||
};
|
||||
|
@ -73,14 +73,7 @@ echo $OUTPUT->heading(get_string('bulkactivitycompletion', 'completion'));
|
||||
|
||||
echo $renderer->navigation($course, 'bulkcompletion');
|
||||
|
||||
$PAGE->requires->yui_module('moodle-core-formchangechecker',
|
||||
'M.core_formchangechecker.init',
|
||||
array(array(
|
||||
'formid' => 'theform'
|
||||
))
|
||||
);
|
||||
$PAGE->requires->string_for_js('changesmadereallygoaway', 'moodle');
|
||||
|
||||
$PAGE->requires->js_call_amd('core_form/changechecker', 'watchFormById', ['theform']);
|
||||
|
||||
echo $renderer->bulkcompletion($bulkcompletiondata);
|
||||
|
||||
|
@ -68,13 +68,7 @@ echo $OUTPUT->heading(get_string('defaultcompletion', 'completion'));
|
||||
|
||||
echo $renderer->navigation($course, 'defaultcompletion');
|
||||
|
||||
$PAGE->requires->yui_module('moodle-core-formchangechecker',
|
||||
'M.core_formchangechecker.init',
|
||||
array(array(
|
||||
'formid' => 'theform'
|
||||
))
|
||||
);
|
||||
$PAGE->requires->string_for_js('changesmadereallygoaway', 'moodle');
|
||||
$PAGE->requires->js_call_amd('core_form/changechecker', 'watchFormById', ['theform']);
|
||||
|
||||
echo $renderer->defaultcompletion($activityresourcedata);
|
||||
|
||||
|
@ -299,13 +299,7 @@ if ($moving) {
|
||||
|
||||
echo $OUTPUT->container_end();
|
||||
|
||||
$PAGE->requires->yui_module('moodle-core-formchangechecker',
|
||||
'M.core_formchangechecker.init',
|
||||
array(array(
|
||||
'formid' => 'gradetreeform'
|
||||
))
|
||||
);
|
||||
$PAGE->requires->string_for_js('changesmadereallygoaway', 'moodle');
|
||||
$PAGE->requires->js_call_amd('core_form/changechecker', 'watchFormById', ['gradetreeform']);
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
die;
|
||||
|
@ -1254,13 +1254,7 @@ class grade_report_grader extends grade_report {
|
||||
$PAGE->requires->strings_for_js(array('addfeedback', 'feedback', 'grade'), 'grades');
|
||||
$PAGE->requires->strings_for_js(array('ajaxchoosescale', 'ajaxclicktoclose', 'ajaxerror', 'ajaxfailedupdate', 'ajaxfieldchanged'), 'gradereport_grader');
|
||||
if (!$enableajax && $USER->gradeediting[$this->courseid]) {
|
||||
$PAGE->requires->yui_module('moodle-core-formchangechecker',
|
||||
'M.core_formchangechecker.init',
|
||||
array(array(
|
||||
'formid' => 'gradereport_grader'
|
||||
))
|
||||
);
|
||||
$PAGE->requires->string_for_js('changesmadereallygoaway', 'moodle');
|
||||
$PAGE->requires->js_call_amd('core_form/changechecker', 'watchFormById', ['gradereport_grader']);
|
||||
}
|
||||
|
||||
$rows = $this->get_right_range_row($rows);
|
||||
|
2
lib/amd/build/form-autocomplete.min.js
vendored
2
lib/amd/build/form-autocomplete.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -21,10 +21,25 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @since 3.0
|
||||
*/
|
||||
define(
|
||||
['jquery', 'core/log', 'core/str', 'core/templates', 'core/notification', 'core/loadingicon', 'core/aria'],
|
||||
function($, log, str, templates, notification, LoadingIcon, Aria) {
|
||||
|
||||
define([
|
||||
'jquery',
|
||||
'core/log',
|
||||
'core/str',
|
||||
'core/templates',
|
||||
'core/notification',
|
||||
'core/loadingicon',
|
||||
'core/aria',
|
||||
'core_form/changechecker',
|
||||
], function(
|
||||
$,
|
||||
log,
|
||||
str,
|
||||
templates,
|
||||
notification,
|
||||
LoadingIcon,
|
||||
Aria,
|
||||
FormChangeChecker
|
||||
) {
|
||||
// Private functions and variables.
|
||||
/** @var {Object} KEYS - List of keycode constants. */
|
||||
var KEYS = {
|
||||
@ -202,9 +217,7 @@ function($, log, str, templates, notification, LoadingIcon, Aria) {
|
||||
* @param {jQuery} originalSelect The jQuery object matching the hidden select list.
|
||||
*/
|
||||
var notifyChange = function(originalSelect) {
|
||||
if (typeof M.core_formchangechecker !== 'undefined') {
|
||||
M.core_formchangechecker.set_form_changed();
|
||||
}
|
||||
FormChangeChecker.markFormChangedFromNode(originalSelect[0]);
|
||||
|
||||
// Note, jQuery .change() was not working here. Better to
|
||||
// use plain JavaScript anyway.
|
||||
|
2
lib/form/amd/build/dynamicform.min.js
vendored
2
lib/form/amd/build/dynamicform.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
2
lib/form/amd/build/modalform.min.js
vendored
2
lib/form/amd/build/modalform.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -34,13 +34,13 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
import Ajax from 'core/ajax';
|
||||
import * as FormChangeChecker from 'core_form/changechecker';
|
||||
import * as FormEvents from 'core_form/events';
|
||||
import Ajax from 'core/ajax';
|
||||
import Fragment from 'core/fragment';
|
||||
import Notification from 'core/notification';
|
||||
import Pending from 'core/pending';
|
||||
import Templates from 'core/templates';
|
||||
import Y from 'core/yui';
|
||||
import {get_strings as getStrings} from 'core/str';
|
||||
|
||||
/**
|
||||
@ -261,18 +261,11 @@ export default class DynamicForm {
|
||||
/**
|
||||
* Notifies listeners that form dirty state should be reset.
|
||||
*
|
||||
* @return {Promise<unknown>}
|
||||
* @fires event:formSubmittedByJavascript
|
||||
*/
|
||||
notifyResetFormChanges() {
|
||||
FormEvents.notifyFormSubmittedByJavascript(this.getFormNode(), true);
|
||||
|
||||
return new Promise(resolve => {
|
||||
Y.use('event', 'moodle-core-event', 'moodle-core-formchangechecker', () => {
|
||||
M.core_formchangechecker.reset_form_dirty_state();
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
FormChangeChecker.resetFormDirtyState(this.getFormNode());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -280,16 +273,13 @@ export default class DynamicForm {
|
||||
*/
|
||||
processCancelButton() {
|
||||
// Notify listeners that the form is about to be submitted (this will reset atto autosave).
|
||||
this.notifyResetFormChanges()
|
||||
.then(() => {
|
||||
const event = this.trigger(this.events.FORM_CANCELLED);
|
||||
if (!event.defaultPrevented) {
|
||||
// By default removes the form from the DOM.
|
||||
this.container.innerHTML = '';
|
||||
}
|
||||
return null;
|
||||
})
|
||||
.catch(null);
|
||||
this.notifyResetFormChanges();
|
||||
|
||||
const event = this.trigger(this.events.FORM_CANCELLED);
|
||||
if (!event.defaultPrevented) {
|
||||
// By default removes the form from the DOM.
|
||||
this.container.innerHTML = '';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -373,9 +363,8 @@ export default class DynamicForm {
|
||||
// Form was submitted properly.
|
||||
const data = JSON.parse(response.data);
|
||||
this.enableButtons();
|
||||
this.notifyResetFormChanges()
|
||||
.then(() => this.onSubmitSuccess(data))
|
||||
.catch();
|
||||
this.notifyResetFormChanges();
|
||||
this.onSubmitSuccess(data);
|
||||
}
|
||||
return null;
|
||||
})
|
||||
|
@ -36,13 +36,13 @@
|
||||
*/
|
||||
|
||||
import Ajax from 'core/ajax';
|
||||
import * as FormChangeChecker from 'core_form/changechecker';
|
||||
import * as FormEvents from 'core_form/events';
|
||||
import Fragment from 'core/fragment';
|
||||
import ModalEvents from 'core/modal_events';
|
||||
import ModalFactory from 'core/modal_factory';
|
||||
import Notification from 'core/notification';
|
||||
import Pending from 'core/pending';
|
||||
import Y from 'core/yui';
|
||||
|
||||
export default class ModalForm {
|
||||
|
||||
@ -129,16 +129,12 @@ export default class ModalForm {
|
||||
|
||||
// After successfull submit, when we press "Cancel" or close the dialogue by clicking on X in the top right corner.
|
||||
this.modal.getRoot().on(ModalEvents.hidden, () => {
|
||||
this.notifyResetFormChanges()
|
||||
.then(() => {
|
||||
this.modal.destroy();
|
||||
// Focus on the element that actually launched the modal.
|
||||
if (this.config.returnFocus) {
|
||||
this.config.returnFocus.focus();
|
||||
}
|
||||
return null;
|
||||
})
|
||||
.catch(() => null);
|
||||
this.notifyResetFormChanges();
|
||||
this.modal.destroy();
|
||||
// Focus on the element that actually launched the modal.
|
||||
if (this.config.returnFocus) {
|
||||
this.config.returnFocus.focus();
|
||||
}
|
||||
});
|
||||
|
||||
// Add the class to the modal dialogue.
|
||||
@ -266,7 +262,6 @@ export default class ModalForm {
|
||||
/**
|
||||
* Notifies listeners that form dirty state should be reset.
|
||||
*
|
||||
* @return {Promise<unknown>}
|
||||
* @fires event:formSubmittedByJavascript
|
||||
*/
|
||||
notifyResetFormChanges() {
|
||||
@ -274,17 +269,10 @@ export default class ModalForm {
|
||||
FormEvents.notifyFormSubmittedByJavascript(this.getFormNode(), true);
|
||||
|
||||
if (!form) {
|
||||
return Promise.resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
return new Promise(resolve => {
|
||||
Y.use('event', 'moodle-core-event', 'moodle-core-formchangechecker', () => {
|
||||
// Ensure that modal contains a form element (it may not if the form class threw an early exception).
|
||||
M.core_formchangechecker.reset_form_dirty_state();
|
||||
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
FormChangeChecker.resetFormDirtyState(this.getFormNode());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -388,14 +376,11 @@ export default class ModalForm {
|
||||
} else {
|
||||
// Form was submitted properly. Hide the modal and execute callback.
|
||||
const data = JSON.parse(response.data);
|
||||
return this.notifyResetFormChanges()
|
||||
.then(() => {
|
||||
const event = this.trigger(this.events.FORM_SUBMITTED, data);
|
||||
if (!event.defaultPrevented) {
|
||||
this.modal.hide();
|
||||
}
|
||||
return null;
|
||||
});
|
||||
this.notifyResetFormChanges();
|
||||
const event = this.trigger(this.events.FORM_SUBMITTED, data);
|
||||
if (!event.defaultPrevented) {
|
||||
this.modal.hide();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
})
|
||||
|
@ -38,12 +38,21 @@
|
||||
* this.options.itemid
|
||||
*/
|
||||
|
||||
/* eslint camelcase: off */
|
||||
|
||||
M.form_filemanager = {templates:{}};
|
||||
M.form_filemanager = {
|
||||
templates: {},
|
||||
formChangeChecker: null,
|
||||
};
|
||||
|
||||
require(['core_form/changechecker'], function(FormChangeChecker) {
|
||||
// This is a nasty, hacky, way of doing it but it's the smallest evil.
|
||||
M.form_filemanager.formChangeChecker = FormChangeChecker;
|
||||
});
|
||||
|
||||
M.form_filemanager.set_templates = function(Y, templates) {
|
||||
M.form_filemanager.templates = templates;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* This fucntion is called for each file picker on page.
|
||||
@ -199,9 +208,7 @@ M.form_filemanager.init = function(Y, options) {
|
||||
this.filecount++;
|
||||
this.check_buttons();
|
||||
this.refresh(this.currentpath);
|
||||
if (typeof M.core_formchangechecker != 'undefined') {
|
||||
M.core_formchangechecker.set_form_changed();
|
||||
}
|
||||
M.form_filemanager.formChangeChecker.markFormChangedFromNode(this.filemanager.getDOMNode());
|
||||
},
|
||||
check_buttons: function() {
|
||||
if (this.filecount>0) {
|
||||
@ -328,9 +335,7 @@ M.form_filemanager.init = function(Y, options) {
|
||||
scope.mkdir_dialog.hide();
|
||||
scope.refresh(filepath);
|
||||
Y.one('#fm-newname-'+scope.client_id).set('value', '');
|
||||
if (typeof M.core_formchangechecker != 'undefined') {
|
||||
M.core_formchangechecker.set_form_changed();
|
||||
}
|
||||
M.form_filemanager.formChangeChecker.markFormChangedFromNode(scope.filemanager.getDOMNode());
|
||||
}
|
||||
});
|
||||
};
|
||||
@ -460,9 +465,7 @@ M.form_filemanager.init = function(Y, options) {
|
||||
if (obj && obj.length) {
|
||||
args.scope.refresh(obj[0]);
|
||||
}
|
||||
if (typeof M.core_formchangechecker != 'undefined') {
|
||||
M.core_formchangechecker.set_form_changed();
|
||||
}
|
||||
M.form_filemanager.formChangeChecker.markFormChangedFromNode(this.scope.filemanager.getDOMNode());
|
||||
}
|
||||
});
|
||||
};
|
||||
@ -853,9 +856,7 @@ M.form_filemanager.init = function(Y, options) {
|
||||
} else {
|
||||
args.scope.selectui.hide();
|
||||
args.scope.refresh((obj && obj.filepath) ? obj.filepath : '/');
|
||||
if (typeof M.core_formchangechecker != 'undefined') {
|
||||
M.core_formchangechecker.set_form_changed();
|
||||
}
|
||||
M.form_filemanager.formChangeChecker.markFormChangedFromNode(this.scope.filemanager.getDOMNode());
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -970,9 +971,7 @@ M.form_filemanager.init = function(Y, options) {
|
||||
//args.scope.selectui.hide();
|
||||
args.scope.filecount--;
|
||||
args.scope.refresh(obj.filepath);
|
||||
if (typeof M.core_formchangechecker != 'undefined') {
|
||||
M.core_formchangechecker.set_form_changed();
|
||||
}
|
||||
M.form_filemanager.formChangeChecker.markFormChangedFromNode(this.scope.filemanager.getDOMNode());
|
||||
}
|
||||
});
|
||||
};
|
||||
|
@ -1615,7 +1615,7 @@ class MoodleQuickForm extends HTML_QuickForm_DHTMLRulesTableless {
|
||||
*/
|
||||
var $_disableShortforms = false;
|
||||
|
||||
/** @var bool whether to automatically initialise M.formchangechecker for this form. */
|
||||
/** @var bool whether to automatically initialise the form change detector this form. */
|
||||
protected $_use_form_change_checker = true;
|
||||
|
||||
/**
|
||||
@ -3135,14 +3135,10 @@ class MoodleQuickForm_Renderer extends HTML_QuickForm_Renderer_Tableless{
|
||||
}
|
||||
|
||||
if ($form->is_form_change_checker_enabled()) {
|
||||
$PAGE->requires->yui_module('moodle-core-formchangechecker',
|
||||
'M.core_formchangechecker.init',
|
||||
array(array(
|
||||
'formid' => $formid,
|
||||
'initialdirtystate' => $form->is_dirty(),
|
||||
))
|
||||
);
|
||||
$PAGE->requires->string_for_js('changesmadereallygoaway', 'moodle');
|
||||
$PAGE->requires->js_call_amd('core_form/changechecker', 'watchFormById', [$formid]);
|
||||
if ($form->is_dirty()) {
|
||||
$PAGE->requires->js_call_amd('core_form/changechecker', 'markFormAsDirtyById', [$formid]);
|
||||
}
|
||||
}
|
||||
if (!empty($this->_collapsibleElements)) {
|
||||
if (count($this->_collapsibleElements) > 1) {
|
||||
|
@ -242,84 +242,84 @@ M.util.show_confirm_dialog = function(e, args) {
|
||||
e.preventDefault();
|
||||
}
|
||||
|
||||
YUI().use('moodle-core-notification-confirm', function(Y) {
|
||||
var confirmationDialogue = new M.core.confirm({
|
||||
width: '300px',
|
||||
center: true,
|
||||
modal: true,
|
||||
visible: false,
|
||||
draggable: false,
|
||||
title: M.util.get_string('confirmation', 'admin'),
|
||||
noLabel: M.util.get_string('cancel', 'moodle'),
|
||||
question: args.message
|
||||
});
|
||||
require(['core_form/changechecker'], function(FormChangeChecker) {
|
||||
// eslint-disable-next-line no-undef, new-cap
|
||||
YUI().use('moodle-core-notification-confirm', function(Y) {
|
||||
var confirmationDialogue = new M.core.confirm({
|
||||
width: '300px',
|
||||
center: true,
|
||||
modal: true,
|
||||
visible: false,
|
||||
draggable: false,
|
||||
title: M.util.get_string('confirmation', 'admin'),
|
||||
noLabel: M.util.get_string('cancel', 'moodle'),
|
||||
question: args.message
|
||||
});
|
||||
|
||||
// The dialogue was submitted with a positive value indication.
|
||||
confirmationDialogue.on('complete-yes', function(e) {
|
||||
// Handle any callbacks.
|
||||
if (args.callback) {
|
||||
if (!Y.Lang.isFunction(args.callback)) {
|
||||
Y.log('Callbacks to show_confirm_dialog must now be functions. Please update your code to pass in a function instead.',
|
||||
'warn', 'M.util.show_confirm_dialog');
|
||||
return;
|
||||
}
|
||||
|
||||
var scope = e.target;
|
||||
if (Y.Lang.isObject(args.scope)) {
|
||||
scope = args.scope;
|
||||
}
|
||||
|
||||
var callbackargs = args.callbackargs || [];
|
||||
args.callback.apply(scope, callbackargs);
|
||||
return;
|
||||
}
|
||||
|
||||
var targetancestor = null,
|
||||
targetform = null;
|
||||
|
||||
if (target.test('a')) {
|
||||
window.location = target.get('href');
|
||||
|
||||
} else if ((targetancestor = target.ancestor('a')) !== null) {
|
||||
window.location = targetancestor.get('href');
|
||||
|
||||
} else if (target.test('input') || target.test('button')) {
|
||||
targetform = target.ancestor('form', true);
|
||||
if (!targetform) {
|
||||
return;
|
||||
}
|
||||
if (target.get('name') && target.get('value')) {
|
||||
targetform.append('<input type="hidden" name="' + target.get('name') +
|
||||
'" value="' + target.get('value') + '">');
|
||||
if (typeof M.core_formchangechecker !== 'undefined') {
|
||||
M.core_formchangechecker.set_form_submitted();
|
||||
// The dialogue was submitted with a positive value indication.
|
||||
confirmationDialogue.on('complete-yes', function(e) {
|
||||
// Handle any callbacks.
|
||||
if (args.callback) {
|
||||
if (!Y.Lang.isFunction(args.callback)) {
|
||||
Y.log('Callbacks to show_confirm_dialog must now be functions. ' +
|
||||
'Please update your code to pass in a function instead.',
|
||||
'warn', 'M.util.show_confirm_dialog');
|
||||
return;
|
||||
}
|
||||
}
|
||||
targetform.submit();
|
||||
|
||||
} else if (target.test('form')) {
|
||||
if (typeof M.core_formchangechecker !== 'undefined') {
|
||||
M.core_formchangechecker.set_form_submitted();
|
||||
}
|
||||
target.submit();
|
||||
var scope = e.target;
|
||||
if (Y.Lang.isObject(args.scope)) {
|
||||
scope = args.scope;
|
||||
}
|
||||
|
||||
} else {
|
||||
Y.log("Element of type " + target.get('tagName') +
|
||||
" is not supported by the M.util.show_confirm_dialog function. Use A, INPUT, BUTTON or FORM",
|
||||
'warn', 'javascript-static');
|
||||
var callbackargs = args.callbackargs || [];
|
||||
args.callback.apply(scope, callbackargs);
|
||||
return;
|
||||
}
|
||||
|
||||
var targetancestor = null,
|
||||
targetform = null;
|
||||
|
||||
if (target.test('a')) {
|
||||
window.location = target.get('href');
|
||||
|
||||
} else if ((targetancestor = target.ancestor('a')) !== null) {
|
||||
window.location = targetancestor.get('href');
|
||||
|
||||
} else if (target.test('input') || target.test('button')) {
|
||||
targetform = target.ancestor('form', true);
|
||||
if (!targetform) {
|
||||
return;
|
||||
}
|
||||
if (target.get('name') && target.get('value')) {
|
||||
targetform.append('<input type="hidden" name="' + target.get('name') +
|
||||
'" value="' + target.get('value') + '">');
|
||||
FormChangeChecker.markFormAsDirty(targetform);
|
||||
}
|
||||
targetform.submit();
|
||||
|
||||
} else if (target.test('form')) {
|
||||
FormChangeChecker.markFormAsDirty(target);
|
||||
target.submit();
|
||||
|
||||
} else {
|
||||
Y.log("Element of type " + target.get('tagName') +
|
||||
" is not supported by the M.util.show_confirm_dialog function. Use A, INPUT, BUTTON or FORM",
|
||||
'warn', 'javascript-static');
|
||||
}
|
||||
}, this);
|
||||
|
||||
if (args.cancellabel) {
|
||||
confirmationDialogue.set('noLabel', args.cancellabel);
|
||||
}
|
||||
}, this);
|
||||
|
||||
if (args.cancellabel) {
|
||||
confirmationDialogue.set('noLabel', args.cancellabel);
|
||||
}
|
||||
if (args.continuelabel) {
|
||||
confirmationDialogue.set('yesLabel', args.continuelabel);
|
||||
}
|
||||
|
||||
if (args.continuelabel) {
|
||||
confirmationDialogue.set('yesLabel', args.continuelabel);
|
||||
}
|
||||
|
||||
confirmationDialogue.render()
|
||||
.show();
|
||||
confirmationDialogue.render()
|
||||
.show();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -4220,8 +4220,6 @@ EOD;
|
||||
'page' => $this->page
|
||||
);
|
||||
}
|
||||
|
||||
$this->page->requires->string_for_js('changesmadereallygoaway', 'moodle');
|
||||
}
|
||||
} else {
|
||||
$heading = null;
|
||||
|
2
mod/assign/amd/build/grading_panel.min.js
vendored
2
mod/assign/amd/build/grading_panel.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
2
mod/assign/amd/build/override_form.min.js
vendored
2
mod/assign/amd/build/override_form.min.js
vendored
@ -1,2 +1,2 @@
|
||||
define ("mod_assign/override_form",["exports","jquery"],function(a,b){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.init=void 0;b=function(a){return a&&a.__esModule?a:{default:a}}(b);var c=function(a,c){var d=document.getElementById(a),e=d.querySelector("[name=\"".concat(c,"\"]"));(0,b.default)(e).on("change",function(){var a=document.createElement("input");a.setAttribute("type","hidden");a.setAttribute("name","userchange");a.setAttribute("value",!0);d.appendChild(a);if("undefined"!=typeof M.core_formchangechecker){M.core_formchangechecker.reset_form_dirty_state()}d.submit()})};a.init=c});
|
||||
function _typeof(a){"@babel/helpers - typeof";if("function"==typeof Symbol&&"symbol"==typeof Symbol.iterator){_typeof=function(a){return typeof a}}else{_typeof=function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a}}return _typeof(a)}define ("mod_assign/override_form",["exports","jquery","core_form/changechecker"],function(a,b,c){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.init=void 0;b=function(a){return a&&a.__esModule?a:{default:a}}(b);c=e(c);function d(){if("function"!=typeof WeakMap)return null;var a=new WeakMap;d=function(){return a};return a}function e(a){if(a&&a.__esModule){return a}if(null===a||"object"!==_typeof(a)&&"function"!=typeof a){return{default:a}}var b=d();if(b&&b.has(a)){return b.get(a)}var c={},e=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var f in a){if(Object.prototype.hasOwnProperty.call(a,f)){var g=e?Object.getOwnPropertyDescriptor(a,f):null;if(g&&(g.get||g.set)){Object.defineProperty(c,f,g)}else{c[f]=a[f]}}}c.default=a;if(b){b.set(a,c)}return c}var f=function(a,d){var e=document.getElementById(a),f=e.querySelector("[name=\"".concat(d,"\"]"));(0,b.default)(f).on("change",function(){var a=document.createElement("input");a.setAttribute("type","hidden");a.setAttribute("name","userchange");a.setAttribute("value",!0);e.appendChild(a);c.markFormSubmitted(a);e.submit()})};a.init=f});
|
||||
//# sourceMappingURL=override_form.min.js.map
|
||||
|
@ -1 +1 @@
|
||||
{"version":3,"sources":["../src/override_form.js"],"names":["init","formId","selectElementName","form","document","getElementById","selectElement","querySelector","on","inputElement","createElement","setAttribute","appendChild","M","core_formchangechecker","reset_form_dirty_state","submit"],"mappings":"kJAsBA,uDAEO,GAAMA,CAAAA,CAAI,CAAG,SAACC,CAAD,CAASC,CAAT,CAA+B,IACzCC,CAAAA,CAAI,CAAGC,QAAQ,CAACC,cAAT,CAAwBJ,CAAxB,CADkC,CAEzCK,CAAa,CAAGH,CAAI,CAACI,aAAL,mBAA6BL,CAA7B,QAFyB,CAI/C,cAAEI,CAAF,EAAiBE,EAAjB,CAAoB,QAApB,CAA8B,UAAM,CAChC,GAAMC,CAAAA,CAAY,CAAGL,QAAQ,CAACM,aAAT,CAAuB,OAAvB,CAArB,CACAD,CAAY,CAACE,YAAb,CAA0B,MAA1B,CAAkC,QAAlC,EACAF,CAAY,CAACE,YAAb,CAA0B,MAA1B,CAAkC,YAAlC,EACAF,CAAY,CAACE,YAAb,CAA0B,OAA1B,KAEAR,CAAI,CAACS,WAAL,CAAiBH,CAAjB,EAEA,GAAwC,WAApC,QAAOI,CAAAA,CAAC,CAACC,sBAAb,CAAqD,CACjDD,CAAC,CAACC,sBAAF,CAAyBC,sBAAzB,EACH,CAEDZ,CAAI,CAACa,MAAL,EACH,CAbD,CAcH,CAlBM,C","sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see <http://www.gnu.org/licenses/>.\n\n/**\n * A javascript module to enhance the override form.\n *\n * @copyright 2019 Ryan Wyllie <ryan@moodle.com>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport $ from 'jquery';\n\nexport const init = (formId, selectElementName) => {\n const form = document.getElementById(formId);\n const selectElement = form.querySelector(`[name=\"${selectElementName}\"]`);\n\n $(selectElement).on('change', () => {\n const inputElement = document.createElement('input');\n inputElement.setAttribute('type', 'hidden');\n inputElement.setAttribute('name', 'userchange');\n inputElement.setAttribute('value', true);\n\n form.appendChild(inputElement);\n\n if (typeof M.core_formchangechecker !== 'undefined') {\n M.core_formchangechecker.reset_form_dirty_state();\n }\n\n form.submit();\n });\n};"],"file":"override_form.min.js"}
|
||||
{"version":3,"sources":["../src/override_form.js"],"names":["init","formId","selectElementName","form","document","getElementById","selectElement","querySelector","on","inputElement","createElement","setAttribute","appendChild","FormChangeChecker","markFormSubmitted","submit"],"mappings":"idAsBA,uDACA,O,siBAEO,GAAMA,CAAAA,CAAI,CAAG,SAACC,CAAD,CAASC,CAAT,CAA+B,IACzCC,CAAAA,CAAI,CAAGC,QAAQ,CAACC,cAAT,CAAwBJ,CAAxB,CADkC,CAEzCK,CAAa,CAAGH,CAAI,CAACI,aAAL,mBAA6BL,CAA7B,QAFyB,CAI/C,cAAEI,CAAF,EAAiBE,EAAjB,CAAoB,QAApB,CAA8B,UAAM,CAChC,GAAMC,CAAAA,CAAY,CAAGL,QAAQ,CAACM,aAAT,CAAuB,OAAvB,CAArB,CACAD,CAAY,CAACE,YAAb,CAA0B,MAA1B,CAAkC,QAAlC,EACAF,CAAY,CAACE,YAAb,CAA0B,MAA1B,CAAkC,YAAlC,EACAF,CAAY,CAACE,YAAb,CAA0B,OAA1B,KAEAR,CAAI,CAACS,WAAL,CAAiBH,CAAjB,EAEAI,CAAiB,CAACC,iBAAlB,CAAoCL,CAApC,EAEAN,CAAI,CAACY,MAAL,EACH,CAXD,CAYH,CAhBM,C","sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see <http://www.gnu.org/licenses/>.\n\n/**\n * A javascript module to enhance the override form.\n *\n * @copyright 2019 Ryan Wyllie <ryan@moodle.com>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport $ from 'jquery';\nimport * as FormChangeChecker from 'core_form/changechecker';\n\nexport const init = (formId, selectElementName) => {\n const form = document.getElementById(formId);\n const selectElement = form.querySelector(`[name=\"${selectElementName}\"]`);\n\n $(selectElement).on('change', () => {\n const inputElement = document.createElement('input');\n inputElement.setAttribute('type', 'hidden');\n inputElement.setAttribute('name', 'userchange');\n inputElement.setAttribute('value', true);\n\n form.appendChild(inputElement);\n\n FormChangeChecker.markFormSubmitted(inputElement);\n\n form.submit();\n });\n};\n"],"file":"override_form.min.js"}
|
@ -22,11 +22,32 @@
|
||||
* @since 3.1
|
||||
*/
|
||||
define([
|
||||
'jquery', 'core/yui', 'core/notification', 'core/templates', 'core/fragment',
|
||||
'core/ajax', 'core/str', 'mod_assign/grading_form_change_checker',
|
||||
'mod_assign/grading_events', 'core_form/events', 'core/toast'
|
||||
],
|
||||
function($, Y, notification, templates, fragment, ajax, str, checker, GradingEvents, FormEvents, Toast) {
|
||||
'jquery',
|
||||
'core/yui',
|
||||
'core/notification',
|
||||
'core/templates',
|
||||
'core/fragment',
|
||||
'core/ajax',
|
||||
'core/str',
|
||||
'mod_assign/grading_form_change_checker',
|
||||
'mod_assign/grading_events',
|
||||
'core_form/events',
|
||||
'core/toast',
|
||||
'core_form/changechecker',
|
||||
], function(
|
||||
$,
|
||||
Y,
|
||||
notification,
|
||||
templates,
|
||||
fragment,
|
||||
ajax,
|
||||
str,
|
||||
checker,
|
||||
GradingEvents,
|
||||
FormEvents,
|
||||
Toast,
|
||||
FormChangeChecker
|
||||
) {
|
||||
|
||||
/**
|
||||
* GradingPanel class.
|
||||
@ -120,6 +141,9 @@ function($, Y, notification, templates, fragment, ajax, str, checker, GradingEve
|
||||
|
||||
$('[data-region="overlay"]').show();
|
||||
|
||||
// Mark the form as submitted in the change checker.
|
||||
FormChangeChecker.markFormSubmitted(form[0]);
|
||||
|
||||
// We call this, so other modules can update the form with the latest state.
|
||||
form.trigger('save-form-state');
|
||||
|
||||
@ -145,9 +169,9 @@ function($, Y, notification, templates, fragment, ajax, str, checker, GradingEve
|
||||
* @private
|
||||
* @method _handleFormSubmissionResponse
|
||||
* @param {Array} formdata - submitted values
|
||||
* @param {Integer} nextUserId - optional. The id of the user to load after the form is saved.
|
||||
* @param {Number} [nextUserId] The id of the user to load after the form is saved
|
||||
* @param {Boolean} [nextUser] - Whether to switch to next user in the grading list.
|
||||
* @param {Array} response List of errors.
|
||||
* @param {Boolean} nextUser - optional. If true, switch to next user in the grading list.
|
||||
*/
|
||||
GradingPanel.prototype._handleFormSubmissionResponse = function(formdata, nextUserId, nextUser, response) {
|
||||
if (typeof nextUserId === "undefined") {
|
||||
@ -158,14 +182,17 @@ function($, Y, notification, templates, fragment, ajax, str, checker, GradingEve
|
||||
// validation errors.
|
||||
$(document).trigger('reset', [this._lastUserId, formdata]);
|
||||
} else {
|
||||
str.get_strings([
|
||||
{key: 'gradechangessaveddetail', component: 'mod_assign'},
|
||||
]).done(function(strs) {
|
||||
Toast.add(strs[0]);
|
||||
}).fail(notification.exception);
|
||||
Y.use('moodle-core-formchangechecker', function() {
|
||||
M.core_formchangechecker.reset_form_dirty_state();
|
||||
});
|
||||
str.get_string('gradechangessaveddetail', 'mod_assign')
|
||||
.then(function(str) {
|
||||
Toast.add(str);
|
||||
return str;
|
||||
})
|
||||
.catch(notification.exception);
|
||||
|
||||
// Reset the form state.
|
||||
var form = $(this._region.find('form.gradeform'));
|
||||
FormChangeChecker.resetFormDirtyState(form[0]);
|
||||
|
||||
if (nextUserId == this._lastUserId) {
|
||||
$(document).trigger('reset', nextUserId);
|
||||
} else if (nextUser) {
|
||||
|
@ -21,6 +21,7 @@
|
||||
*/
|
||||
|
||||
import $ from 'jquery';
|
||||
import * as FormChangeChecker from 'core_form/changechecker';
|
||||
|
||||
export const init = (formId, selectElementName) => {
|
||||
const form = document.getElementById(formId);
|
||||
@ -34,10 +35,8 @@ export const init = (formId, selectElementName) => {
|
||||
|
||||
form.appendChild(inputElement);
|
||||
|
||||
if (typeof M.core_formchangechecker !== 'undefined') {
|
||||
M.core_formchangechecker.reset_form_dirty_state();
|
||||
}
|
||||
FormChangeChecker.markFormSubmitted(inputElement);
|
||||
|
||||
form.submit();
|
||||
});
|
||||
};
|
||||
};
|
||||
|
@ -71,12 +71,17 @@ class feedback_edit_use_template_form extends moodleform {
|
||||
$options[get_string('public', 'feedback')] = $publicoptions;
|
||||
}
|
||||
|
||||
$attributes = 'onChange="M.core_formchangechecker.set_form_submitted(); this.form.submit()"';
|
||||
$elementgroup[] = $mform->createElement('selectgroups',
|
||||
'templateid',
|
||||
get_string('using_templates', 'feedback'),
|
||||
$options,
|
||||
$attributes);
|
||||
$attributes = [
|
||||
'onChange="this.form.submit()"',
|
||||
'data-form-change-checker-override="1"',
|
||||
];
|
||||
$elementgroup[] = $mform->createElement(
|
||||
'selectgroups',
|
||||
'templateid',
|
||||
get_string('using_templates', 'feedback'),
|
||||
$options,
|
||||
implode(' ', $attributes)
|
||||
);
|
||||
|
||||
$elementgroup[] = $mform->createElement('submit',
|
||||
'use_template',
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
2
mod/forum/amd/build/inpage_reply.min.js
vendored
2
mod/forum/amd/build/inpage_reply.min.js
vendored
@ -1,2 +1,2 @@
|
||||
define ("mod_forum/inpage_reply",["jquery","core/templates","core/notification","mod_forum/repository","mod_forum/selectors"],function(a,b,c,d,f){var g={NESTED_V2:4,THREADED:2,NESTED:3,FLAT_OLDEST_FIRST:1,FLAT_NEWEST_FIRST:-1},h={POST_CREATED:"mod_forum-post-created"},i={MOODLE:0},j=function(a){var b=a.find(f.post.inpageSubmitBtnText),c=a.find(f.post.loadingIconContainer),d=a.outerWidth();a.css("width",d);b.addClass("hidden");c.removeClass("hidden")},k=function(a){var b=a.find(f.post.inpageSubmitBtnText),c=a.find(f.post.loadingIconContainer);a.css("width","");b.removeClass("hidden");c.addClass("hidden")},l=function(l){l.on("click",f.post.inpageSubmitBtn,function(m){m.preventDefault();var e=a(m.currentTarget),n=e.parent().find(f.post.inpageReplyButton),o=e.parents(f.post.inpageReplyForm).get(0),p=o.elements.post.value.trim(),q=i.MOODLE,r=o.elements.reply.value,s=o.elements.subject.value,t=e.closest(f.post.post),u=o.elements.privatereply!=void 0?o.elements.privatereply.checked:!1,v=l.find(f.post.modeSelect),w=v.length?parseInt(v.get(0).value):null,x;if(p.length){j(e);n.prop("disabled",!0);d.addDiscussionPost(r,s,p,q,u,!0).then(function(a){var b=a.messages.reduce(function(a,b){if("success"==b.type){a+="<p>"+b.message+"</p>"}return a},"");c.addNotification({message:b,type:"success"});return a}).then(function(a){o.reset();var c=a.post;x=c.id;switch(w){case g.NESTED_V2:var d=c.capabilities,e=t.children().not(f.post.repliesContainer).find(f.post.authorName).text();c.parentauthorname=e;c.showactionmenu=d.view||d.controlreadstatus||d.edit||d.split||d.delete||d.export||c.urls.viewparent;return b.render("mod_forum/forum_discussion_nested_v2_post_reply",c);case g.THREADED:return b.render("mod_forum/forum_discussion_threaded_post",c);case g.NESTED:return b.render("mod_forum/forum_discussion_nested_post",c);default:return b.render("mod_forum/forum_discussion_post",c);}}).then(function(a,c){var d=t.find(f.post.repliesContainer).first();if(w==g.FLAT_NEWEST_FIRST){return b.prependNodeContents(d,a,c)}else{return b.appendNodeContents(d,a,c)}}).then(function(){e.trigger(h.POST_CREATED,x);k(e);n.prop("disabled",!1);if("undefined"!=typeof M.core_formchangechecker){M.core_formchangechecker.reset_form_dirty_state()}return t.find(f.post.inpageReplyContent).hide()}).then(function(){location.href="#p"+x}).catch(function(a){k(e);n.prop("disabled",!1);return c.exception(a)})}})};return{init:function init(a){l(a)},CONTENT_FORMATS:i,EVENTS:h}});
|
||||
define ("mod_forum/inpage_reply",["jquery","core/templates","core/notification","mod_forum/repository","mod_forum/selectors","core_form/changechecker"],function(a,b,c,d,f,g){var h={NESTED_V2:4,THREADED:2,NESTED:3,FLAT_OLDEST_FIRST:1,FLAT_NEWEST_FIRST:-1},i={POST_CREATED:"mod_forum-post-created"},j={MOODLE:0},k=function(a){var b=a.find(f.post.inpageSubmitBtnText),c=a.find(f.post.loadingIconContainer),d=a.outerWidth();a.css("width",d);b.addClass("hidden");c.removeClass("hidden")},l=function(a){var b=a.find(f.post.inpageSubmitBtnText),c=a.find(f.post.loadingIconContainer);a.css("width","");b.removeClass("hidden");c.addClass("hidden")},m=function(m){m.on("click",f.post.inpageSubmitBtn,function(n){n.preventDefault();var e=a(n.currentTarget),o=e.parent().find(f.post.inpageReplyButton),p=e.parents(f.post.inpageReplyForm).get(0),q=p.elements.post.value.trim(),r=j.MOODLE,s=p.elements.reply.value,t=p.elements.subject.value,u=e.closest(f.post.post),v=p.elements.privatereply!=void 0?p.elements.privatereply.checked:!1,w=m.find(f.post.modeSelect),x=w.length?parseInt(w.get(0).value):null,y;if(q.length){k(e);o.prop("disabled",!0);d.addDiscussionPost(s,t,q,r,v,!0).then(function(a){var b=a.messages.reduce(function(a,b){if("success"==b.type){a+="<p>"+b.message+"</p>"}return a},"");c.addNotification({message:b,type:"success"});return a}).then(function(a){p.reset();var c=a.post;y=c.id;switch(x){case h.NESTED_V2:var d=c.capabilities,e=u.children().not(f.post.repliesContainer).find(f.post.authorName).text();c.parentauthorname=e;c.showactionmenu=d.view||d.controlreadstatus||d.edit||d.split||d.delete||d.export||c.urls.viewparent;return b.render("mod_forum/forum_discussion_nested_v2_post_reply",c);case h.THREADED:return b.render("mod_forum/forum_discussion_threaded_post",c);case h.NESTED:return b.render("mod_forum/forum_discussion_nested_post",c);default:return b.render("mod_forum/forum_discussion_post",c);}}).then(function(a,c){var d=u.find(f.post.repliesContainer).first();if(x==h.FLAT_NEWEST_FIRST){return b.prependNodeContents(d,a,c)}else{return b.appendNodeContents(d,a,c)}}).then(function(){e.trigger(i.POST_CREATED,y);l(e);o.prop("disabled",!1);g.resetFormDirtyState(e[0]);return u.find(f.post.inpageReplyContent).hide()}).then(function(){location.href="#p"+y}).catch(function(a){l(e);o.prop("disabled",!1);return c.exception(a)})}})};return{init:function init(a){m(a)},CONTENT_FORMATS:j,EVENTS:i}});
|
||||
//# sourceMappingURL=inpage_reply.min.js.map
|
||||
|
File diff suppressed because one or more lines are too long
2
mod/forum/amd/build/posts_list.min.js
vendored
2
mod/forum/amd/build/posts_list.min.js
vendored
@ -1,2 +1,2 @@
|
||||
define ("mod_forum/posts_list",["jquery","core/templates","core/notification","core/pending","core/yui","mod_forum/selectors","mod_forum/inpage_reply"],function(a,b,c,d,e,f,g){var h=function(h){h.on("click",f.post.inpageReplyLink,function(h){h.preventDefault();if(window.location.hash){var i=window.location.href.split("#")[0];history.pushState({},document.title,i)}var j=new d("inpage-reply"),k=a(h.currentTarget).parents(f.post.forumCoreContent),l=k.find(f.post.forumSubject),m=a(h.currentTarget).parents(f.post.forumContent),n={postid:a(m).data("post-id"),reply_url:a(h.currentTarget).attr("href"),sesskey:M.cfg.sesskey,parentsubject:l.data("replySubject"),canreplyprivately:a(h.currentTarget).data("can-reply-privately"),postformat:g.CONTENT_FORMATS.MOODLE};if(!m.find(f.post.inpageReplyContent).length){b.render("mod_forum/inpage_reply",n).then(function(a,c){return b.appendNodeContents(k,a,c)}).then(function(){return m.find(f.post.inpageReplyContent).slideToggle(300,j.resolve).find("textarea").focus()}).then(function(){e.use("moodle-core-formchangechecker",function(){M.core_formchangechecker.init({formid:"inpage-reply-".concat(n.postid)})})}).fail(c.exception)}else{var o=m.find(f.post.inpageReplyContent);o.slideToggle(300,j.resolve);if(o.is(":visible")){o.find("textarea").focus()}}})};return{init:function init(a){h(a);g.init(a)}}});
|
||||
define ("mod_forum/posts_list",["jquery","core/templates","core/notification","core/pending","mod_forum/selectors","mod_forum/inpage_reply","core_form/changechecker"],function(a,b,c,d,f,g,h){var i=function(e){e.on("click",f.post.inpageReplyLink,function(i){i.preventDefault();if(window.location.hash){var e=window.location.href.split("#")[0];history.pushState({},document.title,e)}var j=new d("inpage-reply"),k=a(i.currentTarget).parents(f.post.forumCoreContent),l=k.find(f.post.forumSubject),m=a(i.currentTarget).parents(f.post.forumContent),n={postid:a(m).data("post-id"),reply_url:a(i.currentTarget).attr("href"),sesskey:M.cfg.sesskey,parentsubject:l.data("replySubject"),canreplyprivately:a(i.currentTarget).data("can-reply-privately"),postformat:g.CONTENT_FORMATS.MOODLE};if(!m.find(f.post.inpageReplyContent).length){b.render("mod_forum/inpage_reply",n).then(function(a,c){return b.appendNodeContents(k,a,c)}).then(function(){return m.find(f.post.inpageReplyContent).slideToggle(300,j.resolve).find("textarea").focus()}).then(function(){h.watchFormById("inpage-reply-".concat(n.postid))}).catch(c.exception)}else{var o=m.find(f.post.inpageReplyContent);o.slideToggle(300,j.resolve);if(o.is(":visible")){o.find("textarea").focus()}}})};return{init:function init(a){i(a);g.init(a)}}});
|
||||
//# sourceMappingURL=posts_list.min.js.map
|
||||
|
File diff suppressed because one or more lines are too long
@ -23,6 +23,7 @@
|
||||
import $ from 'jquery';
|
||||
import AutoRows from 'core/auto_rows';
|
||||
import CustomEvents from 'core/custom_interaction_events';
|
||||
import * as FormChangeChecker from 'core_form/changechecker';
|
||||
import Notification from 'core/notification';
|
||||
import Templates from 'core/templates';
|
||||
import Discussion from 'mod_forum/discussion';
|
||||
@ -247,20 +248,7 @@ const buildShowInPageReplyFormFunction = (additionalTemplateContext) => {
|
||||
Notification.exception(e);
|
||||
}
|
||||
|
||||
// Load formchangechecker module.
|
||||
import('core/yui')
|
||||
.then(Y => {
|
||||
return new Promise(resolve => {
|
||||
Y.use('moodle-core-formchangechecker', Y => {
|
||||
resolve(Y);
|
||||
});
|
||||
});
|
||||
})
|
||||
.then(Y => {
|
||||
M.core_formchangechecker.init({formid: Y.one(postContainer[0].querySelector('form')).generateID()});
|
||||
return Y;
|
||||
})
|
||||
.catch();
|
||||
FormChangeChecker.watchForm(postContainer[0].querySelector('form'));
|
||||
}
|
||||
|
||||
inPageReplyCreateButton.fadeOut(ANIMATION_DURATION, () => {
|
||||
|
@ -21,18 +21,20 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
define([
|
||||
'jquery',
|
||||
'core/templates',
|
||||
'core/notification',
|
||||
'mod_forum/repository',
|
||||
'mod_forum/selectors',
|
||||
], function(
|
||||
$,
|
||||
Templates,
|
||||
Notification,
|
||||
Repository,
|
||||
Selectors
|
||||
) {
|
||||
'jquery',
|
||||
'core/templates',
|
||||
'core/notification',
|
||||
'mod_forum/repository',
|
||||
'mod_forum/selectors',
|
||||
'core_form/changechecker',
|
||||
], function(
|
||||
$,
|
||||
Templates,
|
||||
Notification,
|
||||
Repository,
|
||||
Selectors,
|
||||
FormChangeChecker
|
||||
) {
|
||||
|
||||
var DISPLAYCONSTANTS = {
|
||||
NESTED_V2: 4,
|
||||
@ -170,9 +172,7 @@ define([
|
||||
allButtons.prop('disabled', false);
|
||||
|
||||
// Tell formchangechecker we submitted the form.
|
||||
if (typeof M.core_formchangechecker !== 'undefined') {
|
||||
M.core_formchangechecker.reset_form_dirty_state();
|
||||
}
|
||||
FormChangeChecker.resetFormDirtyState(submitButton[0]);
|
||||
|
||||
return currentRoot.find(Selectors.post.inpageReplyContent).hide();
|
||||
})
|
||||
|
@ -25,22 +25,22 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
define([
|
||||
'jquery',
|
||||
'core/templates',
|
||||
'core/notification',
|
||||
'core/pending',
|
||||
'core/yui',
|
||||
'mod_forum/selectors',
|
||||
'mod_forum/inpage_reply',
|
||||
], function(
|
||||
$,
|
||||
Templates,
|
||||
Notification,
|
||||
Pending,
|
||||
Y,
|
||||
Selectors,
|
||||
InPageReply
|
||||
) {
|
||||
'jquery',
|
||||
'core/templates',
|
||||
'core/notification',
|
||||
'core/pending',
|
||||
'mod_forum/selectors',
|
||||
'mod_forum/inpage_reply',
|
||||
'core_form/changechecker',
|
||||
], function(
|
||||
$,
|
||||
Templates,
|
||||
Notification,
|
||||
Pending,
|
||||
Selectors,
|
||||
InPageReply,
|
||||
FormChangeChecker
|
||||
) {
|
||||
|
||||
var registerEventListeners = function(root) {
|
||||
root.on('click', Selectors.post.inpageReplyLink, function(e) {
|
||||
@ -78,13 +78,10 @@ define([
|
||||
.slideToggle(300, pending.resolve).find('textarea').focus();
|
||||
})
|
||||
.then(function() {
|
||||
// Load formchangechecker module.
|
||||
Y.use('moodle-core-formchangechecker', () => {
|
||||
M.core_formchangechecker.init({formid: `inpage-reply-${context.postid}`});
|
||||
});
|
||||
FormChangeChecker.watchFormById(`inpage-reply-${context.postid}`);
|
||||
return;
|
||||
})
|
||||
.fail(Notification.exception);
|
||||
.catch(Notification.exception);
|
||||
} else {
|
||||
var form = currentRoot.find(Selectors.post.inpageReplyContent);
|
||||
form.slideToggle(300, pending.resolve);
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -25,9 +25,9 @@ import $ from 'jquery';
|
||||
import Popper from 'core/popper';
|
||||
import CustomEvents from 'core/custom_interaction_events';
|
||||
import Selectors from 'forumreport_summary/selectors';
|
||||
import Y from 'core/yui';
|
||||
import Ajax from 'core/ajax';
|
||||
import KeyCodes from 'core/key_codes';
|
||||
import * as FormChangeChecker from 'core_form/changechecker';
|
||||
|
||||
export const init = (root) => {
|
||||
let jqRoot = $(root);
|
||||
@ -131,9 +131,7 @@ export const init = (root) => {
|
||||
// Submit report via filter
|
||||
const submitWithFilter = (containerelement) => {
|
||||
// Disable the dates filter mform checker to prevent any changes triggering a warning to the user.
|
||||
Y.use('moodle-core-formchangechecker', function() {
|
||||
M.core_formchangechecker.reset_form_dirty_state();
|
||||
});
|
||||
FormChangeChecker.unWatchForm(document.forms.filtersform);
|
||||
|
||||
// Close the container (eg popover).
|
||||
$(containerelement).addClass('hidden');
|
||||
@ -349,7 +347,7 @@ export const init = (root) => {
|
||||
let fromTimestamp = 0,
|
||||
toTimestamp = 0;
|
||||
|
||||
result['timestamps'].forEach(function(data){
|
||||
result.timestamps.forEach(function(data) {
|
||||
if (data.key === 'from') {
|
||||
fromTimestamp = data.timestamp;
|
||||
} else if (data.key === 'to') {
|
||||
|
@ -1,2 +1,2 @@
|
||||
define ("mod_quiz/modal_add_random_question",["jquery","core/yui","core/notification","core/modal","core/modal_events","core/modal_registry","core/fragment","core/templates"],function(a,b,c,d,e,f,g,h){var i=!1,j={EXISTING_CATEGORY_CONTAINER:"[data-region=\"existing-category-container\"]",EXISTING_CATEGORY_FORM_ELEMENT:"#id_existingcategoryheader",NEW_CATEGORY_CONTAINER:"[data-region=\"new-category-container\"]",NEW_CATEGORY_FORM_ELEMENT:"#id_newcategoryheader",TAB_CONTENT:"[data-region=\"tab-content\"]",ADD_ON_PAGE_FORM_ELEMENT:"[name=\"addonpage\"]",SUBMIT_BUTTON_ELEMENT:"input[type=\"submit\"]",CANCEL_BUTTON_ELEMENT:"input[type=\"submit\"][name=\"cancel\"]",FORM_HEADER:"legend",BUTTON_CONTAINER:".fitem"},k=function(a){d.call(this,a);this.contextId=null;this.addOnPageId=null;this.category=null;this.returnUrl=null;this.cmid=null;this.loadedForm=!1};k.TYPE="mod_quiz-quiz-add-random-question";k.prototype=Object.create(d.prototype);k.prototype.constructor=k;k.prototype.setContextId=function(a){this.contextId=a};k.prototype.getContextId=function(){return this.contextId};k.prototype.setAddOnPageId=function(a){this.addOnPageId=a;this.getBody().find(j.ADD_ON_PAGE_FORM_ELEMENT).val(a)};k.prototype.getAddOnPageId=function(){return this.addOnPageId};k.prototype.setCategory=function(a){this.category=a};k.prototype.getCategory=function(){return this.category};k.prototype.setReturnUrl=function(a){this.returnUrl=a};k.prototype.getReturnUrl=function(){return this.returnUrl};k.prototype.setCMID=function(a){this.cmid=a};k.prototype.getCMID=function(){return this.cmid};k.prototype.moveFormElementIntoTab=function(b,c){var d=b.find(j.SUBMIT_BUTTON_ELEMENT),e=a("<div class=\"modal-footer mt-1\" data-region=\"footer\"></div>");b.find(j.FORM_HEADER).addClass("hidden");b.wrap(c);d.closest(j.BUTTON_CONTAINER).remove();d.appendTo(e);e.appendTo(b)};k.prototype.moveTabsIntoTabContent=function(a){var b=this.getBody().find(j.TAB_CONTENT).empty();a.find("[role=\"tabpanel\"]").wrapAll(b)};k.prototype.moveCancelButtonToTabs=function(a){var b=a.find(j.CANCEL_BUTTON_ELEMENT).addClass("ml-1"),c=a.find("[data-region=\"footer\"]");b.closest(j.BUTTON_CONTAINER).remove();b.clone().appendTo(c)};k.prototype.loadForm=function(){return g.loadFragment("mod_quiz","add_random_question_form",this.getContextId(),{addonpage:this.getAddOnPageId(),cat:this.getCategory(),returnurl:this.getReturnUrl(),cmid:this.getCMID()}).then(function(b,c){var d=a(b),e=d.find(j.EXISTING_CATEGORY_FORM_ELEMENT),f=this.getBody().find(j.EXISTING_CATEGORY_CONTAINER),g=d.find(j.NEW_CATEGORY_FORM_ELEMENT),i=this.getBody().find(j.NEW_CATEGORY_CONTAINER);this.moveFormElementIntoTab(e,f);this.moveFormElementIntoTab(g,i);this.moveTabsIntoTabContent(d);this.moveCancelButtonToTabs(d);h.replaceNode(this.getBody().find(j.TAB_CONTENT),d,c)}.bind(this)).then(function(){b.use("moodle-core-formchangechecker",function(){M.core_formchangechecker.reset_form_dirty_state()})}).fail(c.exception)};k.prototype.show=function(){d.prototype.show.call(this);if(!this.loadedForm){this.loadForm();this.loadedForm=!0}};if(!i){f.register(k.TYPE,k,"mod_quiz/modal_add_random_question");i=!0}return k});
|
||||
define ("mod_quiz/modal_add_random_question",["jquery","core/notification","core/modal","core/modal_events","core/modal_registry","core/fragment","core/templates","core_form/changechecker"],function(a,b,c,d,e,f,g,h){var i=!1,j={EXISTING_CATEGORY_CONTAINER:"[data-region=\"existing-category-container\"]",EXISTING_CATEGORY_FORM_ELEMENT:"#id_existingcategoryheader",NEW_CATEGORY_CONTAINER:"[data-region=\"new-category-container\"]",NEW_CATEGORY_FORM_ELEMENT:"#id_newcategoryheader",TAB_CONTENT:"[data-region=\"tab-content\"]",ADD_ON_PAGE_FORM_ELEMENT:"[name=\"addonpage\"]",SUBMIT_BUTTON_ELEMENT:"input[type=\"submit\"]",CANCEL_BUTTON_ELEMENT:"input[type=\"submit\"][name=\"cancel\"]",FORM_HEADER:"legend",BUTTON_CONTAINER:".fitem"},k=function(a){c.call(this,a);this.contextId=null;this.addOnPageId=null;this.category=null;this.returnUrl=null;this.cmid=null;this.loadedForm=!1};k.TYPE="mod_quiz-quiz-add-random-question";k.prototype=Object.create(c.prototype);k.prototype.constructor=k;k.prototype.setContextId=function(a){this.contextId=a};k.prototype.getContextId=function(){return this.contextId};k.prototype.setAddOnPageId=function(a){this.addOnPageId=a;this.getBody().find(j.ADD_ON_PAGE_FORM_ELEMENT).val(a)};k.prototype.getAddOnPageId=function(){return this.addOnPageId};k.prototype.setCategory=function(a){this.category=a};k.prototype.getCategory=function(){return this.category};k.prototype.setReturnUrl=function(a){this.returnUrl=a};k.prototype.getReturnUrl=function(){return this.returnUrl};k.prototype.setCMID=function(a){this.cmid=a};k.prototype.getCMID=function(){return this.cmid};k.prototype.moveFormElementIntoTab=function(b,c){var d=b.find(j.SUBMIT_BUTTON_ELEMENT),e=a("<div class=\"modal-footer mt-1\" data-region=\"footer\"></div>");b.find(j.FORM_HEADER).addClass("hidden");b.wrap(c);d.closest(j.BUTTON_CONTAINER).remove();d.appendTo(e);e.appendTo(b)};k.prototype.moveTabsIntoTabContent=function(a){var b=this.getBody().find(j.TAB_CONTENT).empty();a.find("[role=\"tabpanel\"]").wrapAll(b)};k.prototype.moveCancelButtonToTabs=function(a){var b=a.find(j.CANCEL_BUTTON_ELEMENT).addClass("ml-1"),c=a.find("[data-region=\"footer\"]");b.closest(j.BUTTON_CONTAINER).remove();b.clone().appendTo(c)};k.prototype.loadForm=function(){return f.loadFragment("mod_quiz","add_random_question_form",this.getContextId(),{addonpage:this.getAddOnPageId(),cat:this.getCategory(),returnurl:this.getReturnUrl(),cmid:this.getCMID()}).then(function(b,c){var d=a(b),e=d.find(j.EXISTING_CATEGORY_FORM_ELEMENT),f=this.getBody().find(j.EXISTING_CATEGORY_CONTAINER),h=d.find(j.NEW_CATEGORY_FORM_ELEMENT),i=this.getBody().find(j.NEW_CATEGORY_CONTAINER);this.moveFormElementIntoTab(e,f);this.moveFormElementIntoTab(h,i);this.moveTabsIntoTabContent(d);this.moveCancelButtonToTabs(d);g.replaceNode(this.getBody().find(j.TAB_CONTENT),d,c)}.bind(this)).then(function(){h.disableAllChecks()}).fail(b.exception)};k.prototype.show=function(){c.prototype.show.call(this);if(!this.loadedForm){this.loadForm();this.loadedForm=!0}};if(!i){e.register(k.TYPE,k,"mod_quiz/modal_add_random_question");i=!0}return k});
|
||||
//# sourceMappingURL=modal_add_random_question.min.js.map
|
||||
|
File diff suppressed because one or more lines are too long
@ -1,2 +1,2 @@
|
||||
define ("mod_quiz/modal_quiz_question_bank",["jquery","core/yui","core/notification","core/modal","core/modal_events","core/modal_registry","core/fragment"],function(a,b,c,d,e,f,g){var h=!1,i={ADD_TO_QUIZ_CONTAINER:"td.addtoquizaction",ANCHOR:"a[href]",PREVIEW_CONTAINER:"td.previewaction",SEARCH_OPTIONS:"#advancedsearch",DISPLAY_OPTIONS:"#displayoptions",ADD_QUESTIONS_FORM:"form[action=\"edit.php\"]"},j=function(a){d.call(this,a);this.contextId=null;this.addOnPageId=null};j.TYPE="mod_quiz-quiz-question-bank";j.prototype=Object.create(d.prototype);j.prototype.constructor=j;j.prototype.setContextId=function(a){this.contextId=a};j.prototype.getContextId=function(){return this.contextId};j.prototype.setAddOnPageId=function(a){this.addOnPageId=a};j.prototype.getAddOnPageId=function(){return this.addOnPageId};j.prototype.show=function(){this.reloadBodyContent(window.location.search);return d.prototype.show.call(this)};j.prototype.reloadBodyContent=function(a){var b=g.loadFragment("mod_quiz","quiz_question_bank",this.getContextId(),{querystring:a}).fail(c.exception);this.setBody(b)};j.prototype.handleAddToQuizEvent=function(a,b){var c=b.attr("href")+"&addonpage="+this.getAddOnPageId();b.attr("href",c)};j.prototype.handlePreviewContainerEvent=function(a,b){window.openpopup(a,{url:b.attr("href"),name:"questionpreview",options:["height=600","width=800","top=0","left=0","menubar=0","location=0","scrollbars","resizable","toolbar","status","directories=0","fullscreen=0","dependent"].join(",")})};j.prototype.handleDisplayOptionFormEvent=function(b){b.stopPropagation();b.preventDefault();var c=a(b.target).closest(i.DISPLAY_OPTIONS),d="?"+c.serialize();this.reloadBodyContent(d)};j.prototype.registerDisplayOptionListeners=function(){this.getModal().on("change",i.DISPLAY_OPTIONS,function(b){var c=a(b.target);if(c.attr("aria-autocomplete")){return}this.handleDisplayOptionFormEvent(b)}.bind(this));this.getModal().on("submit",i.DISPLAY_OPTIONS,function(a){this.handleDisplayOptionFormEvent(a)}.bind(this))};j.prototype.registerEventListeners=function(){d.prototype.registerEventListeners.call(this);this.registerDisplayOptionListeners();this.getModal().on("submit",i.ADD_QUESTIONS_FORM,function(b){var c=a(b.currentTarget);a("<input />").attr("type","hidden").attr("name","addonpage").attr("value",this.getAddOnPageId()).appendTo(c)}.bind(this));this.getModal().on("click",i.ANCHOR,function(b){var c=a(b.currentTarget);if(c.closest(i.ADD_TO_QUIZ_CONTAINER).length){this.handleAddToQuizEvent(b,c);return}if(c.closest(i.PREVIEW_CONTAINER).length){this.handlePreviewContainerEvent(b,c);return}if(c.closest(i.SEARCH_OPTIONS).length){return}b.preventDefault();this.reloadBodyContent(c.prop("search"))}.bind(this));this.getRoot().on(e.bodyRendered,function(){b.use("moodle-core-formchangechecker",function(){M.core_formchangechecker.reset_form_dirty_state()})})};if(!h){f.register(j.TYPE,j,"core/modal");h=!0}return j});
|
||||
define ("mod_quiz/modal_quiz_question_bank",["jquery","core/notification","core/modal","core/modal_events","core/modal_registry","core/fragment","core_form/changechecker"],function(a,b,c,d,e,f,g){var h=!1,i={ADD_TO_QUIZ_CONTAINER:"td.addtoquizaction",ANCHOR:"a[href]",PREVIEW_CONTAINER:"td.previewaction",SEARCH_OPTIONS:"#advancedsearch",DISPLAY_OPTIONS:"#displayoptions",ADD_QUESTIONS_FORM:"form[action=\"edit.php\"]"},j=function(a){c.call(this,a);this.contextId=null;this.addOnPageId=null};j.TYPE="mod_quiz-quiz-question-bank";j.prototype=Object.create(c.prototype);j.prototype.constructor=j;j.prototype.setContextId=function(a){this.contextId=a};j.prototype.getContextId=function(){return this.contextId};j.prototype.setAddOnPageId=function(a){this.addOnPageId=a};j.prototype.getAddOnPageId=function(){return this.addOnPageId};j.prototype.show=function(){this.reloadBodyContent(window.location.search);return c.prototype.show.call(this)};j.prototype.reloadBodyContent=function(a){var c=f.loadFragment("mod_quiz","quiz_question_bank",this.getContextId(),{querystring:a}).fail(b.exception);this.setBody(c)};j.prototype.handleAddToQuizEvent=function(a,b){var c=b.attr("href")+"&addonpage="+this.getAddOnPageId();b.attr("href",c)};j.prototype.handlePreviewContainerEvent=function(a,b){window.openpopup(a,{url:b.attr("href"),name:"questionpreview",options:["height=600","width=800","top=0","left=0","menubar=0","location=0","scrollbars","resizable","toolbar","status","directories=0","fullscreen=0","dependent"].join(",")})};j.prototype.handleDisplayOptionFormEvent=function(b){b.stopPropagation();b.preventDefault();var c=a(b.target).closest(i.DISPLAY_OPTIONS),d="?"+c.serialize();this.reloadBodyContent(d)};j.prototype.registerDisplayOptionListeners=function(){this.getModal().on("change",i.DISPLAY_OPTIONS,function(b){var c=a(b.target);if(c.attr("aria-autocomplete")){return}this.handleDisplayOptionFormEvent(b)}.bind(this));this.getModal().on("submit",i.DISPLAY_OPTIONS,function(a){this.handleDisplayOptionFormEvent(a)}.bind(this))};j.prototype.registerEventListeners=function(){c.prototype.registerEventListeners.call(this);this.registerDisplayOptionListeners();this.getModal().on("submit",i.ADD_QUESTIONS_FORM,function(b){var c=a(b.currentTarget);a("<input />").attr("type","hidden").attr("name","addonpage").attr("value",this.getAddOnPageId()).appendTo(c)}.bind(this));this.getModal().on("click",i.ANCHOR,function(b){var c=a(b.currentTarget);if(c.closest(i.ADD_TO_QUIZ_CONTAINER).length){this.handleAddToQuizEvent(b,c);return}if(c.closest(i.PREVIEW_CONTAINER).length){this.handlePreviewContainerEvent(b,c);return}if(c.closest(i.SEARCH_OPTIONS).length){return}b.preventDefault();this.reloadBodyContent(c.prop("search"))}.bind(this));this.getRoot().on(d.bodyRendered,function(){g.disableAllChecks()})};if(!h){e.register(j.TYPE,j,"core/modal");h=!0}return j});
|
||||
//# sourceMappingURL=modal_quiz_question_bank.min.js.map
|
||||
|
File diff suppressed because one or more lines are too long
2
mod/quiz/amd/build/preflightcheck.min.js
vendored
2
mod/quiz/amd/build/preflightcheck.min.js
vendored
@ -1,2 +1,2 @@
|
||||
define ("mod_quiz/preflightcheck",["jquery","core/yui"],function(a,b){var c={confirmDialogue:null,init:function init(a,d,e,f){var g=a;b.use("moodle-core-notification",function(){if(b.one(e)){c.confirmDialogue=new M.core.dialogue({headerContent:d,bodyContent:b.one(e),draggable:!0,visible:!1,center:!0,modal:!0,width:null,extraClasses:["mod_quiz_preflight_popup"]});b.one(a).on("click",c.displayDialogue);b.one("#id_cancel").on("click",c.hideDialogue);g=c.confirmDialogue.get("boundingBox").one("[name=\"submitbutton\"]")}if(f){b.one(g).on("click",c.launchQuizPopup,c,f)}})},displayDialogue:function displayDialogue(a){if(a){a.halt()}c.confirmDialogue.show()},hideDialogue:function hideDialogue(a){if(a){a.halt()}c.confirmDialogue.hide(a)},launchQuizPopup:function launchQuizPopup(a,c){a.halt();b.use("moodle-core-formchangechecker","io-form",function(){M.core_formchangechecker.reset_form_dirty_state();var d=a.target.ancestor("form");window.openpopup(a,{url:d.get("action")+"?"+b.IO.stringify(d).replace(/\bcancel=/,"x="),windowname:"quizpopup",options:c,fullscreen:!0})})}};return c});
|
||||
define ("mod_quiz/preflightcheck",["jquery","core/yui","core_form/changechecker"],function(a,b,c){var d={confirmDialogue:null,init:function init(a,c,e,f){var g=a;b.use("moodle-core-notification",function(){if(b.one(e)){d.confirmDialogue=new M.core.dialogue({headerContent:c,bodyContent:b.one(e),draggable:!0,visible:!1,center:!0,modal:!0,width:null,extraClasses:["mod_quiz_preflight_popup"]});b.one(a).on("click",d.displayDialogue);b.one("#id_cancel").on("click",d.hideDialogue);g=d.confirmDialogue.get("boundingBox").one("[name=\"submitbutton\"]")}if(f){b.one(g).on("click",d.launchQuizPopup,d,f)}})},displayDialogue:function displayDialogue(a){if(a){a.halt()}d.confirmDialogue.show()},hideDialogue:function hideDialogue(a){if(a){a.halt()}d.confirmDialogue.hide(a)},launchQuizPopup:function launchQuizPopup(a,d){a.halt();b.use("io-form",function(){var e=a.target.ancestor("form");c.resetFormDirtyState(e.getDOMNode());window.openpopup(a,{url:e.get("action")+"?"+b.IO.stringify(e).replace(/\bcancel=/,"x="),windowname:"quizpopup",options:d,fullscreen:!0})})}};return d});
|
||||
//# sourceMappingURL=preflightcheck.min.js.map
|
||||
|
File diff suppressed because one or more lines are too long
@ -22,23 +22,23 @@
|
||||
*/
|
||||
define([
|
||||
'jquery',
|
||||
'core/yui',
|
||||
'core/notification',
|
||||
'core/modal',
|
||||
'core/modal_events',
|
||||
'core/modal_registry',
|
||||
'core/fragment',
|
||||
'core/templates',
|
||||
'core_form/changechecker',
|
||||
],
|
||||
function(
|
||||
$,
|
||||
Y,
|
||||
Notification,
|
||||
Modal,
|
||||
ModalEvents,
|
||||
ModalRegistry,
|
||||
Fragment,
|
||||
Templates
|
||||
Templates,
|
||||
FormChangeChecker,
|
||||
) {
|
||||
|
||||
var registered = false;
|
||||
@ -272,12 +272,9 @@ function(
|
||||
return;
|
||||
}.bind(this))
|
||||
.then(function() {
|
||||
// Make sure the form change checker is disabled otherwise it'll
|
||||
// stop the user from navigating away from the page once the modal
|
||||
// is hidden.
|
||||
Y.use('moodle-core-formchangechecker', function() {
|
||||
M.core_formchangechecker.reset_form_dirty_state();
|
||||
});
|
||||
// Make sure the form change checker is disabled otherwise it'll stop the user from navigating away from the
|
||||
// page once the modal is hidden.
|
||||
FormChangeChecker.disableAllChecks();
|
||||
return;
|
||||
})
|
||||
.fail(Notification.exception);
|
||||
|
@ -22,21 +22,21 @@
|
||||
*/
|
||||
define([
|
||||
'jquery',
|
||||
'core/yui',
|
||||
'core/notification',
|
||||
'core/modal',
|
||||
'core/modal_events',
|
||||
'core/modal_registry',
|
||||
'core/fragment'
|
||||
'core/fragment',
|
||||
'core_form/changechecker',
|
||||
],
|
||||
function(
|
||||
$,
|
||||
Y,
|
||||
Notification,
|
||||
Modal,
|
||||
ModalEvents,
|
||||
ModalRegistry,
|
||||
Fragment
|
||||
Fragment,
|
||||
FormChangeChecker,
|
||||
) {
|
||||
|
||||
var registered = false;
|
||||
@ -298,12 +298,9 @@ function(
|
||||
|
||||
// Disable the form change checker when the body is rendered.
|
||||
this.getRoot().on(ModalEvents.bodyRendered, function() {
|
||||
// Make sure the form change checker is disabled otherwise it'll
|
||||
// stop the user from navigating away from the page once the modal
|
||||
// is hidden.
|
||||
Y.use('moodle-core-formchangechecker', function() {
|
||||
M.core_formchangechecker.reset_form_dirty_state();
|
||||
});
|
||||
// Make sure the form change checker is disabled otherwise it'll stop the user from navigating away from the
|
||||
// page once the modal is hidden.
|
||||
FormChangeChecker.disableAllChecks();
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -24,7 +24,7 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @since 3.1
|
||||
*/
|
||||
define(['jquery', 'core/yui'], function($, Y) {
|
||||
define(['jquery', 'core/yui', 'core_form/changechecker'], function($, Y, FormChangeChecker) {
|
||||
|
||||
/**
|
||||
* @alias module:mod_quiz/preflightcheck
|
||||
@ -97,9 +97,10 @@ define(['jquery', 'core/yui'], function($, Y) {
|
||||
*/
|
||||
launchQuizPopup: function(e, popupoptions) {
|
||||
e.halt();
|
||||
Y.use('moodle-core-formchangechecker', 'io-form', function() {
|
||||
M.core_formchangechecker.reset_form_dirty_state();
|
||||
Y.use('io-form', function() {
|
||||
var form = e.target.ancestor('form');
|
||||
|
||||
FormChangeChecker.resetFormDirtyState(form.getDOMNode());
|
||||
window.openpopup(e, {
|
||||
url: form.get('action') + '?' + Y.IO.stringify(form).replace(/\bcancel=/, 'x='),
|
||||
windowname: 'quizpopup',
|
||||
|
@ -1970,14 +1970,13 @@ function quiz_get_js_module() {
|
||||
'name' => 'mod_quiz',
|
||||
'fullpath' => '/mod/quiz/module.js',
|
||||
'requires' => array('base', 'dom', 'event-delegate', 'event-key',
|
||||
'core_question_engine', 'moodle-core-formchangechecker'),
|
||||
'core_question_engine'),
|
||||
'strings' => array(
|
||||
array('cancel', 'moodle'),
|
||||
array('flagged', 'question'),
|
||||
array('functiondisabledbysecuremode', 'quiz'),
|
||||
array('startattempt', 'quiz'),
|
||||
array('timesup', 'quiz'),
|
||||
array('changesmadereallygoaway', 'moodle'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
@ -12,6 +12,7 @@
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
/* eslint camelcase: off */
|
||||
|
||||
/**
|
||||
* JavaScript library for the quiz module.
|
||||
@ -27,7 +28,9 @@ M.mod_quiz = M.mod_quiz || {};
|
||||
M.mod_quiz.init_attempt_form = function(Y) {
|
||||
M.core_question_engine.init_form(Y, '#responseform');
|
||||
Y.on('submit', M.mod_quiz.timer.stop, '#responseform');
|
||||
M.core_formchangechecker.init({formid: 'responseform'});
|
||||
require(['core_form/changechecker'], function(FormChangeChecker) {
|
||||
FormChangeChecker.watchFormById('responseform');
|
||||
});
|
||||
};
|
||||
|
||||
M.mod_quiz.init_review_form = function(Y) {
|
||||
@ -72,6 +75,9 @@ M.mod_quiz.timer = {
|
||||
M.mod_quiz.timer.preview = preview;
|
||||
M.mod_quiz.timer.update();
|
||||
Y.one('#quiz-timer-wrapper').setStyle('display', 'flex');
|
||||
require(['core_form/changechecker'], function(FormChangeChecker) {
|
||||
M.mod_quiz.timer.FormChangeChecker = FormChangeChecker;
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
@ -109,7 +115,7 @@ M.mod_quiz.timer = {
|
||||
if (form.one('input[name=finishattempt]')) {
|
||||
form.one('input[name=finishattempt]').set('value', 0);
|
||||
}
|
||||
M.core_formchangechecker.set_form_submitted();
|
||||
M.mod_quiz.timer.FormChangeChecker.markFormSubmitted(input.getDOMNode());
|
||||
form.submit();
|
||||
return;
|
||||
}
|
||||
|
@ -170,9 +170,9 @@ class quiz_grading_renderer extends plugin_renderer_base {
|
||||
]), ['class' => 'mdl-align']);
|
||||
$output .= html_writer::end_tag('div') . html_writer::end_tag('form');
|
||||
|
||||
$this->page->requires->string_for_js('changesmadereallygoaway', 'moodle');
|
||||
$this->page->requires->yui_module('moodle-core-formchangechecker',
|
||||
'M.core_formchangechecker.init', [['formid' => 'manualgradingform']]);
|
||||
// Add the form change checker.
|
||||
$this->page->requires->js_call_amd('core_form/changechecker', 'watchFormById', ['manualgradingform']);
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user