| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
( function () { |
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
mw.widgets.TitleOptionWidget = function MwWidgetsTitleOptionWidget( config ) { |
| 30 |
let icon; |
| 31 |
|
| 32 |
if ( !config.showImages ) { |
| 33 |
icon = null; |
| 34 |
} else if ( config.missing ) { |
| 35 |
icon = 'articleNotFound'; |
| 36 |
} else if ( config.redirect ) { |
| 37 |
icon = 'articleRedirect'; |
| 38 |
} else if ( config.disambiguation ) { |
| 39 |
icon = 'articleDisambiguation'; |
| 40 |
} else { |
| 41 |
icon = 'article'; |
| 42 |
} |
| 43 |
|
| 44 |
|
| 45 |
config = Object.assign( { |
| 46 |
icon: icon, |
| 47 |
label: config.data, |
| 48 |
autoFitLabel: false, |
| 49 |
$label: $( '<a>' ) |
| 50 |
}, config ); |
| 51 |
|
| 52 |
|
| 53 |
mw.widgets.TitleOptionWidget.super.call( this, config ); |
| 54 |
|
| 55 |
|
| 56 |
this.checkIcon.$element.remove(); |
| 57 |
|
| 58 |
|
| 59 |
this.$label.attr( 'href', config.url ); |
| 60 |
this.$element.addClass( 'mw-widget-titleOptionWidget' ); |
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
this.$label.attr( 'tabindex', '-1' ); |
| 66 |
|
| 67 |
|
| 68 |
this.$label.on( 'click', ( e ) => { |
| 69 |
|
| 70 |
if ( !( e.which !== 1 || e.altKey || e.ctrlKey || e.shiftKey || e.metaKey ) ) { |
| 71 |
e.preventDefault(); |
| 72 |
} |
| 73 |
} ); |
| 74 |
|
| 75 |
|
| 76 |
if ( config.query ) { |
| 77 |
this.setHighlightedQuery( config.data, config.query, config.compare, true ); |
| 78 |
} |
| 79 |
this.$label.attr( 'title', config.data ); |
| 80 |
|
| 81 |
if ( config.missing ) { |
| 82 |
this.$label.addClass( 'new' ); |
| 83 |
} else if ( config.redirect ) { |
| 84 |
this.$label.addClass( 'mw-redirect' ); |
| 85 |
} else if ( config.disambiguation ) { |
| 86 |
this.$label.addClass( 'mw-disambig' ); |
| 87 |
} |
| 88 |
|
| 89 |
if ( config.showImages && config.imageUrl ) { |
| 90 |
this.$icon |
| 91 |
.addClass( 'mw-widget-titleOptionWidget-hasImage mw-no-invert' ) |
| 92 |
.css( 'background-image', 'url(' + config.imageUrl + ')' ); |
| 93 |
} |
| 94 |
|
| 95 |
if ( config.description ) { |
| 96 |
this.$element.append( |
| 97 |
$( '<span>' ) |
| 98 |
.addClass( 'mw-widget-titleOptionWidget-description' ) |
| 99 |
.text( config.description ) |
| 100 |
.attr( 'title', config.description ) |
| 101 |
); |
| 102 |
} |
| 103 |
}; |
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
OO.inheritClass( mw.widgets.TitleOptionWidget, OO.ui.MenuOptionWidget ); |
| 108 |
|
| 109 |
}() ); |