Merge "Follow-up 9c9cfa2ec3d7: fix non-session entry point error"
[lhc/web/wiklou.git] / resources / src / mediawiki.util.js
index 27031f1..56bfc42 100644 (file)
@@ -1,7 +1,9 @@
 ( function () {
        'use strict';
 
-       var util;
+       var util,
+               config = require( './config.json' ),
+               origConfig = config;
 
        /**
         * Encode the string like PHP's rawurlencode
 
                /* Main body */
 
+               setOptionsForTest: function ( opts ) {
+                       if ( !window.QUnit ) {
+                               throw new Error( 'Modifying options not allowed outside unit tests' );
+                       }
+                       config = $.extend( {}, config, opts );
+               },
+
+               resetOptionsForTest: function () {
+                       if ( !window.QUnit ) {
+                               throw new Error( 'Resetting options not allowed outside unit tests' );
+                       }
+                       config = origConfig;
+               },
+
                /**
                 * Encode the string like PHP's rawurlencode
                 *
@@ -68,7 +84,7 @@
                 * @return {string} Encoded string
                 */
                escapeIdForAttribute: function ( str ) {
-                       var mode = mw.config.get( 'wgFragmentMode' )[ 0 ];
+                       var mode = config.FragmentMode[ 0 ];
 
                        return escapeIdInternal( str, mode );
                },
@@ -83,7 +99,7 @@
                 * @return {string} Encoded string
                 */
                escapeIdForLink: function ( str ) {
-                       var mode = mw.config.get( 'wgFragmentMode' )[ 0 ];
+                       var mode = config.FragmentMode[ 0 ];
 
                        return escapeIdInternal( str, mode );
                },
                        if ( str === 'index' ) {
                                return mw.config.get( 'wgScript' );
                        } else if ( str === 'load' ) {
-                               return mw.config.get( 'wgLoadScript' );
+                               return config.LoadScript;
                        } else {
                                return mw.config.get( 'wgScriptPath' ) + '/' + str + '.php';
                        }
                }
        };
 
-       /**
-        * Add a little box at the top of the screen to inform the user of
-        * something, replacing any previous message.
-        * Calling with no arguments, with an empty string or null will hide the message
-        *
-        * @method jsMessage
-        * @deprecated since 1.20 Use mw#notify
-        * @param {Mixed} message The DOM-element, jQuery object or HTML-string to be put inside the message box.
-        *  to allow CSS/JS to hide different boxes. null = no class used.
-        */
-       mw.log.deprecate( util, 'jsMessage', function ( message ) {
-               if ( !arguments.length || message === '' || message === null ) {
-                       return true;
-               }
-               if ( typeof message !== 'object' ) {
-                       message = $.parseHTML( message );
-               }
-               mw.notify( message, { autoHide: true, tag: 'legacy' } );
-               return true;
-       }, 'Use mw.notify instead.', 'mw.util.jsMessage' );
-
        /**
         * Initialisation of mw.util.$content
         */