MDL-57687 js: Remove M.util.init_toggle_class_on_click

This commit is contained in:
Dan Poltawski
2017-02-08 11:09:54 +00:00
parent f99313477d
commit e1a38878c1
2 changed files with 10 additions and 39 deletions
+2 -34
View File
@@ -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.');
};
/**