Merge branch 'MDL-26875' of git://github.com/samhemelryk/moodle

This commit is contained in:
Eloy Lafuente (stronk7) 2011-03-21 21:10:55 +01:00
commit c031f2c1e7
2 changed files with 22 additions and 7 deletions

View File

@ -118,6 +118,7 @@ class block_navigation extends block_base {
'courselimit' => $limit,
'expansionlimit' => $expansionlimit
);
$this->page->requires->string_for_js('viewallcourses', 'moodle');
$this->page->requires->yui_module(array('core_dock', 'moodle-block_navigation-navigation'), 'M.block_navigation.init_add_tree', array($arguments));
}

View File

@ -310,11 +310,18 @@ BRANCH.prototype = {
try {
var object = Y.JSON.parse(outcome.responseText);
if (object.children && object.children.length > 0) {
var coursecount = 0;
for (var i in object.children) {
if (typeof(object.children[i])=='object') {
if (object.children[i].type == 20) {
coursecount++;
}
this.addChild(object.children[i]);
}
}
if (this.get('type') == 10 && coursecount >= M.block_navigation.courselimit) {
this.addViewAllCoursesChild(this);
}
this.get('tree').toggleExpansion({target:this.node});
return true;
}
@ -345,16 +352,23 @@ BRANCH.prototype = {
}
}
if (branch.get('type') == 10 && count >= M.block_navigation.courselimit) {
branch.addChild({
name : M.str.moodle.viewallcourses,
title : M.str.moodle.viewallcourses,
link : M.cfg.wwwroot+'/course/category.php?id='+branch.get('key'),
haschildren : false,
icon : {'pix':"i/navigationitem",'component':'moodle'}
}, branch);
this.addViewAllCoursesChild(branch);
}
}
return true;
},
/**
* Add a link to view all courses in a category
*/
addViewAllCoursesChild: function(branch) {
branch.addChild({
name : M.str.moodle.viewallcourses,
title : M.str.moodle.viewallcourses,
link : M.cfg.wwwroot+'/course/category.php?id='+branch.get('key'),
haschildren : false,
icon : {'pix':"i/navigationitem",'component':'moodle'}
});
}
}
Y.extend(BRANCH, Y.Base, BRANCH.prototype, {