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:
Sam Hemelryk
2010-05-27 01:40:11 +00:00
parent e00a95965e
commit 24e27ac0c1
10 changed files with 292 additions and 7 deletions

View File

@@ -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) {