This gadget doesn't work as intended on templates with documentation subpage. Anyway I think it is better to turn off this gadget for templates (by adding wgNamespaceNumber != 10) instead of fixing because actually it is not useful for templates at all. --DixonD (talk) 12:12, 20 February 2011 (UTC)[reply]
How does it not work as intended? It should open the template itself for editing (not the first section of the documentation page). — Edokter (talk) — 14:12, 20 February 2011 (UTC)[reply]
It should but it doesn't. It just copies same links as they are for documentation. Anyway is there any benefit of adding extra edit link for templates if they don't have sections? --DixonD (talk) 17:10, 20 February 2011 (UTC)[reply]
Easy - href for edit link from documentation looks like http://en.wikipedia.org/w/index.php?title=Template:SomeTemplate/doc&action=edit, it doesn't have §ion=T, so
if (a.href.indexOf ("§ion=T") == -1) doesn't do his work correctly
a.getAttribute ("href", 2).replace (/§ion=\d+/, "§ion=0") doesn't do anything all.
Actually IMO a link for "editing leading section" is useless on templates at all. But still in case of existence it should provide link for editing template itself but not for editing template documentation. And I explained why it doesn't work. What exact href for the edit link transcluded from documentation you have? --DixonD (talk) 12:06, 21 February 2011 (UTC)[reply]
(←) I get http://en.wikipedia.org/w/index.php?title=Template:SomeTemplate&action=edit§ion=0, which is correct; the code is doing its job as intended. Are we talking about the same link? The top link in the green part is not touched by this code. — Edokter (talk) — 13:18, 21 February 2011 (UTC)[reply]
Yes, but deactivating them doesn't change anything. In fact, I have no idea how the [purge] link ended up there. Of course, we have it because we are looking for any span with class "plainlinks" and span with links "edit" and "purge" has it as well. Could you also share HTML markup that you get in result so that I could have a look into it? --DixonD (talk) 13:54, 21 February 2011 (UTC)[reply]
This is what I get:
<h1id="firstHeading"class="firstHeading"><spanclass="editsection">[<ahref="/w/index.php?title=Template%3A!&action=edit&section=0"title="Edit lead section">edit</a>]</span>Template:!</h1>
It's looking for a .editsection span. If it then finds one that also has class .plainlinks, it will use that one and modifies the link to replace "§ion=T" with "§ion=0". The [purge] link does not meet the search criterium, so it should never end up there. I really can find no fault in the code, but I'll let someone else look into it. — Edokter (talk) — 15:39, 21 February 2011 (UTC)[reply]
Could you also share markup for span with links transcluded from documentation? It seems that you have something quite different in html than me. --DixonD (talk) 16:30, 21 February 2011 (UTC)[reply]
(←) This is the HTML for the top [edit] and [purge] links:
<spanclass="editsection plainlinks"id="doc_editlinks">[<ahref="http://en.wikipedia.org/w/index.php?title=Template:!/doc&action=edit"class="external text"rel="nofollow"title="">edit</a>] [<spanclass="noprint plainlinks purgelink"><ahref="http://en.wikipedia.org/w/index.php?title=Template:!&action=purge"class="external text"rel="nofollow"><spantitle="Purge this page">purge</span></a></span>]</span>
This is the second [edit] link (plus header) in the documentation:
with [edit] and [purge] links. As it has both classes "editsection" and "plainlinks", it copies to the "lead section" in this script. I cannot understand why you get other result. --DixonD (talk) 08:53, 22 February 2011 (UTC)[reply]
No; The [purge] link does not have the .editsection class, so it is ignored by the script. Why it ends up at the top in your case remains a mistery. — Edokter (talk) — 12:53, 22 February 2011 (UTC)[reply]
The [purge] span is inside <span class=editsection /> and since the script copies the whole span.editsection of course the result is [edit][purge] above H1. — AlexSm18:59, 22 February 2011 (UTC)[reply]
(←) There are two issues here. First, Template:Documentation creates the construction <span class=editsection...>[edit] [purge]<span> which imho is not very nice but whatever. The other isssue is the logic error in the script introduced with this big edit in April 2009 (by the way, who needs top [edit] on the page with no <H2>s? I don't know). Anyway, the code
stops it finds the first span that's not span.plainlinks OR when there are no more spans left. When there are no good spans (like in Template:!) the code ends up with span.plainlinks which was not the intended behavior. The correct loop would be
I still don't understand why Dixon sees the problem while I don't on {{!}} in both IE8 en Chrome9 on XP. I'll change the code (which is basically a line-swap). — Edokter (talk) — 23:35, 22 February 2011 (UTC)[reply]
The script doesn't knows that if a user has selected 'pt-br' (Brazilian Portuguese) and there is no 'pt-br' translation it should use 'pt' (as a fallback language), so it seems to be needed to add both. Helder01:13, 23 February 2011 (UTC)[reply]
"?action=" should be "&action=" as ?title= is already the first url parameter. Also, single statements do not need wrapping in {}. — Edokter (talk) — 20:45, 11 June 2011 (UTC)[reply]
The code mw.util.wikiGetlink( mw.config.get( 'wgPageName' ) ) returns
on the current page, without "?title=", since it uses the value of wgArticlePath (which is equals to "/wikipedia/en/wiki/$1"). I've included the {} because I've validated the code using JSHint, as suggested on mw:Manual:Coding_conventions#JavaScript:
* Validate with JSHint as much as possible. Recommended JSHint settings:
Done. Obviously, you use the secure server... on my end, wgArticlePath returns /wiki/$1. Still, the top edit link now points to the wiki URL instead of the full URL the other point to, so not very consistent. The script needs an overhaul anyway; I bet jQuery can slash 75% of the code. — Edokter (talk) — 23:10, 12 June 2011 (UTC)[reply]
edittop and lefteditlinks?
Aloha!
Is there any chance to combine the two respectively the effect of them? Meaning the edit link of the top section appearing next to the page title? No idea how that could be done best, maybe by branching off a "leftedittop.js".
Hello, author/admin. Thanks for such nice tool. I'm using it on English wikipedia but I've not found a preference to use it on Punjabi wiki (pa.wiki). Actually there is no Gadgets setting in the preferences on Punjabi wiki. Please help me how can I make it available there. I strictly need and really miss it there. Please help. Thank you. Tari Buttar (talk) 07:59, 4 August 2012 (UTC)[reply]
Oh thanks! I'm gonna try it. You're welcome on my talk page here and stay in touch. 'll be there if any more help needed about that. Please have a look that there are some spaces in the text between <syntaxhighlight style="overflow: auto"> and </syntaxhighlight> is it okay or there should be no space like URLs? And one more thing that is this text is enough, I mean No need to copy the full source of edittop tool?? Tari Buttar (talk) 14:15, 4 August 2012 (UTC)[reply]
Also, a subthread suggests changing the wording from [Edit] to [Edit intro].
There are also suggestions to:
Add an automatic edit-summary-prefix, like other subheaders will give you, e.g. /* Header name */
Because currently it just give an empty edit-summary, same as full-page edit
[I suggest /* intro */ , or something equally minimal, so that it stands out and gets read, both by the newcomers whilst editing, and watchlist patrollers whilst glancing through lists]
Fix the display in old skins (TheDJ lists the broken skins (Nostalgia, cologneblue, standard and simple), and gives an explanation)
Done I copied it verbatim with no guarantee as to its effects. Javascript, being one of the C++ family, leaves me hopelessly confused. --Redrose64 (talk) 19:15, 6 May 2013 (UTC)[reply]
I've temporarely restored the topicon code. This should be moved to the righteditlinks gadget. Give me a little time. — Edokter (talk) — 19:12, 14 May 2013 (UTC)[reply]
Why does this Edit Top script need the ".style.marginRight" lines exactly? I'm using Monobook and it just seems to unnecessarily add extra space to the right of the protected icons and pending changes box. Gary King(talk · scripts)19:46, 3 August 2013 (UTC)[reply]
Okay, so can't we only apply the code for those users? I thought I had something broken in one of my scripts when I applied the Edit Top script yesterday, because it looked so out of place. Gary King(talk · scripts)16:54, 4 August 2013 (UTC)[reply]
And in doing so broke the gadget so the edit link overlapped the icons. The error was that you used a type eval ('===') to compare a string (returned by .get) to an integer. — Edokter (talk) — 09:22, 5 August 2013 (UTC)[reply]
Oh heavens, I see we have a huge amount of 'mixed case' in the settings. That really shouldn't return a string, it's a boolean option. —TheDJ (talk • contribs) 11:33, 5 August 2013 (UTC)[reply]
This edit request has been answered. Set the |answered= parameter to no to reactivate your request.
Per this discussion, it might be an idea for the code to be updated to link to VisEd as well as the "source" code. If that seems like too much coding work, fine—I don't see a very pressing need for it (though some might). Sorry for the non-specific {{editprotected}}, but I don't know what the code would be... Ignatzmice•talk14:15, 29 June 2013 (UTC)[reply]
Use editprotected only for specific edits please, not feature requests. That said, this gadget needs a rewrite anyway. I always planned to do this from scratch. — Edokter (talk) — 15:41, 29 June 2013 (UTC)[reply]
As a frequent user of the "edit" link in the lead section, it would be good to have this consistent with the rest of the section "edit" links. I'm not yet sold on VisualEditor (I haven't used it yet, actually), but if I do — and for those who do prefer it — it might quickly become annoying not being able to do in the lead what can be done in every other section independently. —sroc (talk) 14:51, 3 July 2013 (UTC)[reply]
The edittop [edit] link is about the only one which still behaves sensibly. It's always there (doesn't disappear or change its position), always looks the same, and always does the same thing. --Redrose64 (talk) 20:17, 3 July 2013 (UTC)[reply]
jQuery rewrite
This edit request has been answered. Set the |answered= parameter to no to reactivate your request.
This gadget has been broken for awhile: neither link is corrected to point to the lead section, because (a) the VisualEditor link is first, but the code only modifies the first link inside the brackets; and (b) VisualEditor now uses the parameter section rather than vesection.
Over at vi:MediaWiki:Gadget-edittop.js, I rewrote the gadget to address these issues and make better use of jQuery's convenience methods. It's a lot shorter and seemingly just as performant. I also removed the body fallback for skins that have neither a #content nor a #mw_content, because those skins have been removed from MediaWiki.
Finally, I added a couple rules to vi:MediaWiki:Gadget-edittop.css to ensure that the brackets are spaced the same way they are in page content. (The first rule isn't necessary due to a rule that was already added to MediaWiki:Modern.css here.)
Please consider adopting this code, because I'm getting tired of manually correcting the section=1 in my URL bar. :^) Let me know if you see anything else that needs fixing.
Sorry, it looks like you accidentally removed whitespace but left everything else as is. So unfortunately the bug remains. I recommend copying vi:MediaWiki:Gadget-edittop.js wholesale.
Awesome, the links actually work again! The rest is all just to space out the brackets just like in ordinary headings:
The stylesheet isn't complete yet: everything from the first/* @noflip */ to the end of vi:MediaWiki:Gadget-edittop.css should've been copied into MediaWiki:Gadget-edittop.css. (I added a comment in there to help you out. Sorry for being ambiguous earlier.)
Hi, is it possible to add translations of that top which is after this change showed in edit summaries? Czech editors would like to rather see úvod there (according to this discussion). Thanks in advance. --16:13, 27 February 2014 (UTC), Utar (talk)
The Czech wiki should probably just copy the script to their own wiki, then just replace the word "top" with whatever they want, if they're not doing that already. Gary(talk · scripts)16:56, 27 February 2014 (UTC)[reply]
Keep in mind that "top" must be equal to the actual id at the top of the page (<a id="top"></a>), otherwise the link in the edit summary does not work. — Edokter (talk) — 17:24, 27 February 2014 (UTC)[reply]
The pages served by the Czech Wikipedia have the element <a id="top"></a> in the same place as those served by the English Wikipedia. Since the id= is the same, the pre-filled edit summary should be the same. --Redrose64 (talk) 20:38, 27 February 2014 (UTC)[reply]
@Edokter: So it asks for renaming one more thing? Or that id in <a id="top"></a> can't be renamed for other reasons? Is this tag a thing also newly added in MediaWiki or is it something older than your change to edittop.js? --20:47, 27 February 2014 (UTC), Utar (talk)
Well yes, making localisation for that top anchor in MediaWiki is probably not the easiest thing, though probably also nothing too difficult. But as Mormegil has pointed out on cswiki technical Village Pump: the correct link from summary to article is in fact not needed. If there is "/* abc */" written in summary it is showed as a link to the headline of that article; in case there is no such headline found, using the link will get you to the top of the article ... which will show you the top section.
So: Can you add localisation for summary link to top section here? Even if it is not correctly linked to that anchor it would still show the asked text in summaries and show you the top section when clicked. If such change is not possible/appreciated here, we might copy the gadget page to cswiki and change that part ourselves. --15:24, 28 February 2014 (UTC), Utar (talk)
You will have to copy the script. It is not a good idea to add changes to our gadgets intended for other Wikipedias. In the future, there will be global gadgets, which allows fo a better mechanism for localization. — Edokter (talk) — 22:50, 28 February 2014 (UTC)[reply]
Place the cursor at the end of the edit summary textbox
Any chance this script could be updated so that the cursor is placed at the end of the textbox? Right now, when editing the lead section, then hitting "Tab" to move to the edit summary textbox, the cursor is at the start of the text. Perhaps make it start at the end instead? This isn't a huge problem, but it'd be nice.
I think something like the following will work (will need to be tweaked a bit; the last line is most important):
var editSummary = $('input[id=wpSummary]');
var currentSummary = editSummary.val();
editSummary.focus().val('').val(editSummary);
This edit request has been answered. Set the |answered= parameter to no to reactivate your request.
Since gerrit:90569, mw.util.wikiGetlink is deprecated and should be replaced by mw.util.getUrl. Could you make replace "wikiGetlink" by "getUrl" on this script? This will make the warning "Use of "wikiGetlink" is deprecated. Use mw.util.getUrl instead." to go away from the console.
Helder.wiki13:27, 15 July 2014 (UTC)[reply]
This gadget gives an incorrect link for VE: it includes parameters &veaction=edit&vesection=1, but it should actually only include &veaction=edit. See here for some relevant discussion. From the explanation given there, it sounds like the right fix would be to add a substitution: any instance of &vesection=1 in the link being duplicated should be deleted. Mike Christie (talk - contribs - library) 01:55, 3 September 2014 (UTC)[reply]
Bug: The link sometimes is unclickable (with righteditlinks in Vector)
I use Gadget-righteditlinks.css, which is the setting "Move section [edit] links to the right side of the screen" in the gadget preferences (because I prefer the fixed-to-right position of the links and because it gives a hint if I'm logged in or not).
On a small screen and on pages with long titles such as Athletics at the 2014 Commonwealth Games – Women's 800 metres, depending on the font-size setting ("zoom") in the browser, it sometimes happens that there's no room for the edit link on the same line as the page title, and the link then drops down below the horizontal line (the easiest way to reproduce this is to resize the browser window until it happens).
When that happens, the link becomes unresponsive to clicking (or any mouse action).
The reason I bothered to report the above is that if you encounter this, and (as is quite likely) don't change the zoom level or resize the browser window, this will look like a problem specific to the current article, which may lead you on a wild-goose chase to find which template or other page error is causing it. --Pipetricker (talk) 18:58, 8 December 2017 (UTC)[reply]
No padding between brackets and edit links
Hello, on Czech Wikipedia (cswiki) there is no padding between enclosing brackets and edit links inside. I'm not sure why, on enwiki this just works nicely and the gadget on cswiki just calls the code here. Also no other gadget is affecting this. Could someone look into this matter and find the cause? --Dvorapa (talk) 20:28, 9 September 2019 (UTC)[reply]
Oh, I see, thank you. Is there a way to just import (programmatically) the css from enwiki into cswiki as it is with javascript or do we have to copy/paste the actual code from enwiki? --Dvorapa (talk) 20:57, 9 September 2019 (UTC)[reply]
Yes, it works, just with one exception: When an article does not contain any heading (other than the article title) the gadget does not work at all. Is it an issue or a future? Is there a way to fix this issue? --Dvorapa (talk) 22:44, 9 September 2019 (UTC)[reply]
The gadget places the [edit] link adjacent to the page-title. On older skins, that was all below the toolbar at the top, which contained the [edit] link for the whole page. On V2022, the page-title is above that toolbar. So the layout now goes:
[Title] [edit section 0]
[row of links, including [edit] for whole page]
[lead section]
[sections, each with [edit] link]
That's confusing because the edit-section-0 link is not near section-0 and instead a link near the title not near the body suggests that it acts on the whole article. I don't know what the best position is. DMacks (talk) 01:20, 9 February 2023 (UTC)[reply]
Gadget causes page layout to shift on pages with a long title
This gadget causes page layout to shift on pages whose titles are long enough that the "[ edit | edit source ]" links wrap to another line, but short enough that the title itself fits in one line. The issue affects all skins, but it's most reliable to reproduce on Vector 2022 with limited width enabled. For example the following pages reproduce the problem for me:
Additionally, on Vector 2022 only, this also causes links to sections to be imprecise, as the added line of text causes the whole page to shift under the scroll position. For example:
This could be fixed by reserving space for the link somehow in CSS, so that actually adding the link in JS would not cause the page layout to shift. It would significantly increase the complexity of the code though, so I'm not proposing fixes for now, and just documenting the problem. Matma Rextalk21:56, 20 February 2023 (UTC)[reply]
I opened an issue on Phabricator (phab:T362467) to ask that the /* top */ section link is added to the edit summaries on mobile. Since this gadget is where I got the idea, I figured I should let anyone who watches this page know. (I opened that issue a while ago. I would have written this earlier but I forgot.) Nickps (talk) 00:57, 3 May 2024 (UTC)[reply]
Does not work properly with "Prompt me when entering a blank edit summary" preference