mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 08:26:37 +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 {
|
try {
|
||||||
var object = Y.JSON.parse(outcome.responseText);
|
var object = Y.JSON.parse(outcome.responseText);
|
||||||
if (object.children && object.children.length > 0) {
|
if (object.children && object.children.length > 0) {
|
||||||
|
var count = 0;
|
||||||
for (var i in object.children) {
|
for (var i in object.children) {
|
||||||
|
if (object.children[i].type == 20) {
|
||||||
|
count++;
|
||||||
|
}
|
||||||
if (typeof(object.children[i])=='object') {
|
if (typeof(object.children[i])=='object') {
|
||||||
this.addChild(object.children[i]);
|
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});
|
this.get('tree').toggleExpansion({target:this.node});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -345,16 +352,23 @@ BRANCH.prototype = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (branch.get('type') == 10 && count >= M.block_navigation.courselimit) {
|
if (branch.get('type') == 10 && count >= M.block_navigation.courselimit) {
|
||||||
branch.addChild({
|
this.addViewAllCoursesChild(branch);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
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, {
|
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']});
|
||||||
|
|
|
@ -1097,6 +1097,8 @@ class global_navigation extends navigation_node {
|
||||||
} else if ($this->rootnodes['courses']->children->count() >= $limit) {
|
} else if ($this->rootnodes['courses']->children->count() >= $limit) {
|
||||||
$this->rootnodes['courses']->add(get_string('viewallcoursescategories'), new moodle_url('/course/index.php'), self::TYPE_SETTING);
|
$this->rootnodes['courses']->add(get_string('viewallcoursescategories'), new moodle_url('/course/index.php'), self::TYPE_SETTING);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->page->requires->string_for_js('viewallcourses', 'moodle');
|
||||||
|
|
||||||
// Load for the current user
|
// Load for the current user
|
||||||
$this->load_for_user();
|
$this->load_for_user();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue