TitleInputWidget: Correct links when 'relative' option used
authorBartosz Dziewoński <matma.rex@gmail.com>
Thu, 16 Jul 2015 18:37:16 +0000 (20:37 +0200)
committerBartosz Dziewoński <matma.rex@gmail.com>
Thu, 16 Jul 2015 19:09:53 +0000 (19:09 +0000)
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

includes/widget/TitleInputWidget.php
resources/src/mediawiki.widgets/mw.widgets.TitleInputWidget.js
resources/src/mediawiki.widgets/mw.widgets.TitleOptionWidget.js

index e160a23..37c9d9c 100644 (file)
@@ -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
index ca8c400..e715361 100644 (file)
                        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,
index 07b81e4..6623aa7 100644 (file)
@@ -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 );