Jump to content

MediaWiki talk:Gadget-exlinks.js

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by MSGJ (talk | contribs) at 13:53, 12 September 2011 (Update: re). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Update

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)[reply]

Is that not required to be inside a document.ready ? —TheDJ (talkcontribs) 22:04, 31 July 2011 (UTC)[reply]
Yep! And it is. The code $(handler) is equivalent to $(document).ready(handler). Helder 23:22, 31 July 2011 (UTC)[reply]
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 (talkcontribs) 21:39, 1 August 2011 (UTC)[reply]
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)[reply]
Just replace var $alinks = mw.util.$content.find( 'a' ); with var $alinks = $( '#content' ).find( 'a' );. Edokter (talk) — 20:01, 3 August 2011 (UTC)[reply]
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)[reply]