MediaWiki talk:Gadget-MainLangFirst.js

From Wikidata
Jump to navigation Jump to search

Update[edit]

Hi!

Could you make this update to the gadget? The new version fixes the alternate colors of the site links and now highlight any language which is set in the field "Assistant languages:" in the preferences. Helder 17:36, 4 March 2013 (UTC)

✓ DoneReza1615 / T 17:52, 4 March 2013 (UTC)[reply]

Custom color[edit]

Is it possible to change the background color for highlighting by user? I personally don't like the current color. --fryed-peach (talk) 06:04, 10 March 2013 (UTC)[reply]

No. But I think it should, through a class (but this needs to create MediaWiki talk:Gadget-MainLangFirst.css for only one class…). — Ltrl G, 10:24, 5 May 2013 (UTC)[reply]

User language first[edit]

New version now also highlight assistant languages, which is great. Thanks! However I want my user language to be at the very top. i.e. User language is first (highlighted), assistant languages (highlighted) are next and others follow them. --fryed-peach (talk) 13:49, 12 March 2013 (UTC)[reply]

Not working at the moment[edit]

Language codes are now "enwiki" etc. instead just "en". Linnea (talk) 20:42, 8 July 2013 (UTC)[reply]

If possible, please indicate the code to change, because I'm not really good at JavaScript. The Anonymouse (talk) 04:18, 21 July 2013 (UTC)[reply]
Nobody to fix this bug ? Leag ⠇⠑⠁⠛ 09:21, 1 August 2013 (UTC)[reply]

{{Edit protected}}You can take working version from my common.js. --4th-otaku (talk) 00:15, 2 August 2013 (UTC)[reply]

✓ Done Thanks! The Anonymouse (talk) 02:30, 2 August 2013 (UTC)[reply]
Thanks Leag ⠇⠑⠁⠛ 06:13, 2 August 2013 (UTC)[reply]
Great! Thank's.  Ę-oиė  >>> 17:45, 2 August 2013 (UTC)[reply]

Work-around for dummy language codes[edit]

{{Editprotected}} Site codes such as be-x-old, bat-smg and others map to language codes be-tarask, sgs... Could you make the gadget work for these locales? (Full list of dummy codes is located here and here; you unlikely need qqq and qqx.) Thanks! Wizardist (talk) 16:58, 13 September 2013 (UTC)[reply]

Since this is not an edit request, I'm removing the edit protected template. The Anonymouse (talk) 16:34, 17 October 2013 (UTC)[reply]

Edit protected[edit]

{{Edit protected}} Please add:

highlightSiteLinksGroup( 'wikisource', 'wikisource' );

--GZWDer (talk) 15:07, 15 January 2014 (UTC)[reply]

✓ Done The Anonymouse [talk] 17:00, 15 January 2014 (UTC)[reply]

Wikinews[edit]

Please, add also Wikinews to the list!. ThankS! --FRacco (talk) 10:57, 24 August 2014 (UTC)[reply]

Done. (diff) --Fomafix (talk) 11:01, 24 August 2014 (UTC)[reply]

Please update for new core code[edit]

{{Edit request}}

( function ( mw, $ ) {
	'use strict';
 
	var langs;
 
	function highlightSiteLinks( $content ) {
 
		function highlightSiteLinksGroup( group, suffix ) {
			var $group = $content.find( 'div[data-wb-sitelinks-group="' + group + '"]' ),
				selector;
			selector = $.map( langs, function ( code ) {
				return '.wikibase-sitelinkview-' + code + suffix;
			} ).join( ', ' );
			$group.find( selector )
				.prependTo( $group.find( 'tbody' ) )
				.find( 'td' )
					.css( 'background-color', '#CFC' );
 
			// Update zebra style
			$group.find( '.wb-ui-propertyedittool-editablevalue' )
				.each( function ( i ) {
					$( this ).toggleClass( 'even', i % 2 === 0 )
						.toggleClass( 'uneven', i % 2 === 1 );
				} );
		}
 
		highlightSiteLinksGroup( 'wikipedia', 'wiki' );
		highlightSiteLinksGroup( 'wikinews', 'wikinews' );
		highlightSiteLinksGroup( 'wikiquote', 'wikiquote' );
		highlightSiteLinksGroup( 'wikisource', 'wikisource' );
		highlightSiteLinksGroup( 'wikivoyage', 'wikivoyage' );
	}
 
	if ( mw.config.get( 'wgNamespaceNumber' ) === 0 ) {
		langs = mw.user.options.get( 'translate-editlangs' ).split( ', ' );
		if ( $.inArray( mw.config.get( 'wgUserLanguage' ), langs ) === -1 ) {
			langs.push( mw.config.get( 'wgUserLanguage' ) );
		}
		mw.hook( 'wikipage.content' ).add( highlightSiteLinks );
	}
 
}( mediaWiki, jQuery ) );

I try it on my js and I think it's ok. --FRacco (talk) 17:11, 6 September 2014 (UTC)[reply]

✓ Done (diff)--Fomafix (talk) 08:11, 7 September 2014 (UTC)[reply]

doesn't work[edit]

This gadget doesn't work with the new design for the interwiki links.--CENNOXX (talk) 22:32, 5 February 2015 (UTC)[reply]

{{Edit protected}} You can take working version from my common.js. Please note that I've made it to use an external CSS as requested above by User:fryed-peach, so (as far as I understand it) in order for it to work you should create MediaWiki:Gadget-MainLangFirst.css with the following content:

.wikibase-sitelinkview.even { background-color: #F8F8F8 }
.wikibase-sitelinkview.main-lang-highlight { background-color: #CFC }

and then update the corresponding MediaWiki:Gadgets-definition entry:

* MainLangFirst[ResourceLoader|dependencies=user.options]|MainLangFirst.js|MainLangFirst.css

--4th-otaku (talk) 22:07, 25 February 2015 (UTC)[reply]

✓ Done Matěj Suchánek (talk) 10:13, 27 February 2015 (UTC)[reply]

Add language map for languages where site prefix does not equal site language code[edit]

{{Edit request}} The language 'nb' should be mapped to 'nowiki'. Same goes for a few more languages (per InitialiseSettings.php) where the language code differs from the site prefix. These lines can be added right before mw.hook( 'wikipage.content' ).add( highlightSiteLinks ); at the bottom of the script:

                var langMap = {
			'nb': 'no',
			'gsw': 'als',
			'sgs': 'bat_smg',
			'bho': 'bh',
			'vro': 'fiu_vro',
			'rup': 'roa_rup',
			'lzh': 'zh_classical',
			'nan': 'zh_min_nan',
			'yue': 'zh_yue',
		};
		langs.map(function(lang) { return langMap[lang] || lang; })

(ping Fomafix, Matěj Suchánek) -- Danmichaelo (talk) 11:12, 29 May 2016 (UTC)[reply]

✓ Done Sorry for not noticing earlier. Matěj Suchánek (talk) 11:21, 29 May 2016 (UTC)[reply]