r110589 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r110588‎ | r110589 | r110590 >
Date:16:34, 2 February 2012
Author:nad
Status:deferred
Tags:
Comment:
new star menu started
Modified paths:
  • /trunk/extensions/TreeAndMenu/star.js (added) (history)

Diff [purge]

Index: trunk/extensions/TreeAndMenu/star.js
@@ -0,0 +1,50 @@
 2+window.stars = [];
 3+$( function() {
 4+ $('div.tam-star ul').css('list-style','none');
 5+ $('div.tam-star').each( function() {
 6+ $(this).css('width','400px').css('height','400px').css('background','yellow');
 7+ $('a', this).each( function() {
 8+
 9+ // Initialise the <a> element
 10+ var e = $(this);
 11+ e.css('position','absolute').css('background','pink').css('padding','0 5px');
 12+
 13+ // Get the depth of this element
 14+ var li = e.parent();
 15+ var d = 0;
 16+ while( li[0].tagName == 'LI' ) {
 17+ li = li.parent().parent();
 18+ d++;
 19+ }
 20+
 21+ // Get the parent <a> or <div>
 22+ var p = e.parent().parent().parent();
 23+ if( d > 1 ) p = p.children().first();
 24+
 25+ // Create a unique ID and persistent data for this element
 26+ e.attr('id', 'starnode' + window.stars.length);
 27+ window.stars.push( { parent: p, depth: d } );
 28+
 29+ // Animate the element from the parent to the circumference
 30+ var r = 120;
 31+ if( d == 2 ) r = 70;
 32+ if( d == 3 ) r = 30;
 33+ e.animate( { foo: r }, {
 34+ duration: 1000,
 35+ easing: 'swing',
 36+ step: function(now, fx) {
 37+ var e = $(fx.elem);
 38+ var p = window.stars[e.attr('id').substr(8)].parent;
 39+ var ox = p.position().left + p.width() / 2;
 40+ var oy = p.position().top + p.height() / 2;
 41+ var i = e.parent().index();
 42+ var n = e.parent().parent().children().last().index() + 1;
 43+ var a = Math.PI * 2 * i / n;
 44+ var y = Math.sin(a) * now;
 45+ var x = Math.cos(a) * now;
 46+ e.css('left', ox + x - e.width() / 2).css('top', oy + y - e.height() / 2);
 47+ }
 48+ });
 49+ })
 50+ });
 51+});

Status & tagging log