mirror of
https://github.com/moodle/moodle.git
synced 2025-08-06 17:36:38 +02:00
MDL-32657: Add format.js for topics format and remove default
Using topics format as default is not a great idea, as we can end up half-working dragdrop for some formats. With the current soiution, drag-drop will not work for format, unless required js functions have been created in format.js
This commit is contained in:
parent
c77582fe42
commit
d95b77bdb7
3 changed files with 51 additions and 24 deletions
40
course/format/topics/format.js
Normal file
40
course/format/topics/format.js
Normal file
|
@ -0,0 +1,40 @@
|
|||
// Javascript functions for course format
|
||||
|
||||
M.course = M.course || {};
|
||||
|
||||
M.course.format = M.course.format || {};
|
||||
|
||||
/**
|
||||
* Get section list for this format
|
||||
*
|
||||
* @param {YUI} Y YUI3 instance
|
||||
* @return {string} section list selector
|
||||
*/
|
||||
M.course.format.get_section_selector = function(Y) {
|
||||
return 'li.section';
|
||||
}
|
||||
|
||||
/**
|
||||
* Swap section
|
||||
*
|
||||
* @param {YUI} Y YUI3 instance
|
||||
* @param {string} node1 node to swap to
|
||||
* @param {string} node2 node to swap with
|
||||
* @return {NodeList} section list
|
||||
*/
|
||||
M.course.format.swap_sections = function(Y, node1, node2) {
|
||||
var CSS = {
|
||||
COURSECONTENT : 'course-content',
|
||||
LEFT : 'left',
|
||||
RIGHT : 'right',
|
||||
SECTIONADDMENUS : 'section_add_menus',
|
||||
};
|
||||
|
||||
var sectionlist = Y.Node.all('.'+CSS.COURSECONTENT+' '+M.course.format.get_section_selector(Y));
|
||||
// Swap left block
|
||||
sectionlist.item(node1).one('.'+CSS.LEFT).swap(sectionlist.item(node2).one('.'+CSS.LEFT));
|
||||
// Swap right block
|
||||
sectionlist.item(node1).one('.'+CSS.RIGHT).swap(sectionlist.item(node2).one('.'+CSS.RIGHT));
|
||||
// Swap menus
|
||||
sectionlist.item(node1).one('.'+CSS.SECTIONADDMENUS).swap(sectionlist.item(node2).one('.'+CSS.SECTIONADDMENUS));
|
||||
}
|
|
@ -286,3 +286,6 @@ if (!empty($sectionmenu)) {
|
|||
$select->formid = 'sectionmenu';
|
||||
echo $OUTPUT->render($select);
|
||||
}
|
||||
|
||||
// Include course format js module
|
||||
$PAGE->requires->js('/course/format/topics/format.js');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue