Merge "Add unit tests for ChangeTags::modifyDisplayQuery()"
[lhc/web/wiklou.git] / resources / src / mediawiki / mediawiki.util.js
index 78634f6..4844e21 100644 (file)
@@ -8,42 +8,6 @@
         */
        var util = {
 
-               /**
-                * Initialisation
-                * (don't call before document ready)
-                */
-               init: function () {
-                       util.$content = ( function () {
-                               var i, l, $node, selectors;
-
-                               selectors = [
-                                       // The preferred standard is class "mw-body".
-                                       // You may also use class "mw-body mw-body-primary" if you use
-                                       // mw-body in multiple locations. Or class "mw-body-primary" if
-                                       // you use mw-body deeper in the DOM.
-                                       '.mw-body-primary',
-                                       '.mw-body',
-
-                                       // If the skin has no such class, fall back to the parser output
-                                       '#mw-content-text',
-
-                                       // Should never happen... well, it could if someone is not finished writing a
-                                       // skin and has not yet inserted bodytext yet.
-                                       'body'
-                               ];
-
-                               for ( i = 0, l = selectors.length; i < l; i++ ) {
-                                       $node = $( selectors[ i ] );
-                                       if ( $node.length ) {
-                                               return $node.first();
-                                       }
-                               }
-
-                               // Preserve existing customized value in case it was preset
-                               return util.$content;
-                       }() );
-               },
-
                /* Main body */
 
                /**
                 * This function returns the styleSheet object for convience (due to cross-browsers
                 * difference as to where it is located).
                 *
-                *     var sheet = mw.util.addCSS( '.foobar { display: none; }' );
+                *     var sheet = util.addCSS( '.foobar { display: none; }' );
                 *     $( foo ).click( function () {
                 *         // Toggle the sheet on and off
                 *         sheet.disabled = !sheet.disabled;
                /**
                 * The content wrapper of the skin (e.g. `.mw-body`).
                 *
-                * Populated on document ready by #init. To use this property,
-                * wait for `$.ready` and be sure to have a module depedendency on
-                * `mediawiki.util` and `mediawiki.page.startup` which will ensure
-                * your document ready handler fires after #init.
+                * Populated on document ready. To use this property,
+                * wait for `$.ready` and be sure to have a module dependency on
+                * `mediawiki.util` which will ensure
+                * your document ready handler fires after initialization.
                 *
                 * Because of the lazy-initialised nature of this property,
                 * you're discouraged from using it.
                 * (e.g. `document.getElementById( 'foobar' )`) or a jQuery-selector
                 * (e.g. `'#foobar'`) for that item.
                 *
-                *     mw.util.addPortletLink(
+                *     util.addPortletLink(
                 *         'p-tb', 'https://www.mediawiki.org/',
                 *         'mediawiki.org', 't-mworg', 'Go to mediawiki.org', 'm', '#t-print'
                 *     );
                 *
-                *     var node = mw.util.addPortletLink(
+                *     var node = util.addPortletLink(
                 *         'p-tb',
                 *         new mw.Title( 'Special:Example' ).getUrl(),
                 *         'Example'
                        block = allowBlock ? '(?:\\/(?:12[0-8]|1[01][0-9]|[1-9]?\\d))?' : '';
                        RE_IPV6_ADD =
                                '(?:' + // starts with "::" (including "::")
-                               ':(?::|(?::' + '[0-9A-Fa-f]{1,4}' + '){1,7})' +
-                               '|' + // ends with "::" (except "::")
-                               '[0-9A-Fa-f]{1,4}' + '(?::' + '[0-9A-Fa-f]{1,4}' + '){0,6}::' +
-                               '|' + // contains no "::"
-                               '[0-9A-Fa-f]{1,4}' + '(?::' + '[0-9A-Fa-f]{1,4}' + '){7}' +
+                                       ':(?::|(?::' +
+                                               '[0-9A-Fa-f]{1,4}' +
+                                       '){1,7})' +
+                                       '|' + // ends with "::" (except "::")
+                                       '[0-9A-Fa-f]{1,4}' +
+                                       '(?::' +
+                                               '[0-9A-Fa-f]{1,4}' +
+                                       '){0,6}::' +
+                                       '|' + // contains no "::"
+                                       '[0-9A-Fa-f]{1,4}' +
+                                       '(?::' +
+                                               '[0-9A-Fa-f]{1,4}' +
+                                       '){7}' +
                                ')';
 
                        if ( new RegExp( '^' + RE_IPV6_ADD + block + '$' ).test( address ) ) {
                        }
 
                        // contains one "::" in the middle (single '::' check below)
-                       RE_IPV6_ADD = '[0-9A-Fa-f]{1,4}' + '(?:::?' + '[0-9A-Fa-f]{1,4}' + '){1,6}';
+                       RE_IPV6_ADD =
+                               '[0-9A-Fa-f]{1,4}' +
+                               '(?:::?' +
+                                       '[0-9A-Fa-f]{1,4}' +
+                               '){1,6}';
 
                        return (
                                new RegExp( '^' + RE_IPV6_ADD + block + '$' ).test( address ) &&
                return true;
        }, 'Use mw.notify instead.' );
 
+       /**
+        * Initialisation of mw.util.$content
+        */
+       function init() {
+               util.$content = ( function () {
+                       var i, l, $node, selectors;
+
+                       selectors = [
+                               // The preferred standard is class "mw-body".
+                               // You may also use class "mw-body mw-body-primary" if you use
+                               // mw-body in multiple locations. Or class "mw-body-primary" if
+                               // you use mw-body deeper in the DOM.
+                               '.mw-body-primary',
+                               '.mw-body',
+
+                               // If the skin has no such class, fall back to the parser output
+                               '#mw-content-text'
+                       ];
+
+                       for ( i = 0, l = selectors.length; i < l; i++ ) {
+                               $node = $( selectors[ i ] );
+                               if ( $node.length ) {
+                                       return $node.first();
+                               }
+                       }
+
+                       // Should never happen... well, it could if someone is not finished writing a
+                       // skin and has not yet inserted bodytext yet.
+                       return $( 'body' );
+               }() );
+       }
+
+       /**
+        * Former public initialisation. Now a no-op function.
+        *
+        * @method util_init
+        * @deprecated since 1.30
+        */
+       mw.log.deprecate( util, 'init', $.noop, 'Remove the call of mw.util.init().', 'mw.util.init' );
+
+       $( init );
+
        mw.util = util;
+       module.exports = util;
 
 }( mediaWiki, jQuery ) );