Commit c8ffba95 authored by Sam Hemelryk's avatar Sam Hemelryk
Browse files

course MDL-24595 Fixed expand all collapse all links on front page.

parent 1b32bc23
......@@ -66,7 +66,7 @@ class core_course_renderer extends plugin_renderer_base {
// Generate an id and the required JS call to make this a nice widget
$id = html_writer::random_id('course_category_tree');
$this->page->requires->js_init_call('M.util.init_toggle_class_on_click', array($id, '.category.with_children .category_label', 'collapsed'));
$this->page->requires->js_init_call('M.util.init_toggle_class_on_click', array($id, '.category.with_children .category_label', 'collapsed', '.category.with_children'));
// Start content generation
$content = html_writer::start_tag('div', array('class'=>'course_category_tree', 'id'=>$id));
......
......@@ -406,23 +406,32 @@ M.util.init_frametop = function(Y) {
* @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) {
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(node){
node.on('click', function(e){
node.all(cssselector).each(function(n){
n.on('click', function(e){
e.stopPropagation();
if (e.target.test(cssselector) && e.target.get('nodeName')!='A' && e.target.get('nodeName')!='IMG') {
this.ancestor().toggleClass(toggleclassname);
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);
}
}
}, node);
}, 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')) {
node.all(cssselector).addClass(toggleclassname);
this.all(togglecssselector).addClass(toggleclassname);
} else if (e.target.hasClass('removefromall')) {
node.all(cssselector+'.'+toggleclassname).removeClass(toggleclassname);
this.all(togglecssselector+'.'+toggleclassname).removeClass(toggleclassname);
}
}, node);
};
......
......@@ -29,7 +29,7 @@
defined('MOODLE_INTERNAL') || die();
$version = 2010111703; // YYYYMMDD = date of the last version bump
$version = 2010112200; // YYYYMMDD = date of the last version bump
// XX = daily increments
$release = '2.0 RC2 (Build: 20101122)'; // Human-friendly version name
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment