diff --git a/lib/javascript-static.js b/lib/javascript-static.js index d2ce894a0ba..444aab5a781 100644 --- a/lib/javascript-static.js +++ b/lib/javascript-static.js @@ -392,42 +392,10 @@ M.util.init_frametop = function(Y) { }; /** - * Finds all nodes that match the given CSS selector and attaches events to them - * so that they toggle a given classname when clicked. - * - * @param {YUI} Y - * @param {string} id An id containing elements to target - * @param {string} cssselector A selector to use to find targets - * @param {string} toggleclassname A classname to toggle + * @deprecated since Moodle 3.3 */ M.util.init_toggle_class_on_click = function(Y, id, cssselector, toggleclassname, togglecssselector) { - - if (togglecssselector == '') { - togglecssselector = cssselector; - } - - var node = Y.one('#'+id); - node.all(cssselector).each(function(n){ - n.on('click', function(e){ - e.stopPropagation(); - if (e.target.test(cssselector) && !e.target.test('a') && !e.target.test('img')) { - if (this.test(togglecssselector)) { - this.toggleClass(toggleclassname); - } else { - this.ancestor(togglecssselector).toggleClass(toggleclassname); - } - } - }, n); - }); - // Attach this click event to the node rather than all selectors... will be much better - // for performance - node.on('click', function(e){ - if (e.target.hasClass('addtoall')) { - this.all(togglecssselector).addClass(toggleclassname); - } else if (e.target.hasClass('removefromall')) { - this.all(togglecssselector+'.'+toggleclassname).removeClass(toggleclassname); - } - }, node); + throw new Error('M.util.init_toggle_class_on_click can not be used any more. Please use jQuery instead.'); }; /** diff --git a/lib/upgrade.txt b/lib/upgrade.txt index be273d5cddc..7d914be832c 100644 --- a/lib/upgrade.txt +++ b/lib/upgrade.txt @@ -10,14 +10,17 @@ information provided here is intended especially for developers. * $mform->init_javascript_enhancement() is deprecated and no longer does anything. Existing uses of smartselect enhancement should be switched to the searchableselector form element or other solutions. * Return value of the validate_email() is now proper boolean as documented. Previously the function could return 1, 0 or false. -* M.util.focus_login_form and M.util.focus_login_error no longer do anything. Please use jquery instead. See - lib/templates/login.mustache for an example. -* Some outdated global JS functions have been removed and should be replaced with calls to jquery or alternative approaches: - checkall, checknone, select_all_in_element_with_id, select_all_in, deselect_all_in, confirm_if, findParentNode, - filterByParent, stripHTML * The mcore YUI rollup which included various YUI modules such as moodle-core-notification is no longer included on every page. Missing YUI depdencies may be exposed by this change (e.g. missing a requirement on moodle-core-notification when using M.core.dialogue). +* Various legacy javascript functions have been removed: + * M.util.focus_login_form and M.util.focus_login_error no longer do anything. Please use jquery instead. See + lib/templates/login.mustache for an example. + * Some outdated global JS functions have been removed and should be replaced with calls to jquery + or alternative approaches: + checkall, checknone, select_all_in_element_with_id, select_all_in, deselect_all_in, confirm_if, findParentNode, + filterByParent, stripHTML + * M.util.init_toggle_class_on_click has been removed. === 3.2 ===