Set up node-jscs via Grunt (and pass it)

* 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
This commit is contained in:
Timo Tijhof 2014-01-30 18:03:11 -08:00 committed by Krinkle
parent eba9eb1e50
commit 4ec6b0cce1
52 changed files with 983 additions and 899 deletions

30
.jscsrc Normal file
View file

@ -0,0 +1,30 @@
{
"requireCurlyBraces": ["if", "else", "for", "while", "do"],
"requireSpaceAfterKeywords": ["if", "else", "for", "while", "do", "switch", "return", "function"],
"requireParenthesesAroundIIFE": true,
"requireSpacesInFunctionExpression": {
"beforeOpeningCurlyBrace": true
},
"requireMultipleVarDecl": true,
"disallowEmptyBlocks": true,
"requireSpacesInsideObjectBrackets": "all",
"disallowSpaceAfterObjectKeys": true,
"requireCommaBeforeLineBreak": true,
"disallowLeftStickedOperators": ["?", ">", ">=", "<", "<="],
"disallowRightStickedOperators": ["?", "/", "*", ":", "=", "==", "===", "!=", "!==", ">", ">=", "<", "<="],
"requireRightStickedOperators": ["!"],
"requireLeftStickedOperators": [","],
"disallowSpaceAfterPrefixUnaryOperators": ["++", "--", "+", "-", "~"],
"disallowSpaceBeforePostfixUnaryOperators": ["++", "--"],
"requireSpaceBeforeBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!=="],
"requireSpaceAfterBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!=="],
"disallowKeywords": [ "with" ],
"disallowMultipleLineBreaks": true,
"validateLineBreaks": "LF",
"validateQuoteMarks": "'",
"disallowMixedSpacesAndTabs": "smart",
"disallowTrailingWhitespace": true,
"requireLineFeedAtFileEnd": true,
"requireCapitalizedConstructors": true,
"requireDotNotation": true
}

View file

@ -1,14 +1,14 @@
# Generated documentation # Generated documentation
docs/html/ docs/html/**
docs/js/ docs/js/**
resources/mediawiki.ui/docs resources/mediawiki.ui/docs/**
# kss template for mediawiki ui documentation # kss template for mediawiki ui documentation
resources/styleguide-template resources/styleguide-template/**
# third-party libs # third-party libs
extensions/ extensions/**
node_modules/ node_modules/**
resources/jquery/jquery.appear.js resources/jquery/jquery.appear.js
resources/jquery/jquery.async.js resources/jquery/jquery.async.js
resources/jquery/jquery.ba-throttle-debounce.js resources/jquery/jquery.ba-throttle-debounce.js
@ -26,14 +26,15 @@ resources/jquery/jquery.qunit.js
resources/jquery/jquery.validate.js resources/jquery/jquery.validate.js
resources/jquery/jquery.xmldom.js resources/jquery/jquery.xmldom.js
resources/jquery.chosen/chosen.jquery.js resources/jquery.chosen/chosen.jquery.js
resources/jquery.effects/ resources/jquery.effects/**
resources/jquery.tipsy/ resources/jquery.tipsy/**
resources/jquery.ui/ resources/jquery.ui/**
resources/mediawiki.libs/ resources/mediawiki.libs/**
resources/oojs/ resources/moment/**
resources/oojs-ui/ resources/oojs-ui/**
resources/sinonjs/ resources/oojs/**
resources/moment/ resources/sinonjs/**
tests/frontend/node_modules/**
# github.com/jshint/jshint/issues/729 # github.com/jshint/jshint/issues/729
tests/qunit/suites/resources/mediawiki/mediawiki.jscompat.test.js tests/qunit/suites/resources/mediawiki/mediawiki.jscompat.test.js

View file

@ -2,24 +2,20 @@
/* Common */ /* Common */
// Enforcing // Enforcing
"camelcase": true,
"curly": true,
"eqeqeq": true, "eqeqeq": true,
"immed": true,
"latedef": true, "latedef": true,
"newcap": true,
"noarg": true, "noarg": true,
"noempty": true,
"nonew": true, "nonew": true,
"quotmark": "single",
"trailing": true,
"undef": true, "undef": true,
"unused": true, "unused": true,
// Legacy
"onevar": true,
/* Local */ /* Local */
// FIXME: Deprecated, handle these with node-jscs instead.
// Handled here because we still have inline overrides in some places.
"camelcase": true,
"nomen": true,
// Enforcing // Enforcing
"bitwise": true, "bitwise": true,
"forin": false, "forin": false,
@ -31,8 +27,6 @@
"multistr": true, "multistr": true,
// Environment // Environment
"browser": true, "browser": true,
// Legacy
"nomen": true,
"predef": [ "predef": [
"mediaWiki", "mediaWiki",

View file

@ -189,7 +189,6 @@
$el.attr( 'maxlength', elLimit ); $el.attr( 'maxlength', elLimit );
} }
// Safe base value, used to determine the path between the previous state // Safe base value, used to determine the path between the previous state
// and the state that triggered the event handler below - and enforce the // and the state that triggered the event handler below - and enforce the
// limit approppiately (e.g. don't chop from the end if text was inserted // limit approppiately (e.g. don't chop from the end if text was inserted

View file

@ -12,7 +12,7 @@
// By Blair Mitchelmore // By Blair Mitchelmore
// http://jquery.offput.ca/highlightFade/ // http://jquery.offput.ca/highlightFade/
// Parse strings looking for color tuples [255,255,255] // Parse strings looking for color tuples [255,255,255]
getRGB : function ( color ) { getRGB: function ( color ) {
/*jshint boss:true */ /*jshint boss:true */
var result; var result;
@ -28,7 +28,7 @@
// Look for rgb(num%,num%,num%) // Look for rgb(num%,num%,num%)
if (result = /rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(color)) { if (result = /rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(color)) {
return [parseFloat(result[1],10)*2.55, parseFloat(result[2],10)*2.55, parseFloat(result[3])*2.55]; return [parseFloat(result[1],10) * 2.55, parseFloat(result[2],10) * 2.55, parseFloat(result[3]) * 2.55];
} }
// Look for #a0b1c2 // Look for #a0b1c2
@ -38,7 +38,7 @@
// Look for #fff // Look for #fff
if (result = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(color)) { if (result = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(color)) {
return [parseInt(result[1]+result[1],16), parseInt(result[2]+result[2],16), parseInt(result[3]+result[3],16)]; return [parseInt(result[1] + result[1],16), parseInt(result[2] + result[2],16), parseInt(result[3] + result[3],16)];
} }
// Look for rgba(0, 0, 0, 0) == transparent in Safari 3 // Look for rgba(0, 0, 0, 0) == transparent in Safari 3
@ -170,23 +170,23 @@
if ( t > 1 ) { if ( t > 1 ) {
t -= 1; t -= 1;
} }
if ( t < 1/6 ) { if ( t < 1 / 6 ) {
return p + (q - p) * 6 * t; return p + (q - p) * 6 * t;
} }
if ( t < 1/2 ) { if ( t < 1 / 2 ) {
return q; return q;
} }
if ( t < 2/3 ) { if ( t < 2 / 3 ) {
return p + (q - p) * (2/3 - t) * 6; return p + (q - p) * (2 / 3 - t) * 6;
} }
return p; return p;
}; };
q = l < 0.5 ? l * (1 + s) : l + s - l * s; q = l < 0.5 ? l * (1 + s) : l + s - l * s;
p = 2 * l - q; p = 2 * l - q;
r = hue2rgb( p, q, h + 1/3 ); r = hue2rgb( p, q, h + 1 / 3 );
g = hue2rgb( p, q, h ); g = hue2rgb( p, q, h );
b = hue2rgb( p, q, h - 1/3 ); b = hue2rgb( p, q, h - 1 / 3 );
} }
return [r * 255, g * 255, b * 255]; return [r * 255, g * 255, b * 255];
@ -207,7 +207,7 @@
getColorBrightness: function ( currentColor, mod ) { getColorBrightness: function ( currentColor, mod ) {
var rgbArr = $.colorUtil.getRGB( currentColor ), var rgbArr = $.colorUtil.getRGB( currentColor ),
hslArr = $.colorUtil.rgbToHsl(rgbArr[0], rgbArr[1], rgbArr[2] ); hslArr = $.colorUtil.rgbToHsl(rgbArr[0], rgbArr[1], rgbArr[2] );
rgbArr = $.colorUtil.hslToRgb(hslArr[0], hslArr[1], hslArr[2]+mod); rgbArr = $.colorUtil.hslToRgb(hslArr[0], hslArr[1], hslArr[2] + mod);
return 'rgb(' + return 'rgb(' +
[parseInt( rgbArr[0], 10), parseInt( rgbArr[1], 10 ), parseInt( rgbArr[2], 10 )].join( ',' ) + [parseInt( rgbArr[0], 10), parseInt( rgbArr[1], 10 ), parseInt( rgbArr[2], 10 )].join( ',' ) +

View file

@ -66,4 +66,3 @@
}; };
}( jQuery ) ); }( jQuery ) );

View file

@ -146,12 +146,12 @@ $.fn.localize = function ( options ) {
} ); } );
// HTML, Text for elements which cannot have children e.g. OPTION // HTML, Text for elements which cannot have children e.g. OPTION
$target.find( '[data-msg-text]' ).each( function() { $target.find( '[data-msg-text]' ).each( function () {
var $el = $( this ); var $el = $( this );
$el.text( msg( options, $el.attr( 'data-msg-text' ) ) ); $el.text( msg( options, $el.attr( 'data-msg-text' ) ) );
} ); } );
$target.find( '[data-msg-html]' ).each( function() { $target.find( '[data-msg-html]' ).each( function () {
var $el = $( this ); var $el = $( this );
$el.html( msg( options, $el.attr( 'data-msg-html' ) ) ); $el.html( msg( options, $el.attr( 'data-msg-html' ) ) );
} ); } );

View file

@ -13,7 +13,7 @@
* @version 2.1.0 * @version 2.1.0
* @license MIT * @license MIT
*/ */
(function($) { (function ($) {
var isInputSupported = 'placeholder' in document.createElement('input'), var isInputSupported = 'placeholder' in document.createElement('input'),
isTextareaSupported = 'placeholder' in document.createElement('textarea'), isTextareaSupported = 'placeholder' in document.createElement('textarea'),
@ -25,10 +25,10 @@
if (isInputSupported && isTextareaSupported) { if (isInputSupported && isTextareaSupported) {
placeholder = prototype.placeholder = function(text) { placeholder = prototype.placeholder = function (text) {
var hasArgs = arguments.length; var hasArgs = arguments.length;
if( hasArgs ) { if (hasArgs) {
changePlaceholder.call(this, text); changePlaceholder.call(this, text);
} }
@ -39,18 +39,17 @@
} else { } else {
placeholder = prototype.placeholder = function(text) { placeholder = prototype.placeholder = function (text) {
var $this = this, var $this = this,
hasArgs = arguments.length; hasArgs = arguments.length;
if(hasArgs) { if (hasArgs) {
changePlaceholder.call(this, text); changePlaceholder.call(this, text);
} }
$this $this
.filter((isInputSupported ? 'textarea' : ':input') + '[placeholder]') .filter((isInputSupported ? 'textarea' : ':input') + '[placeholder]')
.filter(function() { .filter(function () {
return !$(this).data('placeholder-enabled'); return !$(this).data('placeholder-enabled');
}) })
.bind({ .bind({
@ -66,7 +65,7 @@
placeholder.textarea = isTextareaSupported; placeholder.textarea = isTextareaSupported;
hooks = { hooks = {
'get': function(element) { 'get': function (element) {
var $element = $(element), var $element = $(element),
$passwordInput = $element.data('placeholder-password'); $passwordInput = $element.data('placeholder-password');
if ($passwordInput) { if ($passwordInput) {
@ -75,7 +74,7 @@
return $element.data('placeholder-enabled') && $element.hasClass('placeholder') ? '' : element.value; return $element.data('placeholder-enabled') && $element.hasClass('placeholder') ? '' : element.value;
}, },
'set': function(element, value) { 'set': function (element, value) {
var $element = $(element), var $element = $(element),
$passwordInput = $element.data('placeholder-password'); $passwordInput = $element.data('placeholder-password');
if ($passwordInput) { if ($passwordInput) {
@ -95,7 +94,7 @@
setPlaceholder.call(element); setPlaceholder.call(element);
} }
} else if ($element.hasClass('placeholder')) { } else if ($element.hasClass('placeholder')) {
if(!clearPlaceholder.call(element, true, value)) { if (!clearPlaceholder.call(element, true, value)) {
element.value = value; element.value = value;
} }
} else { } else {
@ -115,20 +114,20 @@
propHooks.value = hooks; propHooks.value = hooks;
} }
$(function() { $(function () {
// Look for forms // Look for forms
$(document).delegate('form', 'submit.placeholder', function() { $(document).delegate('form', 'submit.placeholder', function () {
// Clear the placeholder values so they don't get submitted // Clear the placeholder values so they don't get submitted
var $inputs = $('.placeholder', this).each(clearPlaceholder); var $inputs = $('.placeholder', this).each(clearPlaceholder);
setTimeout(function() { setTimeout(function () {
$inputs.each(setPlaceholder); $inputs.each(setPlaceholder);
}, 10); }, 10);
}); });
}); });
// Clear placeholder values upon page reload // Clear placeholder values upon page reload
$(window).bind('beforeunload.placeholder', function() { $(window).bind('beforeunload.placeholder', function () {
$('.placeholder').each(function() { $('.placeholder').each(function () {
this.value = ''; this.value = '';
}); });
}); });
@ -139,7 +138,7 @@
// Return an object of element attributes // Return an object of element attributes
var newAttrs = {}, var newAttrs = {},
rinlinejQuery = /^jQuery\d+$/; rinlinejQuery = /^jQuery\d+$/;
$.each(elem.attributes, function(i, attr) { $.each(elem.attributes, function (i, attr) {
if (attr.specified && !rinlinejQuery.test(attr.name)) { if (attr.specified && !rinlinejQuery.test(attr.name)) {
newAttrs[attr.name] = attr.value; newAttrs[attr.name] = attr.value;
} }
@ -162,7 +161,7 @@
} else { } else {
input.value = ''; input.value = '';
$input.removeClass('placeholder'); $input.removeClass('placeholder');
if(input === safeActiveElement()) { if (input === safeActiveElement()) {
input.select(); input.select();
} }
} }
@ -217,10 +216,10 @@
function changePlaceholder(text) { function changePlaceholder(text) {
var hasArgs = arguments.length, var hasArgs = arguments.length,
$input = this; $input = this;
if(hasArgs) { if (hasArgs) {
if($input.attr('placeholder') !== text) { if ($input.attr('placeholder') !== text) {
$input.prop('placeholder', text); $input.prop('placeholder', text);
if($input.hasClass('placeholder')) { if ($input.hasClass('placeholder')) {
$input[0].value = text; $input[0].value = text;
} }
} }

View file

@ -79,7 +79,6 @@
isEmptyObject: $.isEmptyObject isEmptyObject: $.isEmptyObject
}; };
/** /**
* CompletenessTest * CompletenessTest
* @constructor * @constructor

View file

@ -142,7 +142,7 @@ $.suggestions = {
i, expWidth, matchedText, maxWidth, text; i, expWidth, matchedText, maxWidth, text;
// Validate creation using fallback values // Validate creation using fallback values
switch( property ) { switch ( property ) {
case 'fetch': case 'fetch':
case 'cancel': case 'cancel':
case 'special': case 'special':
@ -281,7 +281,7 @@ $.suggestions = {
} }
// Apply new width for results box, if any // Apply new width for results box, if any
if ( expWidth > context.data.$container.width() ) { if ( expWidth > context.data.$container.width() ) {
maxWidth = context.config.maxExpandFactor*context.data.$textbox.width(); maxWidth = context.config.maxExpandFactor * context.data.$textbox.width();
context.data.$container.width( Math.min( expWidth, maxWidth ) ); context.data.$container.width( Math.min( expWidth, maxWidth ) );
} }
// autoEllipse the results. Has to be done after changing the width // autoEllipse the results. Has to be done after changing the width

View file

@ -68,8 +68,6 @@
*/ */
( function ( $, mw ) { ( function ( $, mw ) {
/*jshint onevar:false */
/* Local scope */ /* Local scope */
var ts, var ts,
@ -78,8 +76,9 @@
/* Parser utility functions */ /* Parser utility functions */
function getParserById( name ) { function getParserById( name ) {
var len = parsers.length; var i,
for ( var i = 0; i < len; i++ ) { len = parsers.length;
for ( i = 0; i < len; i++ ) {
if ( parsers[i].id.toLowerCase() === name.toLowerCase() ) { if ( parsers[i].id.toLowerCase() === name.toLowerCase() ) {
return parsers[i]; return parsers[i];
} }
@ -228,18 +227,19 @@
} }
function appendToTable( table, cache ) { function appendToTable( table, cache ) {
var row = cache.row, var i, pos, l, j,
row = cache.row,
normalized = cache.normalized, normalized = cache.normalized,
totalRows = normalized.length, totalRows = normalized.length,
checkCell = ( normalized[0].length - 1 ), checkCell = ( normalized[0].length - 1 ),
fragment = document.createDocumentFragment(); fragment = document.createDocumentFragment();
for ( var i = 0; i < totalRows; i++ ) { for ( i = 0; i < totalRows; i++ ) {
var pos = normalized[i][checkCell]; pos = normalized[i][checkCell];
var l = row[pos].length; l = row[pos].length;
for ( var j = 0; j < l; j++ ) { for ( j = 0; j < l; j++ ) {
fragment.appendChild( row[pos][j] ); fragment.appendChild( row[pos][j] );
} }
@ -260,11 +260,12 @@
* @param $table jQuery object for a <table> * @param $table jQuery object for a <table>
*/ */
function emulateTHeadAndFoot( $table ) { function emulateTHeadAndFoot( $table ) {
var $rows = $table.find( '> tbody > tr' ); var $thead, $tfoot, i, len,
if( !$table.get(0).tHead ) { $rows = $table.find( '> tbody > tr' );
var $thead = $( '<thead>' ); if ( !$table.get(0).tHead ) {
$thead = $( '<thead>' );
$rows.each( function () { $rows.each( function () {
if ( $(this).children( 'td' ).length > 0 ) { if ( $(this).children( 'td' ).length ) {
// This row contains a <td>, so it's not a header row // This row contains a <td>, so it's not a header row
// Stop here // Stop here
return false; return false;
@ -273,11 +274,11 @@
} ); } );
$table.find(' > tbody:first').before( $thead ); $table.find(' > tbody:first').before( $thead );
} }
if( !$table.get(0).tFoot ) { if ( !$table.get(0).tFoot ) {
var $tfoot = $( '<tfoot>' ); $tfoot = $( '<tfoot>' );
var len = $rows.length; len = $rows.length;
for ( var i = len-1; i >= 0; i-- ) { for ( i = len - 1; i >= 0; i-- ) {
if( $( $rows[i] ).children( 'td' ).length > 0 ){ if ( $( $rows[i] ).children( 'td' ).length ){
break; break;
} }
$tfoot.prepend( $( $rows[i] )); $tfoot.prepend( $( $rows[i] ));
@ -424,7 +425,6 @@
return false; return false;
} }
function uniqueElements( array ) { function uniqueElements( array ) {
var uniques = []; var uniques = [];
$.each( array, function( index, elem ) { $.each( array, function( index, elem ) {
@ -455,14 +455,15 @@
} }
function multisort( table, sortList, cache ) { function multisort( table, sortList, cache ) {
var sortFn = []; var i,
var len = sortList.length; sortFn = [],
for ( var i = 0; i < len; i++ ) { len = sortList.length;
for ( i = 0; i < len; i++ ) {
sortFn[i] = ( sortList[i][1] ) ? sortTextDesc : sortText; sortFn[i] = ( sortList[i][1] ) ? sortTextDesc : sortText;
} }
cache.normalized.sort( function ( array1, array2 ) { cache.normalized.sort( function ( array1, array2 ) {
var col, ret; var i, col, ret;
for ( var i = 0; i < len; i++ ) { for ( i = 0; i < len; i++ ) {
col = sortList[i][0]; col = sortList[i][0];
ret = sortFn[i].call( this, array1[col], array2[col] ); ret = sortFn[i].call( this, array1[col], array2[col] );
if ( ret !== 0 ) { if ( ret !== 0 ) {
@ -476,25 +477,27 @@
} }
function buildTransformTable() { function buildTransformTable() {
var digits = '0123456789,.'.split( '' ); var ascii, localised, i, digitClass,
var separatorTransformTable = mw.config.get( 'wgSeparatorTransformTable' ); digits = '0123456789,.'.split( '' ),
var digitTransformTable = mw.config.get( 'wgDigitTransformTable' ); separatorTransformTable = mw.config.get( 'wgSeparatorTransformTable' ),
digitTransformTable = mw.config.get( 'wgDigitTransformTable' );
if ( separatorTransformTable === null || ( separatorTransformTable[0] === '' && digitTransformTable[2] === '' ) ) { if ( separatorTransformTable === null || ( separatorTransformTable[0] === '' && digitTransformTable[2] === '' ) ) {
ts.transformTable = false; ts.transformTable = false;
} else { } else {
ts.transformTable = {}; ts.transformTable = {};
// Unpack the transform table // Unpack the transform table
var ascii = separatorTransformTable[0].split( '\t' ).concat( digitTransformTable[0].split( '\t' ) ); ascii = separatorTransformTable[0].split( '\t' ).concat( digitTransformTable[0].split( '\t' ) );
var localised = separatorTransformTable[1].split( '\t' ).concat( digitTransformTable[1].split( '\t' ) ); localised = separatorTransformTable[1].split( '\t' ).concat( digitTransformTable[1].split( '\t' ) );
// Construct regex for number identification // Construct regex for number identification
for ( var i = 0; i < ascii.length; i++ ) { for ( i = 0; i < ascii.length; i++ ) {
ts.transformTable[localised[i]] = ascii[i]; ts.transformTable[localised[i]] = ascii[i];
digits.push( $.escapeRE( localised[i] ) ); digits.push( $.escapeRE( localised[i] ) );
} }
} }
var digitClass = '[' + digits.join( '', digits ) + ']'; digitClass = '[' + digits.join( '', digits ) + ']';
// We allow a trailing percent sign, which we just strip. This works fine // We allow a trailing percent sign, which we just strip. This works fine
// if percents and regular numbers aren't being mixed. // if percents and regular numbers aren't being mixed.
@ -504,11 +507,13 @@
} }
function buildDateTable() { function buildDateTable() {
var regex = []; var i, name,
regex = [];
ts.monthNames = {}; ts.monthNames = {};
for ( var i = 0; i < 12; i++ ) { for ( i = 0; i < 12; i++ ) {
var name = mw.language.months.names[i].toLowerCase(); name = mw.language.months.names[i].toLowerCase();
ts.monthNames[name] = i + 1; ts.monthNames[name] = i + 1;
regex.push( $.escapeRE( name ) ); regex.push( $.escapeRE( name ) );
name = mw.language.months.genitive[i].toLowerCase(); name = mw.language.months.genitive[i].toLowerCase();
@ -541,7 +546,9 @@
* @param $table jQuery object for a <table> * @param $table jQuery object for a <table>
*/ */
function explodeRowspans( $table ) { function explodeRowspans( $table ) {
var rowspanCells = $table.find( '> tbody > tr > [rowspan]' ).get(); var spanningRealCellIndex, rowSpan, colSpan,
cell, i, $tds, $clone, $nextRows,
rowspanCells = $table.find( '> tbody > tr > [rowspan]' ).get();
// Short circuit // Short circuit
if ( !rowspanCells.length ) { if ( !rowspanCells.length ) {
@ -552,9 +559,10 @@
// account colspans. We also cache the rowIndex to avoid having to take // account colspans. We also cache the rowIndex to avoid having to take
// cell.parentNode.rowIndex in the sorting function below. // cell.parentNode.rowIndex in the sorting function below.
$table.find( '> tbody > tr' ).each( function () { $table.find( '> tbody > tr' ).each( function () {
var col = 0; var i,
var l = this.cells.length; col = 0,
for ( var i = 0; i < l; i++ ) { l = this.cells.length;
for ( i = 0; i < l; i++ ) {
this.cells[i].realCellIndex = col; this.cells[i].realCellIndex = col;
this.cells[i].realRowIndex = this.rowIndex; this.cells[i].realRowIndex = this.rowIndex;
col += this.cells[i].colSpan; col += this.cells[i].colSpan;
@ -579,7 +587,6 @@
} }
resortCells(); resortCells();
var spanningRealCellIndex, rowSpan, colSpan;
function filterfunc() { function filterfunc() {
return this.realCellIndex >= spanningRealCellIndex; return this.realCellIndex >= spanningRealCellIndex;
} }
@ -596,15 +603,15 @@
resortCells(); resortCells();
} }
var cell = rowspanCells.shift(); cell = rowspanCells.shift();
rowSpan = cell.rowSpan; rowSpan = cell.rowSpan;
colSpan = cell.colSpan; colSpan = cell.colSpan;
spanningRealCellIndex = cell.realCellIndex; spanningRealCellIndex = cell.realCellIndex;
cell.rowSpan = 1; cell.rowSpan = 1;
var $nextRows = $( cell ).parent().nextAll(); $nextRows = $( cell ).parent().nextAll();
for ( var i = 0; i < rowSpan - 1; i++ ) { for ( i = 0; i < rowSpan - 1; i++ ) {
var $tds = $( $nextRows[i].cells ).filter( filterfunc ); $tds = $( $nextRows[i].cells ).filter( filterfunc );
var $clone = $( cell ).clone(); $clone = $( cell ).clone();
$clone[0].realCellIndex = spanningRealCellIndex; $clone[0].realCellIndex = spanningRealCellIndex;
if ( $tds.length ) { if ( $tds.length ) {
$tds.each( fixTdCellIndex ); $tds.each( fixTdCellIndex );
@ -620,15 +627,17 @@
ts.collationTable = mw.config.get( 'tableSorterCollation' ); ts.collationTable = mw.config.get( 'tableSorterCollation' );
ts.collationRegex = null; ts.collationRegex = null;
if ( ts.collationTable ) { if ( ts.collationTable ) {
var keys = []; var key,
keys = [];
// Build array of key names // Build array of key names
for ( var key in ts.collationTable ) { for ( key in ts.collationTable ) {
if ( ts.collationTable.hasOwnProperty(key) ) { //to be safe // Check hasOwn to be safe
if ( ts.collationTable.hasOwnProperty(key) ) {
keys.push(key); keys.push(key);
} }
} }
if (keys.length) { if ( keys.length ) {
ts.collationRegex = new RegExp( '[' + keys.join( '' ) + ']', 'ig' ); ts.collationRegex = new RegExp( '[' + keys.join( '' ) + ']', 'ig' );
} }
} }
@ -714,7 +723,7 @@
construct: function ( $tables, settings ) { construct: function ( $tables, settings ) {
return $tables.each( function ( i, table ) { return $tables.each( function ( i, table ) {
// Declare and cache. // Declare and cache.
var $headers, cache, config, var $headers, cache, config, sortCSS, sortMsg,
$table = $( table ), $table = $( table ),
firstTime = true; firstTime = true;
@ -745,8 +754,8 @@
$.data( table, 'tablesorter', { config: config } ); $.data( table, 'tablesorter', { config: config } );
// Get the CSS class names, could be done else where. // Get the CSS class names, could be done else where.
var sortCSS = [ config.cssDesc, config.cssAsc ]; sortCSS = [ config.cssDesc, config.cssAsc ];
var sortMsg = [ mw.msg( 'sort-descending' ), mw.msg( 'sort-ascending' ) ]; sortMsg = [ mw.msg( 'sort-descending' ), mw.msg( 'sort-ascending' ) ];
// Build headers // Build headers
$headers = buildHeaders( table, sortMsg ); $headers = buildHeaders( table, sortMsg );
@ -819,15 +828,17 @@
this.order = this.count % 2; this.order = this.count % 2;
this.count++; this.count++;
var cell = this; var cell, columns, newSortList, i;
cell = this;
// Get current column index // Get current column index
var columns = table.headerToColumns[ this.headerIndex ]; columns = table.headerToColumns[ this.headerIndex ];
var newSortList = $.map( columns, function (c) { newSortList = $.map( columns, function ( c ) {
// jQuery "helpfully" flattens the arrays... // jQuery "helpfully" flattens the arrays...
return [[c, cell.order]]; return [[c, cell.order]];
}); });
// Index of first column belonging to this header // Index of first column belonging to this header
var i = columns[0]; i = columns[0];
if ( !e[config.sortMultiSortKey] ) { if ( !e[config.sortMultiSortKey] ) {
// User only wants to sort on one column set // User only wants to sort on one column set
@ -886,7 +897,7 @@
* *
* @param sortList {Array} (optional) List of sort objects. * @param sortList {Array} (optional) List of sort objects.
*/ */
$table.data( 'tablesorter' ).sort = function( sortList ) { $table.data( 'tablesorter' ).sort = function ( sortList ) {
if ( firstTime ) { if ( firstTime ) {
setupForFirstSort(); setupForFirstSort();

View file

@ -2,8 +2,6 @@
* These plugins provide extra functionality for interaction with textareas. * These plugins provide extra functionality for interaction with textareas.
*/ */
( function ( $ ) { ( function ( $ ) {
/*jshint noempty:false */
if ( document.selection && document.selection.createRange ) { if ( document.selection && document.selection.createRange ) {
// On IE, patch the focus() method to restore the windows' scroll position // On IE, patch the focus() method to restore the windows' scroll position
// (bug 32241) // (bug 32241)
@ -13,7 +11,7 @@
var $w, state, result; var $w, state, result;
if ( arguments.length === 0 ) { if ( arguments.length === 0 ) {
$w = $( window ); $w = $( window );
state = {top: $w.scrollTop(), left: $w.scrollLeft()}; state = { top: $w.scrollTop(), left: $w.scrollLeft() };
result = jqFocus.apply( this, arguments ); result = jqFocus.apply( this, arguments );
window.scrollTo( state.top, state.left ); window.scrollTo( state.top, state.left );
return result; return result;
@ -73,7 +71,6 @@
el = this.get( 0 ); el = this.get( 0 );
if ( $(el).is( ':hidden' ) ) { if ( $(el).is( ':hidden' ) ) {
// Do nothing
retval = ''; retval = '';
} else if ( document.selection && document.selection.createRange ) { } else if ( document.selection && document.selection.createRange ) {
activateElementOnIE( el ); activateElementOnIE( el );
@ -143,9 +140,9 @@
} }
isSample = false; isSample = false;
if ( this.style.display === 'none' ) { // Do nothing if display none
// Do nothing if ( this.style.display !== 'none' ) {
} else if ( document.selection && document.selection.createRange ) { if ( document.selection && document.selection.createRange ) {
// IE // IE
// Note that IE9 will trigger the next section unless we check this first. // Note that IE9 will trigger the next section unless we check this first.
@ -188,8 +185,8 @@
range.text = insertText; range.text = insertText;
if ( isSample && options.selectPeri && range.moveStart ) { if ( isSample && options.selectPeri && range.moveStart ) {
range.moveStart( 'character', - post.length - selText.length ); range.moveStart( 'character', -post.length - selText.length );
range.moveEnd( 'character', - post.length ); range.moveEnd( 'character', -post.length );
} }
range.select(); range.select();
// Restore the scroll position // Restore the scroll position
@ -247,6 +244,7 @@
this.selectionEnd = this.selectionStart; this.selectionEnd = this.selectionStart;
} }
} }
}
$(this).trigger( 'encapsulateSelection', [ options.pre, options.peri, options.post, options.ownline, $(this).trigger( 'encapsulateSelection', [ options.pre, options.peri, options.post, options.ownline,
options.replace, options.spitlines ] ); options.replace, options.spitlines ] );
}); });
@ -366,9 +364,9 @@
setSelection: function ( options ) { setSelection: function ( options ) {
return this.each( function () { return this.each( function () {
var selection, length, newLines; var selection, length, newLines;
if ( $(this).is( ':hidden' ) ) { // Do nothing if hidden
// Do nothing if ( !$(this).is( ':hidden' ) ) {
} else if ( this.selectionStart || this.selectionStart === 0 ) { if ( this.selectionStart || this.selectionStart === 0 ) {
// Opera 9.0 doesn't allow setting selectionStart past // Opera 9.0 doesn't allow setting selectionStart past
// selectionEnd; any attempts to do that will be ignored // selectionEnd; any attempts to do that will be ignored
// Make sure to set them in the right order // Make sure to set them in the right order
@ -396,6 +394,7 @@
selection.select(); selection.select();
} catch ( e ) { } } catch ( e ) { }
} }
}
}); });
}, },
/** /**
@ -461,9 +460,9 @@
} }
return this.each(function () { return this.each(function () {
var scroll, range, savedRange, pos, oldScrollTop; var scroll, range, savedRange, pos, oldScrollTop;
if ( $(this).is( ':hidden' ) ) { // Do nothing if hidden
// Do nothing if ( !$(this).is( ':hidden' ) ) {
} else if ( this.selectionStart || this.selectionStart === 0 ) { if ( this.selectionStart || this.selectionStart === 0 ) {
// Mozilla // Mozilla
scroll = getCaretScrollPosition( this ); scroll = getCaretScrollPosition( this );
if ( options.force || scroll < $(this).scrollTop() || if ( options.force || scroll < $(this).scrollTop() ||
@ -496,6 +495,7 @@
} }
savedRange.select(); savedRange.select();
} }
}
$(this).trigger( 'scrollToPosition' ); $(this).trigger( 'scrollToPosition' );
} ); } );
} }

View file

@ -53,4 +53,3 @@
} ); } );
}( mediaWiki, jQuery ) ); }( mediaWiki, jQuery ) );

View file

@ -27,12 +27,12 @@
}; };
} }
var $image = $( '<img>' ).attr( { var $image = $( '<img>' ).attr( {
width : 23, width: 23,
height: 22, height: 22,
src : b.imageFile, src: b.imageFile,
alt : b.speedTip, alt: b.speedTip,
title : b.speedTip, title: b.speedTip,
id : b.imageId || undefined, id: b.imageId || undefined,
'class': 'mw-toolbar-editbutton' 'class': 'mw-toolbar-editbutton'
} ).click( function () { } ).click( function () {
toolbar.insertTags( b.tagOpen, b.tagClose, b.sampleText ); toolbar.insertTags( b.tagOpen, b.tagClose, b.sampleText );

View file

@ -70,7 +70,6 @@ jQuery( function ( $ ) {
// Set initial state // Set initial state
updateDiffRadios(); updateDiffRadios();
// Prettify url output for HistoryAction submissions, // Prettify url output for HistoryAction submissions,
// to cover up action=historysubmit construction. // to cover up action=historysubmit construction.

View file

@ -84,7 +84,6 @@
.promise( { abort: apiPromise.abort } ); .promise( { abort: apiPromise.abort } );
}, },
/** /**
* Get the categories that a particular page on the wiki belongs to * Get the categories that a particular page on the wiki belongs to
* @param {mw.Title} title * @param {mw.Title} title

View file

@ -34,7 +34,7 @@ mediaWiki.language.convertGrammar = function ( word, form ) {
break; break;
case 'illative': case 'illative':
// Double the last letter and add 'n' // Double the last letter and add 'n'
word += word.substr( word.length-1 ) + 'n'; word += word.substr( word.length - 1 ) + 'n';
break; break;
case 'inessive': case 'inessive':
word += ( aou ? 'ssa' : 'ssä' ); word += ( aou ? 'ssa' : 'ssä' );

View file

@ -15,7 +15,7 @@ mediaWiki.language.convertGrammar = function ( word, form ) {
switch ( form ) { switch ( form ) {
case 'genitive': // սեռական հոլով case 'genitive': // սեռական հոլով
if ( word.substr( -1 ) === 'ա' ) { if ( word.substr( -1 ) === 'ա' ) {
word = word.substr( 0, word.length -1 ) + 'այի'; word = word.substr( 0, word.length - 1 ) + 'այի';
} else if ( word.substr( -1 ) === 'ո' ) { } else if ( word.substr( -1 ) === 'ո' ) {
word = word.substr( 0, word.length - 1 ) + 'ոյի'; word = word.substr( 0, word.length - 1 ) + 'ոյի';
} else if ( word.substr( -4 ) === 'գիրք' ) { } else if ( word.substr( -4 ) === 'գիրք' ) {

View file

@ -19,7 +19,7 @@ mediaWiki.language.convertGrammar = function ( word, form ) {
word = word.replace( /tio$/i,'tionis' ); // 3rd declension singular (partly) word = word.replace( /tio$/i,'tionis' ); // 3rd declension singular (partly)
word = word.replace( /ns$/i, 'ntis' ); word = word.replace( /ns$/i, 'ntis' );
word = word.replace( /as$/i, 'atis' ); word = word.replace( /as$/i, 'atis' );
word = word.replace( /es$/i ,'ei' ); // 5th declension singular word = word.replace( /es$/i, 'ei' ); // 5th declension singular
break; break;
case 'accusative': case 'accusative':
// only a few declensions, and even for those mostly the singular only // only a few declensions, and even for those mostly the singular only
@ -31,7 +31,7 @@ mediaWiki.language.convertGrammar = function ( word, form ) {
word = word.replace( /tio$/i,'tionem' ); // 3rd declension singular (partly) word = word.replace( /tio$/i,'tionem' ); // 3rd declension singular (partly)
word = word.replace( /ns$/i, 'ntem' ); word = word.replace( /ns$/i, 'ntem' );
word = word.replace( /as$/i, 'atem'); word = word.replace( /as$/i, 'atem');
word = word.replace( /es$/i ,'em' ); // 5th declension singular word = word.replace( /es$/i, 'em' ); // 5th declension singular
break; break;
case 'ablative': case 'ablative':
// only a few declensions, and even for those mostly the singular only // only a few declensions, and even for those mostly the singular only
@ -43,7 +43,7 @@ mediaWiki.language.convertGrammar = function ( word, form ) {
word = word.replace( /tio$/i,'tione' ); // 3rd declension singular (partly) word = word.replace( /tio$/i,'tione' ); // 3rd declension singular (partly)
word = word.replace( /ns$/i, 'nte' ); word = word.replace( /ns$/i, 'nte' );
word = word.replace( /as$/i, 'ate'); word = word.replace( /as$/i, 'ate');
word = word.replace( /es$/i ,'e' ); // 5th declension singular word = word.replace( /es$/i, 'e' ); // 5th declension singular
break; break;
} }
return word; return word;

View file

@ -30,7 +30,7 @@ mediaWiki.language.convertGrammar = function ( word, form ) {
// Checking if word ends on 'у'. 'У' can be either consonant 'W' or vowel 'U' in cyrillic Ossetic. // Checking if word ends on 'у'. 'У' can be either consonant 'W' or vowel 'U' in cyrillic Ossetic.
// Examples: {{grammar:genitive|аунеу}} = аунеуы, {{grammar:genitive|лæппу}} = лæппуйы. // Examples: {{grammar:genitive|аунеу}} = аунеуы, {{grammar:genitive|лæппу}} = лæппуйы.
else if ( word.match( /у$/i ) ) { else if ( word.match( /у$/i ) ) {
if ( ! word.substring( word.length-2, word.length-1 ).match( /[аæеёиоыэюя]$/i ) ) { if ( !word.substring( word.length - 2, word.length - 1 ).match( /[аæеёиоыэюя]$/i ) ) {
jot = 'й'; jot = 'й';
} }
} else if ( !word.match( /[бвгджзйклмнопрстфхцчшщьъ]$/i ) ) { } else if ( !word.match( /[бвгджзйклмнопрстфхцчшщьъ]$/i ) ) {

View file

@ -3,15 +3,14 @@
*/ */
mediaWiki.language.convertGrammar = function ( word, form ) { mediaWiki.language.convertGrammar = function ( word, form ) {
/*jshint noempty:false */
var grammarForms = mediaWiki.language.getData( 'uk', 'grammarForms' ); var grammarForms = mediaWiki.language.getData( 'uk', 'grammarForms' );
if ( grammarForms && grammarForms[form] ) { if ( grammarForms && grammarForms[form] ) {
return grammarForms[form][word]; return grammarForms[form][word];
} }
switch ( form ) { switch ( form ) {
case 'genitive': // родовий відмінок case 'genitive': // родовий відмінок
if ( ( word.substr( word.length - 4 ) === 'вікі' ) || ( word.substr( word.length - 4 ) === 'Вікі' ) ) { if ( word.substr( word.length - 4 ) !== 'вікі' && word.substr( word.length - 4 ) !== 'Вікі' ) {
} else if ( word.substr( word.length - 1 ) === 'ь' ) { if ( word.substr( word.length - 1 ) === 'ь' ) {
word = word.substr(0, word.length - 1 ) + 'я'; word = word.substr(0, word.length - 1 ) + 'я';
} else if ( word.substr( word.length - 2 ) === 'ія' ) { } else if ( word.substr( word.length - 2 ) === 'ія' ) {
word = word.substr(0, word.length - 2 ) + 'ії'; word = word.substr(0, word.length - 2 ) + 'ії';
@ -24,13 +23,14 @@ mediaWiki.language.convertGrammar = function ( word, form ) {
} else if ( word.substr( word.length - 3 ) === 'ник' ) { } else if ( word.substr( word.length - 3 ) === 'ник' ) {
word = word.substr(0, word.length - 3 ) + 'ника'; word = word.substr(0, word.length - 3 ) + 'ника';
} }
}
break; break;
case 'accusative': // знахідний відмінок case 'accusative': // знахідний відмінок
if ( ( word.substr( word.length - 4 ) === 'вікі' ) || ( word.substr( word.length - 4 ) === 'Вікі' ) ) { if ( word.substr( word.length - 4 ) !== 'вікі' && word.substr( word.length - 4 ) !== 'Вікі' ) {
} if ( word.substr( word.length - 2 ) === 'ія' ) {
else if ( word.substr( word.length - 2 ) === 'ія' ) {
word = word.substr(0, word.length - 2 ) + 'ію'; word = word.substr(0, word.length - 2 ) + 'ію';
} }
}
break; break;
} }
return word; return word;

View file

@ -96,7 +96,7 @@ $.extend( mw.language, {
*/ */
preConvertPlural: function ( forms, count ) { preConvertPlural: function ( forms, count ) {
while ( forms.length < count ) { while ( forms.length < count ) {
forms.push( forms[ forms.length-1 ] ); forms.push( forms[ forms.length - 1 ] );
} }
return forms; return forms;
}, },

View file

@ -66,11 +66,12 @@
imgHeight = 0; imgHeight = 0;
} }
rows[rows.length-1][rows[rows.length-1].length] = { rows[rows.length - 1][rows[rows.length - 1].length] = {
$elm: $this, $elm: $this,
width: $this.outerWidth(), width: $this.outerWidth(),
imgWidth: imgWidth, imgWidth: imgWidth,
aspect: imgWidth / imgHeight, // XXX: can divide by 0 ever happen? // XXX: can divide by 0 ever happen?
aspect: imgWidth / imgHeight,
captionWidth: $this.children().children( 'div.gallerytextwrapper' ).width(), captionWidth: $this.children().children( 'div.gallerytextwrapper' ).width(),
height: imgHeight height: imgHeight
}; };
@ -136,7 +137,7 @@
// Also on the off chance there is a bug in this // Also on the off chance there is a bug in this
// code, would prevent accidentally expanding to // code, would prevent accidentally expanding to
// be 10 billion pixels wide. // be 10 billion pixels wide.
mw.log( 'mw.page.gallery: Cannot fit row, aspect is ' + preferredHeight/curRowHeight ); mw.log( 'mw.page.gallery: Cannot fit row, aspect is ' + preferredHeight / curRowHeight );
if ( i === rows.length - 1 ) { if ( i === rows.length - 1 ) {
// If its the last row, and we can't fit it, // If its the last row, and we can't fit it,
// don't make the entire row huge. // don't make the entire row huge.
@ -159,7 +160,12 @@
} }
if ( preferredHeight < 5 ) { if ( preferredHeight < 5 ) {
// Well something clearly went wrong... // Well something clearly went wrong...
mw.log( {maxWidth: maxWidth, combinedPadding: combinedPadding, combinedAspect: combinedAspect, wantedWidth: wantedWidth } ); mw.log( {
maxWidth: maxWidth,
combinedPadding: combinedPadding,
combinedAspect: combinedAspect,
wantedWidth: wantedWidth
} );
mw.log( 'mw.page.gallery: [BUG!] Fitting row ' + i + ' to too small a size: ' + preferredHeight ); mw.log( 'mw.page.gallery: [BUG!] Fitting row ' + i + ' to too small a size: ' + preferredHeight );
// Skip this row. // Skip this row.
continue; continue;
@ -182,7 +188,6 @@
imageElm = $imageElm.length ? $imageElm[0] : null; imageElm = $imageElm.length ? $imageElm[0] : null;
$caption = $outerDiv.find( 'div.gallerytextwrapper' ); $caption = $outerDiv.find( 'div.gallerytextwrapper' );
// Since we are going to re-adjust the height, the vertical // Since we are going to re-adjust the height, the vertical
// centering margins need to be reset. // centering margins need to be reset.
$imageDiv.children( 'div' ).css( 'margin', '0px auto' ); $imageDiv.children( 'div' ).css( 'margin', '0px auto' );

View file

@ -43,4 +43,3 @@
} }
} ); } );
}( mediaWiki, jQuery ) ); }( mediaWiki, jQuery ) );

View file

@ -34,4 +34,3 @@
} ); } );
}( mediaWiki, jQuery ) ); }( mediaWiki, jQuery ) );

View file

@ -128,7 +128,7 @@ jQuery( function ( $ ) {
// make the selected tab visible. // make the selected tab visible.
hash = window.location.hash; hash = window.location.hash;
if ( hash.match( /^#mw-prefsection-[\w\-]+/ ) ) { if ( hash.match( /^#mw-prefsection-[\w\-]+/ ) ) {
switchPrefTab( hash.replace( '#mw-prefsection-' , '' ) ); switchPrefTab( hash.replace( '#mw-prefsection-', '' ) );
} }
// In browsers that support the onhashchange event we will not bind click // In browsers that support the onhashchange event we will not bind click
@ -140,7 +140,7 @@ jQuery( function ( $ ) {
if ( 'onhashchange' in window && if ( 'onhashchange' in window &&
( document.documentMode === undefined || document.documentMode >= 8 ) ( document.documentMode === undefined || document.documentMode >= 8 )
) { ) {
$( window ).on( 'hashchange' , function () { $( window ).on( 'hashchange', function () {
var hash = window.location.hash; var hash = window.location.hash;
if ( hash.match( /^#mw-prefsection-[\w\-]+/ ) ) { if ( hash.match( /^#mw-prefsection-[\w\-]+/ ) ) {
switchPrefTab( hash.replace( '#mw-prefsection-', '' ) ); switchPrefTab( hash.replace( '#mw-prefsection-', '' ) );

View file

@ -140,7 +140,7 @@
}; };
img.src = dataURL; img.src = dataURL;
}, mw.config.get( 'wgFileCanRotate' ) ? function ( data ) { }, mw.config.get( 'wgFileCanRotate' ) ? function ( data ) {
/*jshint camelcase: false, nomen: false */ /*jshint camelcase:false, nomen:false */
try { try {
meta = mw.libs.jpegmeta( data, file.fileName ); meta = mw.libs.jpegmeta( data, file.fileName );
meta._binary_data = null; meta._binary_data = null;
@ -263,7 +263,6 @@
return true; return true;
} }
/** /**
* Initialization * Initialization
*/ */

View file

@ -179,7 +179,6 @@
.replace( rUnderscoreTrim, '' ); .replace( rUnderscoreTrim, '' );
} }
// Reject illegal characters // Reject illegal characters
if ( title.match( rInvalid ) ) { if ( title.match( rInvalid ) ) {
return false; return false;
@ -271,7 +270,6 @@
}; };
}() ); }() );
/* Static members */ /* Static members */
/** /**
@ -575,7 +573,6 @@
*/ */
Title.prototype.toString = Title.prototype.getPrefixedDb; Title.prototype.toString = Title.prototype.getPrefixedDb;
/** /**
* @alias #getPrefixedText * @alias #getPrefixedText
* @method * @method

View file

@ -238,7 +238,6 @@
$( '<colgroup>' ).appendTo( $table ); $( '<colgroup>' ).appendTo( $table );
$( '<colgroup>' ).css( 'width', 350 ).appendTo( $table ); $( '<colgroup>' ).css( 'width', 350 ).appendTo( $table );
entryTypeText = function ( entryType ) { entryTypeText = function ( entryType ) {
switch ( entryType ) { switch ( entryType ) {
case 'log': case 'log':
@ -297,7 +296,6 @@
.appendTo( $table ); .appendTo( $table );
} }
return $table; return $table;
}, },

View file

@ -163,9 +163,12 @@
* The section of the dialog to show. * The section of the dialog to show.
*/ */
display: function ( s ) { display: function ( s ) {
this.$dialog.dialog( { buttons:{} } ); // hide the buttons // Hide the buttons
this.$dialog.find( '.feedback-mode' ).hide(); // hide everything this.$dialog.dialog( { buttons: {} } );
this.$dialog.find( '.feedback-' + s ).show(); // show the desired div // Hide everything
this.$dialog.find( '.feedback-mode' ).hide();
// Show the desired div
this.$dialog.find( '.feedback-' + s ).show();
}, },
/** /**

View file

@ -14,18 +14,18 @@
var oldParser, var oldParser,
slice = Array.prototype.slice, slice = Array.prototype.slice,
parserDefaults = { parserDefaults = {
magic : { magic: {
'SITENAME' : mw.config.get( 'wgSiteName' ) 'SITENAME': mw.config.get( 'wgSiteName' )
}, },
// This is a whitelist based on, but simpler than, Sanitizer.php. // This is a whitelist based on, but simpler than, Sanitizer.php.
// Self-closing tags are not currently supported. // Self-closing tags are not currently supported.
allowedHtmlElements : [ allowedHtmlElements: [
'b', 'b',
'i' 'i'
], ],
// Key tag name, value allowed attributes for that tag. // Key tag name, value allowed attributes for that tag.
// See Sanitizer::setupAttributeWhitelist // See Sanitizer::setupAttributeWhitelist
allowedHtmlCommonAttributes : [ allowedHtmlCommonAttributes: [
// HTML // HTML
'id', 'id',
'class', 'class',
@ -41,9 +41,9 @@
// Attributes allowed for specific elements. // Attributes allowed for specific elements.
// Key is element name in lower case // Key is element name in lower case
// Value is array of allowed attributes for that element // Value is array of allowed attributes for that element
allowedHtmlAttributesByElement : {}, allowedHtmlAttributesByElement: {},
messages : mw.messages, messages: mw.messages,
language : mw.language, language: mw.language,
// Same meaning as in mediawiki.js. // Same meaning as in mediawiki.js.
// //

View file

@ -91,7 +91,7 @@ relativeforfloats = window.relativeforfloats = function () {
setrelative = window.setrelative = function ( nodes ) { setrelative = window.setrelative = function ( nodes ) {
var i = 0; var i = 0;
while ( i < nodes.length ) { while ( i < nodes.length ) {
if( ( ( nodes[i].style.float && nodes[i].style.float !== ( 'none' ) || if ( ( ( nodes[i].style.float && nodes[i].style.float !== ( 'none' ) ||
( nodes[i].align && nodes[i].align !== ( 'none' ) ) ) && ( nodes[i].align && nodes[i].align !== ( 'none' ) ) ) &&
( !nodes[i].style.position || nodes[i].style.position !== 'relative' ) ) ) ( !nodes[i].style.position || nodes[i].style.position !== 'relative' ) ) )
{ {
@ -135,7 +135,7 @@ window.onbeforeprint = function () {
} }
}; };
window.onafterprint = function() { window.onafterprint = function () {
for ( var i = 0; i < expandedURLs.length; i++ ) { for ( var i = 0; i < expandedURLs.length; i++ ) {
if ( expandedURLs[i] ) { if ( expandedURLs[i] ) {
expandedURLs[i].removeNode( true ); expandedURLs[i].removeNode( true );

View file

@ -5,7 +5,7 @@
* http://www.modernmethod.com/sajax/ * http://www.modernmethod.com/sajax/
*/ */
/*jshint camelcase:false, onevar:false */ /*jshint camelcase:false */
/*global alert */ /*global alert */
( function ( mw ) { ( function ( mw ) {
@ -89,9 +89,7 @@ function createXhr() {
* with id = showFoo * with id = showFoo
*/ */
function doAjaxRequest( func_name, args, target ) { function doAjaxRequest( func_name, args, target ) {
var i, x; var i, x, uri, post_data;
var uri;
var post_data;
uri = mw.util.wikiScript() + '?action=ajax'; uri = mw.util.wikiScript() + '?action=ajax';
if ( window.sajax_request_type === 'GET' ) { if ( window.sajax_request_type === 'GET' ) {
if ( uri.indexOf( '?' ) === -1 ) { if ( uri.indexOf( '?' ) === -1 ) {
@ -146,7 +144,7 @@ function doAjaxRequest( func_name, args, target ) {
} else if ( typeof target === 'object' ) { } else if ( typeof target === 'object' ) {
if ( target.tagName === 'INPUT' ) { if ( target.tagName === 'INPUT' ) {
if ( x.status === 200 ) { if ( x.status === 200 ) {
target.value= x.responseText; target.value = x.responseText;
} }
//else alert( 'Error: ' + x.status + ' ' + x.statusText + ' (' + x.responseText + ')' ); //else alert( 'Error: ' + x.status + ' ' + x.statusText + ' (' + x.responseText + ')' );
} else { } else {
@ -173,8 +171,9 @@ function doAjaxRequest( func_name, args, target ) {
* @return {boolean} Whether the browser supports AJAX * @return {boolean} Whether the browser supports AJAX
*/ */
function wfSupportsAjax() { function wfSupportsAjax() {
var request = createXhr(); var request = createXhr(),
var supportsAjax = request ? true : false; supportsAjax = request ? true : false;
request = undefined; request = undefined;
return supportsAjax; return supportsAjax;
} }

View file

@ -98,7 +98,7 @@
// Show/Hide memcached servers when needed // Show/Hide memcached servers when needed
$( 'input[name$="config_wgMainCacheType"]' ).change( function () { $( 'input[name$="config_wgMainCacheType"]' ).change( function () {
var $memc = $( '#config-memcachewrapper' ); var $memc = $( '#config-memcachewrapper' );
if( $( 'input[name$="config_wgMainCacheType"]:checked' ).val() === 'memcached' ) { if ( $( 'input[name$="config_wgMainCacheType"]:checked' ).val() === 'memcached' ) {
$memc.show( 'slow' ); $memc.show( 'slow' );
} else { } else {
$memc.hide( 'slow' ); $memc.hide( 'slow' );

View file

@ -85,7 +85,6 @@ function uploadSetup() {
wpLicenseTbody.insertBefore( row, wpLicenseRow.nextSibling ); wpLicenseTbody.insertBefore( row, wpLicenseRow.nextSibling );
} }
// fillDestFile setup // fillDestFile setup
uploadSourceIds = mw.config.get( 'wgUploadSourceIds' ); uploadSourceIds = mw.config.get( 'wgUploadSourceIds' );
len = uploadSourceIds.length; len = uploadSourceIds.length;
@ -98,7 +97,7 @@ function uploadSetup() {
} }
wgUploadWarningObj = window.wgUploadWarningObj = { wgUploadWarningObj = window.wgUploadWarningObj = {
responseCache: { '' : '&nbsp;' }, responseCache: { '': '&nbsp;' },
nameToCheck: '', nameToCheck: '',
typing: false, typing: false,
delay: 500, // ms delay: 500, // ms
@ -303,7 +302,7 @@ window.toggleFilenameFiller = function () {
wgUploadLicenseObj = window.wgUploadLicenseObj = { wgUploadLicenseObj = window.wgUploadLicenseObj = {
responseCache: { '' : '' }, responseCache: { '': '' },
fetchPreview: function ( license ) { fetchPreview: function ( license ) {
var cached, title; var cached, title;

View file

@ -240,7 +240,7 @@ win.importStylesheet = function ( page ) {
return win.importStylesheetURI( uri ); return win.importStylesheetURI( uri );
}; };
win.importStylesheetURI = function( url, media ) { win.importStylesheetURI = function ( url, media ) {
var l = document.createElement( 'link' ); var l = document.createElement( 'link' );
l.rel = 'stylesheet'; l.rel = 'stylesheet';
l.href = url; l.href = url;

View file

@ -8,7 +8,7 @@ jQuery( function ( $ ) {
.attr( 'tabindex', '0' ) .attr( 'tabindex', '0' )
// For accessibility, show the menu when the h3 is clicked (bug 24298/46486) // For accessibility, show the menu when the h3 is clicked (bug 24298/46486)
.on( 'click keypress', function ( e ) { .on( 'click keypress', function ( e ) {
if( e.type === 'click' || e.which === 13 ) { if ( e.type === 'click' || e.which === 13 ) {
$el.toggleClass( 'menuForceShow' ); $el.toggleClass( 'menuForceShow' );
e.preventDefault(); e.preventDefault();
} }

View file

@ -0,0 +1,51 @@
/*!
* Grunt file
*/
/*jshint node:true */
module.exports = function ( grunt ) {
grunt.loadNpmTasks( 'grunt-contrib-jshint' );
grunt.loadNpmTasks( 'grunt-contrib-watch' );
grunt.loadNpmTasks( 'grunt-jscs-checker' );
grunt.file.setBase( __dirname + '/../..' );
grunt.initConfig( {
pkg: grunt.file.readJSON( __dirname + '/package.json' ),
jshint: {
options: {
jshintrc: '.jshintrc'
},
all: [ '*.js', '{includes,languages,resources,skins,tests}/**/*.js' ]
},
jscs: {
// Known issues:
// - https://github.com/mdevils/node-jscs/issues/277
// - https://github.com/mdevils/node-jscs/issues/278
all: [
'<%= jshint.all %>',
// Auto-generated file with JSON (double quotes)
'!tests/qunit/data/mediawiki.jqueryMsg.data.js'
// Exclude all files ignored by jshint
].concat( grunt.file.read( '.jshintignore' ).split( '\n' ).reduce( function ( patterns, pattern ) {
// Filter out empty lines
if ( pattern.length && pattern[0] !== '#' ) {
patterns.push( '!' + pattern );
}
return patterns;
}, [] ) )
},
watch: {
files: [
'.{jshintrc,jscs.json,jshintignore,csslintrc}',
'<%= jshint.all %>'
],
tasks: ['test']
}
} );
grunt.registerTask( 'lint', ['jshint', 'jscs'] );
grunt.registerTask( 'test', ['lint'] );
grunt.registerTask( 'default', ['test'] );
};

View file

@ -0,0 +1,13 @@
{
"name": "mediawiki",
"version": "0.0.0",
"scripts": {
"test": "grunt test"
},
"devDependencies": {
"grunt": "0.4.2",
"grunt-contrib-jshint": "0.8.0",
"grunt-contrib-watch": "0.5.3",
"grunt-jscs-checker": "0.4.0"
}
}

View file

@ -135,7 +135,6 @@ class GenerateJqueryMsgData extends Maintenance {
. '// Last generated with ' . basename( __FILE__ ) . ' at ' . gmdate( 'r' ) . "\n" . '// Last generated with ' . basename( __FILE__ ) . ' at ' . gmdate( 'r' ) . "\n"
// This file will contain unquoted JSON strings as javascript native object literals, // This file will contain unquoted JSON strings as javascript native object literals,
// flip the quotemark convention for this file. // flip the quotemark convention for this file.
. "/*jshint quotmark: double */\n"
. "\n" . "\n"
. 'mediaWiki.libs.phpParserData = ' . FormatJson::encode( $phpParserData, true ) . ";\n"; . 'mediaWiki.libs.phpParserData = ' . FormatJson::encode( $phpParserData, true ) . ";\n";

View file

@ -1,8 +1,7 @@
// This file stores the output from the PHP parser for various messages, arguments, // This file stores the output from the PHP parser for various messages, arguments,
// languages, and parser modes. Intended for use by a unit test framework by looping // languages, and parser modes. Intended for use by a unit test framework by looping
// through the object and comparing its parser return value with the 'result' property. // through the object and comparing its parser return value with the 'result' property.
// Last generated with generateJqueryMsgData.php at Sat, 03 Nov 2012 21:32:01 +0000 // Last generated with generateJqueryMsgData.php at Thu, 30 Jan 2014 04:04:41 +0000
/*jshint quotmark: double */
mediaWiki.libs.phpParserData = { mediaWiki.libs.phpParserData = {
"messages": { "messages": {
@ -10,12 +9,12 @@ mediaWiki.libs.phpParserData = {
"en_category-subcat-count": "{{PLURAL:$2|This category has only the following subcategory.|This category has the following {{PLURAL:$1|subcategory|$1 subcategories}}, out of $2 total.}}", "en_category-subcat-count": "{{PLURAL:$2|This category has only the following subcategory.|This category has the following {{PLURAL:$1|subcategory|$1 subcategories}}, out of $2 total.}}",
"fr_undelete_short": "Restaurer $1 modification{{PLURAL:$1||s}}", "fr_undelete_short": "Restaurer $1 modification{{PLURAL:$1||s}}",
"fr_category-subcat-count": "Cette cat\u00e9gorie comprend {{PLURAL:$2|la sous-cat\u00e9gorie|$2 sous-cat\u00e9gories, dont {{PLURAL:$1|celle|les $1}}}} ci-dessous.", "fr_category-subcat-count": "Cette cat\u00e9gorie comprend {{PLURAL:$2|la sous-cat\u00e9gorie|$2 sous-cat\u00e9gories, dont {{PLURAL:$1|celle|les $1}}}} ci-dessous.",
"ar_undelete_short": "\u0627\u0633\u062a\u0631\u062c\u0627\u0639 {{PLURAL:$1|\u062a\u0639\u062f\u064a\u0644 \u0648\u0627\u062d\u062f|\u062a\u0639\u062f\u064a\u0644\u064a\u0646|$1 \u062a\u0639\u062f\u064a\u0644\u0627\u062a|$1 \u062a\u0639\u062f\u064a\u0644|$1 \u062a\u0639\u062f\u064a\u0644\u0627}}", "ar_undelete_short": "\u0627\u0633\u062a\u0631\u062c\u0627\u0639 {{PLURAL:$1||\u062a\u0639\u062f\u064a\u0644 \u0648\u0627\u062d\u062f|\u062a\u0639\u062f\u064a\u0644\u064a\u0646|$1 \u062a\u0639\u062f\u064a\u0644\u0627\u062a|$1 \u062a\u0639\u062f\u064a\u0644\u0627\u064b|$1 \u062a\u0639\u062f\u064a\u0644}}",
"ar_category-subcat-count": "{{PLURAL:$2|\u0644\u0627 \u062a\u0635\u0627\u0646\u064a\u0641 \u0641\u0631\u0639\u064a\u0629 \u0641\u064a \u0647\u0630\u0627 \u0627\u0644\u062a\u0635\u0646\u064a\u0641|\u0647\u0630\u0627 \u0627\u0644\u062a\u0635\u0646\u064a\u0641 \u0641\u064a\u0647 \u0627\u0644\u062a\u0635\u0646\u064a\u0641 \u0627\u0644\u0641\u0631\u0639\u064a \u0627\u0644\u062a\u0627\u0644\u064a \u0641\u0642\u0637.|\u0647\u0630\u0627 \u0627\u0644\u062a\u0635\u0646\u064a\u0641 \u0641\u064a\u0647 {{PLURAL:$1||\u0647\u0630\u0627 \u0627\u0644\u062a\u0635\u0646\u064a\u0641 \u0627\u0644\u0641\u0631\u0639\u064a|\u0647\u0630\u064a\u0646 \u0627\u0644\u062a\u0635\u0646\u064a\u0641\u064a\u0646 \u0627\u0644\u0641\u0631\u0639\u064a\u064a\u0646|\u0647\u0630\u0647 \u0627\u0644$1 \u062a\u0635\u0627\u0646\u064a\u0641 \u0627\u0644\u0641\u0631\u0639\u064a\u0629|\u0647\u0630\u0647 \u0627\u0644$1 \u062a\u0635\u0646\u064a\u0641\u0627 \u0641\u0631\u0639\u064a\u0627|\u0647\u0630\u0647 \u0627\u0644$1 \u062a\u0635\u0646\u064a\u0641 \u0641\u0631\u0639\u064a}}\u060c \u0645\u0646 \u0625\u062c\u0645\u0627\u0644\u064a $2.}}", "ar_category-subcat-count": "{{PLURAL:$2|\u0647\u0630\u0627 \u0627\u0644\u062a\u0635\u0646\u064a\u0641 \u064a\u062d\u0648\u064a \u0627\u0644\u062a\u0635\u0646\u064a\u0641 \u0627\u0644\u0641\u0631\u0639\u064a \u0627\u0644\u062a\u0627\u0644\u064a|\u0647\u0630\u0627 \u0627\u0644\u062a\u0635\u0646\u064a\u0641 \u064a\u062d\u0648\u064a {{PLURAL:$1||\u0627\u0644\u062a\u0635\u0646\u064a\u0641 \u0627\u0644\u0641\u0631\u0639\u064a|\u062a\u0635\u0646\u064a\u0641\u064a\u0646 \u0641\u0631\u0639\u064a\u064a\u0646|$1 \u062a\u0635\u0646\u064a\u0641\u0627\u062a \u0641\u0631\u0639\u064a\u0629}}\u060c \u0645\u0646 \u0625\u062c\u0645\u0627\u0644\u064a $2.}}",
"jp_undelete_short": "Undelete {{PLURAL:$1|one edit|$1 edits}}", "jp_undelete_short": "Undelete {{PLURAL:$1|one edit|$1 edits}}",
"jp_category-subcat-count": "{{PLURAL:$2|This category has only the following subcategory.|This category has the following {{PLURAL:$1|subcategory|$1 subcategories}}, out of $2 total.}}", "jp_category-subcat-count": "{{PLURAL:$2|This category has only the following subcategory.|This category has the following {{PLURAL:$1|subcategory|$1 subcategories}}, out of $2 total.}}",
"zh_undelete_short": "\u6062\u590d$1\u4e2a\u88ab\u5220\u9664\u7684\u7f16\u8f91", "zh_undelete_short": "\u8fd8\u539f{{PLURAL:$1|$1\u4e2a\u7f16\u8f91}}",
"zh_category-subcat-count": "{{PLURAL:$2|\u672c\u5206\u7c7b\u53ea\u6709\u4e0b\u5217\u4e00\u4e2a\u5b50\u5206\u7c7b\u3002|\u672c\u5206\u7c7b\u5305\u542b\u4e0b\u5217$1\u4e2a\u5b50\u5206\u7c7b\uff0c\u5171$2\u4e2a\u5b50\u5206\u7c7b\u3002}}" "zh_category-subcat-count": "{{PLURAL:$2|\u672c\u5206\u7c7b\u53ea\u6709\u4ee5\u4e0b\u5b50\u5206\u7c7b\u3002|\u672c\u5206\u7c7b\u6709\u4ee5\u4e0b$1\u4e2a\u5b50\u5206\u7c7b\uff0c\u5171\u6709$2\u4e2a\u5b50\u5206\u7c7b\u3002}}"
}, },
"tests": [ "tests": [
{ {
@ -212,7 +211,7 @@ mediaWiki.libs.phpParserData = {
"args": [ "args": [
0 0
], ],
"result": "\u0627\u0633\u062a\u0631\u062c\u0627\u0639 \u062a\u0639\u062f\u064a\u0644 \u0648\u0627\u062d\u062f", "result": "\u0627\u0633\u062a\u0631\u062c\u0627\u0639 ",
"lang": "ar" "lang": "ar"
}, },
{ {
@ -221,7 +220,7 @@ mediaWiki.libs.phpParserData = {
"args": [ "args": [
1 1
], ],
"result": "\u0627\u0633\u062a\u0631\u062c\u0627\u0639 \u062a\u0639\u062f\u064a\u0644\u064a\u0646", "result": "\u0627\u0633\u062a\u0631\u062c\u0627\u0639 \u062a\u0639\u062f\u064a\u0644 \u0648\u0627\u062d\u062f",
"lang": "ar" "lang": "ar"
}, },
{ {
@ -230,7 +229,7 @@ mediaWiki.libs.phpParserData = {
"args": [ "args": [
2 2
], ],
"result": "\u0627\u0633\u062a\u0631\u062c\u0627\u0639 2 \u062a\u0639\u062f\u064a\u0644\u0627\u062a", "result": "\u0627\u0633\u062a\u0631\u062c\u0627\u0639 \u062a\u0639\u062f\u064a\u0644\u064a\u0646",
"lang": "ar" "lang": "ar"
}, },
{ {
@ -239,7 +238,7 @@ mediaWiki.libs.phpParserData = {
"args": [ "args": [
5 5
], ],
"result": "\u0627\u0633\u062a\u0631\u062c\u0627\u0639 5 \u062a\u0639\u062f\u064a\u0644", "result": "\u0627\u0633\u062a\u0631\u062c\u0627\u0639 5 \u062a\u0639\u062f\u064a\u0644\u0627\u062a",
"lang": "ar" "lang": "ar"
}, },
{ {
@ -248,7 +247,7 @@ mediaWiki.libs.phpParserData = {
"args": [ "args": [
21 21
], ],
"result": "\u0627\u0633\u062a\u0631\u062c\u0627\u0639 21 \u062a\u0639\u062f\u064a\u0644\u0627", "result": "\u0627\u0633\u062a\u0631\u062c\u0627\u0639 21 \u062a\u0639\u062f\u064a\u0644\u0627\u064b",
"lang": "ar" "lang": "ar"
}, },
{ {
@ -257,7 +256,7 @@ mediaWiki.libs.phpParserData = {
"args": [ "args": [
101 101
], ],
"result": "\u0627\u0633\u062a\u0631\u062c\u0627\u0639 101 \u062a\u0639\u062f\u064a\u0644\u0627", "result": "\u0627\u0633\u062a\u0631\u062c\u0627\u0639 101 \u062a\u0639\u062f\u064a\u0644",
"lang": "ar" "lang": "ar"
}, },
{ {
@ -267,7 +266,7 @@ mediaWiki.libs.phpParserData = {
0, 0,
10 10
], ],
"result": "\u0647\u0630\u0627 \u0627\u0644\u062a\u0635\u0646\u064a\u0641 \u0641\u064a\u0647 \u060c \u0645\u0646 \u0625\u062c\u0645\u0627\u0644\u064a 10.", "result": "\u0647\u0630\u0627 \u0627\u0644\u062a\u0635\u0646\u064a\u0641 \u064a\u062d\u0648\u064a \u060c \u0645\u0646 \u0625\u062c\u0645\u0627\u0644\u064a 10.",
"lang": "ar" "lang": "ar"
}, },
{ {
@ -277,7 +276,7 @@ mediaWiki.libs.phpParserData = {
1, 1,
1 1
], ],
"result": "\u0647\u0630\u0627 \u0627\u0644\u062a\u0635\u0646\u064a\u0641 \u0641\u064a\u0647 \u0627\u0644\u062a\u0635\u0646\u064a\u0641 \u0627\u0644\u0641\u0631\u0639\u064a \u0627\u0644\u062a\u0627\u0644\u064a \u0641\u0642\u0637.", "result": "\u0647\u0630\u0627 \u0627\u0644\u062a\u0635\u0646\u064a\u0641 \u064a\u062d\u0648\u064a \u0627\u0644\u062a\u0635\u0646\u064a\u0641 \u0627\u0644\u0641\u0631\u0639\u064a\u060c \u0645\u0646 \u0625\u062c\u0645\u0627\u0644\u064a 1.",
"lang": "ar" "lang": "ar"
}, },
{ {
@ -287,7 +286,7 @@ mediaWiki.libs.phpParserData = {
1, 1,
2 2
], ],
"result": "\u0647\u0630\u0627 \u0627\u0644\u062a\u0635\u0646\u064a\u0641 \u0641\u064a\u0647 \u0647\u0630\u0627 \u0627\u0644\u062a\u0635\u0646\u064a\u0641 \u0627\u0644\u0641\u0631\u0639\u064a\u060c \u0645\u0646 \u0625\u062c\u0645\u0627\u0644\u064a 2.", "result": "\u0647\u0630\u0627 \u0627\u0644\u062a\u0635\u0646\u064a\u0641 \u064a\u062d\u0648\u064a \u0627\u0644\u062a\u0635\u0646\u064a\u0641 \u0627\u0644\u0641\u0631\u0639\u064a\u060c \u0645\u0646 \u0625\u062c\u0645\u0627\u0644\u064a 2.",
"lang": "ar" "lang": "ar"
}, },
{ {
@ -297,7 +296,7 @@ mediaWiki.libs.phpParserData = {
3, 3,
30 30
], ],
"result": "\u0647\u0630\u0627 \u0627\u0644\u062a\u0635\u0646\u064a\u0641 \u0641\u064a\u0647 \u0647\u0630\u0647 \u0627\u06443 \u062a\u0635\u0627\u0646\u064a\u0641 \u0627\u0644\u0641\u0631\u0639\u064a\u0629\u060c \u0645\u0646 \u0625\u062c\u0645\u0627\u0644\u064a 30.", "result": "\u0647\u0630\u0627 \u0627\u0644\u062a\u0635\u0646\u064a\u0641 \u064a\u062d\u0648\u064a 3 \u062a\u0635\u0646\u064a\u0641\u0627\u062a \u0641\u0631\u0639\u064a\u0629\u060c \u0645\u0646 \u0625\u062c\u0645\u0627\u0644\u064a 30.",
"lang": "ar" "lang": "ar"
}, },
{ {
@ -400,7 +399,7 @@ mediaWiki.libs.phpParserData = {
"args": [ "args": [
0 0
], ],
"result": "\u6062\u590d0\u4e2a\u88ab\u5220\u9664\u7684\u7f16\u8f91", "result": "\u8fd8\u539f0\u4e2a\u7f16\u8f91",
"lang": "zh" "lang": "zh"
}, },
{ {
@ -409,7 +408,7 @@ mediaWiki.libs.phpParserData = {
"args": [ "args": [
1 1
], ],
"result": "\u6062\u590d1\u4e2a\u88ab\u5220\u9664\u7684\u7f16\u8f91", "result": "\u8fd8\u539f1\u4e2a\u7f16\u8f91",
"lang": "zh" "lang": "zh"
}, },
{ {
@ -418,7 +417,7 @@ mediaWiki.libs.phpParserData = {
"args": [ "args": [
2 2
], ],
"result": "\u6062\u590d2\u4e2a\u88ab\u5220\u9664\u7684\u7f16\u8f91", "result": "\u8fd8\u539f2\u4e2a\u7f16\u8f91",
"lang": "zh" "lang": "zh"
}, },
{ {
@ -427,7 +426,7 @@ mediaWiki.libs.phpParserData = {
"args": [ "args": [
5 5
], ],
"result": "\u6062\u590d5\u4e2a\u88ab\u5220\u9664\u7684\u7f16\u8f91", "result": "\u8fd8\u539f5\u4e2a\u7f16\u8f91",
"lang": "zh" "lang": "zh"
}, },
{ {
@ -436,7 +435,7 @@ mediaWiki.libs.phpParserData = {
"args": [ "args": [
21 21
], ],
"result": "\u6062\u590d21\u4e2a\u88ab\u5220\u9664\u7684\u7f16\u8f91", "result": "\u8fd8\u539f21\u4e2a\u7f16\u8f91",
"lang": "zh" "lang": "zh"
}, },
{ {
@ -445,7 +444,7 @@ mediaWiki.libs.phpParserData = {
"args": [ "args": [
101 101
], ],
"result": "\u6062\u590d101\u4e2a\u88ab\u5220\u9664\u7684\u7f16\u8f91", "result": "\u8fd8\u539f101\u4e2a\u7f16\u8f91",
"lang": "zh" "lang": "zh"
}, },
{ {
@ -455,7 +454,7 @@ mediaWiki.libs.phpParserData = {
0, 0,
10 10
], ],
"result": "\u672c\u5206\u7c7b\u5305\u542b\u4e0b\u52170\u4e2a\u5b50\u5206\u7c7b\uff0c\u517110\u4e2a\u5b50\u5206\u7c7b\u3002", "result": "\u672c\u5206\u7c7b\u6709\u4ee5\u4e0b0\u4e2a\u5b50\u5206\u7c7b\uff0c\u5171\u670910\u4e2a\u5b50\u5206\u7c7b\u3002",
"lang": "zh" "lang": "zh"
}, },
{ {
@ -465,7 +464,7 @@ mediaWiki.libs.phpParserData = {
1, 1,
1 1
], ],
"result": "\u672c\u5206\u7c7b\u53ea\u6709\u4e0b\u5217\u4e00\u4e2a\u5b50\u5206\u7c7b\u3002", "result": "\u672c\u5206\u7c7b\u53ea\u6709\u4ee5\u4e0b\u5b50\u5206\u7c7b\u3002",
"lang": "zh" "lang": "zh"
}, },
{ {
@ -475,7 +474,7 @@ mediaWiki.libs.phpParserData = {
1, 1,
2 2
], ],
"result": "\u672c\u5206\u7c7b\u5305\u542b\u4e0b\u52171\u4e2a\u5b50\u5206\u7c7b\uff0c\u51712\u4e2a\u5b50\u5206\u7c7b\u3002", "result": "\u672c\u5206\u7c7b\u6709\u4ee5\u4e0b1\u4e2a\u5b50\u5206\u7c7b\uff0c\u5171\u67092\u4e2a\u5b50\u5206\u7c7b\u3002",
"lang": "zh" "lang": "zh"
}, },
{ {
@ -485,7 +484,7 @@ mediaWiki.libs.phpParserData = {
3, 3,
30 30
], ],
"result": "\u672c\u5206\u7c7b\u5305\u542b\u4e0b\u52173\u4e2a\u5b50\u5206\u7c7b\uff0c\u517130\u4e2a\u5b50\u5206\u7c7b\u3002", "result": "\u672c\u5206\u7c7b\u6709\u4ee5\u4e0b3\u4e2a\u5b50\u5206\u7c7b\uff0c\u5171\u670930\u4e2a\u5b50\u5206\u7c7b\u3002",
"lang": "zh" "lang": "zh"
} }
] ]

View file

@ -4,7 +4,7 @@
QUnit.asyncTest( 'animate', 3, function ( assert ) { QUnit.asyncTest( 'animate', 3, function ( assert ) {
var $canvas = $( '<div>' ).css( 'background-color', '#fff' ); var $canvas = $( '<div>' ).css( 'background-color', '#fff' );
$canvas.animate( { backgroundColor: '#000' }, 4 ).promise().then( function() { $canvas.animate( { backgroundColor: '#000' }, 4 ).promise().then( function () {
var endColors = $.colorUtil.getRGB( $canvas.css( 'background-color' ) ); var endColors = $.colorUtil.getRGB( $canvas.css( 'background-color' ) );
assert.strictEqual( endColors[0], 0 ); assert.strictEqual( endColors[0], 0 );
assert.strictEqual( endColors[1], 0 ); assert.strictEqual( endColors[1], 0 );

View file

@ -269,7 +269,7 @@
$collapsible.find( '.mw-collapsible-toggle' ).trigger( 'click' ); $collapsible.find( '.mw-collapsible-toggle' ).trigger( 'click' );
} ); } );
QUnit.test( 'clicks on links inside toggler pass through (options.linksPassthru)' , 2, function ( assert ) { QUnit.test( 'clicks on links inside toggler pass through (options.linksPassthru)', 2, function ( assert ) {
var $collapsible = prepareCollapsible( var $collapsible = prepareCollapsible(
'<div class="mw-collapsible">' + '<div class="mw-collapsible">' +
'<div class="mw-collapsible-toggle">' + '<div class="mw-collapsible-toggle">' +

View file

@ -1,8 +1,8 @@
(function($) { (function ($) {
QUnit.module('jquery.placeholder', QUnit.newMwEnvironment()); QUnit.module('jquery.placeholder', QUnit.newMwEnvironment());
QUnit.test('caches results of feature tests', 2, function(assert) { QUnit.test('caches results of feature tests', 2, function (assert) {
assert.strictEqual(typeof $.fn.placeholder.input, 'boolean', '$.fn.placeholder.input'); assert.strictEqual(typeof $.fn.placeholder.input, 'boolean', '$.fn.placeholder.input');
assert.strictEqual(typeof $.fn.placeholder.textarea, 'boolean', '$.fn.placeholder.textarea'); assert.strictEqual(typeof $.fn.placeholder.textarea, 'boolean', '$.fn.placeholder.textarea');
}); });
@ -20,7 +20,7 @@
'<input id="input-type-password" type="password" placeholder="e.g. hunter2">' + '<input id="input-type-password" type="password" placeholder="e.g. hunter2">' +
'<textarea id="textarea" name="message" placeholder="Your message goes here"></textarea>' + '<textarea id="textarea" name="message" placeholder="Your message goes here"></textarea>' +
'</form>', '</form>',
testElement = function($el, assert) { testElement = function ($el, assert) {
var el = $el[0], var el = $el[0],
placeholder = el.getAttribute('placeholder'); placeholder = el.getAttribute('placeholder');
@ -67,32 +67,32 @@
$el.placeholder(placeholder); $el.placeholder(placeholder);
}; };
QUnit.test('emulates placeholder for <input type=text>', 22, function(assert) { QUnit.test('emulates placeholder for <input type=text>', 22, function (assert) {
$('<div>').html(html).appendTo($('#qunit-fixture')); $('<div>').html(html).appendTo($('#qunit-fixture'));
testElement($('#input-type-text'), assert); testElement($('#input-type-text'), assert);
}); });
QUnit.test('emulates placeholder for <input type=search>', 22, function(assert) { QUnit.test('emulates placeholder for <input type=search>', 22, function (assert) {
$('<div>').html(html).appendTo($('#qunit-fixture')); $('<div>').html(html).appendTo($('#qunit-fixture'));
testElement($('#input-type-search'), assert); testElement($('#input-type-search'), assert);
}); });
QUnit.test('emulates placeholder for <input type=email>', 22, function(assert) { QUnit.test('emulates placeholder for <input type=email>', 22, function (assert) {
$('<div>').html(html).appendTo($('#qunit-fixture')); $('<div>').html(html).appendTo($('#qunit-fixture'));
testElement($('#input-type-email'), assert); testElement($('#input-type-email'), assert);
}); });
QUnit.test('emulates placeholder for <input type=url>', 22, function(assert) { QUnit.test('emulates placeholder for <input type=url>', 22, function (assert) {
$('<div>').html(html).appendTo($('#qunit-fixture')); $('<div>').html(html).appendTo($('#qunit-fixture'));
testElement($('#input-type-url'), assert); testElement($('#input-type-url'), assert);
}); });
QUnit.test('emulates placeholder for <input type=tel>', 22, function(assert) { QUnit.test('emulates placeholder for <input type=tel>', 22, function (assert) {
$('<div>').html(html).appendTo($('#qunit-fixture')); $('<div>').html(html).appendTo($('#qunit-fixture'));
testElement($('#input-type-tel'), assert); testElement($('#input-type-tel'), assert);
}); });
QUnit.test('emulates placeholder for <input type=password>', 13, function(assert) { QUnit.test('emulates placeholder for <input type=password>', 13, function (assert) {
$('<div>').html(html).appendTo($('#qunit-fixture')); $('<div>').html(html).appendTo($('#qunit-fixture'));
var selector = '#input-type-password', var selector = '#input-type-password',
@ -137,7 +137,7 @@
}); });
QUnit.test('emulates placeholder for <textarea></textarea>', 22, function(assert) { QUnit.test('emulates placeholder for <textarea></textarea>', 22, function (assert) {
$('<div>').html(html).appendTo($('#qunit-fixture')); $('<div>').html(html).appendTo($('#qunit-fixture'));
testElement($('#textarea'), assert); testElement($('#textarea'), assert);
}); });

View file

@ -32,29 +32,33 @@
}, opt.after ); }, opt.after );
QUnit.test( opt.description, function ( assert ) { QUnit.test( opt.description, function ( assert ) {
/*jshint onevar: false */ var $textarea, start, end, options, text,
var tests = 1; tests = 1;
if ( opt.after.selected !== null ) { if ( opt.after.selected !== null ) {
tests++; tests++;
} }
QUnit.expect( tests ); QUnit.expect( tests );
var $textarea = $( '<textarea>' ); $textarea = $( '<textarea>' );
$( '#qunit-fixture' ).append( $textarea ); $( '#qunit-fixture' ).append( $textarea );
//$textarea.textSelection( 'setContents', opt.before.text); // this method is actually missing atm... // This method is actually missing atm...
$textarea.val( opt.before.text ); // won't work with the WikiEditor iframe? //$textarea.textSelection( 'setContents', opt.before.text);
var start = opt.before.start, // Won't work with the WikiEditor iframe?
$textarea.val( opt.before.text );
start = opt.before.start;
end = opt.before.end; end = opt.before.end;
var options = $.extend( {}, opt.replace ); // Clone opt.replace // Clone opt.replace
options = $.extend( {}, opt.replace );
options.selectionStart = start; options.selectionStart = start;
options.selectionEnd = end; options.selectionEnd = end;
$textarea.textSelection( 'encapsulateSelection', options ); $textarea.textSelection( 'encapsulateSelection', options );
var text = $textarea.textSelection( 'getContents' ).replace( /\r\n/g, '\n' ); text = $textarea.textSelection( 'getContents' ).replace( /\r\n/g, '\n' );
assert.equal( text, opt.after.text, 'Checking full text after encapsulation' ); assert.equal( text, opt.after.text, 'Checking full text after encapsulation' );
@ -161,7 +165,6 @@
replace: h2 replace: h2
} ); } );
encapsulateTest( { encapsulateTest( {
description: 'ownline option: turn a partial line into new h2', description: 'ownline option: turn a partial line into new h2',
before: { before: {
@ -176,7 +179,6 @@
replace: h2 replace: h2
} ); } );
encapsulateTest( { encapsulateTest( {
description: 'splitlines option: no selection, insert new list item', description: 'splitlines option: no selection, insert new list item',
before: { before: {
@ -216,10 +218,10 @@
replace: ulist replace: ulist
} ); } );
function caretTest( options ) { function caretTest( options ) {
QUnit.test( options.description, 2, function ( assert ) { QUnit.test( options.description, 2, function ( assert ) {
var pos, $textarea = $( '<textarea>' ).text( options.text ); var pos,
$textarea = $( '<textarea>' ).text( options.text );
$( '#qunit-fixture' ).append( $textarea ); $( '#qunit-fixture' ).append( $textarea );

View file

@ -29,7 +29,6 @@
} ); } );
} ); } );
QUnit.test( 'API error', function ( assert ) { QUnit.test( 'API error', function ( assert ) {
QUnit.expect( 1 ); QUnit.expect( 1 );

View file

@ -25,32 +25,31 @@
100: 'Penguins' 100: 'Penguins'
}, },
wgNamespaceIds: { wgNamespaceIds: {
/*jshint camelcase: false */ 'media': -2,
media: -2, 'special': -1,
special: -1,
'': 0, '': 0,
talk: 1, 'talk': 1,
user: 2, 'user': 2,
user_talk: 3, 'user_talk': 3,
wikipedia: 4, 'wikipedia': 4,
wikipedia_talk: 5, 'wikipedia_talk': 5,
file: 6, 'file': 6,
file_talk: 7, 'file_talk': 7,
mediawiki: 8, 'mediawiki': 8,
mediawiki_talk: 9, 'mediawiki_talk': 9,
template: 10, 'template': 10,
template_talk: 11, 'template_talk': 11,
help: 12, 'help': 12,
help_talk: 13, 'help_talk': 13,
category: 14, 'category': 14,
category_talk: 15, 'category_talk': 15,
image: 6, 'image': 6,
image_talk: 7, 'image_talk': 7,
project: 4, 'project': 4,
project_talk: 5, 'project_talk': 5,
/* testing custom / alias */ // Testing custom namespaces and aliases
penguins: 100, 'penguins': 100,
antarctic_waterfowl: 100 'antarctic_waterfowl': 100
}, },
wgCaseSensitiveNamespaces: [] wgCaseSensitiveNamespaces: []
}, },

View file

@ -705,7 +705,6 @@ QUnit.test( 'HTML', 26, function ( assert ) {
'Escaped attributes are parsed correctly' 'Escaped attributes are parsed correctly'
); );
mw.messages.set( 'jquerymsg-wikitext-contents-parsed', '<i>[http://example.com Example]</i>' ); mw.messages.set( 'jquerymsg-wikitext-contents-parsed', '<i>[http://example.com Example]</i>' );
assert.htmlEqual( assert.htmlEqual(
formatParse( 'jquerymsg-wikitext-contents-parsed' ), formatParse( 'jquerymsg-wikitext-contents-parsed' ),

View file

@ -75,7 +75,7 @@
assert.strictEqual( conf.get( 'constructor' ), 42, 'Map.get for key "constructor"' ); assert.strictEqual( conf.get( 'constructor' ), 42, 'Map.get for key "constructor"' );
assert.strictEqual( conf.set( 'ImUndefined', undefined ), true, 'Map.set allows setting value to `undefined`' ); assert.strictEqual( conf.set( 'ImUndefined', undefined ), true, 'Map.set allows setting value to `undefined`' );
assert.equal( conf.get( 'ImUndefined', 'fallback' ), undefined , 'Map.get supports retreiving value of `undefined`' ); assert.equal( conf.get( 'ImUndefined', 'fallback' ), undefined, 'Map.get supports retreiving value of `undefined`' );
assert.strictEqual( conf.set( funky, 'Funky' ), false, 'Map.set returns boolean false if key was invalid (Function)' ); assert.strictEqual( conf.set( funky, 'Funky' ), false, 'Map.set returns boolean false if key was invalid (Function)' );
assert.strictEqual( conf.set( arry, 'Arry' ), false, 'Map.set returns boolean false if key was invalid (Array)' ); assert.strictEqual( conf.set( arry, 'Arry' ), false, 'Map.set returns boolean false if key was invalid (Array)' );
@ -109,7 +109,6 @@
'notExist': null 'notExist': null
}, 'Map.get return includes keys that were not found as null values' ); }, 'Map.get return includes keys that were not found as null values' );
// Interacting with globals and accessing the values object // Interacting with globals and accessing the values object
assert.strictEqual( conf.get(), conf.values, 'Map.get returns the entire values object by reference (if called without arguments)' ); assert.strictEqual( conf.get(), conf.values, 'Map.get returns the entire values object by reference (if called without arguments)' );
@ -181,7 +180,7 @@
assertMultipleFormats( ['mediawiki-test-version-entrypoints-index-php'], ['plain', 'text', 'escaped'], mw.messages.get( 'mediawiki-test-version-entrypoints-index-php' ), 'External link markup is unprocessed' ); assertMultipleFormats( ['mediawiki-test-version-entrypoints-index-php'], ['plain', 'text', 'escaped'], mw.messages.get( 'mediawiki-test-version-entrypoints-index-php' ), 'External link markup is unprocessed' );
assert.htmlEqual( mw.message( 'mediawiki-test-version-entrypoints-index-php' ).parse(), '<a href="https://www.mediawiki.org/wiki/Manual:index.php">index.php</a>', 'External link works correctly in parse mode' ); assert.htmlEqual( mw.message( 'mediawiki-test-version-entrypoints-index-php' ).parse(), '<a href="https://www.mediawiki.org/wiki/Manual:index.php">index.php</a>', 'External link works correctly in parse mode' );
assertMultipleFormats( ['external-link-replace', 'http://example.org/?x=y&z'], ['plain', 'text'] , 'Foo [http://example.org/?x=y&z bar]', 'Parameters are substituted but external link is not processed' ); assertMultipleFormats( ['external-link-replace', 'http://example.org/?x=y&z'], ['plain', 'text'], 'Foo [http://example.org/?x=y&z bar]', 'Parameters are substituted but external link is not processed' );
assert.equal( mw.message( 'external-link-replace', 'http://example.org/?x=y&z' ).escaped(), 'Foo [http://example.org/?x=y&amp;z bar]', 'In escaped mode, parameters are substituted and ampersand is escaped, but external link is not processed' ); assert.equal( mw.message( 'external-link-replace', 'http://example.org/?x=y&z' ).escaped(), 'Foo [http://example.org/?x=y&amp;z bar]', 'In escaped mode, parameters are substituted and ampersand is escaped, but external link is not processed' );
assert.htmlEqual( mw.message( 'external-link-replace', 'http://example.org/?x=y&z' ).parse(), 'Foo <a href="http://example.org/?x=y&amp;z">bar</a>', 'External link with replacement works in parse mode without double-escaping' ); assert.htmlEqual( mw.message( 'external-link-replace', 'http://example.org/?x=y&z' ).parse(), 'Foo <a href="http://example.org/?x=y&amp;z">bar</a>', 'External link with replacement works in parse mode without double-escaping' );
@ -216,14 +215,12 @@
assertMultipleFormats( ['plural-test-msg-explicit-beginning', 6], ['text', 'parse', 'escaped'], 'Basket has half a dozen eggs', 'explicit plural given at beginning get resolved for 6' ); assertMultipleFormats( ['plural-test-msg-explicit-beginning', 6], ['text', 'parse', 'escaped'], 'Basket has half a dozen eggs', 'explicit plural given at beginning get resolved for 6' );
assertMultipleFormats( ['plural-test-msg-explicit-beginning', 0], ['text', 'parse', 'escaped'], 'Basket has no eggs', 'explicit plural given at beginning get resolved for 0' ); assertMultipleFormats( ['plural-test-msg-explicit-beginning', 0], ['text', 'parse', 'escaped'], 'Basket has no eggs', 'explicit plural given at beginning get resolved for 0' );
assertMultipleFormats( ['mediawiki-test-pagetriage-del-talk-page-notify-summary'], ['plain', 'text'], mw.messages.get( 'mediawiki-test-pagetriage-del-talk-page-notify-summary' ), 'Double square brackets with no parameters unchanged' ); assertMultipleFormats( ['mediawiki-test-pagetriage-del-talk-page-notify-summary'], ['plain', 'text'], mw.messages.get( 'mediawiki-test-pagetriage-del-talk-page-notify-summary' ), 'Double square brackets with no parameters unchanged' );
assertMultipleFormats( ['mediawiki-test-pagetriage-del-talk-page-notify-summary', specialCharactersPageName], ['plain', 'text'], 'Notifying author of deletion nomination for [[' + specialCharactersPageName + ']]', 'Double square brackets with one parameter' ); assertMultipleFormats( ['mediawiki-test-pagetriage-del-talk-page-notify-summary', specialCharactersPageName], ['plain', 'text'], 'Notifying author of deletion nomination for [[' + specialCharactersPageName + ']]', 'Double square brackets with one parameter' );
assert.equal( mw.message( 'mediawiki-test-pagetriage-del-talk-page-notify-summary', specialCharactersPageName ).escaped(), 'Notifying author of deletion nomination for [[' + mw.html.escape( specialCharactersPageName ) + ']]', 'Double square brackets with one parameter, when escaped' ); assert.equal( mw.message( 'mediawiki-test-pagetriage-del-talk-page-notify-summary', specialCharactersPageName ).escaped(), 'Notifying author of deletion nomination for [[' + mw.html.escape( specialCharactersPageName ) + ']]', 'Double square brackets with one parameter, when escaped' );
assert.ok( mw.messages.set( 'mediawiki-test-categorytree-collapse-bullet', '[<b></b>]' ), 'mw.messages.set: Register' ); assert.ok( mw.messages.set( 'mediawiki-test-categorytree-collapse-bullet', '[<b></b>]' ), 'mw.messages.set: Register' );
assert.equal( mw.message( 'mediawiki-test-categorytree-collapse-bullet' ).plain(), mw.messages.get( 'mediawiki-test-categorytree-collapse-bullet' ), 'Single square brackets unchanged in plain mode' ); assert.equal( mw.message( 'mediawiki-test-categorytree-collapse-bullet' ).plain(), mw.messages.get( 'mediawiki-test-categorytree-collapse-bullet' ), 'Single square brackets unchanged in plain mode' );
@ -277,7 +274,6 @@
'Script escaped when using parse format' 'Script escaped when using parse format'
); );
} ); } );
QUnit.test( 'mw.msg', 14, function ( assert ) { QUnit.test( 'mw.msg', 14, function ( assert ) {
@ -285,7 +281,7 @@
assert.equal( mw.msg( 'hello' ), 'Hello <b>awesome</b> world', 'Gets message with default options (existing message)' ); assert.equal( mw.msg( 'hello' ), 'Hello <b>awesome</b> world', 'Gets message with default options (existing message)' );
assert.equal( mw.msg( 'goodbye' ), '<goodbye>', 'Gets message with default options (nonexistent message)' ); assert.equal( mw.msg( 'goodbye' ), '<goodbye>', 'Gets message with default options (nonexistent message)' );
assert.ok( mw.messages.set( 'plural-item' , 'Found $1 {{PLURAL:$1|item|items}}' ), 'mw.messages.set: Register' ); assert.ok( mw.messages.set( 'plural-item', 'Found $1 {{PLURAL:$1|item|items}}' ), 'mw.messages.set: Register' );
assert.equal( mw.msg( 'plural-item', 5 ), 'Found 5 items', 'Apply plural for count 5' ); assert.equal( mw.msg( 'plural-item', 5 ), 'Found 5 items', 'Apply plural for count 5' );
assert.equal( mw.msg( 'plural-item', 0 ), 'Found 0 items', 'Apply plural for count 0' ); assert.equal( mw.msg( 'plural-item', 0 ), 'Found 0 items', 'Apply plural for count 0' );
assert.equal( mw.msg( 'plural-item', 1 ), 'Found 1 item', 'Apply plural for count 1' ); assert.equal( mw.msg( 'plural-item', 1 ), 'Found 1 item', 'Apply plural for count 1' );