2020-11-18 09:11:12 +00:00
|
|
|
/**
|
2020-11-18 10:51:22 +00:00
|
|
|
* @class HelpButtonView
|
2020-11-18 09:11:12 +00:00
|
|
|
* Module containing presentation logic for the helper button
|
|
|
|
*/
|
2023-06-22 09:41:37 +00:00
|
|
|
const HelpButtonView = {
|
2020-11-18 09:11:12 +00:00
|
|
|
|
2017-03-24 13:14:18 +00:00
|
|
|
/**
|
2020-11-18 09:11:12 +00:00
|
|
|
* Renders the help button and renders and adds the popup for it.
|
|
|
|
*
|
|
|
|
* @return {jQuery} the help button object
|
2017-03-24 13:14:18 +00:00
|
|
|
*/
|
2020-11-18 09:11:12 +00:00
|
|
|
render: function () {
|
2023-06-22 09:41:37 +00:00
|
|
|
const helpButton = new OO.ui.ButtonWidget( {
|
2020-11-18 09:11:12 +00:00
|
|
|
icon: 'helpNotice',
|
|
|
|
framed: false,
|
|
|
|
classes: [ 'mw-revslider-show-help' ]
|
|
|
|
} );
|
2023-06-22 09:41:37 +00:00
|
|
|
const helpPopup = new OO.ui.PopupWidget( {
|
2020-11-18 09:11:12 +00:00
|
|
|
$content: $( '<p>' ).text( mw.msg( 'revisionslider-show-help-tooltip' ) ),
|
|
|
|
$floatableContainer: helpButton.$element,
|
|
|
|
width: 200,
|
|
|
|
classes: [ 'mw-revslider-tooltip', 'mw-revslider-help-tooltip' ]
|
|
|
|
} );
|
|
|
|
helpButton.connect( this, {
|
|
|
|
click: 'showDialog'
|
|
|
|
} );
|
|
|
|
helpButton.$element
|
2024-06-08 04:13:35 +00:00
|
|
|
.on( 'mouseover', () => {
|
2020-11-18 09:11:12 +00:00
|
|
|
helpPopup.toggle( true );
|
|
|
|
} )
|
2024-06-08 04:13:35 +00:00
|
|
|
.on( 'mouseout', () => {
|
2020-11-18 09:11:12 +00:00
|
|
|
helpPopup.toggle( false );
|
|
|
|
} )
|
|
|
|
.children().attr( {
|
|
|
|
'aria-haspopup': 'true',
|
|
|
|
'aria-label': mw.msg( 'revisionslider-show-help-tooltip' )
|
2017-05-19 16:04:00 +00:00
|
|
|
} );
|
2017-03-24 13:14:18 +00:00
|
|
|
|
2023-04-21 07:03:07 +00:00
|
|
|
$( document.body ).append( helpPopup.$element );
|
2017-03-24 13:14:18 +00:00
|
|
|
|
2020-11-18 09:11:12 +00:00
|
|
|
return helpButton.$element;
|
|
|
|
},
|
2017-05-19 16:04:00 +00:00
|
|
|
|
2020-11-18 09:11:12 +00:00
|
|
|
showDialog: function () {
|
2020-11-20 09:27:07 +00:00
|
|
|
require( './ext.RevisionSlider.HelpDialog.js' ).show();
|
2020-11-18 09:11:12 +00:00
|
|
|
}
|
|
|
|
};
|
2017-03-24 13:14:18 +00:00
|
|
|
|
2020-11-18 09:11:12 +00:00
|
|
|
module.exports = HelpButtonView;
|