Permalink
Browse files

navigation MDL-26875 Moved course type check into object check and mo…

…ved JS string call to navigation block where the navigation JS is initialised.
  • Loading branch information...
1 parent c683165 commit 4c2820fbd820b5b1e694b0ba9751d19fb4525a02 Sam Hemelryk committed Mar 18, 2011
@@ -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));
}
@@ -310,16 +310,16 @@ BRANCH.prototype = {
try {
var object = Y.JSON.parse(outcome.responseText);
if (object.children && object.children.length > 0) {
- var count = 0;
+ var coursecount = 0;
for (var i in object.children) {
- if (object.children[i].type == 20) {
- count++;
- }
if (typeof(object.children[i])=='object') {
+ if (object.children[i].type == 20) {
+ coursecount++;
+ }
this.addChild(object.children[i]);
}
}
- if (this.get('type') == 10 && count >= M.block_navigation.courselimit) {
+ if (this.get('type') == 10 && coursecount >= M.block_navigation.courselimit) {
this.addViewAllCoursesChild(this);
}
this.get('tree').toggleExpansion({target:this.node});
@@ -357,7 +357,7 @@ BRANCH.prototype = {
}
return true;
},
-
+
/**
* Add a link to view all courses in a category
*/
@@ -455,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']});
View
@@ -1097,8 +1097,6 @@ public function initialise() {
} 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->page->requires->string_for_js('viewallcourses', 'moodle');
// Load for the current user
$this->load_for_user();

0 comments on commit 4c2820f

Please sign in to comment.