Merge "rdbms: fix LBFactory::commitAll() round handling"
[lhc/web/wiklou.git] / resources / src / mediawiki / mediawiki.jqueryMsg.js
index ea91afe..d81df65 100644 (file)
@@ -60,7 +60,7 @@
         * Wrapper around jQuery append that converts all non-objects to TextNode so append will not
         * convert what it detects as an htmlString to an element.
         *
-        * If our own htmlEmitter jQuery object is given, its children will be unwrapped and appended to
+        * If our own HtmlEmitter jQuery object is given, its children will be unwrapped and appended to
         * new parent.
         *
         * Object elements of children (jQuery, HTMLElement, TextNode, etc.) will be left as is.
        function getFailableParserFn( options ) {
                return function ( args ) {
                        var fallback,
-                               // eslint-disable-next-line new-cap
-                               parser = new mw.jqueryMsg.parser( options ),
+                               parser = new mw.jqueryMsg.Parser( options ),
                                key = args[ 0 ],
                                argsArray = Array.isArray( args[ 1 ] ) ? args[ 1 ] : slice.call( args, 1 );
                        try {
         *
         * ResourceLoaderJqueryMsgModule calls this to provide default values from
         * Sanitizer.php for allowed HTML elements. To override this data for individual
-        * parsers, pass the relevant options to mw.jqueryMsg.parser.
+        * parsers, pass the relevant options to mw.jqueryMsg.Parser.
         *
         * @private
         * @param {Object} data New data to extend parser defaults with
        };
 
        /**
-        * Returns a function suitable for use as a global, to construct strings from the message key (and optional replacements).
-        * e.g.
+        * Returns a function suitable for static use, to construct strings from a message key (and optional replacements).
+        *
+        * Example:
         *
-        *       window.gM = mediaWiki.jqueryMsg.getMessageFunction( options );
-        *       $( 'p#headline' ).html( gM( 'hello-user', username ) );
+        *       var format = mediaWiki.jqueryMsg.getMessageFunction( options );
+        *       $( '#example' ).text( format( 'hello-user', username ) );
         *
-        * Like the old gM() function this returns only strings, so it destroys any bindings. If you want to preserve bindings use the
-        * jQuery plugin version instead. This is only included for backwards compatibility with gM().
+        * Tthis returns only strings, so it destroys any bindings. If you want to preserve bindings, use the
+        * jQuery plugin version instead. This was originally created to ease migration from `window.gM()`,
+        * from a time when the parser used by `mw.message` was not extendable.
         *
         * N.B. replacements are variadic arguments or an array in second parameter. In other words:
         *    somefunction( a, b, c, d )
         *    somefunction( a, [b, c, d] )
         *
         * @param {Object} options parser options
-        * @return {Function} Function suitable for assigning to window.gM
+        * @return {Function} Function The message formatter
         * @return {string} return.key Message key.
         * @return {Array|Mixed} return.replacements Optional variable replacements (variadically or an array).
         * @return {string} return.return Rendered HTML.
         * @private
         * @param {Object} options
         */
-       mw.jqueryMsg.parser = function ( options ) {
+       mw.jqueryMsg.Parser = function ( options ) {
                this.settings = $.extend( {}, parserDefaults, options );
                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 );
        };
+       // Backwards-compatible alias
+       // @deprecated since 1.31
+       mw.jqueryMsg.parser = mw.jqueryMsg.Parser;
 
-       mw.jqueryMsg.parser.prototype = {
+       mw.jqueryMsg.Parser.prototype = {
                /**
                 * Where the magic happens.
                 * Parses a message from the key, and swaps in replacements as necessary, wraps in jQuery
        };
 
        /**
-        * htmlEmitter - object which primarily exists to emit HTML from parser ASTs
+        * Class that primarily exists to emit HTML from parser ASTs.
         *
+        * @private
+        * @class
         * @param {Object} language
         * @param {Object} magic
         */
-       mw.jqueryMsg.htmlEmitter = function ( language, magic ) {
+       mw.jqueryMsg.HtmlEmitter = function ( language, magic ) {
                var jmsg = this;
                this.language = language;
                $.each( magic, function ( key, val ) {
        //
        // An emitter method takes the parent node, the array of subnodes and the array of replacements (the values that $1, $2... should translate to).
        // Note: all such functions must be pure, with the exception of referring to other pure functions via this.language (convertPlural and so on)
-       mw.jqueryMsg.htmlEmitter.prototype = {
+       mw.jqueryMsg.HtmlEmitter.prototype = {
                /**
                 * Parsing has been applied depth-first we can assume that all nodes here are single nodes
                 * Must return a single node to parents -- a jQuery with synthetic span
                 * The "href" can be:
                 * - a jQuery object, treat it as "enclosing" the link text.
                 * - a function, treat it as the click handler.
-                * - a string, or our htmlEmitter jQuery object, treat it as a URI after stringifying.
+                * - a string, or our HtmlEmitter jQuery object, treat it as a URI after stringifying.
                 *
                 * TODO: throw an error if nodes.length > 2 ?
                 *
                }
        };
 
-       // Deprecated! don't rely on gM existing.
-       // The window.gM ought not to be required - or if required, not required here.
-       // But moving it to extensions breaks it (?!)
-       // Need to fix plugin so it could do attributes as well, then will be okay to remove this.
-       // @deprecated since 1.23
-       mw.log.deprecate( window, 'gM', mw.jqueryMsg.getMessageFunction(), 'Use mw.message( ... ).parse() instead.' );
-
        /**
         * @method
         * @member jQuery