mirror of
https://github.com/moodle/moodle.git
synced 2025-07-24 07:41:40 +02:00
course MDL-8369 Front page combo list is now restructured and exandable by JavaScript
This patch also implements a course renderer.
This commit is contained in:
@@ -393,6 +393,36 @@ 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
|
||||
*/
|
||||
M.util.init_toggle_class_on_click = function(Y, id, cssselector, toggleclassname) {
|
||||
var node = Y.one('#'+id);
|
||||
node.all(cssselector).each(function(node){
|
||||
node.on('click', function(e){
|
||||
e.stopPropagation();
|
||||
if (e.target.get('nodeName')!='A' && e.target.get('nodeName')!='IMG') {
|
||||
this.toggleClass(toggleclassname);
|
||||
}
|
||||
}, node);
|
||||
});
|
||||
// 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')) {
|
||||
node.all(cssselector).addClass(toggleclassname);
|
||||
} else if (e.target.hasClass('removefromall')) {
|
||||
node.all(cssselector+'.'+toggleclassname).removeClass(toggleclassname);
|
||||
}
|
||||
}, node);
|
||||
}
|
||||
|
||||
//=== old legacy JS code, hopefully to be replaced soon by M.xx.yy and YUI3 code ===
|
||||
|
||||
function popupchecker(msg) {
|
||||
|
Reference in New Issue
Block a user