MediaWiki:Wikia.js: Difference between revisions
Appearance
m Re-added ratings and added skin to mw.config |
m Fixed link |
||
| (2 intermediate revisions by the same user not shown) | |||
| Line 5: | Line 5: | ||
var conf = mw.config.get( [ | var conf = mw.config.get( [ | ||
'wgAction', | 'wgAction', | ||
'wgCanonicalSpecialPageName', | 'wgCanonicalSpecialPageName', | ||
| Line 40: | Line 39: | ||
$( '<a>' ) | $( '<a>' ) | ||
.addClass( 'subnav-2a' ) | .addClass( 'subnav-2a' ) | ||
.attr( 'href', mw.util.wikiGetlink( 'Elite Dangerous:Policies' ) ) | .attr( 'href', mw.util.wikiGetlink( 'Elite Dangerous Wiki:Policies' ) ) | ||
.text( 'Policies' ) | .text( 'Policies' ) | ||
) | ) | ||
| Line 107: | Line 106: | ||
* Ratings sidebar module (oasis) | * Ratings sidebar module (oasis) | ||
*/ | */ | ||
ratings: { | /**ratings: { | ||
conditional: ( | conditional: ( | ||
conf.wgAction === 'view' && | conf.wgAction === 'view' && | ||
conf.wgNamespaceNumber === 0 | conf.wgNamespaceNumber === 0 | ||
), | ), | ||
scripts: 'MediaWiki:Wikia.js/ratings.js' | scripts: 'MediaWiki:Wikia.js/ratings.js' | ||
}, | },*/ | ||
}; | }; | ||
Latest revision as of 19:51, 20 January 2016
/* This JavaScript file is meant for the Wikia-skin only. To see the other skin, see MediaWiki:Monobook.js. For use in global use see MediaWiki:Common.js.*/
(function ($, mw, ed) {
'use strict';
var conf = mw.config.get( [
'wgAction',
'wgCanonicalSpecialPageName',
'wgNamespaceNumber',
'wgUserName'
] );
var includes = {
/**
* Taken from RuneScape Wiki.
*
* Add extra links to the on wiki tab tab on wiki navigation.
*
* @author Ryan PM
* @author Suppa chuppa
* @author Sactage
* @author Cqm
*/
addTabLinks: {
conditional: ( conf.wgAction === 'view' ),
exec: function () {
$( '.WikiHeader nav ul li.marked ul' )
.append(
/*$( '<li>' )
.addClass( 'subnav-2-item' )
.append(
$( '<a>' )
.addClass( 'subnav-2a' )
.attr( 'href', mw.util.wikiGetlink( 'Elite Dangerous:About' ) )
.text( 'About us' )
),*/
$( '<li>' )
.addClass( 'subnav-2-item' )
.append(
$( '<a>' )
.addClass( 'subnav-2a' )
.attr( 'href', mw.util.wikiGetlink( 'Elite Dangerous Wiki:Policies' ) )
.text( 'Policies' )
)
);
}
},
/**
* Taken from RuneScape Wiki.
*
* Add custom masthead boxes to profile masthead
*
* @author Rappy 4187 (Aion Wiki)
* @author Amaurice
* @author Cqm
*/
mastheadBoxes: {
conditional: (
(
conf.wgAction === 'view' &&
[2, 3].indexOf( conf.wgNamespaceNumber ) > -1
) ||
conf.wgCanonicalSpecialPageName === 'Contributions'
),
exec: function () {
var title = mw.config.get( 'wgTitle' ),
rights = {
// awb
// bot
'Kyouko Bot': 'BOT',
// bureaucrat
// Frontier staff
'BrettC Frontier': 'FRONTIER'
},
$masthead;
// fix for [[Special:Contibutions/username]]
if ( conf.wgCanonicalSpecialPageName === 'Contributions' ) {
title = title.split( '/' )[1];
}
if ( rights[title] ) {
$masthead = $( '.UserProfileMasthead' );
// remove old rights if not from Frontier
if(rights[ title ] !== 'FRONTIER'){
$masthead
.find( '.tag' )
.remove();
}
// add new rights
$masthead
.find( 'hgroup' )
.append(
$( '<span>' )
.addClass( 'tag' )
.text( rights[ title ] )
);
}
}
},
/**
* Ratings sidebar module (oasis)
*/
/**ratings: {
conditional: (
conf.wgAction === 'view' &&
conf.wgNamespaceNumber === 0
),
scripts: 'MediaWiki:Wikia.js/ratings.js'
},*/
};
var loaded = [];
// stripped down version of [[MediaWiki:Common.js]] loader
// this is only designed to have functions in each include
// imports should be done in [[MediaWiki:Common.js]] to cut down on http requests
function init() {
$.each( includes, function ( k, v ) {
var check = $.isFunction( v.conditional ) ? v.conditional() : v.conditional;
if ( check ) {
// used for tracking which includes are loading
loaded.push( 'oasis.' + k );
if ( v.exec ) {
v.exec();
}
}
} );
// this should always be defined
// but just in case ResourceLoader develops a quirk
ed.loaded = ( ed.loaded || [] ).concat( loaded );
}
$( init );
}( this.jQuery, this.mediaWiki, this.edwiki = this.edwiki || {} ) );