r113139 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r113138‎ | r113139 | r113140 >
Date:14:31, 6 March 2012
Author:nad
Status:deferred (Comments)
Tags:
Comment:
position root element based on total width and height, not relative to parent
Modified paths:
  • /trunk/extensions/TreeAndMenu/star.js (modified) (history)

Diff [purge]

Index: trunk/extensions/TreeAndMenu/star.js
@@ -7,8 +7,8 @@
88 easing: 'swing',
99 out_spin: 2,
1010 in_spin: 2,
11 - width: '500px',
12 - height: '500px'
 11+ width: 500,
 12+ height: 500
1313 }
1414
1515 /**
@@ -59,13 +59,17 @@
6060 p = p.children().first();
6161 $('img', p).attr('src', window.tamBaseUrl + window.star_config.img_node);
6262 getData(p).children.push(e);
 63+
 64+ // Set initial position to parent
 65+ var ox = p.position().left + p.width() / 2;
 66+ var oy = p.position().top + p.height() / 2;
 67+ e.css('left', ox - e.width() / 2).css('top', oy - e.height() / 2);
6368 }
6469
65 - // Set initial position to parent
66 - var ox = p.position().left + p.width() / 2;
67 - var oy = p.position().top + p.height() / 2;
68 - e.css('left', ox - e.width() / 2).css('top', oy - e.height() / 2);
 70+ // If root, set position to half width/height
 71+ else e.css('left', window.star_config.width / 2).css('top', window.star_config.height / 2);
6972
 73+
7074 // Create a unique ID and persistent data for this element
7175 e.attr('id', 'starnode' + window.stars.length);
7276 window.stars.push( {

Comments

#Comment by Robmoen (talk | contribs)   01:23, 7 March 2012

It seems one call to .css() would be more efficient / elegant. Also, having it inside a closed control structure could help with future proofing.


} else {
    e.css({
        'left': window.star_config.width / 2),
        "top': window.star_config.height / 2)
    });
}

Status & tagging log