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

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

View file

@ -47,7 +47,6 @@
changePlaceholder.call(this, text); changePlaceholder.call(this, text);
} }
$this $this
.filter((isInputSupported ? 'textarea' : ':input') + '[placeholder]') .filter((isInputSupported ? 'textarea' : ':input') + '[placeholder]')
.filter(function () { .filter(function () {

View file

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

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,
$rows = $table.find( '> tbody > tr' );
if ( !$table.get(0).tHead ) { if ( !$table.get(0).tHead ) {
var $thead = $( '<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;
@ -274,10 +275,10 @@
$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,11 +627,13 @@
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);
} }
} }
@ -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

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)
@ -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.
@ -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

@ -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

@ -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

@ -70,7 +70,8 @@
$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
}; };
@ -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

@ -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

@ -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 ) {
@ -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

@ -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;

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

@ -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

@ -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)' );
@ -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 ) {