Constrain contribute box width; consistent Gallery placement
Fix Gallery whitespace: no clear:both; collapse contribute UI
Line 598: Line 598:


/**
/**
  * Soldier page contribute box (Gallery) — photo/document upload + OCR slot.
  * Soldier page contribute tools — compact disclosure under Gallery heading.
  * Always mounts at the end of the Gallery section (creates Gallery if missing)
  * Sits in the text column beside the floated infobox (no clear:both gap).
* so position is consistent across profiles.
  */
  */
$(function () {
$(function () {
Line 641: Line 640:
return headingWrap($h2);
return headingWrap($h2);
}
}
/* No Gallery yet — insert a heading before Technical record / Sources. */
var $anchor = findSectionHeading(['Technical record', 'Sources']);
var $anchor = findSectionHeading(['Technical record', 'Sources']);
var $wrap = $('<div>', { 'class': 'mw-heading mw-heading2' });
var $wrap = $('<div>', { 'class': 'mw-heading mw-heading2' });
Line 657: Line 655:
return;
return;
}
}
var $gal = $('.mw-parser-output .soldier-gallery').last();
/* Always directly under the Gallery heading — same place on every profile. */
if ($gal.length) {
ensureGalleryAnchor().after($box);
$gal.after($box);
return;
}
var $start = ensureGalleryAnchor();
var $next = $();
$start.nextAll('.mw-heading, h2').each(function () {
var t = headingText($(this));
if (/^(Technical record|Sources|Awards|See also)$/i.test(t)) {
$next = $(this).is('h2') ? headingWrap($(this)) : $(this);
return false;
}
});
if ($next.length) {
$next.before($box);
} else {
$start.after($box);
}
}
}


Line 682: Line 663:
var uploadUrl = mw.util.getUrl('Special:Upload') + '&wpRitchieSoldierPage=' + encodeURIComponent(pageTitle);
var uploadUrl = mw.util.getUrl('Special:Upload') + '&wpRitchieSoldierPage=' + encodeURIComponent(pageTitle);


var $box = $('<div>', { 'class': 'soldier-upload-box' });
var $box = $('<details>', { 'class': 'soldier-upload-box' });
$box.append($('<p>').append(
var $summary = $('<summary>').text('Add photos or OCR a document');
$('<strong>').text('Contribute files for this soldier'),
$box.append($summary);
document.createTextNode(' — photos (portrait or Gallery), documents, or OCR a scan below. You can also use '),
 
var $body = $('<div>', { 'class': 'soldier-upload-body' });
$body.append($('<p>', { 'class': 'soldier-contrib-help' }).append(
document.createTextNode('Photos for the portrait or Gallery, or a document scan for OCR review. Also '),
$('<a>', { href: uploadUrl, text: 'Special:Upload' }),
$('<a>', { href: uploadUrl, text: 'Special:Upload' }),
document.createTextNode('.')
document.createTextNode('.')
Line 699: Line 683:
'<a href="' + mw.util.getUrl('Special:UserLogin', { returnto: pageTitle }) + '">Log in</a> to upload files or run document OCR.'
'<a href="' + mw.util.getUrl('Special:UserLogin', { returnto: pageTitle }) + '">Log in</a> to upload files or run document OCR.'
));
));
$box.append($photoSection);
$body.append($photoSection);
$box.append($('<div>', { 'class': 'soldier-ocr-slot' }));
$body.append($('<div>', { 'class': 'soldier-ocr-slot' }));
$box.append($body);
placeContributeBox($box);
placeContributeBox($box);
return;
return;
Line 720: Line 705:
$form.append($file, $profile, $gallery, $submit, $status);
$form.append($file, $profile, $gallery, $submit, $status);
$photoSection.append($form);
$photoSection.append($form);
$box.append($photoSection);
$body.append($photoSection);
$box.append($('<div>', { 'class': 'soldier-ocr-slot' }));
$body.append($('<div>', { 'class': 'soldier-ocr-slot' }));
$box.append($body);
placeContributeBox($box);
placeContributeBox($box);