MediaWiki:Gadget-common-action-edit.js

mw.hook ('wikipage.content') .add (function { // Automatically fill in fields when adding new topics at the top var summary = $ ('#wpSummary') .val ; if (decodeURIComponent (location.search) .search (/ [? &] summary = \ / \ * [+] * \ * \ //)! == -1 || (mw.config.get ('wgAction') === 'submit' && summary! == undefined && summary.search (/ \ / \ * \ s * \ * \ //)! == -1 ) ) { mw.loader.load ('ext.gadget.newTopicOnTop'); } });

// Gadgets section in the toolbar if (mw.user.options.get ('usebetatoolbar') === 1) { $ .when ( mw.loader.using ('ext.wikiEditor'), $ .ready ) .then (function { function addGadgetsGroup  { $ ('# wpTextbox1') .wikiEditor ('addToToolbar', { 'section': 'main', 'groups': { 'gadgets': {} } });

$ groupGadgets = $ ('# wikiEditor-section-main .group-gadgets'); $ groupFormat = $ ('# wikiEditor-section-main .group-format'); if ($ groupGadgets.length) { if ($ groupFormat.length) { $ groupGadgets.insertBefore ($ groupFormat); } mw.hook ('wikieditor.toolbar.gadgetsgroup') .fire ; } }

var $ groupGadgets, $ groupFormat; addGadgetsGroup ; if (! $ groupGadgets.length) { // Treatment for cases when the toolbar is drawn late setTimeout (addGadgetsGroup, 0); } }); }

// Signature reminder. Displayed in the discussion namespaces, Wikipedia, and Project. var namespaceNumber = mw.config.get ('wgNamespaceNumber'); if (namespaceNumber% 2 || namespaceNumber === 4 || namespaceNumber === 104) { $ (function { var $ textbox, matches, newLinesCountInitial, $ tildes, $ signReminderCommon, $ signReminder, $ copyrightWarning = $ ('# editpage-copywarn'), $ saveButton = $ ('#wpSave'), warningDone = false;

if (! $ copyrightWarning.length || ! $ saveButton.length || // Namespaces "Wikipedia" and "Project" (mw.config.get ('wgNamespaceNumber') === 4 || mw.config.get ('wgNamespaceNumber') === 104) && (! mw.config.get ('wgTitle') .match ( // Wikipedia: '^ (?: Forum [/] | Polls / | Polls / | Discussion of rules / | Applications for | Inquiries | Applicants for. * / |' + 'To (?: Delete | merge | rename | split | improve | source evaluation | mediation) / |' + 'Challenging | Reviewing / | Checking Participants / | Filter Edits / Triggers |' + // Project: 'Incubator / (?: Mini Review | Forum) | Social Responsibility / Forum | Water Bodies |' + 'Library / (?: Books Wanted | Questions | Hot Topics | Technical Questions) |' + 'Graphic workshop / Applications | Good-quality articles / To deprivation of status | Literacy / Requests |. * Requests)' ) || mw.config.get ('wgTitle') .match ('/ Archive') ) ) { return; }

$ textbox = $ ('# wpTextbox1'); matches = $ textbox.val. trim. match (/ \ n / g); newLinesCountInitial = matches? matches.length: 0;

$ tildes = $ ('') .attr ('href', 'javascript:') .text (' \ ') .click (function { $ textbox.textSelection ('encapsulateSelection', {pre: ' \ '}); }); $ signReminderCommon = $ (' ') .addClass ('signReminder-common') .append ( 'Don't forget to add a signature to your post with', $ tildes ); $ signReminder = $ (' ') .attr ('id', 'signReminder') .append ($ signReminderCommon) .insertAfter ($ copyrightWarning);

if (mw.config.get ('wgUserGroups') .indexOf ('autoconfirmed')! == -1 &&! window.sigWarning) { return; }

// Only unregistered / new users and those who have enabled the warning in their personal JS line // var sigWarning = true; $ saveButton.click (function { try { var newLinesCount, $ signReminderWarningbox, $ tildesCopy, textboxContent = $ textbox.val ;

matches = textboxContent.trim. match (/ \ n / g); newLinesCount = matches? matches.length: 0;

if (textboxContent.indexOf (' \ ')! == -1 || $ ('#wpMinoredit') .prop ('checked') || newLinesCountInitial === newLinesCount || warningDone ) { return true; }

warningDone = true; $ tildesCopy = $ tildes.clone (true); $ signReminderCommon.remove ; $ signReminderWarning = $ (' ') .addClass ('signReminder-warning') .append ('Please subscribe by adding at the end of your post', $ tildesCopy, ' ( learn more ) < / small> ' ); $ (' ') .addClass ('warningbox signReminder-warningbox') .append ($ signReminderWarning) .appendTo ($ signReminder); return false; } catch (e) { return true; } }); }); }