Merge branch 'MDL-68189-m38' of https://github.com/NeillM/moodle into MOODLE_38_STABLE
This commit is contained in:
+2
@@ -0,0 +1,2 @@
|
||||
define ("core_course/sectionlistener",["jquery"],function(a){var b=function(a,b){a.attr("aria-label",b);a.find(".hidden.sectionname").text(b)};a("body").on("updated",".inplaceeditable",function processUpdatedEvent(c){var d=a(this);if("sectionname"===d.data("itemtype")){var e=M.course.format.get_config(),f=d.closest("."+e.section_class);b(f,c.ajaxreturn.value)}})});
|
||||
//# sourceMappingURL=sectionlistener.min.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../src/sectionlistener.js"],"names":["define","$","updateSectionName","section","newname","attr","find","text","on","processUpdatedEvent","e","editable","data","config","M","course","format","get_config","closest","section_class","ajaxreturn","value"],"mappings":"AAwBAA,OAAM,+BAAC,CAAC,QAAD,CAAD,CAAa,SAASC,CAAT,CAAY,IAyBvBC,CAAAA,CAAiB,CAAG,SAASC,CAAT,CAAkBC,CAAlB,CAA2B,CAC/CD,CAAO,CAACE,IAAR,CAAa,YAAb,CAA2BD,CAA3B,EACAD,CAAO,CAACG,IAAR,CAAa,qBAAb,EAAoCC,IAApC,CAAyCH,CAAzC,CACH,CA5B0B,CA8B3BH,CAAC,CAAC,MAAD,CAAD,CAAUO,EAAV,CAAa,SAAb,CAAwB,kBAAxB,CAtB0B,QAAtBC,CAAAA,mBAAsB,CAASC,CAAT,CAAY,CAClC,GAAIC,CAAAA,CAAQ,CAAGV,CAAC,CAAC,IAAD,CAAhB,CACA,GAAkC,aAA9B,GAAAU,CAAQ,CAACC,IAAT,CAAc,UAAd,CAAJ,CAAiD,IACzCC,CAAAA,CAAM,CAAGC,CAAC,CAACC,MAAF,CAASC,MAAT,CAAgBC,UAAhB,EADgC,CAGzCd,CAAO,CAAGQ,CAAQ,CAACO,OAAT,CAAiB,IAAML,CAAM,CAACM,aAA9B,CAH+B,CAI7CjB,CAAiB,CAACC,CAAD,CAAUO,CAAC,CAACU,UAAF,CAAaC,KAAvB,CACpB,CAEJ,CAaD,CACH,CA/BK,CAAN","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 * Define listeners related to sections.\n *\n * @module core_course/sectionlistener\n * @package core_course\n * @copyright 2020 University of Nottingham\n * @author Neill Magill <[email protected]>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery'], function($) {\n /**\n * Processes an updated event.\n *\n * We only want to handle events related to a section, and not activities.\n *\n * @param {Event} e The updated event\n */\n var processUpdatedEvent = function(e) {\n var editable = $(this);\n if (editable.data('itemtype') === 'sectionname') {\n var config = M.course.format.get_config();\n // A section name got updated.\n var section = editable.closest('.' + config.section_class);\n updateSectionName(section, e.ajaxreturn.value);\n }\n // Ignore other types of inplace updates, for example activity name changes.\n };\n\n /**\n * Updates the name of the section in places outside of the inplace editable field.\n *\n * @param {jQuery} section The section that was updated.\n * @param {String} newname The new name for the section.\n */\n var updateSectionName = function(section, newname) {\n section.attr('aria-label', newname);\n section.find('.hidden.sectionname').text(newname);\n };\n\n $('body').on('updated', '.inplaceeditable', processUpdatedEvent);\n});"],"file":"sectionlistener.min.js"}
|
||||
@@ -0,0 +1,56 @@
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Define listeners related to sections.
|
||||
*
|
||||
* @module core_course/sectionlistener
|
||||
* @package core_course
|
||||
* @copyright 2020 University of Nottingham
|
||||
* @author Neill Magill <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
define(['jquery'], function($) {
|
||||
/**
|
||||
* Processes an updated event.
|
||||
*
|
||||
* We only want to handle events related to a section, and not activities.
|
||||
*
|
||||
* @param {Event} e The updated event
|
||||
*/
|
||||
var processUpdatedEvent = function(e) {
|
||||
var editable = $(this);
|
||||
if (editable.data('itemtype') === 'sectionname') {
|
||||
var config = M.course.format.get_config();
|
||||
// A section name got updated.
|
||||
var section = editable.closest('.' + config.section_class);
|
||||
updateSectionName(section, e.ajaxreturn.value);
|
||||
}
|
||||
// Ignore other types of inplace updates, for example activity name changes.
|
||||
};
|
||||
|
||||
/**
|
||||
* Updates the name of the section in places outside of the inplace editable field.
|
||||
*
|
||||
* @param {jQuery} section The section that was updated.
|
||||
* @param {String} newname The new name for the section.
|
||||
*/
|
||||
var updateSectionName = function(section, newname) {
|
||||
section.attr('aria-label', newname);
|
||||
section.find('.hidden.sectionname').text(newname);
|
||||
};
|
||||
|
||||
$('body').on('updated', '.inplaceeditable', processUpdatedEvent);
|
||||
});
|
||||
@@ -59,3 +59,4 @@ if (!empty($displaysection)) {
|
||||
|
||||
// Include course format js module
|
||||
$PAGE->requires->js('/course/format/topics/format.js');
|
||||
$PAGE->requires->js_call_amd('core_course/sectionlistener');
|
||||
|
||||
@@ -50,3 +50,4 @@ if (!empty($displaysection)) {
|
||||
}
|
||||
|
||||
$PAGE->requires->js('/course/format/weeks/format.js');
|
||||
$PAGE->requires->js_call_amd('core_course/sectionlistener');
|
||||
|
||||
Reference in New Issue
Block a user