mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 05:58:34 +01:00
navigation MDL-22671 Fixed another misused image + a bug with AJAX requests
This commit is contained in:
parent
4bd1108f9f
commit
246a9b05ba
@ -162,7 +162,7 @@ M.block_navigation.classes.tree.prototype.init_load_ajax = function(e, branch) {
|
||||
M.block_navigation.classes.tree.prototype.load_ajax = function(tid, outcome, args) {
|
||||
try {
|
||||
var object = this.Y.JSON.parse(outcome.responseText);
|
||||
if (this.add_branch(object, args.target.ancestor('LI') ,1)) {
|
||||
if (this.add_branch(object, args.target.ancestor('li') ,1)) {
|
||||
if (this.candock) {
|
||||
M.core_dock.resize();
|
||||
}
|
||||
@ -298,8 +298,10 @@ M.block_navigation.classes.branch.prototype.construct_from_json = function(obj)
|
||||
*/
|
||||
M.block_navigation.classes.branch.prototype.inject_into_dom = function(element) {
|
||||
|
||||
var Y = this.tree.Y;
|
||||
|
||||
var isbranch = ((this.expandable !== null || this.haschildren) && this.expansionceiling===null);
|
||||
var branchli = this.tree.Y.Node.create('<li></li>');
|
||||
var branchli = Y.Node.create('<li></li>');
|
||||
var branchp = this.tree.Y.Node.create('<p class="tree_item"></p>');
|
||||
|
||||
if (isbranch) {
|
||||
@ -322,7 +324,8 @@ M.block_navigation.classes.branch.prototype.inject_into_dom = function(element)
|
||||
// Prepare the icon, should be an object representing a pix_icon
|
||||
var branchicon = false;
|
||||
if (this.icon != null && !isbranch) {
|
||||
branchicon = this.tree.Y.Node.create('<img src="'+M.util.image_url(this.icon.pix, this.icon.component)+'" alt="" />');
|
||||
branchicon = Y.Node.create('<img alt="" />');
|
||||
branchicon.setAttribute('src', M.util.image_url(this.icon.pix, this.icon.component));
|
||||
branchli.addClass('item_with_icon');
|
||||
if (this.icon.alt) {
|
||||
branchicon.setAttribute('alt', this.icon.alt);
|
||||
@ -343,7 +346,7 @@ M.block_navigation.classes.branch.prototype.inject_into_dom = function(element)
|
||||
}
|
||||
branchp.append(this.name.replace(/\n/g, '<br />'));
|
||||
} else {
|
||||
var branchlink = this.tree.Y.Node.create('<a title="'+this.title+'" href="'+this.link+'"></a>');
|
||||
var branchlink = Y.Node.create('<a title="'+this.title+'" href="'+this.link+'"></a>');
|
||||
if (branchicon) {
|
||||
branchlink.appendChild(branchicon);
|
||||
}
|
||||
@ -356,7 +359,7 @@ M.block_navigation.classes.branch.prototype.inject_into_dom = function(element)
|
||||
|
||||
branchli.appendChild(branchp);
|
||||
if (this.haschildren) {
|
||||
var childrenul = this.tree.Y.Node.create('<ul></ul>');
|
||||
var childrenul = Y.Node.create('<ul></ul>');
|
||||
branchli.appendChild(childrenul);
|
||||
element.appendChild(branchli);
|
||||
return childrenul
|
||||
|
@ -43,7 +43,7 @@ try {
|
||||
$PAGE->set_context(get_context_instance(CONTEXT_SYSTEM));
|
||||
|
||||
// Create a global nav object
|
||||
$navigation = new global_navigation_for_ajax($PAGE);
|
||||
$navigation = new global_navigation_for_ajax($PAGE, $branchtype, $branchid);
|
||||
|
||||
if ($instanceid!==null) {
|
||||
// Get the db record for the block instance
|
||||
@ -68,8 +68,6 @@ try {
|
||||
}
|
||||
|
||||
// Create a navigation object to use, we can't guarantee PAGE will be complete
|
||||
|
||||
$expandable = $navigation->initialise($branchtype, $branchid);
|
||||
if (!isloggedin() || isguestuser()) {
|
||||
$navigation->set_expansion_limit(navigation_node::TYPE_COURSE);
|
||||
} else {
|
||||
@ -102,7 +100,7 @@ if (empty($branch) || $branch->nodetype !== navigation_node::NODETYPE_BRANCH) {
|
||||
}
|
||||
|
||||
// Prepare an XML converter for the branch
|
||||
$converter->set_expandable($expandable);
|
||||
$converter->set_expandable($navigation->get_expandable());
|
||||
// Set XML headers
|
||||
header('Content-type: text/plain');
|
||||
// Convert and output the branch as XML
|
||||
|
@ -1878,12 +1878,16 @@ class global_navigation extends navigation_node {
|
||||
}
|
||||
|
||||
public function get($key, $type = null) {
|
||||
$this->initialise();
|
||||
if (!$this->initialised) {
|
||||
$this->initialise();
|
||||
}
|
||||
return parent::get($key, $type);
|
||||
}
|
||||
|
||||
public function find($key, $type) {
|
||||
$this->initialise();
|
||||
if (!$this->initialised) {
|
||||
$this->initialise();
|
||||
}
|
||||
return parent::find($key, $type);
|
||||
}
|
||||
}
|
||||
@ -1912,14 +1916,11 @@ class global_navigation_for_ajax extends global_navigation {
|
||||
/**
|
||||
* Constructs the navigation for use in AJAX request
|
||||
*/
|
||||
public function __construct($page) {
|
||||
global $SITE;
|
||||
public function __construct($page, $branchtype, $id) {
|
||||
$this->page = $page;
|
||||
$this->cache = new navigation_cache(NAVIGATION_CACHE_NAME);
|
||||
$this->children = new navigation_node_collection();
|
||||
$this->rootnodes = array();
|
||||
$this->rootnodes['site'] = $this->add_course($SITE);
|
||||
$this->rootnodes['courses'] = $this->add(get_string('courses'), null, self::TYPE_ROOTNODE, null, 'courses');
|
||||
$this->initialise($branchtype, $id);
|
||||
}
|
||||
/**
|
||||
* Initialise the navigation given the type and id for the branch to expand.
|
||||
@ -1929,11 +1930,16 @@ class global_navigation_for_ajax extends global_navigation {
|
||||
* @return array The expandable nodes
|
||||
*/
|
||||
public function initialise($branchtype, $id) {
|
||||
global $CFG, $DB, $PAGE;
|
||||
global $CFG, $DB, $PAGE, $SITE;
|
||||
|
||||
if ($this->initialised || during_initial_install()) {
|
||||
return $this->expandable;
|
||||
}
|
||||
$this->initialised = true;
|
||||
|
||||
$this->rootnodes = array();
|
||||
$this->rootnodes['site'] = $this->add_course($SITE);
|
||||
$this->rootnodes['courses'] = $this->add(get_string('courses'), null, self::TYPE_ROOTNODE, null, 'courses');
|
||||
|
||||
// Branchtype will be one of navigation_node::TYPE_*
|
||||
switch ($branchtype) {
|
||||
@ -2001,6 +2007,10 @@ class global_navigation_for_ajax extends global_navigation {
|
||||
$this->find_expandable($this->expandable);
|
||||
return $this->expandable;
|
||||
}
|
||||
|
||||
public function get_expandable() {
|
||||
return $this->expandable;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user