MediaWiki:Common.js: Difference between revisions
Birth name label in soldier edit form |
Place awards section after biography |
||
| Line 26: | Line 26: | ||
$form.append($row); | $form.append($row); | ||
$slot.find('.home-find-title').after($form); | $slot.find('.home-find-title').after($form); | ||
}()); | |||
(function placeSoldierAwardsSection() { | |||
// Ribbon racks belong in the main column (like Wikipedia), not beside the | |||
// floated infobox. Move after Biography / Life, else before Gallery/Sources. | |||
var $out = $('.mw-parser-output').first(); | |||
var $awards = $out.find('.soldier-awards-section').first(); | |||
if (!$out.length || !$awards.length || $awards.data('rbAwardsPlaced')) { | |||
return; | |||
} | |||
$awards.data('rbAwardsPlaced', 1); | |||
function sectionAfter($h) { | |||
var $nodes = $h.nextUntil('h2'); | |||
if ($nodes.length) { | |||
return $nodes.last(); | |||
} | |||
return $h; | |||
} | |||
var $bio = $out.find('h2').filter(function () { | |||
var t = $(this).find('.mw-headline').text() || $(this).text(); | |||
return /^(Biography|Life)\b/i.test($.trim(t)); | |||
}).first(); | |||
if ($bio.length) { | |||
sectionAfter($bio).after($awards); | |||
return; | |||
} | |||
var $before = $out.find('h2').filter(function () { | |||
var t = $(this).find('.mw-headline').text() || $(this).text(); | |||
return /^(Gallery|Research notes|Sources|Technical record)\b/i.test($.trim(t)); | |||
}).first(); | |||
if ($before.length) { | |||
$before.before($awards); | |||
return; | |||
} | |||
$out.append($awards); | |||
}()); | }()); | ||