MediaWiki talk:Common.js/Archive 21: Difference between revisions
Content deleted Content added
m Archiving 2 discussion(s) from MediaWiki talk:Common.js) (bot |
m Archiving 2 discussion(s) from MediaWiki talk:Common.js) (bot |
||
Line 429:
Remove: function addAnonToolbarLinks() and all of it's associated code & comments, as this has now been added to MediaWiki core. <span style="font-family:Comic Sans MS; font-variant:caps;">[[User:Kharkiv07|<span style="color:black">Kharkiv07</span>]] ([[User talk:Kharkiv07|<span style="color: black">T</span>]])</span> 19:51, 9 December 2015 (UTC)
:It is set to deploy tomorrow (december 10). I already made the code conditional. <code style="font-size:small;white-space:nowrap">-- [[[[User:Edokter|<span style="color:#006">User:Edokter</span>]]]] {{[[User talk:Edokter|<span style="color:#060">talk</span>]]}}</code> 22:36, 9 December 2015 (UTC)
== Collapsing MOS-compliant tables ==
The guideline for creating tables in articles/lists on Wikipedia is [[MOS:DTT]]. That recommends using captions ({{code|{{!}}+}}) to annotate tables and provide them with headers, etc. There is a specific exception for collapsible tables, because the code used for collapsing does not support captions. I've been looking at the relevant bit of code in [[Mediawiki:Common.js]] and it seems to me that it would be trivial to add it so that this works correctly. It's not a nice little bit of Javascript (it abuses the {{code|id}} property) but it's not complex and this is a fairly simple addition.
It would need to go around line 233.
<syntaxhighlight lang="js">
/* only add button and increment count if the table has content */
var HeaderRow = table.getElementsByTagName( 'tr' )[0];
if ( !HeaderRow ) {
return;
}
var Header = table.getElementsByTagName( 'caption' )[0];
if ( !Header ) {
Header = table.getElementsByTagName( 'th' )[0];
if ( !Header ) {
return;
}
}
</syntaxhighlight>
This adds the content to the caption if it exists and to the first {{code|th}} cell if it doesn't, to support the current functionality. I've tried this out and as far as I can tell this works on {{code|caption}} cells as well as it does on {{code|th}} cells. It would be really good if the MOS-recommended tables worked with captions as well.
If we do this, we would also need to add code to determine whether the first row of the table needs collapsing as well. Perhaps something like:
<syntaxhighlight lang="js">
if ( Button.parentNode.parentNode.nodeName.toLowerCase() === 'caption' ) {
var i = 0;
} else {
var i = 1;
}
</syntaxhighlight>
and then change the loop to
<syntaxhighlight lang="js">
for ( ; i < Rows.length; i++ ) {
</syntaxhighlight>
I'm not familiar with Wikipedia's JS rules/standards or the processes of this page, so I hope I've got it right! Do let me know if I ought to cross-post to [[WP:VPT]] or if this is a perennial proposal that I've missed. [[User:Relentlessly|Relentlessly]] ([[User talk:Relentlessly|talk]]) 10:48, 9 October 2015 (UTC)
:{{ping|Relentlessly}} What is the <code>id</code> abuse? I don't see it. Maybe I need coffee. If this can work without literally abusing <code>id</code> (i.e. having more than one <code>id</code> with the same value on the same page, or using invalid values of the attribute), then this would be really fantastic to implement. <span style="white-space:nowrap;font-family:'Trebuchet MS'"> — [[User:SMcCandlish|'''SMcCandlish''' ☺]] [[User talk:SMcCandlish|☏]] [[Special:Contributions/SMcCandlish|¢]] ≽<sup>ʌ</sup>ⱷ҅<sub>ᴥ</sub>ⱷ<sup>ʌ</sup>≼ </span> 12:48, 6 March 2016 (UTC)
::{{replyto|SMcCandlish}} {{diff|MediaWiki talk:Common.js|prev|708592642|This won't work}}. --[[User:Redrose64|<span style="color:#a80000; background:#ffeeee; text-decoration:inherit">Red</span>rose64]] ([[User talk:Redrose64|talk]]) 21:07, 6 March 2016 (UTC)
:::I thought the ping would work as long as there was a new sig/timestamp. Why can't they fix this thing? <sigh> <span style="white-space:nowrap;font-family:'Trebuchet MS'"> — [[User:SMcCandlish|'''SMcCandlish''' ☺]] [[User talk:SMcCandlish|☏]] [[Special:Contributions/SMcCandlish|¢]] ≽<sup>ʌ</sup>ⱷ҅<sub>ᴥ</sub>ⱷ<sup>ʌ</sup>≼ </span> 00:38, 7 March 2016 (UTC)
::::No, you cannot cause a notification by modifying an existing post. It's covered at [[WP:Echo#Triggering events]] and see [//en.wikipedia.org/w/index.php?title=Special:Contributions/Redrose64&limit=3&offset=20160307134200 these three edits], individually. --[[User:Redrose64|<span style="color:#a80000; background:#ffeeee; text-decoration:inherit">Red</span>rose64]] ([[User talk:Redrose64|talk]]) 13:51, 7 March 2016 (UTC)
::Re-ping: {{U|Relentlessly}} <span style="white-space:nowrap;font-family:'Trebuchet MS'"> — [[User:SMcCandlish|'''SMcCandlish''' ☺]] [[User talk:SMcCandlish|☏]] [[Special:Contributions/SMcCandlish|¢]] ≽<sup>ʌ</sup>ⱷ҅<sub>ᴥ</sub>ⱷ<sup>ʌ</sup>≼ </span> 00:38, 7 March 2016 (UTC)
:Thanks for the ping, {{U|SMcCandlish}}. The abuse is this:
::<syntaxhighlight lang=js>table.setAttribute( 'id', 'collapsibleTable' + tableIndex );</syntaxhighlight>
:The problem here is (a) that it uses the <code>id</code> attribute to store data, which is semantically wrong (and why isn't it using the <code>id</code> property instead?!) and (b) that it destroys any existing <code>id</code> attribute on the element. Now, this won't be an issue for most tables, but occasionally it might be useful to give a table an <code>id</code>, e.g. if direct linking is useful. [[User:Relentlessly|Relentlessly]] ([[User talk:Relentlessly|talk]]) 14:15, 7 March 2016 (UTC)
::Such as, for example, the table linked by [[The Daleks' Master Plan#Doctor Who episode head]]. --[[User:Redrose64|<span style="color:#a80000; background:#ffeeee; text-decoration:inherit">Red</span>rose64]] ([[User talk:Redrose64|talk]]) 00:07, 8 March 2016 (UTC)
== Infobox collapsing and moving options ==
I've started a documentation snippet at [[Help:Infobox/user style]], transcluded into various relevant pages, on how to hide infoboxes with user CSS. It would be useful for many users who don't like infoboxes (and for WP as a whole, to get those people to give it a rest) to have two alternatives to hiding them: a) be able to have infoboxes be collapsible (including collapsed by default for those users if they want it that way), or b) be able to move them to the bottom. I'm not sure what the most effective way to go about this is with [[Special:MyPage/common.js]]. One cannot simply try to shunt the infobox to the bottom with pure CSS. This is notoriously impossible without the moved element overlapping other content [https://stackoverflow.com/questions/311990/how-do-i-get-a-div-to-float-to-the-bottom-of-its-container]. It requires one of several methods of injecting additional HTML and CSS into the document strategically [https://stackoverflow.com/questions/814564/inserting-html-elements-with-javascript], but I'm not sure which of these has the lowest impact, or will even work (given the kinds of "don't do certain things" filtering that MW does).
The most common usage is almost certainly going to be to make them collapsible, and for users who don't like them and to have them collapsed by default. This way, their content would still be available in the frequent cases that [[MOS:INFOBOX]] has not been complied with and details are in the infobox but not in the main article body. I myself would like to be able to collapse them after skimming them, especially on mobile. But I'm not sure what the lowest-overhead method is to inject the <code>mw-collapsible</code> class (it doesn't work with either of [[#s#Collapsible code cleanup|the other two classes for collapsibility]]). I have to wonder why infoboxes do not already have this class, uncollapsed by default; I would have thought that would have been implemented immediately. (That said, there is for now a minor display bug with making them collapsible, as I've documented and demoed at [[Template talk:Infobox#Minor bug]].)
I suspect that someone has already worked this out, however, given how many people hate infoboxes. (I'm not among them, but the constant activism by some against infoboxes has led to multiple ArbCom cases, and will lead to more of them, because the anti-infobox warring has not abated. The only solution is to make it easy to move them "out of the way" to remove the inspiration for people's "cleanse" infoboxes from WP or from articles particular wikiprojects where these people have gathered are claiming scope.) <span style="white-space:nowrap;font-family:'Trebuchet MS'"> — [[User:SMcCandlish|'''SMcCandlish''' ☺]] [[User talk:SMcCandlish|☏]] [[Special:Contributions/SMcCandlish|¢]] ≽<sup>ʌ</sup>ⱷ҅<sub>ᴥ</sub>ⱷ<sup>ʌ</sup>≼ </span> 13:02, 6 March 2016 (UTC)
:I used to like infoboxes, but their proliferation has gotten a bit absurd ({{tl|Infobox fictional artifact}}, {{tl|Infobox ambulance company}}, {{tl|Infobox Magic: The Gathering player}}). I also hate how no matter how complex and nuanced a subject is, someone will insist that it can be boiled into an infobox. Anyway, thanks for making them easier to hide. [[User:Kaldari|Kaldari]] ([[User talk:Kaldari|talk]]) 04:44, 8 March 2016 (UTC)
|