X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=resources%2Fsrc%2Fmediawiki.widgets%2Fmw.widgets.TitleOptionWidget.js;h=661f9aecd6f197d98b26990f1260bba1129b10c7;hb=add9bd191fd4d16250b301208600854cb52f6b33;hp=51508ab527aa0d6ff4830f7ca67b8e7573a1a89d;hpb=2ffff73a46c29cdad1cbf59063f4dd75debd3b4c;p=lhc%2Fweb%2Fwiklou.git diff --git a/resources/src/mediawiki.widgets/mw.widgets.TitleOptionWidget.js b/resources/src/mediawiki.widgets/mw.widgets.TitleOptionWidget.js index 51508ab527..661f9aecd6 100644 --- a/resources/src/mediawiki.widgets/mw.widgets.TitleOptionWidget.js +++ b/resources/src/mediawiki.widgets/mw.widgets.TitleOptionWidget.js @@ -4,7 +4,7 @@ * @copyright 2011-2015 MediaWiki Widgets Team and others; see AUTHORS.txt * @license The MIT License (MIT); see LICENSE.txt */ -( function ( $, mw ) { +( function () { /** * Creates a mw.widgets.TitleOptionWidget object. @@ -16,17 +16,21 @@ * @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 * @cfg {boolean} [redirect] Page is a redirect * @cfg {boolean} [disambiguation] Page is a disambiguation page - * @cfg {string} [query] Matching query string + * @cfg {string} [query] Matching query string to highlight + * @cfg {string} [compare] String comparison function for query highlighting */ 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'; @@ -47,6 +51,9 @@ // Parent constructor mw.widgets.TitleOptionWidget.parent.call( this, config ); + // Remove check icon + this.checkIcon.$element.remove(); + // Initialization this.$label.attr( 'href', config.url ); this.$element.addClass( 'mw-widget-titleOptionWidget' ); @@ -65,9 +72,10 @@ } ); // Highlight matching parts of link suggestion - this.$label - .highlightText( config.query ) - .attr( 'title', config.data ); + if ( config.query ) { + this.setHighlightedQuery( config.data, config.query, config.compare ); + } + this.$label.attr( 'title', config.data ); if ( config.missing ) { this.$label.addClass( 'new' ); @@ -77,7 +85,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 + ')' ); @@ -97,4 +105,4 @@ OO.inheritClass( mw.widgets.TitleOptionWidget, OO.ui.MenuOptionWidget ); -}( jQuery, mediaWiki ) ); +}() );