* Set up Grunt via package.json (run `npm install` in mediawiki-core) * Add grunt task for node-jscs (NEW) This is a style checker (as opposed to jshint, which is for code quality). There are a few small style-related things that JSHint can check (camelcase, onevar etc.) but those are being deprecated in JSHint v3, people should use more sophisticated tools like node-jscs for this instead. As such this commit removes moves of those options from our jshint configuration. See: http://jshint.com/blog/jshint-3-plans/ * Add grunt task for jshint This will use the same jshint configuration as we use on Jenkins but makes it easier to run locally from the command line by being part of the same `$ grunt test` task list. Also: * Changed jshintignore to use "dir/**"" instead of "/dir" or "dir" because the latter is not compatible with Grunt for some reason. See also https://github.com/gruntjs/grunt-contrib-jshint/issues/126. Examples of coding style rules that were being violated that we can now catch in node-jscs: * Operator "," should stick to preceding expression * Missing space after "if" keyword * Multiple line break * Empty block (in jquery.textSelection and mediawiki.language) Bug: 54218 Change-Id: Ib9d7eab9f0d5cea5fb33f0b9f82e5554897fdfe0
36 lines
1 KiB
JavaScript
36 lines
1 KiB
JavaScript
/**
|
|
* JavaScript for Special:JavaScriptTest
|
|
*/
|
|
( function ( mw, $ ) {
|
|
$( function () {
|
|
|
|
// Create useskin dropdown menu and reload onchange to the selected skin
|
|
// (only if a framework was found, not on error pages).
|
|
$( '#mw-javascripttest-summary.mw-javascripttest-frameworkfound' ).append( function () {
|
|
|
|
var $html = $( '<p><label for="useskin">'
|
|
+ mw.message( 'javascripttest-pagetext-skins' ).escaped()
|
|
+ ' '
|
|
+ '</label></p>' ),
|
|
select = '<select name="useskin" id="useskin">';
|
|
|
|
// Build <select> further
|
|
$.each( mw.config.get( 'wgAvailableSkins' ), function ( id ) {
|
|
select += '<option value="' + id + '"'
|
|
+ ( mw.config.get( 'skin' ) === id ? ' selected="selected"' : '' )
|
|
+ '>' + mw.message( 'skinname-' + id ).escaped() + '</option>';
|
|
} );
|
|
select += '</select>';
|
|
|
|
// Bind onchange event handler and append to form
|
|
$html.append(
|
|
$( select ).change( function () {
|
|
window.location = QUnit.url( { useskin: $( this ).val() } );
|
|
} )
|
|
);
|
|
|
|
return $html;
|
|
} );
|
|
} );
|
|
|
|
}( mediaWiki, jQuery ) );
|