From d9022f63880ce039446fba8364f68e656b7bf4cb Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Thu, 3 May 2012 13:01:35 +0200 Subject: Update to MediaWiki 1.19.0 --- resources/mediawiki/mediawiki.Uri.js | 327 +-- resources/mediawiki/mediawiki.debug.css | 185 ++ resources/mediawiki/mediawiki.debug.init.js | 3 + resources/mediawiki/mediawiki.debug.js | 351 +++ resources/mediawiki/mediawiki.feedback.css | 9 + resources/mediawiki/mediawiki.feedback.js | 242 ++ resources/mediawiki/mediawiki.feedback.spinner.gif | Bin 0 -> 1108 bytes resources/mediawiki/mediawiki.htmlform.js | 6 +- resources/mediawiki/mediawiki.jqueryMsg.js | 685 ++++++ resources/mediawiki/mediawiki.jqueryMsg.peg | 76 + resources/mediawiki/mediawiki.js | 2342 +++++++++++--------- resources/mediawiki/mediawiki.log.js | 95 +- resources/mediawiki/mediawiki.user.js | 12 +- resources/mediawiki/mediawiki.util.js | 410 ++-- 14 files changed, 3297 insertions(+), 1446 deletions(-) create mode 100644 resources/mediawiki/mediawiki.debug.css create mode 100644 resources/mediawiki/mediawiki.debug.init.js create mode 100644 resources/mediawiki/mediawiki.debug.js create mode 100644 resources/mediawiki/mediawiki.feedback.css create mode 100644 resources/mediawiki/mediawiki.feedback.js create mode 100644 resources/mediawiki/mediawiki.feedback.spinner.gif create mode 100644 resources/mediawiki/mediawiki.jqueryMsg.js create mode 100644 resources/mediawiki/mediawiki.jqueryMsg.peg (limited to 'resources/mediawiki') diff --git a/resources/mediawiki/mediawiki.Uri.js b/resources/mediawiki/mediawiki.Uri.js index 7ff8dda4..26fdfa9e 100644 --- a/resources/mediawiki/mediawiki.Uri.js +++ b/resources/mediawiki/mediawiki.Uri.js @@ -56,7 +56,7 @@ * */ -( function( $ ) { +( function( $, mw ) { /** * Function that's useful when constructing the URI string -- we frequently encounter the pattern of @@ -89,172 +89,213 @@ 'host', // www.test.com 'port', // 81 'path', // /dir/dir.2/index.htm - 'query', // q1=0&&test1&test2=value (will become { q1: 0, test1: '', test2: 'value' } ) + 'query', // q1=0&&test1&test2=value (will become { q1: '0', test1: '', test2: 'value' } ) 'fragment' // top ]; - /** - * Constructs URI object. Throws error if arguments are illegal/impossible, or otherwise don't parse. - * @constructor - * @param {!Object|String} URI string, or an Object with appropriate properties (especially another URI object to clone). Object must have non-blank 'protocol', 'host', and 'path' properties. - * @param {Boolean} strict mode (when parsing a string) - */ - mw.Uri = function( uri, strictMode ) { - strictMode = !!strictMode; - if ( uri !== undefined && uri !== null || uri !== '' ) { - if ( typeof uri === 'string' ) { - this._parse( uri, strictMode ); - } else if ( typeof uri === 'object' ) { - var _this = this; - $.each( properties, function( i, property ) { - _this[property] = uri[property]; - } ); - if ( this.query === undefined ) { - this.query = {}; - } - } - } - if ( !( this.protocol && this.host && this.path ) ) { - throw new Error( 'Bad constructor arguments' ); - } - }; /** - * Standard encodeURIComponent, with extra stuff to make all browsers work similarly and more compliant with RFC 3986 - * Similar to rawurlencode from PHP and our JS library mw.util.rawurlencode, but we also replace space with a + - * @param {String} string - * @return {String} encoded for URI + * We use a factory to inject a document location, for relative URLs, including protocol-relative URLs. + * so the library is still testable & purely functional. */ - mw.Uri.encode = function( s ) { - return encodeURIComponent( s ) - .replace( /!/g, '%21').replace( /'/g, '%27').replace( /\(/g, '%28') - .replace( /\)/g, '%29').replace( /\*/g, '%2A') - .replace( /%20/g, '+' ); - }; - - /** - * Standard decodeURIComponent, with '+' to space - * @param {String} string encoded for URI - * @return {String} decoded string - */ - mw.Uri.decode = function( s ) { - return decodeURIComponent( s ).replace( /\+/g, ' ' ); - }; - - mw.Uri.prototype = { + mw.UriRelative = function( documentLocation ) { /** - * Parse a string and set our properties accordingly. - * @param {String} URI - * @param {Boolean} strictness - * @return {Boolean} success + * Constructs URI object. Throws error if arguments are illegal/impossible, or otherwise don't parse. + * @constructor + * @param {Object|String} URI string, or an Object with appropriate properties (especially another URI object to clone). + * Object must have non-blank 'protocol', 'host', and 'path' properties. + * @param {Object|Boolean} Object with options, or (backwards compatibility) a boolean for strictMode + * - strictMode {Boolean} Trigger strict mode parsing of the url. Default: false + * - overrideKeys {Boolean} Wether to let duplicate query parameters override eachother (true) or automagically + * convert to an array (false, default). */ - _parse: function( str, strictMode ) { - var matches = parser[ strictMode ? 'strict' : 'loose' ].exec( str ); - var uri = this; - $.each( properties, function( i, property ) { - uri[ property ] = matches[ i+1 ]; - } ); + function Uri( uri, options ) { + options = typeof options === 'object' ? options : { strictMode: !!options }; + options = $.extend( { + strictMode: false, + overrideKeys: false + }, options ); - // uri.query starts out as the query string; we will parse it into key-val pairs then make - // that object the "query" property. - // we overwrite query in uri way to make cloning easier, it can use the same list of properties. - var q = {}; - // using replace to iterate over a string - if ( uri.query ) { - uri.query.replace( /(?:^|&)([^&=]*)(?:(=)([^&]*))?/g, function ($0, $1, $2, $3) { - if ( $1 ) { - var k = mw.Uri.decode( $1 ); - var v = ( $2 === '' || $2 === undefined ) ? null : mw.Uri.decode( $3 ); - if ( typeof q[ k ] === 'string' ) { - q[ k ] = [ q[ k ] ]; - } - if ( typeof q[ k ] === 'object' ) { - q[ k ].push( v ); - } else { - q[ k ] = v; - } + if ( uri !== undefined && uri !== null || uri !== '' ) { + if ( typeof uri === 'string' ) { + this._parse( uri, options ); + } else if ( typeof uri === 'object' ) { + var _this = this; + $.each( properties, function( i, property ) { + _this[property] = uri[property]; + } ); + if ( this.query === undefined ) { + this.query = {}; } - } ); + } } - this.query = q; - }, - /** - * Returns user and password portion of a URI. - * @return {String} - */ - getUserInfo: function() { - return cat( '', this.user, cat( ':', this.password, '' ) ); - }, + // protocol-relative URLs + if ( !this.protocol ) { + this.protocol = defaultProtocol; + } - /** - * Gets host and port portion of a URI. - * @return {String} - */ - getHostPort: function() { - return this.host + cat( ':', this.port, '' ); - }, + if ( !( this.protocol && this.host && this.path ) ) { + throw new Error( 'Bad constructor arguments' ); + } + } /** - * Returns the userInfo and host and port portion of the URI. - * In most real-world URLs, this is simply the hostname, but it is more general. - * @return {String} + * Standard encodeURIComponent, with extra stuff to make all browsers work similarly and more compliant with RFC 3986 + * Similar to rawurlencode from PHP and our JS library mw.util.rawurlencode, but we also replace space with a + + * @param {String} string + * @return {String} encoded for URI */ - getAuthority: function() { - return cat( '', this.getUserInfo(), '@' ) + this.getHostPort(); - }, + Uri.encode = function( s ) { + return encodeURIComponent( s ) + .replace( /!/g, '%21').replace( /'/g, '%27').replace( /\(/g, '%28') + .replace( /\)/g, '%29').replace( /\*/g, '%2A') + .replace( /%20/g, '+' ); + }; /** - * Returns the query arguments of the URL, encoded into a string - * Does not preserve the order of arguments passed into the URI. Does handle escaping. - * @return {String} + * Standard decodeURIComponent, with '+' to space + * @param {String} string encoded for URI + * @return {String} decoded string */ - getQueryString: function() { - var args = []; - $.each( this.query, function( key, val ) { - var k = mw.Uri.encode( key ); - var vals = val === null ? [ null ] : $.makeArray( val ); - $.each( vals, function( i, v ) { - args.push( k + ( v === null ? '' : '=' + mw.Uri.encode( v ) ) ); + Uri.decode = function( s ) { + return decodeURIComponent( s.replace( /\+/g, '%20' ) ); + }; + + Uri.prototype = { + + /** + * Parse a string and set our properties accordingly. + * @param {String} URI + * @param {Object} options + * @return {Boolean} success + */ + _parse: function( str, options ) { + var matches = parser[ options.strictMode ? 'strict' : 'loose' ].exec( str ); + var uri = this; + $.each( properties, function( i, property ) { + uri[ property ] = matches[ i+1 ]; } ); - } ); - return args.join( '&' ); - }, - /** - * Returns everything after the authority section of the URI - * @return {String} - */ - getRelativePath: function() { - return this.path + cat( '?', this.getQueryString(), '', true ) + cat( '#', this.fragment, '' ); - }, + // uri.query starts out as the query string; we will parse it into key-val pairs then make + // that object the "query" property. + // we overwrite query in uri way to make cloning easier, it can use the same list of properties. + var q = {}; + // using replace to iterate over a string + if ( uri.query ) { + uri.query.replace( /(?:^|&)([^&=]*)(?:(=)([^&]*))?/g, function ($0, $1, $2, $3) { + if ( $1 ) { + var k = Uri.decode( $1 ); + var v = ( $2 === '' || $2 === undefined ) ? null : Uri.decode( $3 ); - /** - * Gets the entire URI string. May not be precisely the same as input due to order of query arguments. - * @return {String} the URI string - */ - toString: function() { - return this.protocol + '://' + this.getAuthority() + this.getRelativePath(); - }, + // If overrideKeys, always (re)set top level value. + // If not overrideKeys but this key wasn't set before, then we set it as well. + if ( options.overrideKeys || q[ k ] === undefined ) { + q[ k ] = v; - /** - * Clone this URI - * @return {Object} new URI object with same properties - */ - clone: function() { - return new mw.Uri( this ); - }, + // Use arrays if overrideKeys is false and key was already seen before + } else { + // Once before, still a string, turn into an array + if ( typeof q[ k ] === 'string' ) { + q[ k ] = [ q[ k ] ]; + } + // Add to the array + if ( $.isArray( q[ k ] ) ) { + q[ k ].push( v ); + } + } + } + } ); + } + this.query = q; + }, - /** - * Extend the query -- supply query parameters to override or add to ours - * @param {Object} query parameters in key-val form to override or add - * @return {Object} this URI object - */ - extend: function( parameters ) { - $.extend( this.query, parameters ); - return this; - } + /** + * Returns user and password portion of a URI. + * @return {String} + */ + getUserInfo: function() { + return cat( '', this.user, cat( ':', this.password, '' ) ); + }, + + /** + * Gets host and port portion of a URI. + * @return {String} + */ + getHostPort: function() { + return this.host + cat( ':', this.port, '' ); + }, + + /** + * Returns the userInfo and host and port portion of the URI. + * In most real-world URLs, this is simply the hostname, but it is more general. + * @return {String} + */ + getAuthority: function() { + return cat( '', this.getUserInfo(), '@' ) + this.getHostPort(); + }, + + /** + * Returns the query arguments of the URL, encoded into a string + * Does not preserve the order of arguments passed into the URI. Does handle escaping. + * @return {String} + */ + getQueryString: function() { + var args = []; + $.each( this.query, function( key, val ) { + var k = Uri.encode( key ); + var vals = val === null ? [ null ] : $.makeArray( val ); + $.each( vals, function( i, v ) { + args.push( k + ( v === null ? '' : '=' + Uri.encode( v ) ) ); + } ); + } ); + return args.join( '&' ); + }, + + /** + * Returns everything after the authority section of the URI + * @return {String} + */ + getRelativePath: function() { + return this.path + cat( '?', this.getQueryString(), '', true ) + cat( '#', this.fragment, '' ); + }, + + /** + * Gets the entire URI string. May not be precisely the same as input due to order of query arguments. + * @return {String} the URI string + */ + toString: function() { + return this.protocol + '://' + this.getAuthority() + this.getRelativePath(); + }, + + /** + * Clone this URI + * @return {Object} new URI object with same properties + */ + clone: function() { + return new Uri( this ); + }, + + /** + * Extend the query -- supply query parameters to override or add to ours + * @param {Object} query parameters in key-val form to override or add + * @return {Object} this URI object + */ + extend: function( parameters ) { + $.extend( this.query, parameters ); + return this; + } + }; + + var defaultProtocol = ( new Uri( documentLocation ) ).protocol; + + return Uri; }; -} )( jQuery ); + // if we are running in a browser, inject the current document location, for relative URLs + if ( document && document.location && document.location.href ) { + mw.Uri = mw.UriRelative( document.location.href ); + } + +} )( jQuery, mediaWiki ); diff --git a/resources/mediawiki/mediawiki.debug.css b/resources/mediawiki/mediawiki.debug.css new file mode 100644 index 00000000..923d4a47 --- /dev/null +++ b/resources/mediawiki/mediawiki.debug.css @@ -0,0 +1,185 @@ +.mw-debug { + width: 100%; + text-align: left; + background-color: #eee; + border-top: 1px solid #aaa; +} + +.mw-debug pre { + font-family: Monaco, "Consolas", "Lucida Console", "Courier New", monospace; + font-size: 11px; + padding: 0; + margin: 0; + background: none; + border: none; +} + +.mw-debug table { + border-spacing: 0; + width: 100%; + table-layout: fixed; +} + +.mw-debug table tr { + background-color: #fff; +} + +.mw-debug table tr:nth-child(even) { + background-color: #f9f9f9; +} + +.mw-debug table td, .mw-debug table th { + padding: 4px 10px; +} + +.mw-debug table td { + border-bottom: 1px solid #eee; + word-wrap: break-word; +} + +.mw-debug table td.nr { + text-align: right; +} + +.mw-debug table td span.stats { + color: #808080; +} + +.mw-debug ul { + margin: 0; + list-style: none; +} + +.mw-debug li { + padding: 4px 0; + width: 100%; +} + +.mw-debug-bits { + text-align: center; + border-bottom: 1px solid #aaa; +} + +.mw-debug-bit { + display: inline-block; + padding: 10px 5px; + font-size: 13px; + /* IE-hack for display: inline-block */ + zoom: 1; + *display:inline; +} + +.mw-debug-panelink { + background-color: #eee; + border-right: 1px solid #ccc; +} + +.mw-debug-panelink:first-child { + border-left: 1px solid #ccc; +} + +.mw-debug-panelink:hover { + background-color: #fefefe; + cursor: pointer; +} +.mw-debug-panelink.current { + background-color: #dedede; + +} +a.mw-debug-panelabel, +a.mw-debug-panelabel:visited { + color: #000; +} + +.mw-debug-pane { + height: 300px; + overflow: scroll; + display: none; + font-size: 11px; + background-color: #e1eff2; + box-sizing: border-box; +} + +#mw-debug-pane-debuglog, +#mw-debug-pane-request { + padding: 20px; +} + +#mw-debug-pane-request table { + width: 100%; + margin: 10px 0 30px; +} + +#mw-debug-pane-request tr, +#mw-debug-pane-request th, +#mw-debug-pane-request td, +#mw-debug-pane-request table { + border: 1px solid #D0DBB3; + border-collapse: collapse; + margin: 0; +} + +#mw-debug-pane-request th, +#mw-debug-pane-request td { + font-size: 12px; + padding: 8px 10px; +} + +#mw-debug-pane-request th { + background-color: #F1F7E2; + font-weight: bold; +} + +#mw-debug-pane-request td { + background-color: white; +} + +#mw-debug-console tr td:first-child { + font-weight: bold; + vertical-align: top; +} + +#mw-debug-console tr td:last-child { + vertical-align: top; +} + +.mw-debug-console-log { + background-color: #add8e6; +} + +.mw-debug-console-warn { + background-color: #ffa07a; +} + +.mw-debug-console-deprecated { + background-color: #ffb6c1; +} + +.mw-debug-backtrace { + padding: 5px 10px; + margin: 5px; + background-color: #dedede; +} + +.mw-debug-backtrace span { + font-weight: bold; + color: #111; +} + +.mw-debug-backtrace ul { + padding-left: 10px; +} + +.mw-debug-backtrace li { + width: auto; + padding: 0; + color: #333; + font-size: 10px; + margin-bottom: 0; + line-height: 1em; +} + +/* Cheapo hack to hide the first 3 lines of the backtrace */ +.mw-debug-backtrace li:nth-child(-n+3) { + display: none; +} diff --git a/resources/mediawiki/mediawiki.debug.init.js b/resources/mediawiki/mediawiki.debug.init.js new file mode 100644 index 00000000..0f85e80d --- /dev/null +++ b/resources/mediawiki/mediawiki.debug.init.js @@ -0,0 +1,3 @@ +jQuery( function () { + mediaWiki.Debug.init(); +} ); diff --git a/resources/mediawiki/mediawiki.debug.js b/resources/mediawiki/mediawiki.debug.js new file mode 100644 index 00000000..a2bfbcbe --- /dev/null +++ b/resources/mediawiki/mediawiki.debug.js @@ -0,0 +1,351 @@ +/** + * JavaScript for the new debug toolbar, enabled through $wgDebugToolbar. + * + * @author John Du Hart + * @since 1.19 + */ + +( function ( $, mw, undefined ) { +"use strict"; + + var hovzer = $.getFootHovzer(); + + var debug = mw.Debug = { + /** + * Toolbar container element + * + * @var {jQuery} + */ + $container: null, + + /** + * Object containing data for the debug toolbar + * + * @var {Object} + */ + data: {}, + + /** + * Initializes the debugging pane. + * Shouldn't be called before the document is ready + * (since it binds to elements on the page). + * + * @param {Object} data, defaults to 'debugInfo' from mw.config + */ + init: function ( data ) { + + this.data = data || mw.config.get( 'debugInfo' ); + this.buildHtml(); + + // Insert the container into the DOM + hovzer.$.append( this.$container ); + hovzer.update(); + + $( '.mw-debug-panelink' ).click( this.switchPane ); + }, + + /** + * Switches between panes + * + * @todo Store cookie for last pane open + * @context {Element} + * @param {jQuery.Event} e + */ + switchPane: function ( e ) { + var currentPaneId = debug.$container.data( 'currentPane' ), + requestedPaneId = $(this).prop( 'id' ).substr( 9 ), + $currentPane = $( '#mw-debug-pane-' + currentPaneId ), + $requestedPane = $( '#mw-debug-pane-' + requestedPaneId ), + hovDone = false; + + function updateHov() { + if ( !hovDone ) { + hovzer.update(); + hovDone = true; + } + } + + // Skip hash fragment handling. Prevents screen from jumping. + e.preventDefault(); + + $( this ).addClass( 'current '); + $( '.mw-debug-panelink' ).not( this ).removeClass( 'current '); + + // Hide the current pane + if ( requestedPaneId === currentPaneId ) { + $currentPane.slideUp( updateHov ); + debug.$container.data( 'currentPane', null ); + return; + } + + debug.$container.data( 'currentPane', requestedPaneId ); + + if ( currentPaneId === undefined || currentPaneId === null ) { + $requestedPane.slideDown( updateHov ); + } else { + $currentPane.hide(); + $requestedPane.show(); + updateHov(); + } + }, + + /** + * Constructs the HTML for the debugging toolbar + */ + buildHtml: function () { + var $container, $bits, panes, id; + + $container = $( '
' ); + + $bits = $( '
' ); + + /** + * Returns a jQuery element for a debug-bit div + * + * @param id + * @return {jQuery} + */ + function bitDiv( id ) { + return $( '
' ).attr({ + id: 'mw-debug-' + id, + 'class': 'mw-debug-bit' + }) + .appendTo( $bits ); + } + + /** + * Returns a jQuery element for a pane link + * + * @param id + * @param text + * @return {jQuery} + */ + function paneLabel( id, text ) { + return $( '' ) + .attr({ + 'class': 'mw-debug-panelabel', + href: '#mw-debug-pane-' + id + }) + .text( text ); + } + + /** + * Returns a jQuery element for a debug-bit div with a for a pane link + * + * @param id CSS id snippet. Will be prefixed with 'mw-debug-' + * @param text Text to show + * @param count Optional count to show + * @return {jQuery} + */ + function paneTriggerBitDiv( id, text, count ) { + if( count ) { + text = text + ' (' + count + ')'; + } + return $( '
' ).attr({ + id: 'mw-debug-' + id, + 'class': 'mw-debug-bit mw-debug-panelink' + }) + .append( paneLabel( id, text ) ) + .appendTo( $bits ); + } + + paneTriggerBitDiv( 'console', 'Console', this.data.log.length ); + + paneTriggerBitDiv( 'querylist', 'Queries', this.data.queries.length ); + + paneTriggerBitDiv( 'debuglog', 'Debug log', this.data.debugLog.length ); + + paneTriggerBitDiv( 'request', 'Request' ); + + paneTriggerBitDiv( 'includes', 'PHP includes', this.data.includes.length ); + + bitDiv( 'mwversion' ) + .append( $( '' ).text( 'MediaWiki' ) ) + .append( ': ' + this.data.mwVersion ); + + bitDiv( 'phpversion' ) + .append( $( '' ).text( 'PHP' ) ) + .append( ': ' + this.data.phpVersion ); + + bitDiv( 'time' ) + .text( 'Time: ' + this.data.time.toFixed( 5 ) ); + + bitDiv( 'memory' ) + .text( 'Memory: ' + this.data.memory ) + .append( $( '' ).text( ' (' + this.data.memoryPeak + ')' ) ); + + + $bits.appendTo( $container ); + + panes = { + console: this.buildConsoleTable(), + querylist: this.buildQueryTable(), + debuglog: this.buildDebugLogTable(), + request: this.buildRequestPane(), + includes: this.buildIncludesPane() + }; + + for ( id in panes ) { + if ( !panes.hasOwnProperty( id ) ) { + continue; + } + + $( '
' ) + .attr({ + 'class': 'mw-debug-pane', + id: 'mw-debug-pane-' + id + }) + .append( panes[id] ) + .appendTo( $container ); + } + + this.$container = $container; + }, + + /** + * Builds the console panel + */ + buildConsoleTable: function () { + var $table, entryTypeText, i, length, entry; + + $table = $( '' ); + + $('').css( 'width', /*padding=*/20 + ( 10*/*fontSize*/11 ) ).appendTo( $table ); + $('').appendTo( $table ); + $('').css( 'width', 350 ).appendTo( $table ); + + + entryTypeText = function( entryType ) { + switch ( entryType ) { + case 'log': + return 'Log'; + case 'warn': + return 'Warning'; + case 'deprecated': + return 'Deprecated'; + default: + return 'Unknown'; + } + }; + + for ( i = 0, length = this.data.log.length; i < length; i += 1 ) { + entry = this.data.log[i]; + entry.typeText = entryTypeText( entry.type ); + + $( '' ) + .append( $( '' ) + .append( $('').css( 'width', '4em' ) ) + .append( $('') ) + .append( $('').css( 'width', '8em' ) ) + .append( $('').css( 'width', '18em' ) ) + .appendTo( $table ); + + for ( i = 0, length = this.data.queries.length; i < length; i += 1 ) { + query = this.data.queries[i]; + + $( '' ) + .append( $( '
' ) + .text( entry.typeText ) + .attr( 'class', 'mw-debug-console-' + entry.type ) + ) + .append( $( '' ).html( entry.msg ) ) + .append( $( '' ).text( entry.caller ) ) + .appendTo( $table ); + } + + return $table; + }, + + /** + * Query list pane + */ + buildQueryTable: function () { + var $table, i, length, query; + + $table = $( '
' ); + + $( '
#SQLTimeCall
' ).text( i + 1 ) ) + .append( $( '' ).text( query.sql ) ) + .append( $( '' ).text( ( query.time * 1000 ).toFixed( 4 ) + 'ms' ) ) + .append( $( '' ).text( query['function'] ) ) + .appendTo( $table ); + } + + + return $table; + }, + + /** + * Legacy debug log pane + */ + buildDebugLogTable: function () { + var $list, i, length, line; + $list = $( '