07b81e48db5ab81b5397074344e8b69e5bf3b1cf
2 * MediaWiki Widgets - TitleOptionWidget class.
4 * @copyright 2011-2015 MediaWiki Widgets Team and others; see AUTHORS.txt
5 * @license The MIT License (MIT); see LICENSE.txt
10 * Creates a mw.widgets.TitleOptionWidget object.
13 * @extends OO.ui.MenuOptionWidget
16 * @param {Object} [config] Configuration options
17 * @cfg {string} [data] Page title
18 * @cfg {string} [imageUrl] Thumbnail image URL with URL encoding
19 * @cfg {string} [description] Page description
20 * @cfg {boolean} [missing] Page doesn't exist
21 * @cfg {boolean} [redirect] Page is a redirect
22 * @cfg {boolean} [disambiguation] Page is a disambiguation page
23 * @cfg {string} [query] Matching query string
25 mw
.widgets
.TitleOptionWidget
= function MwWidgetsTitleOptionWidget( config
) {
26 var icon
, title
= config
.data
;
28 if ( config
.missing
) {
29 icon
= 'page-not-found';
30 } else if ( config
.redirect
) {
31 icon
= 'page-redirect';
32 } else if ( config
.disambiguation
) {
33 icon
= 'page-disambiguation';
35 icon
= 'page-existing';
38 // Config initialization
42 href
: mw
.util
.getUrl( title
),
47 OO
.ui
.MenuOptionWidget
.call( this, config
);
50 this.$label
.wrap( '<a>' );
51 this.$link
= this.$label
.parent();
52 this.$link
.attr( 'href', config
.href
);
53 this.$element
.addClass( 'mw-widget-titleOptionWidget' );
55 // Highlight matching parts of link suggestion
56 this.$label
.autoEllipsis( { hasSpan
: false, tooltip
: true, matchText
: config
.query
} );
58 if ( config
.missing
) {
59 this.$link
.addClass( 'new' );
62 if ( config
.imageUrl
) {
64 .addClass( 'mw-widget-titleOptionWidget-hasImage' )
65 .css( 'background-image', 'url(' + config
.imageUrl
+ ')' );
68 if ( config
.description
) {
71 .addClass( 'mw-widget-titleOptionWidget-description' )
72 .text( config
.description
)
79 OO
.inheritClass( mw
.widgets
.TitleOptionWidget
, OO
.ui
.MenuOptionWidget
);
81 }( jQuery
, mediaWiki
) );