dev

This is the talk page for discussing improvements to the Standard Edit Summary page.

Untitled

When I started using this script, I made some changes, including merging the duplicate code, ignoring comments, and fixing tabindexes.
I don't know what the protocol is for editing code that is possibly in use, so I've posted the changes here for others: Standard_Edit_Summary/Changes -452 17:26, December 18, 2012 (UTC)

You might also want to see this.— UltimateSupreme (Talk) 18:34, December 18, 2012 (UTC)
The select is inaccessible when the source editor is in wide mode. This should fix it:
.editpage-sourcewidemode-on #stdSummaries {
    border-radius: 4px;
    left: -17px;
    padding: 1px 2px;
    position: relative;
    top: 25px;
    width: 278px;
}


--  pecoes  19:26, December 18, 2012 (UTC) 
Thanks, I'm happy with my current implementation, but it's definitely good to see there's more than one way to arrive with the same results. -452 20:02, December 18, 2012 (UTC)
Another little thing: You shouldn't append nodes to the document in a loop. It would be much faster to concatenate all those options to a single string and then append the lot of them after the loop. --  pecoes  19:31, December 18, 2012 (UTC) 
I agree, but since the current implementation also uses a loop, you can't really fault UltimateSupreme for that. -452 19:43, December 18, 2012 (UTC)
I was talking about the loop in your code 452 :)
And while am at it: Please, don't use for..in for arrays! :( --  pecoes  19:48, December 18, 2012 (UTC) 
Your indents did not indicate you were responding to me. I've now fixed the indents.
It's not my code. I did not write the code on Standard_Edit_Summary/code.js. -452 20:02, December 18, 2012 (UTC)
I'm not even sure who did originally write it, I'll try to find out and get back to you. -452 20:03, December 18, 2012 (UTC)
I'm sorry! I thought that was obvious. All of my comments - including the CSS suggestion - where in references to your rewrite. --  pecoes  20:06, December 18, 2012 (UTC) 
Oh ok. Yes, I've made a number of CSS modifications as well, I didn't think to include them, thanks. -452 21:00, December 18, 2012 (UTC)
With regards to the origins of this script, I believe it comes from Wookieepedia. It's included in the first revision of their Common.js, way back in 2007 - standard delete reasons and template preloads also exist at this time. It appears that the scripts predate the page, but whether that's a mark of Common.js not being part of MediaWiki back then I don't know. cqm 02:05, 19 Dec 2012 (UTC)
The jQuery version of it was written by Grunny.— UltimateSupreme (Talk)02:59, December 19, 2012 (UTC)
Looks like you're both right, the version of wookiepedia was always named "fillEditSummaries", runescape copied "fillEditSummaries" from there, but didn't attribute the source properly, and later renamed it. -452 07:14, December 19, 2012 (UTC)
On 2007-10-04, User:Richard1990 pasted a fillEditSummaries script on runescape identical to the one in use on wookiepedia. This script remained in use until 2010-07-16, with fillEditSummaries remaining unchanged and matching wookiepedia's on the same date
On 2010-07-17, runescape's script was upgraded by User:Quarenon, and renamed to become the basis for the current version.
Wookiepedia's script remained the same until 2011-07-29, it took a different path than runescape's script, but they're both based on the same original script which was on wookiepedia since 2006. (So, Grunny's jQuery filleditsummaries script is not an ancestor of the current script, it is a cousin of the current script, with a shared ancestor which was on wookiepedia before anywhere else currently known. 452 07:58, December 19, 2012 (UTC))
Richard1990 plagiarised the script without attribution, Quarenon is responsible for both the "For .. in" loop and the append loop. -452 07:48, December 19, 2012 (UTC)
I'm thoroughly confused now. How should we credit this script? And to whom? --  pecoes  15:17, December 20, 2012 (UTC) 
Technically, it's within the citing requirements to just link to the copied version. But in theory, the version you're linking should cite the source before them, so that the chain can be followed to the true source, but in practice, since we know this chain is broken... I don't know if it's our responsibility to fix Richard1990's violation.
I'd credit Wookiepedia in general (at least until we find out who wrote it originally - I didn't think of it earlier, but I'll ask on wookiepedia See below), Quarenon from Runescape and Runescape in general, Casualty in general (unless you want to dig and find out who was involved - they were content to credit only their wiki rather than individuals), then there's me and you. -452 17:00, December 20, 2012 (UTC)
Looks like Sikon on Wookiepedia wrote it originally, he added it to Monobook.js on 2006-08-20, this forum post happened at the same time, and it appears he wrote it rather than copying it.
Additionally, here's some additional proof that User:Richard1990 copied the script from there. -452 17:27, December 20, 2012 (UTC)
That's some nice detective work :) You should update the credits in the code and on the page then!  pecoes  17:35, December 20, 2012 (UTC) 
Casualty Wiki modifications were done by me. It was back when we switched to the new Oasis editor - and was mostly on disabling the section headers from Template:Stdsummaries, which got copied back to RS at some point. I've updated the credits.    ǝsʞpɐןǝ  (talk page)  13:15, 6 April 2013

Another version

I optimized 452' version a bit and added the CSS for the wide-screen mode of the source editor:

/** ============================================================
 * Standard edit summaries
 *
 * Adapted from http://runescape.wikia.com/wiki/MediaWiki:Common.js/standardeditsummaries.js
 * Updated to handle comments and tabindexes by User:452
 * Updated to handle wide-screen mode and slightly optmized by User:Pecoes
 * =========================================================== */
 
/*jshint jquery:true, browser:true, es5:true, devel:true, camelcase:true, curly:false, undef:true, bitwise:true, eqeqeq:true, forin:true, immed:true, latedef:true, newcap:true, noarg:true, unused:true, regexp:true, strict:true, trailing:true*/

$(function() {
    
    'use strict';
    
    var $textarea = $('#wpSummary');
    
    if (!$textarea.length || document.getElementById('stdSummaries')) return;
    
    var templateLoader = $.get('/wiki/Template:Stdsummaries?action=raw');
    
    $textarea.attr('tabindex', '3'); //set tabindex for summaries text area
    $('#wpMinoredit').attr('tabindex', '4'); //set tabindex for minor edit checkbox
    $('#wpSave').attr('tabindex', '5'); //set tabindex for publish button
        
    var $summary = $('#wpSummaryEnhanced');
    if (!$summary.length) $summary = $textarea;

    $('head').append('<style type="text/css">#stdSummaries { border-radius: 4px; padding: 1px 2px; width: 284px; } .editpage-sourcewidemode-on.mode-source #stdSummaries { left: -17px; position: relative; top: 25px; width: 278px; }</style>');

    var $combo = $('<select id="stdSummaries" tabindex="2"></select>')
    .insertAfter($textarea)
    .change(function() {
        var val = $summary.val();
        $summary.val(val + (val.length ? '; ' : '') + $(this).val());
    });
 
    templateLoader
    .done(function (data) {
        var lines = data.split(/\r\n|\n|\r/),
            options = '', selected = ' selected',
            ignore = { ':': 1, '*': 1,  '<': 1 };
        for (var i = 0; i < lines.length; i++, selected = '') {
            if (!lines[i].length || ignore[lines[i][0]]) {
                continue; // lines beginning with these characters: : * < are ignored
            }
            if (lines[i].substring(0, 3) === '-- ') {
                var contents = lines[i].substring(3);
                options += '<option value="' + contents + '"' +
                    selected + '>&nbsp;&nbsp;' + contents + '</option>';
            } else {
                options += '<option value="" disabled' +
                    selected + '>' + lines[i] + '</option>';
            }
        }
        $combo.append(options);
    });
});

 pecoes  07:39, December 19, 2012 (UTC) 

If there are no objections, I'll replace the current version with the above today. --  pecoes  15:14, December 20, 2012 (UTC) 

Contribution

I'm not sure if any of this is actually any use - as the code has changed alot since I took a copy a year or so ago - but here's the script (and accompanying CSS) as I'm running it at Holby Wiki (replacement to Casualty Wiki):

MediaWiki:Summaries.js
MediaWiki:Summaries.css

My bad JS skills means it's probably worthless - and it has probably been superseded anyways - but I thought I'd post it here in case there is something useful. On the other hand, would the current dev build do all the things my custom build does? I'd prefer to use that if so.    ǝsʞpɐןǝ  (talk page)  10:17, 6 April 2013

Would you mind comparing the two versions and telling me what yours does that this one doesn't? --  pecoes  10:34, April 06, 2013 (UTC) 
Well if I knew that, I wouldn't be asking. :P From what I can see, your code certainly is a lot cleaner, has more features, and implements features I use better. I patched on disabled labels quite rudimentary (though looking back, I think that actually got used by by RS wiki).
I'm not a JS expert, so I struggle in places to read what the dev build does. I only posted my version here in case you saw something useful. If not, that's fine. I'll probably switch to the dev build ans tweak it for my CSS.    ǝsʞpɐןǝ  (talk page)  10:54, 6 April 2013
Ok, I see :)
From the looks of it, your version doesn't add anything. There are two additional features in Standard Edit Summary however:
  1. You can add comments by starting the line with * : <
  2. The tabindex sequence is altered to allow tabbing to the select field
A notable difference is that this version uses Template:Stdsummaries whereas your version uses MediaWiki:Edit-summaries to store the summaries. That would require a minor change.
Also: You distinguish between oasis and monobook in your code, but that difference is actually non-existent. It doesn't hurt and you can leave your code as is. That's just a FYI ;) --  pecoes  11:23, April 06, 2013 (UTC) 
Yeah, I've migrated over to the dev version now (link). I've already made the tweaks I need, and moved the CSS. The main feature I like already is the ability to add multiple reasons. The older code (the one still run on Runescape) didn't do that.    ǝsʞpɐןǝ  (talk page)  13:08, 6 April 2013
You've essentially forked the code now. That's not optimal. You're not going to profit from future bug fixes and enhancements that way. Chances are, we'd be having the same conversation a year from now.
There seem to be two things you'd like to be optional:
  1. The source for the default summaries and
  2. the CSS
If you want I can add those as customization options to the dev version! --  pecoes  13:26, April 06, 2013 (UTC) 
You can if you want - another user seems to want to change the pagename. But I'll still probably be manually checking the dev version. For me, it gives more flexibility - I've tweaked a lot of scripts in the past that won't suit other wikis too well. I check here regularly anyways, I just didn't realise there was a dev build of this script.    ǝsʞpɐןǝ  (talk page)  13:32, 6 April 2013
Ok. Done. --  pecoes  14:30, April 06, 2013 (UTC) 

Inline option

Anecdote: Interesting, I also wasn't aware that this script was on here. I did a rewrite of Runescape wiki's version last year [1], but didn't think to put it on Dev Wiki. My version is actually pretty close to the Dev Wiki version, except that I have the <option>'s in an array in the script itself, rather than unnecessarily AJAXing some random external page that I'd have to bookmark. 20px_Rin_Tohsaka_Avatar.png Mathmagician ƒ(♫) 21:00 UTC, Saturday, 6 April 2013

Now that I've started adding options, I could also add one for using an inline <option> list. Shall I do that? Or do you want to? --  pecoes  07:01, April 07, 2013 (UTC) 
I'll leave it up to you if that's something you want to add in. To be honest, I'm not sure increasing the complexity of the script (and the instructions on the help page!) is worth it just for the inline optimization.
Inline options could have another potential advantage: a wiki could have this script in their Common.js, and a user could have their own options in a user JS page to override it. Previously that would not have been possible if the script only pulls the options from Template:Stdsummaries. I believe the "select" option you recently added covers this case already though. 20px_Rin_Tohsaka_Avatar.png Mathmagician ƒ(♫) 15:59 UTC, Sunday, 7 April 2013
The select option could be enhanced to accept an array as well as a string... I'll rewrite it, if you test it :) --  pecoes  16:22, April 07, 2013 (UTC) 
Okay, I can do that! 20px_Rin_Tohsaka_Avatar.png Mathmagician ƒ(♫) 17:15 UTC, Sunday, 7 April 2013
Alright. The array's syntax is:
['title1', ['summary1_1', 'summary1_2'], 'title2', [ 'summary2_1'] ]
--  pecoes  18:56, April 07, 2013 (UTC) 

(reset indent) Seems to be mostly working. Notes:

  1. Bug: The existing text in the edit summary box is not cleared when choosing an option from the dropdown. This happens both with the inline options, and with Template:Stdsummaries.
    Stdeditsum-bug-1
  2. Styling recommendation: Remove border-radius from the default styling of the <select> tag, or add border-color: #ccc; to make it match the edit summary field. I am currently experiencing a very unsightly 1px solid black border (from Chrome's user agent style sheet) that occurs directly as a result of the border-radius being explicitly set without a color being set.
  3. Query: With inline options, how do I set a (click to browse) that is visible by default but cannot be chosen again in the dropdown, as seen in Template:Stdsummaries?

20px_Rin_Tohsaka_Avatar.png Mathmagician ƒ(♫) 19:42 UTC, Sunday, 7 April 2013

  1. Bug: The existing text in the edit summary box is not cleared when choosing an option from the dropdown. This happens both with the inline options, and with Template:Stdsummaries.

    » That's a feature :)

  2. Styling recommendation: Remove border-radius from the default styling of the <select> tag, or add border-color: #ccc; to make it match the edit summary field. I am currently experiencing a very unsightly 1px solid black border (from Chrome's user agent style sheet) that occurs directly as a result of the border-radius being explicitly set without a color being set.

    » Good point. I changed the color.

  3. Query: With inline options, how do I set a (click to browse) that is visible by default but cannot be chosen again in the dropdown, as seen in Template:Stdsummaries?

    » I've updated the docs at Standard_Edit_Summary#Summaries. Hopefully that answers your question!

--  pecoes  20:00, April 07, 2013 (UTC) 
(click to browse) — thanks, that answers my question
Bug a "feature" — can you add an option to disable that feature? I rarely have need of multiple default edit summaries, it's far more frequent for me to misclick (or change my mind) about which option to use. In those cases, it's very convenient that changing the option replaces the current summary. 20px_Rin_Tohsaka_Avatar.png Mathmagician ƒ(♫) 20:09 UTC, Sunday, 7 April 2013
I'll have to think about that... It's already approaching option-creep, don't you think? :( --  pecoes  20:13, April 07, 2013 (UTC) 
Let me put it this way: forget everything I said about inline options. I don't care about inline options any more. Remove them from the script to reduce option creep if you want. Please add an option to replace the current summary instead of appending multiple summaries :) 20px_Rin_Tohsaka_Avatar.png Mathmagician ƒ(♫) 20:22 UTC, Sunday, 7 April 2013
Alright, alright. I can probably remove this feature without annoying anybody. Maybe, you're right. Maybe it's a "feature" anyway. But since you were so quick to sacrifice the inline summaries, I'd rather remove those as well :P --  pecoes  20:34, April 07, 2013 (UTC) 
The reason I added that feature was so that the box wasn't cleared unintentionally, which I feel is a bigger problem than adding something to it unintentionally. As a general GUI convention, if I type in one box, then browse a dropdown, it's unexpected behaviour that my typed text would be replaced.
One way around that would be to add a listener to set a "dirty" flag for when the input field is edited directly.
  • On textarea.change, dirty=true (Also, if textarea is blanked, set dirty=false)
  • On select.change, if dirty==false, replace field with selected option. else append selected option.
Another solution I had considered at the time, but didn't try implementing, was not adding the selected option to the input box at all, instead only appending it when the form is submitted, but I figured it would probably be too confusing. -452 22:51, April 7, 2013 (UTC)
If possible to have some way to get the best of both worlds here, I'd be all for it. I can see how it might be confusing from the GUI perspective for a dropdown to physically change the contents of a textfield, or that some people may like being able to append more than 1 default summary. That's just not in alignment with my preferences.
The way I see it, the "default" summaries ought to be good enough to the point that — for the types of edits you use them for — you don't have to do any additional typing in the summary field. If you do, the default summaries probably need updating, or it's just not the type of edit that can be well described with a default summary. In that case, just write the whole summary by hand, or select an option from the dropdown first and revise it by hand after it has populated the text field.
If I'm using the dropdown, I'm not going to be concerned about it erasing the existing summary because there isn't an existing summary. In the few cases that there is, I'm intentionally wanting to replace it with a newly chosen default summary. 20px_Rin_Tohsaka_Avatar.png Mathmagician ƒ(♫) 23:35 UTC, Sunday, 7 April 2013

────────────────────────────────────────────────────────────────────────────────────────────────────I just ran a few tests and apparently setting the textarea's content with JS breaks the textarea's undo-history in all browsers except for Firefox. Short of writing an undo-manager - which I'm not willing to do - there's no way to fix this. In light of this I'd say it's best to throw all attempts to make this more useable overboard. It needs to be good enough that the select overwrites the textarea. --  pecoes  00:56, April 08, 2013 (UTC) 

Option removal

Unless you guys have objections, I'll remove the option to specify an alternate source for standard summaries - both inline and external. --  pecoes  04:50, April 08, 2013 (UTC) 


Replace

Hello guys! Now the choice of a new summary replaces the entire contents of the input-box. How I can change it to add? For example: [First summary; Second summary...] Sorry for my eng. :) --Alex6122 © 10:32, April 23, 2016 (UTC)

Inline summaries

Inline summaries don't work at least for me. This is what I have in my global.js:

/* Standard Edit Summary Settings */
window.dev.editSummaries = {
    select: [
        '(click to browse)',
        'Quick', [
            'Removing vandalism',
            'Fixing error(s)',
            'Corrected spelling/grammar',
            'Corrected formatting/layout'
        ]
        'General', [
            'Testing',
            'Testing … will revert shortly, if fails',
            'Testing complete',
            'Added/removed/corrected wikilink(s)',
            'Added/removed/corrected interwiki link(s)',
            'Added/removed/corrected external link(s)',
            'Cleanup',
            'Comment',
            'Correction(s), coding',
            'Expanded',
            'Formatting',
            'Grammar',
            'Headings (adjusting, etc.)',
            'HTML → wikicode',
            'Layout',
            'Mini-wikifying',
            'Punctuation',
            'Redlink removal',
            'Refactoring',
            'Removing RTE refuse',
            'Removing accidental signing due to [[w:c:dev:Sine|Sine]]',
            'Re-ordering/re-organizing',
            'Reply',
            'Revised',
            'Signing',
            'Spelling',
            'Style/layout',
            'Suggestion',
            'Tidying',
            'Updating',
            'Wikifying';
        ];
        'Content', [
            'Copy edit, major',
            'Copy edit, minor',
            'Copy editing',
            'Factual correction',
            'Neutral point of view',
            'Added/removed/corrected quote',
            'Added/removed/corrected sources/appearances'
        ];
        'Removal/Reversion', [
            'Reverted vandalism',
            'Reverted test edit',
            'Reverted vanity edit',
            'Removed fanon',
            'Removed libel/slander',
            'Removed copyvio',
            'Removed spam'
        ];
        'Templates', [
            'Added/removed/corrected template(s)',
            'Added/removed/corrected infobox(es)',
            'Added/removed/corrected disambig template(s)',
            'Substituting template(s)',
        ];
        'Categories', [
            'Added category(ies)',
            'Alphabetised category(ies)',
            'Creating Category page',
            'Modified category(ies)',
            'Removed category(ies)',
            'Removed defunct category(ies)',
            'Removed duplicate category(ies)'
        ];
        'Images/Files', [
            'Adding image(s)',
            'Modifying image(s)',
            'Deleting image(s)'
        ];
        'Videos', [
            'Adding video(s)',
            'Modifying video(s)',
            'Deleting video(s)'
        ];
    ]
};

--Sophie 07:34, June 10, 2016 (UTC)

Where you are using semi-colons now (after each [ ]), use commas instead, and it should work. - OneTwoThreeFall (talk) 09:29, June 10, 2016 (UTC)
It's working now, thanks for the help. --Sophie 11:17, June 10, 2016 (UTC)

Overwrite

Is there a opportunity to overwrite local summaries? Because in a few wikias, where the script is wikia-wide imported, instead of my own summaries the local summaries were displayed. -- DarkBarbarian.png Barbar (talk) 08:57, June 21, 2016 (UTC)

Wide mode broken

The styling of the wide mode is now broken again. Fix below.

.EditPage.toolbar-expanded.editpage-sourcewidemode-on.mode-source #stdSummaries {
    right: 290px;
    top: 3px;
    width: 278px;
}

.EditPage.toolbar-expanded.editpage-sourcewidemode-on.mode-source .module_page_controls .preview_box,.EditPage.toolbar-expanded.editpage-sourcewidemode-on.mode-source .module_page_controls .buttons {
    position: relative;
    top: -21px;
    right: -56px;
}

 MACH-59330   talk contribs  20:13, July 31, 2016 (UTC)

Thanks for the fix! Maybe add it somewhere on the page? Many people don't read the talk page, so they won't see this. —Monochromatic Bunny | 20:19, July 31, 2016 (UTC)
I'm hoping (in vain, possibly) that author/s will add the CSS to the script's code. I'd rather avoid editing someone else's code, but it would be wise to ping 452 locally. Thanks  MACH-59330   talk contribs  20:34, July 31, 2016 (UTC)
Ah, I was suggesting to put the CSS under a header on the actual page indicating it is a fix for the wide mode view. However, fixing the source of the problem is probably a better solution. —Monochromatic Bunny | 21:07, July 31, 2016 (UTC)
I'm not sure what you mean by "again". In my experience, the version of the script here has always overlapped the edit area, which is why I mentioned in 2012 that I had also made CSS improvements which I did not include here. -452 21:52, July 31, 2016 (UTC)
I'll replace the relevant CSS string now, apologies for assuming anyone fixed the bug.  MACH-59330   talk contribs  02:14, August 1, 2016 (UTC)

Floating during full screen source mode

The dropdown seems to "float" whenever it's full screen for source mode. This also caused the Preview buttons and the Publish button to get pushed down as well, and since they all go outside the edit page toolbar, they tend to overlap to the text area and it's harder to see if I'm editing CSS and JS pages. Lia 17:08, October 30, 2015 (UTC)

Inconvenience
When used in a Source Editor, it is floating right under the actual box, covering one line of text. Is there any way for this to be fixed?—|| Grudgeholderr ||— 06:22, December 15, 2017 (UTC)
Problem still existing.--EDBerG316 (talk) 12:47, May 15, 2020 (UTC)