Permalink
Browse files

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

  • Loading branch information...
2 parents 63187a6 + 4c2820f commit c031f2c1e7388c3fd60266777d9bb7b969bb2d53 @stronk7 stronk7 committed Mar 21, 2011
Showing with 22 additions and 7 deletions.
  1. +1 −0 blocks/navigation/block_navigation.php
  2. +21 −7 blocks/navigation/yui/navigation/navigation.js
View
1 blocks/navigation/block_navigation.php
@@ -118,6 +118,7 @@ function get_required_javascript() {
'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
28 blocks/navigation/yui/navigation/navigation.js
@@ -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, {

0 comments on commit c031f2c

Please sign in to comment.