https://www.mediawiki.org/wiki/Special:Code/MediaWiki/115375
Revision: 115375
Author: nad
Date: 2012-05-14 15:29:44 +0000 (Mon, 14 May 2012)
Log Message:
-----------
only one node open at a time, others retire to breadcrumbs list at top left
Modified Paths:
--------------
trunk/extensions/TreeAndMenu/star.js
Modified: trunk/extensions/TreeAndMenu/star.js
===================================================================
--- trunk/extensions/TreeAndMenu/star.js 2012-05-14 14:38:27 UTC (rev
115374)
+++ trunk/extensions/TreeAndMenu/star.js 2012-05-14 15:29:44 UTC (rev
115375)
@@ -69,7 +69,7 @@
});
}
- // If root, main dev center and initialise the common
tree root data
+ // If root, initialise the commonly accessible root data
else {
var div = e.parent().parent().parent();
root = {
@@ -77,10 +77,6 @@
y: div.height() / 2,
crumbs: []
};
- //e.css({
- // left: root.x,
- // top: root.y
- //});
}
// Add spoke for this node
@@ -103,6 +99,7 @@
parent: p,
depth: d,
open: false,
+ anim: false,
spoke: spoke
});
@@ -114,7 +111,7 @@
var e = $('#'+root);
e.css({
display: 'block',
- left: 500,
+ left: 0,
top: tree.top + tree.height() / 2
});
});
@@ -136,42 +133,74 @@
var o = t * window.star_config.out_spin;
var d = data.depth;
+ // Set node state as animating
+ data.anim = true;
+
// Hide the labels during animation
var col = t < 0.9 ? 'white' : 'black';
- // If closing, change icon to "plus", flip t, and hide
items at end
+ // Set initial origin for the children to this elements
center
+ 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( 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);
+
+ // 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;
+
+ // 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;
}
- // If opening, change icon to "minus", close any other
open node
- else if( fx.pos == 0 ) {
- $('img', e).attr('src', window.tamBaseUrl +
window.star_config.img_open);
- //if( d > 1 ) {
+ // If opening,
+ else {
+
+ // At start of open sequence,
+ if( fx.pos == 0 ) {
+
+ // Change icon to "minus"
+ $('img', e).attr('src',
window.tamBaseUrl + window.star_config.img_open);
+
+ // Set any open non-animating nodes to
begin closing
for( var i = 0; i <
window.stars.length; i++ ) {
var id = 'starnode' + i;
if( id != e.attr('id') ) {
var ndata =
window.stars[i];
- if( ndata.open )
animateNode($('#'+id));
+ 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
+ ox += ( root.x - ox ) * t;
+ oy += ( root.y - oy ) * t;
}
- // Set origin for the children to this elements center
animating to the root center
- var ox = e.position().left + e.width() / 2;
- var oy = e.position().top + e.height() / 2;
- ox += ( root.x - ox ) * t;
- oy += ( root.y - oy ) * t;
+ // Position the node at the current origin
+ e.css({
+ display: 'block',
+ left: ox - e.width() / 2,
+ top: oy - e.height() / 2
+ });
// Position the children to their locations around the
origin
var n = data.children.length;
var k = Math.PI * 2 / n;
var r = t * n * 15;
- //if( r < 50 ) r = 50;
for( var i in data.children ) {
var child = data.children[i];
var cdata = getData(child);
@@ -198,16 +227,23 @@
y2: oy + y -
window.star_config.spokev
})
}
-
- // If closing, and this is the first iteration,
close this child too if open
- //if( data.open && fx.pos == 0 && cdata.open )
animateNode(child);
}
},
// Toggle the status on completion
complete: function() {
- var data = getData($(this));
+ var e = $(this);
+ var data = getData(e);
+ var root = data.root;
+
+ // Toggle open state
data.open = !data.open;
+
+ // 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