dépôts
/
lhc
/
web
/
wiklou.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge "Bypass login page if no user input is required."
[lhc/web/wiklou.git]
/
resources
/
src
/
mediawiki
/
mediawiki.jqueryMsg.js
diff --git
a/resources/src/mediawiki/mediawiki.jqueryMsg.js
b/resources/src/mediawiki/mediawiki.jqueryMsg.js
index
44b9117
..
c82b9cb
100644
(file)
--- a/
resources/src/mediawiki/mediawiki.jqueryMsg.js
+++ b/
resources/src/mediawiki/mediawiki.jqueryMsg.js
@@
-136,6
+136,7
@@
function getFailableParserFn( options ) {
return function ( args ) {
var fallback,
function getFailableParserFn( options ) {
return function ( args ) {
var fallback,
+ // eslint-disable-next-line new-cap
parser = new mw.jqueryMsg.parser( options ),
key = args[ 0 ],
argsArray = $.isArray( args[ 1 ] ) ? args[ 1 ] : slice.call( args, 1 );
parser = new mw.jqueryMsg.parser( options ),
key = args[ 0 ],
argsArray = $.isArray( args[ 1 ] ) ? args[ 1 ] : slice.call( args, 1 );
@@
-212,10
+213,11
@@
}
return function () {
}
return function () {
+ var failableResult;
if ( !failableParserFn ) {
failableParserFn = getFailableParserFn( options );
}
if ( !failableParserFn ) {
failableParserFn = getFailableParserFn( options );
}
-
var
failableResult = failableParserFn( arguments );
+ failableResult = failableParserFn( arguments );
if ( format === 'text' || format === 'escaped' ) {
return failableResult.text();
} else {
if ( format === 'text' || format === 'escaped' ) {
return failableResult.text();
} else {
@@
-250,10
+252,11
@@
var failableParserFn;
return function () {
var failableParserFn;
return function () {
+ var $target;
if ( !failableParserFn ) {
failableParserFn = getFailableParserFn( options );
}
if ( !failableParserFn ) {
failableParserFn = getFailableParserFn( options );
}
-
var
$target = this.empty();
+ $target = this.empty();
appendWithoutParsing( $target, failableParserFn( arguments ) );
return $target;
};
appendWithoutParsing( $target, failableParserFn( arguments ) );
return $target;
};
@@
-272,6
+275,7
@@
this.settings.onlyCurlyBraceTransform = ( this.settings.format === 'text' || this.settings.format === 'escaped' );
this.astCache = {};
this.settings.onlyCurlyBraceTransform = ( this.settings.format === 'text' || this.settings.format === 'escaped' );
this.astCache = {};
+ // eslint-disable-next-line new-cap
this.emitter = new mw.jqueryMsg.htmlEmitter( this.settings.language, this.settings.magic );
};
this.emitter = new mw.jqueryMsg.htmlEmitter( this.settings.language, this.settings.magic );
};
@@
-292,10
+296,10
@@
/**
* Fetch the message string associated with a key, return parsed structure. Memoized.
/**
* Fetch the message string associated with a key, return parsed structure. Memoized.
- * Note that we pass '
[' + key + ']
' back for a missing message here.
+ * Note that we pass '
⧼' + key + '⧽
' back for a missing message here.
*
* @param {string} key
*
* @param {string} key
- * @return {string|Array} string of '
[key]
' if message missing, simple string if possible, array of arrays if needs parsing
+ * @return {string|Array} string of '
⧼key⧽
' if message missing, simple string if possible, array of arrays if needs parsing
*/
getAst: function ( key ) {
var wikiText;
*/
getAst: function ( key ) {
var wikiText;
@@
-303,7
+307,7
@@
if ( !this.astCache.hasOwnProperty( key ) ) {
wikiText = this.settings.messages.get( key );
if ( typeof wikiText !== 'string' ) {
if ( !this.astCache.hasOwnProperty( key ) ) {
wikiText = this.settings.messages.get( key );
if ( typeof wikiText !== 'string' ) {
- wikiText = '
\\[' + key + '\\]
';
+ wikiText = '
⧼' + key + '⧽
';
}
this.astCache[ key ] = this.wikiTextToAst( wikiText );
}
}
this.astCache[ key ] = this.wikiTextToAst( wikiText );
}
@@
-903,7
+907,8
@@
/**
* Starts the parse
*
/**
* Starts the parse
*
- * @param {Function} rootExpression root parse function
+ * @param {Function} rootExpression Root parse function
+ * @return {Array|null}
*/
function start( rootExpression ) {
var result = nOrMore( 0, rootExpression )();
*/
function start( rootExpression ) {
var result = nOrMore( 0, rootExpression )();
@@
-933,10
+938,13
@@
/**
* htmlEmitter - object which primarily exists to emit HTML from parser ASTs
/**
* htmlEmitter - object which primarily exists to emit HTML from parser ASTs
+ *
+ * @param {Object} language
+ * @param {Object} magic
*/
mw.jqueryMsg.htmlEmitter = function ( language, magic ) {
*/
mw.jqueryMsg.htmlEmitter = function ( language, magic ) {
- this.language = language;
var jmsg = this;
var jmsg = this;
+ this.language = language;
$.each( magic, function ( key, val ) {
jmsg[ key.toLowerCase() ] = function () {
return val;
$.each( magic, function ( key, val ) {
jmsg[ key.toLowerCase() ] = function () {
return val;
@@
-1046,6
+1054,7
@@
* It may, though, if the wikitext appears in extension-controlled content.
*
* @param {string[]} nodes
* It may, though, if the wikitext appears in extension-controlled content.
*
* @param {string[]} nodes
+ * @return {jQuery}
*/
wikilink: function ( nodes ) {
var page, anchor, url, $el;
*/
wikilink: function ( nodes ) {
var page, anchor, url, $el;
@@
-1126,11
+1135,18
@@
} else {
$el = $( '<a>' );
if ( typeof arg === 'function' ) {
} else {
$el = $( '<a>' );
if ( typeof arg === 'function' ) {
- $el.attr(
'href', '#' )
- .click( function ( e ) {
- e.preventDefault();
+ $el.attr(
{
+ role: 'button',
+ tabindex: 0
} )
} )
- .click( arg );
+ .on( 'click keypress', function ( e ) {
+ if (
+ e.type === 'click' ||
+ e.type === 'keypress' && e.which === 13
+ ) {
+ arg.call( this, e );
+ }
+ } );
} else {
$el.attr( 'href', textify( arg ) );
}
} else {
$el.attr( 'href', textify( arg ) );
}
@@
-1268,7
+1284,7
@@
* @return {number|string} Formatted number
*/
formatnum: function ( nodes ) {
* @return {number|string} Formatted number
*/
formatnum: function ( nodes ) {
- var isInteger =
( nodes[ 1 ] && nodes[ 1 ] === 'R' ) ? true : false
,
+ var isInteger =
!!nodes[ 1 ] && nodes[ 1 ] === 'R'
,
number = nodes[ 0 ];
return this.language.convertNumber( number, isInteger );
number = nodes[ 0 ];
return this.language.convertNumber( number, isInteger );
@@
-1364,6
+1380,6
@@
return function () {
return reusableParent.msg( this.key, this.parameters ).contents().detach();
};
return function () {
return reusableParent.msg( this.key, this.parameters ).contents().detach();
};
- }
)(
);
+ }
()
);
}( mediaWiki, jQuery ) );
}( mediaWiki, jQuery ) );