first commit

This commit is contained in:
CHIEFSOFT\ameye
2024-09-30 18:11:26 -04:00
commit e592ca6823
27270 changed files with 5002257 additions and 0 deletions
@@ -0,0 +1,193 @@
YUI.add('moodle-backup-backupselectall', function (Y, NAME) {
/**
* Adds select all/none links to the top of the backup/restore/import schema page.
*
* @module moodle-backup-backupselectall
*/
// Namespace for the backup
M.core_backup = M.core_backup || {};
/**
* Adds select all/none links to the top of the backup/restore/import schema page.
*
* @class M.core_backup.backupselectall
*/
M.core_backup.backupselectall = function(modnames) {
var formid = null;
var helper = function(e, check, type, mod) {
e.preventDefault();
var prefix = '';
if (typeof mod !== 'undefined') {
prefix = 'setting_activity_' + mod + '_';
}
var len = type.length;
Y.all('input[type="checkbox"]').each(function(checkbox) {
var name = checkbox.get('name');
// If a prefix has been set, ignore checkboxes which don't have that prefix.
if (prefix && name.substring(0, prefix.length) !== prefix) {
return;
}
if (name.substring(name.length - len) === type) {
checkbox.set('checked', check);
}
});
// At this point, we really need to persuade the form we are part of to
// update all of its disabledIf rules. However, as far as I can see,
// given the way that lib/form/form.js is written, that is impossible.
if (formid && M.form) {
M.form.updateFormState(formid);
}
};
var html_generator = function(classname, idtype, heading, extra) {
if (typeof extra === 'undefined') {
extra = '';
}
return '<div class="' + classname + '">' +
'<div class="fitem fitem_fcheckbox backup_selector">' +
'<div class="fitemtitle">' + heading + '</div>' +
'<div class="felement">' +
'<a id="backup-all-' + idtype + '" href="#">' + M.util.get_string('all', 'moodle') + '</a> / ' +
'<a id="backup-none-' + idtype + '" href="#">' + M.util.get_string('none', 'moodle') + '</a>' +
extra +
'</div>' +
'</div>' +
'</div>';
};
var firstsection = Y.one('fieldset#id_coursesettings .fcontainer .grouped_settings.section_level');
if (!firstsection) {
// This is not a relevant page.
return;
}
if (!firstsection.one('input[type="checkbox"]')) {
// No checkboxes.
return;
}
formid = firstsection.ancestor('form').getAttribute('id');
var withuserdata = false;
Y.all('input[type="checkbox"]').each(function(checkbox) {
var name = checkbox.get('name');
if (name.substring(name.length - 9) === '_userdata') {
withuserdata = '_userdata';
} else if (name.substring(name.length - 9) === '_userinfo') {
withuserdata = '_userinfo';
}
});
// Add global select all/none options.
var html = html_generator('include_setting section_level', 'included', M.util.get_string('select', 'moodle'),
' (<a id="backup-bytype" href="#">' + M.util.get_string('showtypes', 'backup') + '</a>)');
if (withuserdata) {
html += html_generator('normal_setting', 'userdata', M.util.get_string('select', 'moodle'));
}
var links = Y.Node.create('<div class="grouped_settings section_level">' + html + '</div>');
firstsection.insert(links, 'before');
// Add select all/none for each module type.
var initlinks = function(links, mod) {
Y.one('#backup-all-mod_' + mod).on('click', function(e) {
helper(e, true, '_included', mod);
});
Y.one('#backup-none-mod_' + mod).on('click', function(e) {
helper(e, false, '_included', mod);
});
if (withuserdata) {
Y.one('#backup-all-userdata-mod_' + mod).on('click', function(e) {
helper(e, true, withuserdata, mod);
});
Y.one('#backup-none-userdata-mod_' + mod).on('click', function(e) {
helper(e, false, withuserdata, mod);
});
}
};
// For each module type on the course, add hidden select all/none options.
var modlist = Y.Node.create('<div id="mod_select_links">');
modlist.hide();
modlist.currentlyshown = false;
links.appendChild(modlist);
for (var mod in modnames) {
// Only include actual values from the list.
if (!modnames.hasOwnProperty(mod)) {
continue;
}
html = html_generator('include_setting section_level', 'mod_' + mod, modnames[mod]);
if (withuserdata) {
html += html_generator('normal_setting', 'userdata-mod_' + mod, modnames[mod]);
}
var modlinks = Y.Node.create(
'<div class="grouped_settings section_level">' + html + '</div>');
modlist.appendChild(modlinks);
initlinks(modlinks, mod);
}
// Toggles the display of the hidden module select all/none links.
var toggletypes = function() {
// Change text of type toggle link.
var link = Y.one('#backup-bytype');
if (modlist.currentlyshown) {
link.setHTML(M.util.get_string('showtypes', 'backup'));
} else {
link.setHTML(M.util.get_string('hidetypes', 'backup'));
}
// The link has now been toggled (from show to hide, or vice-versa).
modlist.currentlyshown = !modlist.currentlyshown;
// Either hide or show the links.
var animcfg = {node: modlist, duration: 0.2},
anim;
if (modlist.currentlyshown) {
// Animate reveal of the module links.
modlist.show();
animcfg.to = {maxHeight: modlist.get('clientHeight') + 'px'};
modlist.setStyle('maxHeight', '0px');
anim = new Y.Anim(animcfg);
anim.on('end', function() {
modlist.setStyle('maxHeight', 'none');
});
anim.run();
} else {
// Animate hide of the module links.
animcfg.to = {maxHeight: '0px'};
modlist.setStyle('maxHeight', modlist.get('clientHeight') + 'px');
anim = new Y.Anim(animcfg);
anim.on('end', function() {
modlist.hide();
modlist.setStyle('maxHeight', 'none');
});
anim.run();
}
};
Y.one('#backup-bytype').on('click', function(e) {
e.preventDefault();
toggletypes();
});
Y.one('#backup-all-included').on('click', function(e) {
helper(e, true, '_included');
});
Y.one('#backup-none-included').on('click', function(e) {
helper(e, false, '_included');
});
if (withuserdata) {
Y.one('#backup-all-userdata').on('click', function(e) {
helper(e, true, withuserdata);
});
Y.one('#backup-none-userdata').on('click', function(e) {
helper(e, false, withuserdata);
});
}
};
}, '@VERSION@', {"requires": ["node", "event", "node-event-simulate", "anim"]});
@@ -0,0 +1 @@
YUI.add("moodle-backup-backupselectall",function(g,e){M.core_backup=M.core_backup||{},M.core_backup.backupselectall=function(e){var t,n,i,d,o,c,r,p,l=null,a=function(e,t,i,n){var o,c;e.preventDefault(),o=void 0!==n?"setting_activity_"+n+"_":"",c=i.length,g.all('input[type="checkbox"]').each(function(e){var n=e.get("name");o&&n.substring(0,o.length)!==o||n.substring(n.length-c)===i&&e.set("checked",t)}),l&&M.form&&M.form.updateFormState(l)},u=function(e,n,t,i){return void 0===i&&(i=""),'<div class="'+e+'"><div class="fitem fitem_fcheckbox backup_selector"><div class="fitemtitle">'+t+'</div><div class="felement"><a id="backup-all-'+n+'" href="#">'+M.util.get_string("all","moodle")+'</a> / <a id="backup-none-'+n+'" href="#">'+M.util.get_string("none","moodle")+"</a>"+i+"</div></div></div>"},s=g.one("fieldset#id_coursesettings .fcontainer .grouped_settings.section_level");if(s&&s.one('input[type="checkbox"]')){for(c in l=s.ancestor("form").getAttribute("id"),t=!1,g.all('input[type="checkbox"]').each(function(e){e=e.get("name");"_userdata"===e.substring(e.length-9)?t="_userdata":"_userinfo"===e.substring(e.length-9)&&(t="_userinfo")}),n=u("include_setting section_level","included",M.util.get_string("select","moodle"),' (<a id="backup-bytype" href="#">'+M.util.get_string("showtypes","backup")+"</a>)"),t&&(n+=u("normal_setting","userdata",M.util.get_string("select","moodle"))),i=g.Node.create('<div class="grouped_settings section_level">'+n+"</div>"),s.insert(i,"before"),d=function(e,n){g.one("#backup-all-mod_"+n).on("click",function(e){a(e,!0,"_included",n)}),g.one("#backup-none-mod_"+n).on("click",function(e){a(e,!1,"_included",n)}),t&&(g.one("#backup-all-userdata-mod_"+n).on("click",function(e){a(e,!0,t,n)}),g.one("#backup-none-userdata-mod_"+n).on("click",function(e){a(e,!1,t,n)}))},(o=g.Node.create('<div id="mod_select_links">')).hide(),o.currentlyshown=!1,i.appendChild(o),e)e.hasOwnProperty(c)&&(n=u("include_setting section_level","mod_"+c,e[c]),t&&(n+=u("normal_setting","userdata-mod_"+c,e[c])),r=g.Node.create('<div class="grouped_settings section_level">'+n+"</div>"),o.appendChild(r),d(0,c));p=function(){var e,n=g.one("#backup-bytype");o.currentlyshown?n.setHTML(M.util.get_string("showtypes","backup")):n.setHTML(M.util.get_string("hidetypes","backup")),o.currentlyshown=!o.currentlyshown,n={node:o,duration:.2},o.currentlyshown?(o.show(),n.to={maxHeight:o.get("clientHeight")+"px"},o.setStyle("maxHeight","0px"),(e=new g.Anim(n)).on("end",function(){o.setStyle("maxHeight","none")})):(n.to={maxHeight:"0px"},o.setStyle("maxHeight",o.get("clientHeight")+"px"),(e=new g.Anim(n)).on("end",function(){o.hide(),o.setStyle("maxHeight","none")})),e.run()},g.one("#backup-bytype").on("click",function(e){e.preventDefault(),p()}),g.one("#backup-all-included").on("click",function(e){a(e,!0,"_included")}),g.one("#backup-none-included").on("click",function(e){a(e,!1,"_included")}),t&&(g.one("#backup-all-userdata").on("click",function(e){a(e,!0,t)}),g.one("#backup-none-userdata").on("click",function(e){a(e,!1,t)}))}}},"@VERSION@",{requires:["node","event","node-event-simulate","anim"]});
@@ -0,0 +1,193 @@
YUI.add('moodle-backup-backupselectall', function (Y, NAME) {
/**
* Adds select all/none links to the top of the backup/restore/import schema page.
*
* @module moodle-backup-backupselectall
*/
// Namespace for the backup
M.core_backup = M.core_backup || {};
/**
* Adds select all/none links to the top of the backup/restore/import schema page.
*
* @class M.core_backup.backupselectall
*/
M.core_backup.backupselectall = function(modnames) {
var formid = null;
var helper = function(e, check, type, mod) {
e.preventDefault();
var prefix = '';
if (typeof mod !== 'undefined') {
prefix = 'setting_activity_' + mod + '_';
}
var len = type.length;
Y.all('input[type="checkbox"]').each(function(checkbox) {
var name = checkbox.get('name');
// If a prefix has been set, ignore checkboxes which don't have that prefix.
if (prefix && name.substring(0, prefix.length) !== prefix) {
return;
}
if (name.substring(name.length - len) === type) {
checkbox.set('checked', check);
}
});
// At this point, we really need to persuade the form we are part of to
// update all of its disabledIf rules. However, as far as I can see,
// given the way that lib/form/form.js is written, that is impossible.
if (formid && M.form) {
M.form.updateFormState(formid);
}
};
var html_generator = function(classname, idtype, heading, extra) {
if (typeof extra === 'undefined') {
extra = '';
}
return '<div class="' + classname + '">' +
'<div class="fitem fitem_fcheckbox backup_selector">' +
'<div class="fitemtitle">' + heading + '</div>' +
'<div class="felement">' +
'<a id="backup-all-' + idtype + '" href="#">' + M.util.get_string('all', 'moodle') + '</a> / ' +
'<a id="backup-none-' + idtype + '" href="#">' + M.util.get_string('none', 'moodle') + '</a>' +
extra +
'</div>' +
'</div>' +
'</div>';
};
var firstsection = Y.one('fieldset#id_coursesettings .fcontainer .grouped_settings.section_level');
if (!firstsection) {
// This is not a relevant page.
return;
}
if (!firstsection.one('input[type="checkbox"]')) {
// No checkboxes.
return;
}
formid = firstsection.ancestor('form').getAttribute('id');
var withuserdata = false;
Y.all('input[type="checkbox"]').each(function(checkbox) {
var name = checkbox.get('name');
if (name.substring(name.length - 9) === '_userdata') {
withuserdata = '_userdata';
} else if (name.substring(name.length - 9) === '_userinfo') {
withuserdata = '_userinfo';
}
});
// Add global select all/none options.
var html = html_generator('include_setting section_level', 'included', M.util.get_string('select', 'moodle'),
' (<a id="backup-bytype" href="#">' + M.util.get_string('showtypes', 'backup') + '</a>)');
if (withuserdata) {
html += html_generator('normal_setting', 'userdata', M.util.get_string('select', 'moodle'));
}
var links = Y.Node.create('<div class="grouped_settings section_level">' + html + '</div>');
firstsection.insert(links, 'before');
// Add select all/none for each module type.
var initlinks = function(links, mod) {
Y.one('#backup-all-mod_' + mod).on('click', function(e) {
helper(e, true, '_included', mod);
});
Y.one('#backup-none-mod_' + mod).on('click', function(e) {
helper(e, false, '_included', mod);
});
if (withuserdata) {
Y.one('#backup-all-userdata-mod_' + mod).on('click', function(e) {
helper(e, true, withuserdata, mod);
});
Y.one('#backup-none-userdata-mod_' + mod).on('click', function(e) {
helper(e, false, withuserdata, mod);
});
}
};
// For each module type on the course, add hidden select all/none options.
var modlist = Y.Node.create('<div id="mod_select_links">');
modlist.hide();
modlist.currentlyshown = false;
links.appendChild(modlist);
for (var mod in modnames) {
// Only include actual values from the list.
if (!modnames.hasOwnProperty(mod)) {
continue;
}
html = html_generator('include_setting section_level', 'mod_' + mod, modnames[mod]);
if (withuserdata) {
html += html_generator('normal_setting', 'userdata-mod_' + mod, modnames[mod]);
}
var modlinks = Y.Node.create(
'<div class="grouped_settings section_level">' + html + '</div>');
modlist.appendChild(modlinks);
initlinks(modlinks, mod);
}
// Toggles the display of the hidden module select all/none links.
var toggletypes = function() {
// Change text of type toggle link.
var link = Y.one('#backup-bytype');
if (modlist.currentlyshown) {
link.setHTML(M.util.get_string('showtypes', 'backup'));
} else {
link.setHTML(M.util.get_string('hidetypes', 'backup'));
}
// The link has now been toggled (from show to hide, or vice-versa).
modlist.currentlyshown = !modlist.currentlyshown;
// Either hide or show the links.
var animcfg = {node: modlist, duration: 0.2},
anim;
if (modlist.currentlyshown) {
// Animate reveal of the module links.
modlist.show();
animcfg.to = {maxHeight: modlist.get('clientHeight') + 'px'};
modlist.setStyle('maxHeight', '0px');
anim = new Y.Anim(animcfg);
anim.on('end', function() {
modlist.setStyle('maxHeight', 'none');
});
anim.run();
} else {
// Animate hide of the module links.
animcfg.to = {maxHeight: '0px'};
modlist.setStyle('maxHeight', modlist.get('clientHeight') + 'px');
anim = new Y.Anim(animcfg);
anim.on('end', function() {
modlist.hide();
modlist.setStyle('maxHeight', 'none');
});
anim.run();
}
};
Y.one('#backup-bytype').on('click', function(e) {
e.preventDefault();
toggletypes();
});
Y.one('#backup-all-included').on('click', function(e) {
helper(e, true, '_included');
});
Y.one('#backup-none-included').on('click', function(e) {
helper(e, false, '_included');
});
if (withuserdata) {
Y.one('#backup-all-userdata').on('click', function(e) {
helper(e, true, withuserdata);
});
Y.one('#backup-none-userdata').on('click', function(e) {
helper(e, false, withuserdata);
});
}
};
}, '@VERSION@', {"requires": ["node", "event", "node-event-simulate", "anim"]});
@@ -0,0 +1,10 @@
{
"name": "moodle-backup-backupselectall",
"builds": {
"moodle-backup-backupselectall": {
"jsfiles": [
"backupselectall.js"
]
}
}
}
@@ -0,0 +1,188 @@
/**
* Adds select all/none links to the top of the backup/restore/import schema page.
*
* @module moodle-backup-backupselectall
*/
// Namespace for the backup
M.core_backup = M.core_backup || {};
/**
* Adds select all/none links to the top of the backup/restore/import schema page.
*
* @class M.core_backup.backupselectall
*/
M.core_backup.backupselectall = function(modnames) {
var formid = null;
var helper = function(e, check, type, mod) {
e.preventDefault();
var prefix = '';
if (typeof mod !== 'undefined') {
prefix = 'setting_activity_' + mod + '_';
}
var len = type.length;
Y.all('input[type="checkbox"]').each(function(checkbox) {
var name = checkbox.get('name');
// If a prefix has been set, ignore checkboxes which don't have that prefix.
if (prefix && name.substring(0, prefix.length) !== prefix) {
return;
}
if (name.substring(name.length - len) === type) {
checkbox.set('checked', check);
}
});
// At this point, we really need to persuade the form we are part of to
// update all of its disabledIf rules. However, as far as I can see,
// given the way that lib/form/form.js is written, that is impossible.
if (formid && M.form) {
M.form.updateFormState(formid);
}
};
var html_generator = function(classname, idtype, heading, extra) {
if (typeof extra === 'undefined') {
extra = '';
}
return '<div class="' + classname + '">' +
'<div class="fitem fitem_fcheckbox backup_selector">' +
'<div class="fitemtitle">' + heading + '</div>' +
'<div class="felement">' +
'<a id="backup-all-' + idtype + '" href="#">' + M.util.get_string('all', 'moodle') + '</a> / ' +
'<a id="backup-none-' + idtype + '" href="#">' + M.util.get_string('none', 'moodle') + '</a>' +
extra +
'</div>' +
'</div>' +
'</div>';
};
var firstsection = Y.one('fieldset#id_coursesettings .fcontainer .grouped_settings.section_level');
if (!firstsection) {
// This is not a relevant page.
return;
}
if (!firstsection.one('input[type="checkbox"]')) {
// No checkboxes.
return;
}
formid = firstsection.ancestor('form').getAttribute('id');
var withuserdata = false;
Y.all('input[type="checkbox"]').each(function(checkbox) {
var name = checkbox.get('name');
if (name.substring(name.length - 9) === '_userdata') {
withuserdata = '_userdata';
} else if (name.substring(name.length - 9) === '_userinfo') {
withuserdata = '_userinfo';
}
});
// Add global select all/none options.
var html = html_generator('include_setting section_level', 'included', M.util.get_string('select', 'moodle'),
' (<a id="backup-bytype" href="#">' + M.util.get_string('showtypes', 'backup') + '</a>)');
if (withuserdata) {
html += html_generator('normal_setting', 'userdata', M.util.get_string('select', 'moodle'));
}
var links = Y.Node.create('<div class="grouped_settings section_level">' + html + '</div>');
firstsection.insert(links, 'before');
// Add select all/none for each module type.
var initlinks = function(links, mod) {
Y.one('#backup-all-mod_' + mod).on('click', function(e) {
helper(e, true, '_included', mod);
});
Y.one('#backup-none-mod_' + mod).on('click', function(e) {
helper(e, false, '_included', mod);
});
if (withuserdata) {
Y.one('#backup-all-userdata-mod_' + mod).on('click', function(e) {
helper(e, true, withuserdata, mod);
});
Y.one('#backup-none-userdata-mod_' + mod).on('click', function(e) {
helper(e, false, withuserdata, mod);
});
}
};
// For each module type on the course, add hidden select all/none options.
var modlist = Y.Node.create('<div id="mod_select_links">');
modlist.hide();
modlist.currentlyshown = false;
links.appendChild(modlist);
for (var mod in modnames) {
// Only include actual values from the list.
if (!modnames.hasOwnProperty(mod)) {
continue;
}
html = html_generator('include_setting section_level', 'mod_' + mod, modnames[mod]);
if (withuserdata) {
html += html_generator('normal_setting', 'userdata-mod_' + mod, modnames[mod]);
}
var modlinks = Y.Node.create(
'<div class="grouped_settings section_level">' + html + '</div>');
modlist.appendChild(modlinks);
initlinks(modlinks, mod);
}
// Toggles the display of the hidden module select all/none links.
var toggletypes = function() {
// Change text of type toggle link.
var link = Y.one('#backup-bytype');
if (modlist.currentlyshown) {
link.setHTML(M.util.get_string('showtypes', 'backup'));
} else {
link.setHTML(M.util.get_string('hidetypes', 'backup'));
}
// The link has now been toggled (from show to hide, or vice-versa).
modlist.currentlyshown = !modlist.currentlyshown;
// Either hide or show the links.
var animcfg = {node: modlist, duration: 0.2},
anim;
if (modlist.currentlyshown) {
// Animate reveal of the module links.
modlist.show();
animcfg.to = {maxHeight: modlist.get('clientHeight') + 'px'};
modlist.setStyle('maxHeight', '0px');
anim = new Y.Anim(animcfg);
anim.on('end', function() {
modlist.setStyle('maxHeight', 'none');
});
anim.run();
} else {
// Animate hide of the module links.
animcfg.to = {maxHeight: '0px'};
modlist.setStyle('maxHeight', modlist.get('clientHeight') + 'px');
anim = new Y.Anim(animcfg);
anim.on('end', function() {
modlist.hide();
modlist.setStyle('maxHeight', 'none');
});
anim.run();
}
};
Y.one('#backup-bytype').on('click', function(e) {
e.preventDefault();
toggletypes();
});
Y.one('#backup-all-included').on('click', function(e) {
helper(e, true, '_included');
});
Y.one('#backup-none-included').on('click', function(e) {
helper(e, false, '_included');
});
if (withuserdata) {
Y.one('#backup-all-userdata').on('click', function(e) {
helper(e, true, withuserdata);
});
Y.one('#backup-none-userdata').on('click', function(e) {
helper(e, false, withuserdata);
});
}
};
@@ -0,0 +1,10 @@
{
"moodle-backup-backupselectall": {
"requires": [
"node",
"event",
"node-event-simulate",
"anim"
]
}
}