diff --git a/backup/util/ui/base_moodleform.class.php b/backup/util/ui/base_moodleform.class.php index 3a72edcad2064..ce95e7a81d6f7 100644 --- a/backup/util/ui/base_moodleform.class.php +++ b/backup/util/ui/base_moodleform.class.php @@ -324,6 +324,9 @@ public function display() { $config->noLabel = get_string('confirmcancelno', 'backup'); $PAGE->requires->yui_module('moodle-backup-confirmcancel', 'M.core_backup.watch_cancel_buttons', array($config)); + $PAGE->requires->yui_module('moodle-backup-backupselectall', 'M.core_backup.select_all_init', + array(array('select' => get_string('select'), 'all' => get_string('all'), 'none' => get_string('none')))); + parent::display(); } diff --git a/backup/util/ui/yui/backupselectall/backupselectall.js b/backup/util/ui/yui/backupselectall/backupselectall.js new file mode 100644 index 0000000000000..9f05b7f4272b8 --- /dev/null +++ b/backup/util/ui/yui/backupselectall/backupselectall.js @@ -0,0 +1,80 @@ +YUI.add('moodle-backup-backupselectall', function(Y) { + +// 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. + */ +M.core_backup.select_all_init = function(str) { + var formid = null; + + var helper = function(e, check, type) { + e.preventDefault(); + + var len = type.length; + Y.all('input[type="checkbox"]').each(function(checkbox) { + var name = checkbox.get('name'); + 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) { + return '