2018-11-16 16:33:52 +00:00
|
|
|
( function () {
|
2017-03-24 13:14:18 +00:00
|
|
|
/**
|
|
|
|
* Module containing presentation logic for the helper button
|
|
|
|
*/
|
|
|
|
var HelpButtonView = {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Renders the help button and renders and adds the popup for it.
|
|
|
|
*
|
|
|
|
* @return {jQuery} the help button object
|
|
|
|
*/
|
2017-05-04 20:57:38 +00:00
|
|
|
render: function () {
|
2017-03-24 13:14:18 +00:00
|
|
|
var helpButton, helpPopup;
|
|
|
|
|
|
|
|
helpButton = new OO.ui.ButtonWidget( {
|
2018-10-11 09:27:45 +00:00
|
|
|
icon: 'helpNotice',
|
2017-03-24 13:14:18 +00:00
|
|
|
framed: false,
|
|
|
|
classes: [ 'mw-revslider-show-help' ]
|
|
|
|
} );
|
|
|
|
helpPopup = new OO.ui.PopupWidget( {
|
|
|
|
$content: $( '<p>' ).text( mw.msg( 'revisionslider-show-help-tooltip' ) ),
|
|
|
|
$floatableContainer: helpButton.$element,
|
|
|
|
width: 200,
|
|
|
|
classes: [ 'mw-revslider-tooltip', 'mw-revslider-help-tooltip' ]
|
|
|
|
} );
|
2017-05-19 16:04:00 +00:00
|
|
|
helpButton.connect( this, {
|
|
|
|
click: 'showDialog'
|
|
|
|
} );
|
2017-03-24 13:14:18 +00:00
|
|
|
helpButton.$element
|
2019-02-10 16:54:28 +00:00
|
|
|
.on( 'mouseover', function () {
|
2017-03-24 13:14:18 +00:00
|
|
|
helpPopup.toggle( true );
|
|
|
|
} )
|
2019-02-10 16:54:28 +00:00
|
|
|
.on( 'mouseout', function () {
|
2017-03-24 13:14:18 +00:00
|
|
|
helpPopup.toggle( false );
|
2017-05-19 16:04:00 +00:00
|
|
|
} )
|
|
|
|
.children().attr( {
|
|
|
|
'aria-haspopup': 'true',
|
|
|
|
'aria-label': mw.msg( 'revisionslider-show-help-tooltip' )
|
2017-03-24 13:14:18 +00:00
|
|
|
} );
|
|
|
|
|
|
|
|
$( 'body' ).append( helpPopup.$element );
|
|
|
|
|
|
|
|
return helpButton.$element;
|
2017-05-19 16:04:00 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
showDialog: function () {
|
2020-03-29 20:45:09 +00:00
|
|
|
require( 'ext.RevisionSlider.HelpDialog' ).HelpDialog.show();
|
2017-03-24 13:14:18 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-03-29 20:45:09 +00:00
|
|
|
module.exports = HelpButtonView;
|
2018-11-16 16:33:52 +00:00
|
|
|
}() );
|