Extension talk:Gadgets

Jump to navigation Jump to search

About this board

Previous discussion was archived at Extension talk:Gadgets/Archive on 2012-01-06.

Minilexikon (talkcontribs)

I'm a coding guy from several wikis at FANDOM (formerly known as Wikia). FANDOM is running MediaWiki v1.19 (what a shame), so it's technically able to use the Gadgets extension. I was wondering when I did an api request to get all my activated gadgets, what query.gadgets.metadata.settings.shared means. Is it something like the current "dependencies" option?

Thanks in advance!

Reply to ""shared" in metadata"
Johnywhy (talkcontribs)
Ciencia Al Poder (talkcontribs)
Reply to "What are "system messages"?"

Conditional loading in definitions, depending on action, namespace, etc.

2
Od1n (talkcontribs)

Gadgets are often wrapped with conditional execution tests, like (made-up example):

if ( mw.config.get( 'wgNamespaceNumber' ) === 14
|| mw.config.get( 'wgAction' ) === 'history'
|| mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Contributions' ) {

    mw.loader.using( 'oojs-ui', function () {
        // gadget code
    } );

}

Note the above avoids loading the heavy OOUI when it's not used.


However, if you have the following definition line:

MyGadget [ResourceLoader|dependencies=oojs-ui] | MyGadget.js

… then OOUI will be loaded on each and every page.


Therefore, it could be helpful to implement additional definition options, that would load the gadget only on given namespaces/actions/specialpages/etc., like:

MyGadget [ResourceLoader|dependencies=oojs-ui|namespaces=14,>=0,Category,categorie|actions=diff,edit,history,view|specialpages=all/any,Contributions,whatlinkshere] | MyGadget.js
PerfektesChaos (talkcontribs)

I do support this request.

If I recall correctly, some other conditions like user group have been added in recent years, and similar wishes for namespace condition and action condition came up multiple times.

Reply to "Conditional loading in definitions, depending on action, namespace, etc."

Possibility to load from interwiki

3
Minilexikon (talkcontribs)
Jeblad (talkcontribs)
He7d3r (talkcontribs)
Reply to "Possibility to load from interwiki"
Pcj (talkcontribs)

What is the Gadget definition namespace for? I noticed there's nothing in the manual for it (and it's not even being used on Wikipedia). So what is it for?

He7d3r (talkcontribs)
Reply to "Gadget definition namespace?"
Summary by Iniquity

Thanks.

Iniquity (talkcontribs)

Hello, I want to use

mw.loader.load('//en.wikipedia.org/w/load.php?modules=ext.gadget.popups&only=scripts');

instead of

mw.loader.load('https://en.wikipedia.org/w/index.php?title=MediaWiki:Gadget-popups.js&action=raw&ctype=text/javascript');

But this code doesnt work.

He7d3r (talkcontribs)
Reza1615 (talkcontribs)

Is it possible to add option that we can set some of the gadgets only for IP and not confirmed and when they will registered it will dis-activated.

Subfader (talkcontribs)

For anons: make them standard JS and check for javascript globals in the DOM (above body).

קיפודנחש (talkcontribs)

close, but this won't create the desired effect exactly - what the OP asked for would allow for registered users to "opt-in", while your solution does not. however, this is the closest i can think of with a single script.

alternatively, you could play a little variation on the above: call the gadget directly from common.js under the condition "mw.user.anonymous()", and make the gadget non-default.

Subfader (talkcontribs)

He wants it active for anons and inactive for loggedin users = no gadget.

Krinkle (talkcontribs)

I'd recommend do making it as a gadget to allow optimized loading of it as well as internalization. Simply make it a normal gadget that doesn't have [default] but does have [ResourceLoader]. And from MediaWiki:Common.js (as קיפודנחש suggested), call mw.loader.load('gadget.YOUR_GADGET_ID') under a conditional:

mw.loader.using('medawiki.user', function() {
    if (mw.user.anonymous()) {
        mw.loader.load('ext.gadget.YOUR_GADGET_ID');
    }
});
He7d3r (talkcontribs)

For the record: the mw.loader.load can also be in a default gadget hidden from preferences with the "|rights=hidden" hack (example) or with the native "hidden" option from the next version of the gadgets extension.

Edokter (talkcontribs)

Someone with proper insight should properly document the [hidden] parameter.

Saper (talkcontribs)

Be aware of typos, here's a working version of the code above:

mw.loader.using('mediawiki.user').done(function() {
    if (mw.user.isAnon()) {
        mw.loader.load('ext.gadget.allinterwiki');
    }
});
Reply to "New feature"
Wargo (talkcontribs)

What is use of these two gadget namespaces (gadget and gadget_definition)? I found some informations on Gadgets 2.0 but it is not released yet.

He7d3r (talkcontribs)

It is only for Gadgets 2.0. You can subscribe to phab:T31272 and/or its subtasks to get notified of any progress on this.

Reply to "Namespaces"

Renaming a gadget while keeping its activation state for users

1
Od1n (talkcontribs)

Hi, just a feature request. It would be great to be able to rename a gadget (in MediaWiki:Gadgets-definition plus renaming the corresponding MediaWiki:Gadget-Foobar page), while keeping the users' preferences about its activation state.

Reply to "Renaming a gadget while keeping its activation state for users"

<nowiki> necessary in gadget-code

1
Stephan Kulla (talkcontribs)

I deleted a section about adding <nowik> in comments to the gadget code because this seems to be obsolete now. Please revert my edit, when this is still necessary. Thanks!

Reply to "<nowiki> necessary in gadget-code"