navigation MDL-26875 Moved course type check into object check and moved JS string call to navigation block where the navigation JS is initialised.

This commit is contained in:
Sam Hemelryk 2011-03-18 14:45:10 +08:00
parent c683165a4a
commit 4c2820fbd8
3 changed files with 8 additions and 9 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,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 File

@ -1097,8 +1097,6 @@ class global_navigation extends navigation_node {
} 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();