From f6d65e533c62f6deb21342d4901ece24497b433e Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Thu, 4 Jun 2015 07:31:04 +0200 Subject: Update to MediaWiki 1.25.1 --- resources/src/mediawiki/mediawiki.util.js | 73 ++++++++++++++++++++----------- 1 file changed, 47 insertions(+), 26 deletions(-) (limited to 'resources/src/mediawiki/mediawiki.util.js') diff --git a/resources/src/mediawiki/mediawiki.util.js b/resources/src/mediawiki/mediawiki.util.js index 26629137..6723e5f9 100644 --- a/resources/src/mediawiki/mediawiki.util.js +++ b/resources/src/mediawiki/mediawiki.util.js @@ -88,7 +88,7 @@ /** * Get the link to a page name (relative to `wgServer`), * - * @param {string} str Page name + * @param {string|null} [str=wgPageName] Page name * @param {Object} [params] A mapping of query parameter names to values, * e.g. `{ action: 'edit' }` * @return {string} Url of the page with name of `str` @@ -151,12 +151,12 @@ * Returns null if not found. * * @param {string} param The parameter name. - * @param {string} [url=document.location.href] URL to search through, defaulting to the current document's URL. + * @param {string} [url=location.href] URL to search through, defaulting to the current browsing location. * @return {Mixed} Parameter value or null. */ getParamValue: function ( param, url ) { if ( url === undefined ) { - url = document.location.href; + url = location.href; } // Get last match, stop at hash var re = new RegExp( '^[^#]*[&?]' + $.escapeRE( param ) + '=([^&#]*)' ), @@ -196,7 +196,7 @@ * p-cactions (Content actions), p-personal (Personal tools), * p-navigation (Navigation), p-tb (Toolbox) * - * The first three paramters are required, the others are optional and + * The first three parameters are required, the others are optional and * may be null. Though providing an id and tooltip is recommended. * * By default the new link will be added to the end of the list. To @@ -228,7 +228,7 @@ addPortletLink: function ( portlet, href, text, id, tooltip, accesskey, nextnode ) { var $item, $link, $portlet, $ul; - // Check if there's atleast 3 arguments to prevent a TypeError + // Check if there's at least 3 arguments to prevent a TypeError if ( arguments.length < 3 ) { return null; } @@ -286,30 +286,38 @@ } if ( tooltip ) { - $link.attr( 'title', tooltip ).updateTooltipAccessKeys(); + $link.attr( 'title', tooltip ); } if ( nextnode ) { + // Case: nextnode is a DOM element (was the only option before MW 1.17, in wikibits.js) + // Case: nextnode is a CSS selector for jQuery if ( nextnode.nodeType || typeof nextnode === 'string' ) { - // nextnode is a DOM element (was the only option before MW 1.17, in wikibits.js) - // or nextnode is a CSS selector for jQuery nextnode = $ul.find( nextnode ); - } else if ( !nextnode.jquery || ( nextnode.length && nextnode[0].parentNode !== $ul[0] ) ) { - // Fallback - $ul.append( $item ); - return $item[0]; + } else if ( !nextnode.jquery ) { + // Error: Invalid nextnode + nextnode = undefined; } - if ( nextnode.length === 1 ) { - // nextnode is a jQuery object that represents exactly one element - nextnode.before( $item ); - return $item[0]; + if ( nextnode && ( nextnode.length !== 1 || nextnode[0].parentNode !== $ul[0] ) ) { + // Error: nextnode must resolve to a single node + // Error: nextnode must have the associated