]> git.mjollnir.org Git - moodle.git/commitdiff
navigation MDL-20297 Fixed bug whereby ajax events wern't be detached leading to...
authorsamhemelryk <samhemelryk>
Fri, 18 Sep 2009 06:24:42 +0000 (06:24 +0000)
committersamhemelryk <samhemelryk>
Fri, 18 Sep 2009 06:24:42 +0000 (06:24 +0000)
lib/javascript-navigation.js

index 50e461593f928969161043707e97d29bf93bea99..d16f0658d299c153c26843ec34eb683ecd4cc7b8 100644 (file)
@@ -66,6 +66,7 @@ function navigation_tree (treename, key) {
     this.cachedcontent = null;
     this.cachedfooter = null;
     this.position = 'block';
+    this.skipsetposition = false;
     this.togglesidetabdisplay = '[[togglesidetabdisplay]]';
     this.toggleblockdisplay = '[[toggleblockdisplay]]';
     this.sideblockwidth = null;
@@ -105,6 +106,7 @@ navigation_tree.prototype.initialise = function() {
     }
     for (i = 0; i<this.expansions.length; i++) {
         try {
+            this.expansions[i].element = document.getElementById(this.expansions[i].id);
             YAHOO.util.Event.addListener(this.expansions[i].id, 'click', this.init_load_ajax, this.expansions[i], this);
         } catch (err) {
             this.errorlog += "attaching ajax load events: \t"+err+"\n";
@@ -132,6 +134,7 @@ navigation_tree.prototype.initialise = function() {
 
     if (YAHOO.util.Dom.hasClass(e, 'sideblock_js_sidebarpopout')) {
         YAHOO.util.Dom.removeClass(e, 'sideblock_js_sidebarpopout');
+        this.skipsetposition = true;
         this.toggle_block_display(e, this);
     } else if (YAHOO.util.Dom.hasClass(e, 'sideblock_js_expansion')) {
         YAHOO.util.Event.addListener(e, 'mouseover', this.togglesize, e, this);
@@ -219,7 +222,7 @@ navigation_tree.prototype.load_ajax = function(outcome) {
         var branch = outcome.responseXML.documentElement;
         if (branch!=null && this.add_branch(branch,outcome.argument.target ,1)) {
             // If we get here everything worked perfectly
-            YAHOO.util.Event.removeListener(outcome.argument.branch.id, 'click', this.init_load_ajax);
+            YAHOO.util.Event.removeListener(outcome.argument.branch.element, 'click', navigation_tree.prototype.init_load_ajax);
             if (this.position === 'sidebar') {
                 YAHOO.moodle.navigation.tabpanel.resize_tab();
             }
@@ -351,7 +354,11 @@ navigation_tree.prototype.move_to_sidebar_popout = function(e) {
         YAHOO.moodle.navigation.tabpanel = new navigation_tab_panel();
     }
     YAHOO.moodle.navigation.tabpanel.add_to_tab_panel(this.name, tabtitle, tabcontent, tabcommands);
-    set_user_preference('nav_in_tab_panel_'+this.name, 1);
+    if (!this.skipsetposition) {
+        set_user_preference('nav_in_tab_panel_'+this.name, 1);
+    } else {
+        this.skipsetposition = false;
+    }
     return true;
 }
 /**
@@ -744,7 +751,7 @@ navigation_tree_branch.prototype.inject_into_dom = function (element, gntinstanc
         YAHOO.util.Dom.addClass(branchli, 'collapsed');
         YAHOO.util.Event.addListener(branchp, 'click', gntinstance.toggleexpansion, this, gntinstance);
         if (this.myexpandable) {
-            YAHOO.util.Event.addListener(branchp, 'click', gntinstance.init_load_ajax, {branchid:this.mykey,id:this.myid,type:this.mytype}, gntinstance);
+            YAHOO.util.Event.addListener(branchp, 'click', gntinstance.init_load_ajax, {branchid:this.mykey,id:this.myid,type:this.mytype,element:branchp}, gntinstance);
         }
     }
     if (this.myclass != null) {