MediaWiki talk:Common.js

Latest comment: 5 months ago by Xaosflux in topic WMF template?
Please use this talk page to propose and request changes to the MediaWiki:Common.js. Use {{editprotected}} to get attention from Meta-Wiki interface administrators. If your request is not handled in some days you may leave a message in the administrators' noticeboard. Thank you.
SpBot archives all sections tagged with {{Section resolved|1=~~~~}} after 1 day. For the archive overview, see MediaWiki talk:Common.js/Archives. The latest archive is located at 2024.

Local implementation of importScript edit

Can we remove this function importScript? Or maybe add mw.log.deprecate to it and use the default one if there is only one argument? Helder.wiki 23:07, 25 July 2014 (UTC)

Collapsible tables edit

Is MediaWiki:Common.js#L-3 to 93 still needed? Since MW ≥ 1.18 collapsible elements are available in core. —MarcoAurelio (talk) 22:43, 12 March 2023 (UTC)Reply

@MarcoAurelio, these lines provide autocollapsing, which is not offered by core. en.wp reimplemented this in terms of mw-collapsible some time ago in lines 73 to 141, so I think it would be easy to crib what's there. I would not recommend importing inner/outer collapse, which look fairly easy to remove from the set of things implemented here.
Additionally, it probably wouldn't be that hard to get rid of the 'collapsible' and 'collapsed' classes here in favor of pure mw-collapsible (it might confuse some people to start), which would allow us to skip lines 73 to 106 entirely and remove a few more lines in the other block. Only about 600 pretty easy replacements, which is trivially within AWBable quantity. Izno (talk) 03:47, 13 March 2023 (UTC)Reply
I think it'd be better to replace with mw-collapsible/mw-collapsed where possible to avoid the maintenance burden. What do other people think? —MarcoAurelio (talk) 14:23, 13 March 2023 (UTC)Reply
If I could get AWB and a flood flag if meta has one I'd be able to migrate everything to mw-collapsible/mw-collapsed. (I can do it without the flood flag ofc, I'll just have to take a bit longer not to swamp RC.)
Do you want autocollapse? It's not really obvious to me if you were still supportive of it. I think it makes sense as a general thing to keep with both Template:Navbox and Template:Sidebar with collapsible lists using it. Izno (talk) 03:17, 1 April 2023 (UTC)Reply

Shuffle for election candidates edit

See MediaWiki:Common.js#L-95 to 126. I'm not sure there's any recent election using this? Can it be removed if no longer useful or needed? —MarcoAurelio (talk) 22:53, 12 March 2023 (UTC)Reply

Search lists a few from 2021 and 2022. I do not think this is worth supporting. Izno (talk) 03:52, 13 March 2023 (UTC)Reply
In looking at pages like Template:WMF elections candidate/2021/candidates gallery - not even sure if it is working? — xaosflux Talk 13:01, 13 March 2023 (UTC)Reply
It works for me in Wikimedia Foundation elections/Board elections/2011/Candidates/en. While the Table of Contents itself do not get shuffled, the contents itself do at each page reload. —MarcoAurelio (talk) 14:41, 13 March 2023 (UTC)Reply
The 2021 version does have randomization on the main page but it looks to have been set up using basic wiki functionality.
I think if that's available and apparently deemed acceptable, then this shuffling can be removed. Izno (talk) 22:01, 13 March 2023 (UTC)Reply

Gadgetize load CSS/JS with URL? edit

I updated this JS snipped to the latest version available on mediawiki.org (cf. MediaWiki:Common.js#L-326-361). However, I feel it'd be better to have this as an optional gadget for users that want to use it. While it would only work for pages in the MediaWiki namespace, it doesn't look like a feature that is used everyday; thus I feel there's no need to load this to every user. A gadget interested users can enable feels safer too. Thoughts? —MarcoAurelio (talk) 14:38, 13 March 2023 (UTC)Reply

@MarcoAurelio need some searches, is it being used for some workflows like a single page form button somewhere? — xaosflux Talk 15:50, 13 March 2023 (UTC)Reply
Agreed. I did a quick one but I want to re-run it later more calmly. We should also consider using the withgadget URL parametre when possible instead of this Snippet per Tech/News/2022/02. —MarcoAurelio (talk) 15:55, 13 March 2023 (UTC)Reply
Kind of a weird question, moving the JavaScript directly to a gadget doesn't really win anything (since Common.js is ResourceLoaded already -- just not on mobile, so maybe you gain something there). withgadget is maybe interesting.
Izno (talk) 21:01, 14 March 2023 (UTC)Reply

WMF template? edit

Hello,
Sorry for the delay in replying here–it took us a bit to discuss amongst ourselves and understand the issue. Firstly of course let me apologize for any disruption we’ve caused!
As background, the work Jay is helping with is related to a project to make a better "front door" to the Foundation, which comes from requests from the community to better organize and structure Foundation pages so that people can more easily find the support they’re looking for (you can read about that background on the linked page above). A big part of this is an organized and maintained list of Foundation departments and teams and what they do. We built templates to better organize our information and help people navigate between pages. Our intention was to get these templates in place to have something concrete to show the community and invite discussion.
It's a bit of a chicken and egg situation. It's hard to talk about visual changes without showing you. Since there are technical concerns and we don't want to show the Meta-wiki community broken pages, here's a few screenshots.
Given the complications, we’re wondering about the best path forward to get some of the elements you see here working. Mostly around the header navigation you see in the screenshots. The language picker, page indicators for team pages, moving the title, search box, and a few page elements as well.
I copied the code we've been using in our development on Collab wiki to this page if you want to see it all.
We’d like to talk about this implementation and next steps. Where should we have a conversion on the technical bit? Is this the right venue? Thanks for any guidance you have on this! Chris Koerner (Wikimedia Foundation) [he/him] (talk) 20:16, 8 November 2023 (UTC)Reply
@CKoerner (WMF) Why do we need to run javascript for every single reader on every single page load to facilitate something like styling the userpages of foundation staffers? We wouldn't expect this sort of load for any other user group. For foundation pages that will be managed by staffers, the foundation wiki is already managed by WMF staffers and is right around the corner as well. — xaosflux Talk 22:49, 8 November 2023 (UTC)Reply
Hey @Xaosflux
I'm sorry about this; it wasn’t fully clear to us that implementing some of these changes would need a site wide change, and if we’d realized that was an issue we would have started a conversation earlier. We’re happy to do that now, and to talk about alternatives that would accomplish the type of functionality that community members want on the Foundation’s Meta pages without being a burden. We’ve started talking as a team about alternatives but aren’t exactly sure yet, how to go about everything we need.
In talking to Jay who we contracted for development help, it seems it’ll be hard for things like the navigation functionality and styling to work without it, but of course we are open to alternatives, or to leaving behind some of these elements if needed. Jay's trying to be very cautious about how the code works, checking to see if the template exists first and then only running when appropriate.
I hear your concerns and I don't want to put more on you as a volunteer, but if after looking at the code, our project pages, and screenshots, you have suggestions of making this work better on Meta, I'd really welcome it. Chris Koerner (Wikimedia Foundation) [he/him] (talk) 15:43, 10 November 2023 (UTC)Reply
@CKoerner (WMF) A good place to propose site-wide changes (as this is about teams wanting to install site-wide scripts) to the community is Meta:Babel. I think this is a bad idea for several reasons, but the community as a whole may be fine with it. My primary suggestion would be to attempt to present your content in the ways that the rest of the content on meta-wiki is presented, some examples of popular pages are Grants:Start, Research:Index. Significant styling of sections may be able to be achieved with templatestyles. For wiki-style operations, but extensive niche customizations the foundation wiki may be a better home. If wiki-style page changes aren't needed for the "front door" the foundation website may also be a better home, and would allow for almost unlimited types of customization. — xaosflux Talk 16:03, 10 November 2023 (UTC)Reply
@Xaosflux Hi, some of these changes can be done via template styles (and already done so) but due to some limitations (e.g. you can't remove the header via template styles for security reasons hence the first line in that page), we might still need to load some js in some cases. That being said, it indeed doesn't need to be loaded unconditionally everywhere, Would adding something like this address your concerns?
if ( mw.config.get('wgCategories').indexOf( 'WMF landing pages' ) != -1 ) {
importScript( 'MediaWiki:WMF_template/common.js' );
}
We definitely need to move more js to css as the current state can cause FUC and is not desirable. ASarabadani (WMF) (talk) 18:16, 13 November 2023 (UTC)Reply
@ASarabadani (WMF) I'm not convinced that "remove the header" is that important, but also this is creating technical debt for volunteers - getting bespoke scripts dropped in by staffers that ultimately won't end up being supported by staffers is something I see as undesirable (this is one of the bigger picture concepts that I think should be discussed at the Babel forum though). — xaosflux Talk 18:40, 13 November 2023 (UTC)Reply
@Xaosflux, thanks for the pointers, much appreciated. As Amir notes above we're looking at other solutions to implement some of these features for our work. We're not going to request any further changes to common.js for the moment. :)
Here's what I propose, let me know if this sounds good to you. We'll keep working on updating our templates to rely less on modifying common.js and more on other solutions that won't impact Meta-wiki as a whole. We (well, Amir!) have already made progress on this, there's an updated version of the code I shared above on Collab wiki.
Jay's going to continue moving the templates over from Collab wiki that don’t involve touching commons.js or other site-wide interface bits, so we can more easily share our work with the wider Meta-wiki community for feedback. We'll have some of the demo pages in the screenshots above set up so folks can not just see what we're working on, but interact with it too.
If, after exploring some different options, we do feel like we need to make site-wide changes for a few remaining things, we'll make a proposal for the changes and start a conversation at Babel.
FWIW I agree, we don't want to be creating technical debt! We plan to keep these templates – and more importantly, the documentation within – up-to-date and continue to improve them over time. The template will of course be available for remixing and reuse by others and may evolve outside of our purview and we want to build these in a way that can be iterated on. Chris Koerner (Wikimedia Foundation) [he/him] (talk) 16:19, 15 November 2023 (UTC)Reply
Sounds good, and having experienced developers author reusable code is a win for everyone! — xaosflux Talk 16:55, 15 November 2023 (UTC)Reply
Return to "Common.js" page.