mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 00:16:46 +02:00
insert a 'View all courses' link when loading category navigation entries from AJAX
This commit is contained in:
parent
56babbcb76
commit
c683165a4a
2 changed files with 24 additions and 8 deletions
30
blocks/navigation/yui/navigation/navigation.js
vendored
30
blocks/navigation/yui/navigation/navigation.js
vendored
|
@ -310,11 +310,18 @@ BRANCH.prototype = {
|
|||
try {
|
||||
var object = Y.JSON.parse(outcome.responseText);
|
||||
if (object.children && object.children.length > 0) {
|
||||
var count = 0;
|
||||
for (var i in object.children) {
|
||||
if (object.children[i].type == 20) {
|
||||
count++;
|
||||
}
|
||||
if (typeof(object.children[i])=='object') {
|
||||
this.addChild(object.children[i]);
|
||||
}
|
||||
}
|
||||
if (this.get('type') == 10 && count >= 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, {
|
||||
|
@ -441,4 +455,4 @@ M.block_navigation = M.block_navigation || {
|
|||
}
|
||||
};
|
||||
|
||||
}, '@VERSION@', {requires:['base', 'core_dock', 'io', 'node', 'dom', 'event-custom', 'event-delegate', 'json-parse']});
|
||||
}, '@VERSION@', {requires:['base', 'core_dock', 'io', 'node', 'dom', 'event-custom', 'event-delegate', 'json-parse']});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue