MediaWiki talk:Gadget-exlinks.js
Update
![]() | This edit request has been answered. Set the |answered= parameter to no to reactivate your request. |
Hi!
Could someone update this gadget to use jQuery and the recommended functions from MW 1.17? It would be something like this:
$( function() {
var $alinks = mw.util.$content.find( 'a' );
$alinks.each( function() {
var $tablink = $( this );
if ( $tablink.hasClass( 'external' ) && $tablink.attr( 'href' ).indexOf( mw.config.get( 'wgServer' ) ) !== 0 ) {
$tablink.attr( 'target', '_blank' );
}
});
});
After the change, I think it will be possible to change the definition of this gadget to
* exlinks[ResourceLoader|dependencies=mediawiki.util]|exlinks.js
Helder 18:09, 27 July 2011 (UTC)
- Is that not required to be inside a document.ready ? —TheDJ (talk • contribs) 22:04, 31 July 2011 (UTC)
- Yep! And it is.
The code
$(handler)
is equivalent to$(document).ready(handler)
. Helder 23:22, 31 July 2011 (UTC) - This does not work. mw.util.$content is null for me. (Is init'ed in a .ready() after mw.util is considered to be init'ed....... —TheDJ (talk • contribs) 21:39, 1 August 2011 (UTC)
- That is weird. On Portuguese Wikibooks it works fine. Besides, if I copy the following to the address bar (here, on English Wikipedia):
javascript:alert( mw.util.$content )
- I get "[object Object]", and not null. Helder 12:31, 2 August 2011 (UTC)
- Just replace var $alinks = mw.util.$content.find( 'a' ); with var $alinks = $( '#content' ).find( 'a' );. — Edokter (talk) — 20:01, 3 August 2011 (UTC)
- I'll ask Edokter to make this change himself, as he seems to know what this is all about. — Martin (MSGJ · talk) 13:53, 12 September 2011 (UTC)
- Changed the code above, but not making it live before it is tested. — Edokter (talk) — 21:25, 12 September 2011 (UTC)
- I'll ask Edokter to make this change himself, as he seems to know what this is all about. — Martin (MSGJ · talk) 13:53, 12 September 2011 (UTC)
- That is weird. On Portuguese Wikibooks it works fine. Besides, if I copy the following to the address bar (here, on English Wikipedia):
- Yep! And it is.
- If TheDJ is using Modern skin that would explain why
mw.util.$content
doesn't work for him, see mw:Talk:ResourceLoader/Default_modules#mw.util.$content undefined in Modern. — AlexSm 00:54, 13 September 2011 (UTC)- Can this get deployed with MW 1.18? --Locos epraix ~ Beastepraix 15:10, 1 October 2011 (UTC)
- For the record,
mw.util.$content
seems to be working on modern skin on MW 1.18, because it is on wmf/1.18wmf1 branch. Helder 13:42, 5 October 2011 (UTC)
- For the record,
- Can this get deployed with MW 1.18? --Locos epraix ~ Beastepraix 15:10, 1 October 2011 (UTC)
- If TheDJ is using Modern skin that would explain why
Done. Tested code in Modern and it works. — Edokter (talk) — 14:06, 5 October 2011 (UTC)
![]() | It is requested that an edit be made to the interface page at MediaWiki:Gadget-exlinks.js. (edit · history · last · links)
This template must be followed by a complete and specific description of the request, that is, specify what text should be removed and a verbatim copy of the text that should replace it. "Please change X" is not acceptable and will be rejected; the request must be of the form "please change X to Y".
The edit may be made by any interface administrator. Remember to change the |
Could someone update this gadget to the current version of mw:Snippets/Open external links in new window? It is compatible with the live preview. Moreover, the new version doesn't use mw.util.$content, so the dependency "mediawiki.util" can be removed from Mediawiki:Gadgets-definition. Helder 17:13, 29 October 2013 (UTC)