|
|
| 1. rindiņa: |
1. rindiņa: |
| mw.notify('Common.js loaded');
| |
|
| |
|
| (function () {
| |
| // Desired field order (based on the IDs you provided)
| |
| var ORDER = [
| |
| '#wpCreateaccountMail',
| |
| '#wpName2',
| |
| '#wpPassword2',
| |
| '#wpRetype',
| |
| '#wpEmail',
| |
| '#wpRealName',
| |
| '#mw-input-captchaWord',
| |
| '#wpReason',
| |
| '#wpCreateaccount'
| |
| ];
| |
|
| |
| // Find the container that holds the field blocks
| |
| function findWrap($root) {
| |
| var $wrap = $root.find('#mw-createaccount-form .mw-htmlform-ooui');
| |
| if (!$wrap.length) $wrap = $root.find('#mw-createaccount-form .oo-ui-panelLayout');
| |
| if (!$wrap.length) $wrap = $root.find('#mw-createaccount-form .mw-htmlform');
| |
| if (!$wrap.length) $wrap = $root.find('#mw-createaccount-form');
| |
| return $wrap.first();
| |
| }
| |
|
| |
| // Given an input/button id, return its field "block" wrapper
| |
| function fieldBlock($wrap, sel) {
| |
| var $el = $wrap.find(sel);
| |
| if (!$el.length) return null;
| |
| var $blk = $el.closest(
| |
| '.oo-ui-fieldLayout, .mw-htmlform-field, .mw-htmlform-submit,' +
| |
| ' .mw-htmlform-field-HTMLCheckField, .mw-htmlform-field-HTMLInfoField,' +
| |
| ' tr, li, dd, .oo-ui-widget, .oo-ui-layout, div'
| |
| );
| |
| return $blk.length ? $blk : $el;
| |
| }
| |
|
| |
| function reorder($root) {
| |
| var $wrap = findWrap($root);
| |
| if (!$wrap.length) return false;
| |
|
| |
| var prev = null;
| |
| for (var i = 0; i < ORDER.length; i++) {
| |
| var $blk = fieldBlock($wrap, ORDER[i]);
| |
| if (!$blk) continue;
| |
|
| |
| if (prev) {
| |
| $blk.insertAfter(prev); // place after the previous moved block
| |
| } else {
| |
| $blk.prependTo($wrap); // first block goes to the very top
| |
| }
| |
| prev = $blk;
| |
| }
| |
| return true;
| |
| }
| |
|
| |
| function run($content) {
| |
| // Try immediately and also after short delays (OOUI may mutate after load)
| |
| reorder($content);
| |
| setTimeout(function () { reorder($content); }, 0);
| |
| setTimeout(function () { reorder($content); }, 100);
| |
| setTimeout(function () { reorder($content); }, 500);
| |
|
| |
| // Watch for late DOM changes and re-apply (disconnect after a bit)
| |
| var form = document.getElementById('mw-createaccount-form');
| |
| if (form) {
| |
| var obs = new MutationObserver(function () { reorder($content); });
| |
| obs.observe(form, { childList: true, subtree: true });
| |
| setTimeout(function () { obs.disconnect(); }, 5000);
| |
| }
| |
| }
| |
|
| |
| if (mw && mw.hook) {
| |
| mw.hook('wikipage.content').add(function ($content) { run($content); });
| |
| } else {
| |
| jQuery(function ($) { run($(document)); });
| |
| }
| |
| })();
| |