Index: branches/jsgrammar/resources/mediawiki/mediawiki.jqueryMsg.js |
— | — | @@ -1,7 +1,7 @@ |
2 | 2 | /** |
3 | | - * Experimental advanced wikitext parser-emitter. |
| 3 | + * Experimental advanced wikitext parser-emitter. |
4 | 4 | * See: http://www.mediawiki.org/wiki/Extension:UploadWizard/MessageParser for docs |
5 | | - * |
| 5 | + * |
6 | 6 | * @author neilk@wikimedia.org |
7 | 7 | */ |
8 | 8 | |
— | — | @@ -14,9 +14,9 @@ |
15 | 15 | * @param {Object} parser options |
16 | 16 | * @return {Function} accepting ( String message key, String replacement1, String replacement2 ... ) and returning {jQuery} |
17 | 17 | */ |
18 | | - function getFailableParserFn( options ) { |
19 | | - var parser = new mw.jqueryMsg.parser( options ); |
20 | | - /** |
| 18 | + function getFailableParserFn( options ) { |
| 19 | + var parser = new mw.jqueryMsg.parser( options ); |
| 20 | + /** |
21 | 21 | * Try to parse a key and optional replacements, returning a jQuery object that may be a tree of jQuery nodes. |
22 | 22 | * If there was an error parsing, return the key and the error message (wrapped in jQuery). This should put the error right into |
23 | 23 | * the interface, without causing the page to halt script execution, and it hopefully should be clearer how to fix it. |
— | — | @@ -26,22 +26,22 @@ |
27 | 27 | */ |
28 | 28 | return function( args ) { |
29 | 29 | var key = args[0]; |
30 | | - var argsArray = $.isArray( args[1] ) ? args[1] : $.makeArray( args ).slice( 1 ); |
31 | | - var escapedArgsArray = $.map( argsArray, function( arg ) { |
| 30 | + var argsArray = $.isArray( args[1] ) ? args[1] : $.makeArray( args ).slice( 1 ); |
| 31 | + var escapedArgsArray = $.map( argsArray, function( arg ) { |
32 | 32 | return typeof arg === 'string' ? mw.html.escape( arg ) : arg; |
33 | 33 | } ); |
34 | 34 | try { |
35 | 35 | return parser.parse( key, escapedArgsArray ); |
36 | 36 | } catch ( e ) { |
37 | | - return $( '<span></span>' ).append( key + ': ' + e.message ); |
| 37 | + return $( '<span>' ).append( key + ': ' + e.message ); |
38 | 38 | } |
39 | 39 | }; |
40 | 40 | } |
41 | 41 | |
42 | 42 | /** |
43 | | - * Class method. |
| 43 | + * Class method. |
44 | 44 | * Returns a function suitable for use as a global, to construct strings from the message key (and optional replacements). |
45 | | - * e.g. |
| 45 | + * e.g. |
46 | 46 | * window.gM = mediaWiki.parser.getMessageFunction( options ); |
47 | 47 | * $( 'p#headline' ).html( gM( 'hello-user', username ) ); |
48 | 48 | * |
— | — | @@ -51,12 +51,12 @@ |
52 | 52 | * @param {Array} parser options |
53 | 53 | * @return {Function} function suitable for assigning to window.gM |
54 | 54 | */ |
55 | | - mw.jqueryMsg.getMessageFunction = function( options ) { |
| 55 | + mw.jqueryMsg.getMessageFunction = function( options ) { |
56 | 56 | var failableParserFn = getFailableParserFn( options ); |
57 | | - /** |
| 57 | + /** |
58 | 58 | * N.B. replacements are variadic arguments or an array in second parameter. In other words: |
59 | | - * somefunction(a, b, c, d) |
60 | | - * is equivalent to |
| 59 | + * somefunction(a, b, c, d) |
| 60 | + * is equivalent to |
61 | 61 | * somefunction(a, [b, c, d]) |
62 | 62 | * |
63 | 63 | * @param {String} message key |
— | — | @@ -69,10 +69,10 @@ |
70 | 70 | }; |
71 | 71 | |
72 | 72 | /** |
73 | | - * Class method. |
74 | | - * Returns a jQuery plugin which parses the message in the message key, doing replacements optionally, and appends the nodes to |
75 | | - * the current selector. Bindings to passed-in jquery elements are preserved. Functions become click handlers for [$1 linktext] links. |
76 | | - * e.g. |
| 73 | + * Class method. |
| 74 | + * Returns a jQuery plugin which parses the message in the message key, doing replacements optionally, and appends the nodes to |
| 75 | + * the current selector. Bindings to passed-in jquery elements are preserved. Functions become click handlers for [$1 linktext] links. |
| 76 | + * e.g. |
77 | 77 | * $.fn.msg = mediaWiki.parser.getJqueryPlugin( options ); |
78 | 78 | * var userlink = $( '<a>' ).click( function() { alert( "hello!!") } ); |
79 | 79 | * $( 'p#headline' ).msg( 'hello-user', userlink ); |
— | — | @@ -82,12 +82,12 @@ |
83 | 83 | */ |
84 | 84 | mw.jqueryMsg.getPlugin = function( options ) { |
85 | 85 | var failableParserFn = getFailableParserFn( options ); |
86 | | - /** |
| 86 | + /** |
87 | 87 | * N.B. replacements are variadic arguments or an array in second parameter. In other words: |
88 | | - * somefunction(a, b, c, d) |
89 | | - * is equivalent to |
| 88 | + * somefunction(a, b, c, d) |
| 89 | + * is equivalent to |
90 | 90 | * somefunction(a, [b, c, d]) |
91 | | - * |
| 91 | + * |
92 | 92 | * We append to 'this', which in a jQuery plugin context will be the selected elements. |
93 | 93 | * @param {String} message key |
94 | 94 | * @param {Array} optional replacements (can also specify variadically) |
— | — | @@ -102,9 +102,9 @@ |
103 | 103 | }; |
104 | 104 | }; |
105 | 105 | |
106 | | - var parserDefaults = { |
| 106 | + var parserDefaults = { |
107 | 107 | 'magic' : { |
108 | | - 'SITENAME' : mw.config.get( 'wgSiteName' ) |
| 108 | + 'SITENAME' : mw.config.get( 'wgSiteName' ) |
109 | 109 | }, |
110 | 110 | 'messages' : mw.messages, |
111 | 111 | 'language' : mw.language |
— | — | @@ -140,19 +140,19 @@ |
141 | 141 | |
142 | 142 | /** |
143 | 143 | * Fetch the message string associated with a key, return parsed structure. Memoized. |
144 | | - * Note that we pass '[' + key + ']' back for a missing message here. |
| 144 | + * Note that we pass '[' + key + ']' back for a missing message here. |
145 | 145 | * @param {String} key |
146 | 146 | * @return {String|Array} string of '[key]' if message missing, simple string if possible, array of arrays if needs parsing |
147 | 147 | */ |
148 | 148 | getAst: function( key ) { |
149 | | - if ( this.astCache[ key ] === undefined ) { |
| 149 | + if ( this.astCache[ key ] === undefined ) { |
150 | 150 | var wikiText = this.settings.messages.get( key ); |
151 | 151 | if ( typeof wikiText !== 'string' ) { |
152 | 152 | wikiText = "\\[" + key + "\\]"; |
153 | 153 | } |
154 | 154 | this.astCache[ key ] = this.wikiTextToAst( wikiText ); |
155 | 155 | } |
156 | | - return this.astCache[ key ]; |
| 156 | + return this.astCache[ key ]; |
157 | 157 | }, |
158 | 158 | |
159 | 159 | /* |
— | — | @@ -160,15 +160,15 @@ |
161 | 161 | * |
162 | 162 | * CAVEAT: This does not parse all wikitext. It could be more efficient, but it's pretty good already. |
163 | 163 | * n.b. We want to move this functionality to the server. Nothing here is required to be on the client. |
164 | | - * |
| 164 | + * |
165 | 165 | * @param {String} message string wikitext |
166 | 166 | * @throws Error |
167 | 167 | * @return {Mixed} abstract syntax tree |
168 | 168 | */ |
169 | 169 | wikiTextToAst: function( input ) { |
170 | | - |
171 | | - // Indicates current position in input as we parse through it. |
172 | | - // Shared among all parsing functions below. |
| 170 | + |
| 171 | + // Indicates current position in input as we parse through it. |
| 172 | + // Shared among all parsing functions below. |
173 | 173 | var pos = 0; |
174 | 174 | |
175 | 175 | // ========================================================= |
— | — | @@ -176,7 +176,7 @@ |
177 | 177 | // ========================================================= |
178 | 178 | |
179 | 179 | |
180 | | - // Try parsers until one works, if none work return null |
| 180 | + // Try parsers until one works, if none work return null |
181 | 181 | function choice( ps ) { |
182 | 182 | return function() { |
183 | 183 | for ( var i = 0; i < ps.length; i++ ) { |
— | — | @@ -194,12 +194,12 @@ |
195 | 195 | function sequence( ps ) { |
196 | 196 | var originalPos = pos; |
197 | 197 | var result = []; |
198 | | - for ( var i = 0; i < ps.length; i++ ) { |
| 198 | + for ( var i = 0; i < ps.length; i++ ) { |
199 | 199 | var res = ps[i](); |
200 | 200 | if ( res === null ) { |
201 | 201 | pos = originalPos; |
202 | 202 | return null; |
203 | | - } |
| 203 | + } |
204 | 204 | result.push( res ); |
205 | 205 | } |
206 | 206 | return result; |
— | — | @@ -219,7 +219,7 @@ |
220 | 220 | if ( result.length < n ) { |
221 | 221 | pos = originalPos; |
222 | 222 | return null; |
223 | | - } |
| 223 | + } |
224 | 224 | return result; |
225 | 225 | }; |
226 | 226 | } |
— | — | @@ -228,7 +228,7 @@ |
229 | 229 | // But using this as a combinator seems to cause problems when combined with nOrMore(). |
230 | 230 | // May be some scoping issue |
231 | 231 | function transform( p, fn ) { |
232 | | - return function() { |
| 232 | + return function() { |
233 | 233 | var result = p(); |
234 | 234 | return result === null ? null : fn( result ); |
235 | 235 | }; |
— | — | @@ -236,7 +236,7 @@ |
237 | 237 | |
238 | 238 | // Helpers -- just make ps out of simpler JS builtin types |
239 | 239 | |
240 | | - function makeStringParser( s ) { |
| 240 | + function makeStringParser( s ) { |
241 | 241 | var len = s.length; |
242 | 242 | return function() { |
243 | 243 | var result = null; |
— | — | @@ -249,21 +249,21 @@ |
250 | 250 | } |
251 | 251 | |
252 | 252 | function makeRegexParser( regex ) { |
253 | | - return function() { |
| 253 | + return function() { |
254 | 254 | var matches = input.substr( pos ).match( regex ); |
255 | | - if ( matches === null ) { |
| 255 | + if ( matches === null ) { |
256 | 256 | return null; |
257 | | - } |
| 257 | + } |
258 | 258 | pos += matches[0].length; |
259 | 259 | return matches[0]; |
260 | 260 | }; |
261 | 261 | } |
262 | | - |
263 | 262 | |
264 | | - /** |
265 | | - * =================================================================== |
| 263 | + |
| 264 | + /** |
| 265 | + * =================================================================== |
266 | 266 | * General patterns above this line -- wikitext specific parsers below |
267 | | - * =================================================================== |
| 267 | + * =================================================================== |
268 | 268 | */ |
269 | 269 | |
270 | 270 | // Parsing functions follow. All parsing functions work like this: |
— | — | @@ -288,7 +288,7 @@ |
289 | 289 | |
290 | 290 | function escapedLiteral() { |
291 | 291 | var result = sequence( [ |
292 | | - backslash, |
| 292 | + backslash, |
293 | 293 | anyCharacter |
294 | 294 | ] ); |
295 | 295 | return result === null ? null : result[1]; |
— | — | @@ -304,7 +304,7 @@ |
305 | 305 | regularLiteralWithoutBar |
306 | 306 | ] ); |
307 | 307 | |
308 | | - var escapedOrRegularLiteral = choice( [ |
| 308 | + var escapedOrRegularLiteral = choice( [ |
309 | 309 | escapedLiteral, |
310 | 310 | regularLiteral |
311 | 311 | ] ); |
— | — | @@ -315,7 +315,7 @@ |
316 | 316 | return result === null ? null : result.join(''); |
317 | 317 | } |
318 | 318 | |
319 | | - // Used to define "literals" within template parameters. The pipe character is the parameter delimeter, so by default |
| 319 | + // Used to define "literals" within template parameters. The pipe character is the parameter delimeter, so by default |
320 | 320 | // it is not a literal in the parameter |
321 | 321 | function literalWithoutBar() { |
322 | 322 | var result = nOrMore( 1, escapedOrLiteralWithoutBar )(); |
— | — | @@ -327,16 +327,16 @@ |
328 | 328 | return result === null ? null : result.join(''); |
329 | 329 | } |
330 | 330 | |
331 | | - var whitespace = makeRegexParser( /^\s+/ ); |
| 331 | + var whitespace = makeRegexParser( /^\s+/ ); |
332 | 332 | var dollar = makeStringParser( '$' ); |
333 | | - var digits = makeRegexParser( /^\d+/ ); |
| 333 | + var digits = makeRegexParser( /^\d+/ ); |
334 | 334 | |
335 | 335 | function replacement() { |
336 | 336 | var result = sequence( [ |
337 | 337 | dollar, |
338 | 338 | digits |
339 | 339 | ] ); |
340 | | - if ( result === null ) { |
| 340 | + if ( result === null ) { |
341 | 341 | return null; |
342 | 342 | } |
343 | 343 | return [ 'REPLACE', parseInt( result[1], 10 ) - 1 ]; |
— | — | @@ -378,7 +378,7 @@ |
379 | 379 | return result; |
380 | 380 | } |
381 | 381 | |
382 | | - var templateName = transform( |
| 382 | + var templateName = transform( |
383 | 383 | // see $wgLegalTitleChars |
384 | 384 | // not allowing : due to the need to catch "PLURAL:$1" |
385 | 385 | makeRegexParser( /^[ !"$&'()*,.\/0-9;=?@A-Z\^_`a-z~\x80-\xFF+-]+/ ), |
— | — | @@ -386,7 +386,7 @@ |
387 | 387 | ); |
388 | 388 | |
389 | 389 | function templateParam() { |
390 | | - var result = sequence( [ |
| 390 | + var result = sequence( [ |
391 | 391 | pipe, |
392 | 392 | nOrMore( 0, paramExpression ) |
393 | 393 | ] ); |
— | — | @@ -428,10 +428,10 @@ |
429 | 429 | ] ); |
430 | 430 | return res === null ? null : res[0].concat( res[1] ); |
431 | 431 | }, |
432 | | - function() { |
| 432 | + function() { |
433 | 433 | var res = sequence( [ |
434 | 434 | templateName, |
435 | | - nOrMore( 0, templateParam ) |
| 435 | + nOrMore( 0, templateParam ) |
436 | 436 | ] ); |
437 | 437 | if ( res === null ) { |
438 | 438 | return null; |
— | — | @@ -453,7 +453,7 @@ |
454 | 454 | } |
455 | 455 | |
456 | 456 | var nonWhitespaceExpression = choice( [ |
457 | | - template, |
| 457 | + template, |
458 | 458 | link, |
459 | 459 | extlink, |
460 | 460 | replacement, |
— | — | @@ -461,19 +461,19 @@ |
462 | 462 | ] ); |
463 | 463 | |
464 | 464 | var paramExpression = choice( [ |
465 | | - template, |
| 465 | + template, |
466 | 466 | link, |
467 | 467 | extlink, |
468 | 468 | replacement, |
469 | 469 | literalWithoutBar |
470 | 470 | ] ); |
471 | 471 | |
472 | | - var expression = choice( [ |
| 472 | + var expression = choice( [ |
473 | 473 | template, |
474 | 474 | link, |
475 | 475 | extlink, |
476 | 476 | replacement, |
477 | | - literal |
| 477 | + literal |
478 | 478 | ] ); |
479 | 479 | |
480 | 480 | function start() { |
— | — | @@ -490,9 +490,9 @@ |
491 | 491 | // finally let's do some actual work... |
492 | 492 | |
493 | 493 | var result = start(); |
494 | | - |
| 494 | + |
495 | 495 | /* |
496 | | - * For success, the p must have gotten to the end of the input |
| 496 | + * For success, the p must have gotten to the end of the input |
497 | 497 | * and returned a non-null. |
498 | 498 | * n.b. This is part of language infrastructure, so we do not throw an internationalizable message. |
499 | 499 | */ |
— | — | @@ -501,7 +501,7 @@ |
502 | 502 | } |
503 | 503 | return result; |
504 | 504 | } |
505 | | - |
| 505 | + |
506 | 506 | }; |
507 | 507 | |
508 | 508 | /** |
— | — | @@ -511,7 +511,7 @@ |
512 | 512 | this.language = language; |
513 | 513 | var _this = this; |
514 | 514 | |
515 | | - $.each( magic, function( key, val ) { |
| 515 | + $.each( magic, function( key, val ) { |
516 | 516 | _this[ key.toLowerCase() ] = function() { return val; }; |
517 | 517 | } ); |
518 | 518 | |
— | — | @@ -531,11 +531,11 @@ |
532 | 532 | ret = node; |
533 | 533 | break; |
534 | 534 | case 'object': // node is an array of nodes |
535 | | - var subnodes = $.map( node.slice( 1 ), function( n ) { |
| 535 | + var subnodes = $.map( node.slice( 1 ), function( n ) { |
536 | 536 | return _this.emit( n, replacements ); |
537 | 537 | } ); |
538 | 538 | var operation = node[0].toLowerCase(); |
539 | | - if ( typeof _this[operation] === 'function' ) { |
| 539 | + if ( typeof _this[operation] === 'function' ) { |
540 | 540 | ret = _this[ operation ]( subnodes, replacements ); |
541 | 541 | } else { |
542 | 542 | throw new Error( 'unknown operation "' + operation + '"' ); |
— | — | @@ -556,7 +556,7 @@ |
557 | 557 | }; |
558 | 558 | |
559 | 559 | // For everything in input that follows double-open-curly braces, there should be an equivalent parser |
560 | | - // function. For instance {{PLURAL ... }} will be processed by 'plural'. |
| 560 | + // function. For instance {{PLURAL ... }} will be processed by 'plural'. |
561 | 561 | // If you have 'magic words' then configure the parser to have them upon creation. |
562 | 562 | // |
563 | 563 | // An emitter method takes the parent node, the array of subnodes and the array of replacements (the values that $1, $2... should translate to). |
— | — | @@ -572,7 +572,7 @@ |
573 | 573 | */ |
574 | 574 | concat: function( nodes ) { |
575 | 575 | var span = $( '<span>' ).addClass( 'mediaWiki_htmlEmitter' ); |
576 | | - $.each( nodes, function( i, node ) { |
| 576 | + $.each( nodes, function( i, node ) { |
577 | 577 | if ( node instanceof jQuery && node.hasClass( 'mediaWiki_htmlEmitter' ) ) { |
578 | 578 | $.each( node.contents(), function( j, childNode ) { |
579 | 579 | span.append( childNode ); |
— | — | @@ -596,12 +596,12 @@ |
597 | 597 | */ |
598 | 598 | replace: function( nodes, replacements ) { |
599 | 599 | var index = parseInt( nodes[0], 10 ); |
600 | | - return index < replacements.length ? replacements[index] : '$' + ( index + 1 ); |
| 600 | + return index < replacements.length ? replacements[index] : '$' + ( index + 1 ); |
601 | 601 | }, |
602 | 602 | |
603 | | - /** |
| 603 | + /** |
604 | 604 | * Transform wiki-link |
605 | | - * TODO unimplemented |
| 605 | + * TODO unimplemented |
606 | 606 | */ |
607 | 607 | wlink: function( nodes ) { |
608 | 608 | return "unimplemented"; |
— | — | @@ -610,16 +610,16 @@ |
611 | 611 | /** |
612 | 612 | * Transform parsed structure into external link |
613 | 613 | * If the href is a jQuery object, treat it as "enclosing" the link text. |
614 | | - * ... function, treat it as the click handler |
615 | | - * ... string, treat it as a URI |
616 | | - * TODO: throw an error if nodes.length > 2 ? |
| 614 | + * ... function, treat it as the click handler |
| 615 | + * ... string, treat it as a URI |
| 616 | + * TODO: throw an error if nodes.length > 2 ? |
617 | 617 | * @param {Array} of two elements, {jQuery|Function|String} and {String} |
618 | 618 | * @return {jQuery} |
619 | 619 | */ |
620 | 620 | link: function( nodes ) { |
621 | 621 | var arg = nodes[0]; |
622 | 622 | var contents = nodes[1]; |
623 | | - var $el; |
| 623 | + var $el; |
624 | 624 | if ( arg instanceof jQuery ) { |
625 | 625 | $el = arg; |
626 | 626 | } else { |
— | — | @@ -630,7 +630,7 @@ |
631 | 631 | $el.attr( 'href', arg.toString() ); |
632 | 632 | } |
633 | 633 | } |
634 | | - $el.append( contents ); |
| 634 | + $el.append( contents ); |
635 | 635 | return $el; |
636 | 636 | }, |
637 | 637 | |
— | — | @@ -638,10 +638,10 @@ |
639 | 639 | * Transform parsed structure into pluralization |
640 | 640 | * n.b. The first node may be a non-integer (for instance, a string representing an Arabic number). |
641 | 641 | * So convert it back with the current language's convertNumber. |
642 | | - * @param {Array} of nodes, [ {String|Number}, {String}, {String} ... ] |
| 642 | + * @param {Array} of nodes, [ {String|Number}, {String}, {String} ... ] |
643 | 643 | * @return {String} selected pluralized form according to current language |
644 | 644 | */ |
645 | | - plural: function( nodes ) { |
| 645 | + plural: function( nodes ) { |
646 | 646 | var count = parseInt( this.language.convertNumber( nodes[0], true ), 10 ); |
647 | 647 | var forms = nodes.slice(1); |
648 | 648 | return forms.length ? this.language.convertPlural( count, forms ) : ''; |
— | — | @@ -650,12 +650,12 @@ |
651 | 651 | /** |
652 | 652 | * Transform parsed structure into gender |
653 | 653 | * Usage {{gender:[gender| mw.user object ] | masculine|feminine|neutral}}. |
654 | | - * @param {Array} of nodes, [ {String|mw.User}, {String}, {String} , {String} ] |
| 654 | + * @param {Array} of nodes, [ {String|mw.User}, {String}, {String} , {String} ] |
655 | 655 | * @return {String} selected gender form according to current language |
656 | 656 | */ |
657 | | - gender: function( nodes ) { |
| 657 | + gender: function( nodes ) { |
658 | 658 | var gender; |
659 | | - if ( nodes[0] && nodes[0].options instanceof mw.Map ){ |
| 659 | + if ( nodes[0] && nodes[0].options instanceof mw.Map ){ |
660 | 660 | gender = nodes[0].options.get( 'gender' ); |
661 | 661 | } else { |
662 | 662 | gender = nodes[0]; |
— | — | @@ -666,10 +666,10 @@ |
667 | 667 | /** |
668 | 668 | * Transform parsed structure into grammar conversion. |
669 | 669 | * Invoked by putting {{grammar:form|word}} in a message |
670 | | - * @param {Array} of nodes [{Grammar case eg: genitive}, {String word}] |
| 670 | + * @param {Array} of nodes [{Grammar case eg: genitive}, {String word}] |
671 | 671 | * @return {String} selected grammatical form according to current language |
672 | 672 | */ |
673 | | - grammar: function( nodes ) { |
| 673 | + grammar: function( nodes ) { |
674 | 674 | var form = nodes[0]; |
675 | 675 | var word = nodes[1]; |
676 | 676 | return this.language.convertGrammar( word , form ); |
— | — | @@ -682,23 +682,23 @@ |
683 | 683 | // deprecated! don't rely on gM existing. |
684 | 684 | // the window.gM ought not to be required - or if required, not required here. But moving it to extensions breaks it (?!) |
685 | 685 | // Need to fix plugin so it could do attributes as well, then will be okay to remove this. |
686 | | - window.gM = mw.jqueryMsg.getMessageFunction(); |
| 686 | + window.gM = mw.jqueryMsg.getMessageFunction(); |
687 | 687 | |
688 | 688 | $.fn.msg = mw.jqueryMsg.getPlugin(); |
689 | | - |
| 689 | + |
690 | 690 | // Replace the default message parser with jqueryMsg |
691 | 691 | var oldParser = mw.Message.prototype.parser; |
692 | 692 | mw.Message.prototype.parser = function() { |
693 | 693 | // TODO: should we cache the message function so we don't create a new one every time? Benchmark this maybe? |
694 | 694 | // Caching is somewhat problematic, because we do need different message functions for different maps, so |
695 | 695 | // we'd have to cache the parser as a member of this.map, which sounds a bit ugly. |
696 | | - |
| 696 | + |
697 | 697 | // Do not use mw.jqueryMsg unless required |
698 | 698 | if ( this.map.get( this.key ).indexOf( '{{' ) < 0 ) { |
699 | 699 | // Fall back to mw.msg's simple parser |
700 | 700 | return oldParser.apply( this ); |
701 | 701 | } |
702 | | - |
| 702 | + |
703 | 703 | var messageFunction = mw.jqueryMsg.getMessageFunction( { 'messages': this.map } ); |
704 | 704 | return messageFunction( this.key, this.parameters ); |
705 | 705 | }; |