https://www.mediawiki.org/wiki/Special:Code/MediaWiki/115506

Revision: 115506
Author:   nad
Date:     2012-06-13 15:20:29 +0000 (Wed, 13 Jun 2012)
Log Message:
-----------
fix starmenu breadcrumbs

Modified Paths:
--------------
    trunk/extensions/TreeAndMenu/star.js

Modified: trunk/extensions/TreeAndMenu/star.js
===================================================================
--- trunk/extensions/TreeAndMenu/star.js        2012-06-13 11:45:31 UTC (rev 
115505)
+++ trunk/extensions/TreeAndMenu/star.js        2012-06-13 15:20:29 UTC (rev 
115506)
@@ -75,7 +75,7 @@
                                root = {
                                        x: div.width() / 2,
                                        y: div.height() / 2,
-                                       crumbs: []
+                                       openDepth: 0
                                };
                        }
 
@@ -143,19 +143,34 @@
                        var ox = e.position().left + e.width() / 2;
                        var oy = e.position().top + e.height() / 2;
 
-                       // If closing, flip t, and define final position in 
crumbs
+                       // If closing, flip t, and move to depth position in 
crumbs area
                        if( data.open ) {
 
-                               // At start of close sequence, change icon to 
"plus"
-                               if( fx.pos == 0 ) $('img', e).attr('src', 
window.tamBaseUrl + window.star_config.img_node);
+                               // At start of close sequence, change icon to 
"plus" and set crumbs to parent crumbs state
+                               if( fx.pos == 0 ) {
+                                       $('img', e).attr('src', 
window.tamBaseUrl + window.star_config.img_node);
+                               }
 
                                // Hide node at end of animation
                                if( t > 0.9 ) display = 'none';
 
-                               // Animate the circle's center to the crumbs 
area
-                               ox += ( root.crumbs.length * ( e.width() + 50 ) 
- ox ) * t;
-                               oy -= oy * t;
+                               // Animate the circle's center to the crumbs
+                               if( root.openDepth >= d ) {
+                                       ox += ( ( d - 1 ) * ( e.width() + 50 ) 
- ox ) * t;
+                                       oy -= oy * t;
+                               }
 
+                               // animate to parents location
+                               else {
+                                       var p = data.parent;
+                                       //var px = p.position().left + 
p.width() / 2;
+                                       //var py = p.position().top + 
p.height() / 2;
+                                       //ox += ( px - ox ) * t;
+                                       //oy += ( py - oy ) * t;
+                                       ox += ( root.x - ox ) * t;
+                                       oy += ( root.y - oy ) * t;
+                               }
+
                                // Set the angle and radius to match the final 
opening's state
                                o = window.star_config.out_spin + t * 
window.star_config.in_spin;
                                t = 1 - t;
@@ -167,6 +182,9 @@
                                // At start of open sequence,
                                if( fx.pos == 0 ) {
 
+                                       // Record depth of currently open node
+                                       root.openDepth = d;
+
                                        // Change icon to "minus"
                                        $('img', e).attr('src', 
window.tamBaseUrl + window.star_config.img_open);
 
@@ -178,11 +196,6 @@
                                                        if( ndata.open && 
!ndata.anim ) animateNode($('#'+id));
                                                }
                                        }
-
-                                       // Remove this node and everything 
after from the crumbs
-                                       var i = 
root.crumbs.indexOf(e.attr('id'));
-                                       if( i >= 0 ) root.crumbs = 
root.crumbs.slice(0,i);
-
                                }
 
                                // Animate the circle's center to the root 
center
@@ -241,9 +254,6 @@
 
                        // Set state to not animating
                        data.anim = false;
-
-                       // If closed, add to end of crumbs
-                       if( !data.open ) root.crumbs.push(e.attr('id'));
                }
        });
 }


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to