mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/RevisionSlider
synced 2024-11-24 07:23:41 +00:00
b900446572
Reintroduces IIFE closures in test files because variables were declared in the global namespace, and "const" now causes hard errors. Bug: T339323 Change-Id: I69e9d7a29591137f185f3e5ab02dea590ec4dff6
50 lines
1.2 KiB
JavaScript
50 lines
1.2 KiB
JavaScript
/**
|
|
* @class HelpButtonView
|
|
* Module containing presentation logic for the helper button
|
|
*/
|
|
const HelpButtonView = {
|
|
|
|
/**
|
|
* Renders the help button and renders and adds the popup for it.
|
|
*
|
|
* @return {jQuery} the help button object
|
|
*/
|
|
render: function () {
|
|
const helpButton = new OO.ui.ButtonWidget( {
|
|
icon: 'helpNotice',
|
|
framed: false,
|
|
classes: [ 'mw-revslider-show-help' ]
|
|
} );
|
|
const 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' ]
|
|
} );
|
|
helpButton.connect( this, {
|
|
click: 'showDialog'
|
|
} );
|
|
helpButton.$element
|
|
.on( 'mouseover', function () {
|
|
helpPopup.toggle( true );
|
|
} )
|
|
.on( 'mouseout', function () {
|
|
helpPopup.toggle( false );
|
|
} )
|
|
.children().attr( {
|
|
'aria-haspopup': 'true',
|
|
'aria-label': mw.msg( 'revisionslider-show-help-tooltip' )
|
|
} );
|
|
|
|
$( document.body ).append( helpPopup.$element );
|
|
|
|
return helpButton.$element;
|
|
},
|
|
|
|
showDialog: function () {
|
|
require( './ext.RevisionSlider.HelpDialog.js' ).show();
|
|
}
|
|
};
|
|
|
|
module.exports = HelpButtonView;
|