From: Bartosz DziewoƄski Date: Thu, 16 Jul 2015 18:37:16 +0000 (+0200) Subject: TitleInputWidget: Correct links when 'relative' option used X-Git-Tag: 1.31.0-rc.0~10741^2 X-Git-Url: http://git.cyclocoop.org/%24href?a=commitdiff_plain;h=ecc073bb89dcfa3ecd8aab8e0cb47c84a7558130;p=lhc%2Fweb%2Fwiklou.git TitleInputWidget: Correct links when 'relative' option used Previously, the links in the suggestions dropdown also pointed to the relative version, e.g. "/wiki/Foo" instead of "/wiki/Template:Foo". This also corrects missing dependency for mediawiki.util, which is no longer used directly (although mediawiki.Title depends on it, so the code worked correctly in spite of missing dependency). Follow-up to ddca1c657e21bd49c01ead2e5e0fbcdb9ee26255. Change-Id: I8f9293636c597cd617e68b4c238d7424915cf351 --- diff --git a/includes/widget/TitleInputWidget.php b/includes/widget/TitleInputWidget.php index e160a23d22..37c9d9c4b9 100644 --- a/includes/widget/TitleInputWidget.php +++ b/includes/widget/TitleInputWidget.php @@ -20,7 +20,7 @@ class TitleInputWidget extends TextInputWidget { /** * @param array $config Configuration options * @param int|null $config['namespace'] Namespace to prepend to queries - * @param bool|null $config['relative'] If a namespace is set, return a title relative to it (default; true) + * @param bool|null $config['relative'] If a namespace is set, return a title relative to it (default: true) */ public function __construct( array $config = array() ) { // Parent constructor diff --git a/resources/src/mediawiki.widgets/mw.widgets.TitleInputWidget.js b/resources/src/mediawiki.widgets/mw.widgets.TitleInputWidget.js index ca8c400fcb..e7153613f4 100644 --- a/resources/src/mediawiki.widgets/mw.widgets.TitleInputWidget.js +++ b/resources/src/mediawiki.widgets/mw.widgets.TitleInputWidget.js @@ -263,6 +263,7 @@ data: this.namespace !== null && this.relative ? mwTitle.getRelativeText( this.namespace ) : title, + title: mwTitle, imageUrl: this.showImages ? data.imageUrl : null, description: this.showDescriptions ? data.description : null, missing: data.missing, diff --git a/resources/src/mediawiki.widgets/mw.widgets.TitleOptionWidget.js b/resources/src/mediawiki.widgets/mw.widgets.TitleOptionWidget.js index 07b81e48db..6623aa789d 100644 --- a/resources/src/mediawiki.widgets/mw.widgets.TitleOptionWidget.js +++ b/resources/src/mediawiki.widgets/mw.widgets.TitleOptionWidget.js @@ -14,7 +14,8 @@ * * @constructor * @param {Object} [config] Configuration options - * @cfg {string} [data] Page title + * @cfg {string} [data] Label to display + * @cfg {mw.Title} [title] Page title object * @cfg {string} [imageUrl] Thumbnail image URL with URL encoding * @cfg {string} [description] Page description * @cfg {boolean} [missing] Page doesn't exist @@ -23,7 +24,7 @@ * @cfg {string} [query] Matching query string */ mw.widgets.TitleOptionWidget = function MwWidgetsTitleOptionWidget( config ) { - var icon, title = config.data; + var icon; if ( config.missing ) { icon = 'page-not-found'; @@ -38,8 +39,8 @@ // Config initialization config = $.extend( { icon: icon, - label: title, - href: mw.util.getUrl( title ), + label: config.data, + href: config.title.getUrl(), autoFitLabel: false }, config );