TitleOptionWidget: Don't show an icon when showImages=false
authorEd Sanders <esanders@wikimedia.org>
Tue, 3 Oct 2017 14:52:13 +0000 (15:52 +0100)
committerEd Sanders <esanders@wikimedia.org>
Tue, 3 Oct 2017 14:52:49 +0000 (15:52 +0100)
Change-Id: Ib4262bc15a3845ec9e7af484dbdfa4277f2f4014

resources/src/mediawiki.widgets/mw.widgets.TitleOptionWidget.js
resources/src/mediawiki.widgets/mw.widgets.TitleWidget.js

index 0f1815b..638f461 100644 (file)
@@ -16,6 +16,7 @@
         * @param {Object} config Configuration options
         * @cfg {string} data Label to display
         * @cfg {string} url URL of page
+        * @cfg {boolean} [showImages] Whether to attempt to show images
         * @cfg {string} [imageUrl] Thumbnail image URL with URL encoding
         * @cfg {string} [description] Page description
         * @cfg {boolean} [missing] Page doesn't exist
@@ -26,7 +27,9 @@
        mw.widgets.TitleOptionWidget = function MwWidgetsTitleOptionWidget( config ) {
                var icon;
 
-               if ( config.missing ) {
+               if ( !config.showImages ) {
+                       icon = null;
+               } else if ( config.missing ) {
                        icon = 'page-not-found';
                } else if ( config.redirect ) {
                        icon = 'page-redirect';
@@ -78,7 +81,7 @@
                        this.$label.addClass( 'mw-disambig' );
                }
 
-               if ( config.imageUrl ) {
+               if ( config.showImages && config.imageUrl ) {
                        this.$icon
                                .addClass( 'mw-widget-titleOptionWidget-hasImage' )
                                .css( 'background-image', 'url(' + config.imageUrl + ')' );
index 8e7afd7..5fe094f 100644 (file)
                                mwTitle.getRelativeText( this.namespace ) :
                                title,
                        url: mwTitle.getUrl(),
+                       showImages: this.showImages,
                        imageUrl: this.showImages ? data.imageUrl : null,
                        description: this.showDescriptions ? description : null,
                        missing: data.missing,