Merge branch 'MDL-57490-master' of git://github.com/danpoltawski/moodle

This commit is contained in:
Andrew Nicols
2017-01-18 12:09:20 +08:00
7 changed files with 106 additions and 157 deletions
+37 -141
View File
@@ -896,96 +896,53 @@ M.util.add_spinner = function(Y, node) {
return spinner;
}
//=== old legacy JS code, hopefully to be replaced soon by M.xx.yy and YUI3 code ===
/**
* @deprecated since Moodle 3.3.
*/
function checkall() {
var inputs = document.getElementsByTagName('input');
for (var i = 0; i < inputs.length; i++) {
if (inputs[i].type == 'checkbox') {
if (inputs[i].disabled || inputs[i].readOnly) {
continue;
}
inputs[i].checked = true;
}
}
}
function checknone() {
var inputs = document.getElementsByTagName('input');
for (var i = 0; i < inputs.length; i++) {
if (inputs[i].type == 'checkbox') {
if (inputs[i].disabled || inputs[i].readOnly) {
continue;
}
inputs[i].checked = false;
}
}
throw new Error('checkall can not be used any more. Please use jQuery instead.');
}
/**
* Either check, or uncheck, all checkboxes inside the element with id is
* @param id the id of the container
* @param checked the new state, either '' or 'checked'.
* @deprecated since Moodle 3.3.
*/
function checknone() {
throw new Error('checknone can not be used any more. Please use jQuery instead.');
}
/**
* @deprecated since Moodle 3.3.
*/
function select_all_in_element_with_id(id, checked) {
var container = document.getElementById(id);
if (!container) {
return;
}
var inputs = container.getElementsByTagName('input');
for (var i = 0; i < inputs.length; ++i) {
if (inputs[i].type == 'checkbox' || inputs[i].type == 'radio') {
inputs[i].checked = checked;
}
}
throw new Error('select_all_in_element_with_id can not be used any more. Please use jQuery instead.');
}
/**
* @deprecated since Moodle 3.3.
*/
function select_all_in(elTagName, elClass, elId) {
var inputs = document.getElementsByTagName('input');
inputs = filterByParent(inputs, function(el) {return findParentNode(el, elTagName, elClass, elId);});
for(var i = 0; i < inputs.length; ++i) {
if(inputs[i].type == 'checkbox' || inputs[i].type == 'radio') {
inputs[i].checked = 'checked';
}
}
throw new Error('select_all_in can not be used any more. Please use jQuery instead.');
}
/**
* @deprecated since Moodle 3.3.
*/
function deselect_all_in(elTagName, elClass, elId) {
var inputs = document.getElementsByTagName('INPUT');
inputs = filterByParent(inputs, function(el) {return findParentNode(el, elTagName, elClass, elId);});
for(var i = 0; i < inputs.length; ++i) {
if(inputs[i].type == 'checkbox' || inputs[i].type == 'radio') {
inputs[i].checked = '';
}
}
throw new Error('deselect_all_in can not be used any more. Please use jQuery instead.');
}
/**
* @deprecated since Moodle 3.3.
*/
function confirm_if(expr, message) {
if(!expr) {
return true;
}
return confirm(message);
throw new Error('confirm_if can not be used any more.');
}
/*
findParentNode (start, elementName, elementClass, elementID)
Travels up the DOM hierarchy to find a parent element with the
specified tag name, class, and id. All conditions must be met,
but any can be ommitted. Returns the BODY element if no match
found.
*/
/**
* @deprecated since Moodle 3.3.
*/
function findParentNode(el, elName, elClass, elId) {
while (el.nodeName.toUpperCase() != 'BODY') {
if ((!elName || el.nodeName.toUpperCase() == elName) &&
(!elClass || el.className.indexOf(elClass) != -1) &&
(!elId || el.id == elId)) {
break;
}
el = el.parentNode;
}
return el;
throw new Error('findParentNode can not be used any more. Please use jQuery instead.');
}
function unmaskPassword(id) {
@@ -1031,15 +988,11 @@ function unmaskPassword(id) {
}
}
/**
* @deprecated since Moodle 3.3.
*/
function filterByParent(elCollection, parentFinder) {
var filteredCollection = [];
for (var i = 0; i < elCollection.length; ++i) {
var findParent = parentFinder(elCollection[i]);
if (findParent.nodeName.toUpperCase() != 'BODY') {
filteredCollection.push(elCollection[i]);
}
}
return filteredCollection;
throw new Error('filterByParent can not be used any more. Please use jQuery instead.');
}
/**
@@ -1253,10 +1206,11 @@ function convert_object_to_string(obj, separator) {
return list.join(separator);
}
/**
* @deprecated since Moodle 3.3.
*/
function stripHTML(str) {
var re = /<\S[^><]*>/g;
var ret = str.replace(re, "");
return ret;
throw new Error('stripHTML can not be used any more. Please use jQuery instead.');
}
function updateProgressBar(id, percent, msg, estimate) {
@@ -1290,64 +1244,6 @@ function updateProgressBar(id, percent, msg, estimate) {
el.dispatchEvent(event);
}
// ===== Deprecated core Javascript functions for Moodle ====
// DO NOT USE!!!!!!!
// Do not put this stuff in separate file because it only adds extra load on servers!
/**
* @method show_item
* @deprecated since Moodle 2.7.
* @see Y.Node.show
*/
function show_item() {
throw new Error('show_item can not be used any more. Please use Y.Node.show.');
}
/**
* @method destroy_item
* @deprecated since Moodle 2.7.
* @see Y.Node.destroy
*/
function destroy_item() {
throw new Error('destroy_item can not be used any more. Please use Y.Node.destroy.');
}
/**
* @method hide_item
* @deprecated since Moodle 2.7.
* @see Y.Node.hide
*/
function hide_item() {
throw new Error('hide_item can not be used any more. Please use Y.Node.hide.');
}
/**
* @method addonload
* @deprecated since Moodle 2.7 - please do not use this function any more.
*/
function addonload() {
throw new Error('addonload can not be used any more.');
}
/**
* @method getElementsByClassName
* @deprecated Since Moodle 2.7 - please do not use this function any more.
* @see Y.one
* @see Y.all
*/
function getElementsByClassName() {
throw new Error('getElementsByClassName can not be used any more. Please use Y.one or Y.all.');
}
/**
* @method findChildNodes
* @deprecated since Moodle 2.7 - please do not use this function any more.
* @see Y.all
*/
function findChildNodes() {
throw new Error('findChildNodes can not be used any more. Please use Y.all.');
}
M.util.help_popups = {
setup : function(Y) {
Y.one('body').delegate('click', this.open_popup, 'a.helplinkpopup', this);