* @extends OO.ui.MenuOptionWidget
*
* @constructor
- * @param {Object} [config] Configuration options
- * @cfg {string} [data] Page title
+ * @param {Object} config Configuration options
+ * @cfg {string} data Label to display
+ * @cfg {string} url URL of page
* @cfg {string} [imageUrl] Thumbnail image URL with URL encoding
* @cfg {string} [description] Page description
* @cfg {boolean} [missing] Page doesn't exist
* @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';
// Config initialization
config = $.extend( {
icon: icon,
- label: title,
- href: mw.util.getUrl( title ),
- autoFitLabel: false
+ label: config.data,
+ autoFitLabel: false,
+ $label: $( '<a>' )
}, config );
// Parent constructor
- OO.ui.MenuOptionWidget.call( this, config );
+ mw.widgets.TitleOptionWidget.parent.call( this, config );
- // Intialization
- this.$label.wrap( '<a>' );
- this.$link = this.$label.parent();
- this.$link.attr( 'href', config.href );
+ // Initialization
+ this.$label.attr( 'href', config.url );
this.$element.addClass( 'mw-widget-titleOptionWidget' );
// Highlight matching parts of link suggestion
this.$label.autoEllipsis( { hasSpan: false, tooltip: true, matchText: config.query } );
if ( config.missing ) {
- this.$link.addClass( 'new' );
+ this.$label.addClass( 'new' );
}
if ( config.imageUrl ) {
}
};
- /* Inheritance */
+ /* Setup */
OO.inheritClass( mw.widgets.TitleOptionWidget, OO.ui.MenuOptionWidget );