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 307:
:There's an older version here at the English Wikipedia, [[MediaWiki:Gadget-OSM.js]], but it needs to be updated to use WMF Labs instead of the Toolserver. The OSM gadget is currently used in place of WikiMiniAtlas at the German Wikipedia and a few other wikis ([[:de:Wikipedia:WikiProjekt Georeferenzierung/Anwendungen/OpenStreetMap/en|more info]]). Since that gadget uses a tile server that only supports labels in three languages, the Vietnamese Wikipedia has a [[:vi:Gadget-OpenStreetMap.js|separate OSM gadget]] hooked up to yet another tile server that supports all languages. It also uses the Leaflet library instead of OpenLayers, resulting in [{{fullurle:vi:Bắc Kinh|withJS=MediaWiki:Gadget-OpenStreetMap.js}} a smoother UI] than Gadget-OSM.js. In defense of WMA, though, it supports 3D buildings, [[Equirectangular projection|a different projection]] capable of displaying the poles, and several other planetary bodies. – [[User:Mxn|Minh <span style="font-variant: small-caps;">Nguyễn</span>]] <sup>[[User talk:Mxn|<span style="display: inline-block;">💬</span>]]</sup> 05:30, 14 February 2015 (UTC)
== Proposal to add a switcher ==
I'd like to propose that we add the code from [[User:Jackmcbarn/switcher.js]] to MediaWiki:Common.js. You can see a demo of it at [[User:Jackmcbarn/switcher]], and one use case for it is described at [[Wikipedia talk:WikiProject Architecture#Template:Infobox building maps]]. There's precedent for this sort of code in the similar createCollapseButtons() function, and other Wikipedias (like frwiki, [[fr:Gare de Lille-Flandres|example]]) already run similar code. [[User:Jackmcbarn|Jackmcbarn]] ([[User talk:Jackmcbarn|talk]]) 15:01, 10 October 2014 (UTC)
:{{u|Jackmcbarn}}, I have added the linked example to your statement. Note that the proposal is the fruit of a discussion at [[Wikipedia_talk:WikiProject_Architecture#Template:Infobox_building_maps]]. The primary discussants there were Jackmcbarn, myself, {{u|Frietjes}} and {{u|Denimadept}}. {{u|Elekhh}} also commented there briefly and the conversation there was the suggestion of {{u|Dr. Blofeld}} and Frietjes following my inquiries on their user talk pages. I '''SUPPORT''' this proposal.--[[User:TonyTheTiger|TonyTheTiger]] <small>([[User talk:TonyTheTiger|T]] / [[Special:Contributions/TonyTheTiger|C]] / [[WP:FOUR]] / [[WP:CHICAGO]] / [[WP:WAWARD]])</small> 15:30, 10 October 2014 (UTC)
::We should avoid adding new things to common.js and create Gadgets instead. Main reasons are: makes debugging easier, allows users to opt-in/out of specific features, better modularization. [[User:He7d3r|Helder]] 16:12, 10 October 2014 (UTC)
:::There's no way to have a gadget be always-on, though. [[User:Jackmcbarn|Jackmcbarn]] ([[User talk:Jackmcbarn|talk]]) 16:13, 10 October 2014 (UTC)
:::* There's no way to have javascript be always-on, so there is no reason to force scripts on to anyone and a Gadget is more appropriate (even if it is on by default forcing them to opt-out). — <span class="nowrap">{{U|[[User:Technical 13|Technical 13]]}} <sup>([[Special:EmailUser/Technical 13|e]] • [[User talk:Technical 13|t]] • [[Special:Contribs/Technical 13|c]])</sup></span> 16:50, 10 October 2014 (UTC)
:::*:I consider it a disadvantage that it could be disabled, since users who don't understand what it does may accidentally turn it off and then wonder why infoboxes look stretched out for them. After all, you can't accidentally turn off autocollapse in core. [[User:Jackmcbarn|Jackmcbarn]] ([[User talk:Jackmcbarn|talk]]) 04:37, 11 October 2014 (UTC)
:::*::A gadget can be marked as <code>[default|rights=hidden]</code> at [[MediaWiki:Gadgets-definition]], so that it appears for everyone and no one can disable it using [[Special:Preferences]]. That would be one way to modularize this script. – [[User:Mxn|Minh Nguyễn]] <small>([[User talk:Mxn|talk]], [[Special:Contributions/Mxn|contribs]])</small> 02:38, 16 October 2014 (UTC)
:::*:::{{ping|Mxn}} I tested that in my own wiki and it doesn't work. [[User:Jackmcbarn|Jackmcbarn]] ([[User talk:Jackmcbarn|talk]]) 02:47, 16 October 2014 (UTC)
:::*::::{{ping|Jackmcbarn}} I think the <code>ResourceLoader</code> flag also needs to be set. (Although it often makes sense to set the <code>rights</code> to <code>editinterface</code> so people who know what they're doing can see the gadget.) There's also the <code>hidden</code> flag, which is used by [[MediaWiki:Gadgets-definition]] presumably for helper gadgets that are only loaded by other gadgets as dependencies. – [[User:Mxn|Minh Nguyễn]] <small>([[User talk:Mxn|talk]], [[Special:Contributions/Mxn|contribs]])</small> 09:06, 16 October 2014 (UTC)
:::*:::::{{ping|Mxn}} I tried that, and it didn't work either. There is no actual hidden flag in Gadgets right now, and if a user doesn't have the right to see a gadget, it's not enabled for them, even if it's otherwise enabled by default. There's currently no way to have a mandatory gadget. [[User:Jackmcbarn|Jackmcbarn]] ([[User talk:Jackmcbarn|talk]]) 15:31, 16 October 2014 (UTC)
:::*:::::* Which would be '''opposed''' anyways. Quite simply, people on mobile devices might not care about how infoboxes look (I certainly don't) and won't want additional JavaScript bloat forced upon them costing them extra money for every page they want to view. There has to be an opt out option for this kind of "cosmetic" .js bloat. — <span class="nowrap">{{U|[[User:Technical 13|Technical 13]]}} <sup>([[Special:EmailUser/Technical 13|e]] • [[User talk:Technical 13|t]] • [[Special:Contribs/Technical 13|c]])</sup></span> 17:17, 16 October 2014 (UTC)
::'''Support'''. We need better ways to provide geographic information (i.e. maps) in infoboxes than we have currently, and this proposal seems to be a step in the right direction. I see this as a basic need, not optional, thus not simply a gadget. --<small>[[User:Elekhh|ELEKHH]]<sup>[[User talk:Elekhh|T]]</sup></small> 01:25, 11 October 2014 (UTC)
: Support '''as a default-enabled gadget'''. We had the exact same functionality added on the Polish Wikipedia as a default gadget some years ago ([[:pl:MediaWiki:Gadget-map-toggler.js]]; limited by design to two maps only; see e.g. [[:pl:Kraków]]) and no one had ever complained after accidentally disabling it. We even have the styling of the main page implemented as a default-on gadget ([[:pl:MediaWiki:Gadget-main-page.css]]) and no one has problems with it either (I'd make it always-enabled if it was possible, though). I have no reasons to suspect the community here is stupider than the one there and I believe they can deal with it. [[User:Matma Rex|Matma Rex]] <small>[[User talk:Matma Rex|talk]]</small> 08:04, 11 October 2014 (UTC)
:'''Support''' as default-enabled gadget, with an appropriate description so users know what it does <tt>[[User:PC-XT|—PC]][[User talk:PC-XT|-XT]][[Special:Contribs/PC-XT|+]]</tt> 19:39, 15 October 2014 (UTC)
:I think using OSM.js (see below) is a better solution than cluttering up already cluttered infoboxes. [[User:MoreTomorrow|MoreTomorrow]] ([[User talk:MoreTomorrow|talk]]) 06:35, 20 February 2015 (UTC)
::{{ping|MoreTomorrow}} This does something totally different than OSM.js. [[User:Jackmcbarn|Jackmcbarn]] ([[User talk:Jackmcbarn|talk]]) 19:29, 1 March 2015 (UTC)
:::Well, sort of. They both provide an interface for looking at maps at different scales. Personally I don't think infoboxes are a great interface for interactive UI elements, as you have limited space and they are already pretty complicated as far as the density of information and UI. Personally, I would want to be able to opt-out of such a feature, so I think I would '''oppose''' adding it to Common.js. [[User:MoreTomorrow|MoreTomorrow]] ([[User talk:MoreTomorrow|talk]]) 19:02, 10 March 2015 (UTC)
== Button for collapsible contents added more than once for dynamic content ==
[https://en.wikipedia.org/w/index.php?title=MediaWiki:Common.js&diff=prev&oldid=570114240 This edit] ({{ping|TheDJ}}) added the code to insert buttons to collapse content to the <code>wikipage.content</code>-hook, but this hook can be fired multiple times even though only part of the page changes. You can see this behavior on [[:File:Herculano, Alexandre, História da Origem e Estabelecimento da Inquisição em Portugal, Tomo I.pdf]]. Note that the author entry is collapsed. Now click "next page". You'll find that a second (and when you click more often even more) button to show the author is inserted. The code to add a button to collapse content must only work on the newly added content, not on the whole page. --[[User:Schnark|Schnark]] ([[User talk:Schnark|talk]]) 09:16, 20 January 2015 (UTC)
:I undid the edit, so it should work as before. mw.hook() is indeed not mature enough to handle only-once scenarios. <code style="white-space:nowrap">-- [[[[User:Edokter|<span style="color:#006">User:Edokter</span>]]]] {{[[User talk:Edokter|<span style="color:#060">talk</span>]]}}</code> 12:30, 20 January 2015 (UTC)
=== Collapsible buttons broken on ajax preview ===
@[[User:Edokter|Edokter]]: [[User:TheDJ|TheDJ]] added [[Special:Diff/643362863|that code]] so that it works for scripts like [[User:Js/ajaxPreview]] (now the links do not appear anymore). [[User:He7d3r|Helder]] 00:50, 10 March 2015 (UTC)
:It suspect worked before, ie. I don't think he added it to ''make'' it work. But if the code is essential, there should be some option to prevent the hook being fired ''ad infinitum''. <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> 09:22, 10 March 2015 (UTC)
::It is fired multiple times by design. [[User:He7d3r|Helder]] 18:38, 10 March 2015 (UTC)
:::The user script was manually redoing the setup before, but that was removed in favor of the hooks. I have made [https://test.wikipedia.org/w/index.php?title=MediaWiki%3ACommon.js&diff=223717&oldid=223713 some changes on the test wiki], that should probably fix the behavior that has been observed. —[[User:TheDJ|Th<span style="color: green">e</span>DJ]] ([[User talk:TheDJ|talk]] • [[Special:Contributions/TheDJ|contribs]]) 19:24, 10 March 2015 (UTC)
::::ping [[User:Edokter|Edokter]] or [[User:He7d3r|He7d3r]] —[[User:TheDJ|Th<span style="color: green">e</span>DJ]] ([[User talk:TheDJ|talk]] • [[Special:Contributions/TheDJ|contribs]]) 18:48, 14 March 2015 (UTC)
:::::{{Done}}. <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> 19:02, 14 March 2015 (UTC)
:::::[[User:TheDJ|TheDJ]]: is that change from <code>HeaderRow.getElementsByTagName( 'th' )[0];</code> to <code>table.getElementsByTagName( 'th' )[0];</code> intentional? Previously, it would get the first <code>th</code> which is inside the first <code>tr</code> of the <code>table</code>. Now it gets the first <code>th</code> of the <code>table</code> (even if it is not inside the first <code>tr</code>). [[User:He7d3r|Helder]] 21:37, 14 March 2015 (UTC)
::::::A header always resides inside a row; the parser makes sure of that. Even if you craft some handy HTML where it doesn't, Tidy will make sure of that. <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> 23:04, 14 March 2015 (UTC)
:::::::Yeah, but what if the ''first'' <code>th</code> of the <code>table</code> is inside the ''second'' <code>tr</code>? In [https://en.wikipedia.org/w/index.php?title=Wikipedia:Sandbox&oldid=651403910&action=edit&preview=yes this example] the cells c,d,e and f can't be unhidden. [[User:He7d3r|Helder]] 23:41, 14 March 2015 (UTC)
::::::::I think that was an accidental change, at least I can't figure out anymore why I would have made it. —[[User:TheDJ|Th<span style="color: green">e</span>DJ]] ([[User talk:TheDJ|talk]] • [[Special:Contributions/TheDJ|contribs]]) 08:16, 15 March 2015 (UTC)
|