2016-03-18 00:00:05 +00:00
|
|
|
( function ( mw, $ ) {
|
|
|
|
/**
|
|
|
|
* Footer notice widget.
|
|
|
|
*
|
|
|
|
* @class
|
|
|
|
* @extends OO.ui.Widget
|
|
|
|
*
|
|
|
|
* @constructor
|
|
|
|
* @param {Object} [config] Configuration object
|
|
|
|
* @cfg {string} [iconUrl] The source URL of the feedback icon
|
|
|
|
* @cfg {string} [url] The URL for the survey
|
|
|
|
*/
|
|
|
|
mw.echo.ui.FooterNoticeWidget = function MwEchoUiFooterNoticeWidget( config ) {
|
2016-04-26 01:33:01 +00:00
|
|
|
var $icon, label, dismissButton,
|
2016-03-18 00:00:05 +00:00
|
|
|
$row = $( '<div>' )
|
|
|
|
.addClass( 'mw-echo-ui-footerNoticeWidget-row' );
|
|
|
|
|
|
|
|
config = config || {};
|
|
|
|
|
|
|
|
// Parent constructor
|
|
|
|
mw.echo.ui.FooterNoticeWidget.parent.call( this, config );
|
|
|
|
|
|
|
|
if ( config.iconUrl ) {
|
|
|
|
$icon = $( '<div>' )
|
|
|
|
.addClass( 'mw-echo-ui-footerNoticeWidget-icon' )
|
2016-04-09 00:12:05 +00:00
|
|
|
.append( $( '<img>' ).attr( { src: config.iconUrl, width: 30, height: 30 } ) );
|
2016-03-18 00:00:05 +00:00
|
|
|
|
|
|
|
$row.append( $icon );
|
|
|
|
}
|
|
|
|
|
|
|
|
label = new OO.ui.LabelWidget( {
|
|
|
|
label: $( '<span>' ).append(
|
2016-04-26 01:33:01 +00:00
|
|
|
mw.message( 'echo-popup-footer-beta-invitation',
|
2016-03-18 00:00:05 +00:00
|
|
|
// Text
|
2016-04-26 01:33:01 +00:00
|
|
|
mw.msg( 'echo-popup-footer-beta-invitation-link' ),
|
2016-03-18 00:00:05 +00:00
|
|
|
// Link
|
|
|
|
config.url
|
|
|
|
).parse()
|
|
|
|
).contents(),
|
|
|
|
classes: [ 'mw-echo-ui-footerNoticeWidget-label' ]
|
|
|
|
} );
|
|
|
|
|
|
|
|
dismissButton = new OO.ui.ButtonWidget( {
|
|
|
|
icon: 'close',
|
|
|
|
framed: false,
|
|
|
|
classes: [ 'mw-echo-ui-footerNoticeWidget-dismiss' ]
|
|
|
|
} );
|
|
|
|
|
|
|
|
// Events
|
|
|
|
dismissButton.connect( this, { click: 'onDismissButtonClick' } );
|
|
|
|
|
|
|
|
this.$element
|
|
|
|
.addClass( 'mw-echo-ui-footerNoticeWidget' )
|
|
|
|
.append(
|
|
|
|
$row
|
|
|
|
.append(
|
|
|
|
label.$element,
|
|
|
|
dismissButton.$element
|
|
|
|
)
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Initialization */
|
|
|
|
|
|
|
|
OO.inheritClass( mw.echo.ui.FooterNoticeWidget, OO.ui.Widget );
|
|
|
|
|
|
|
|
/* Events */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The notice was dismissed.
|
|
|
|
*
|
|
|
|
* @event dismiss
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Methods */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Respond to dismiss button click.
|
|
|
|
*
|
|
|
|
* @fires dismiss
|
|
|
|
*/
|
|
|
|
mw.echo.ui.FooterNoticeWidget.prototype.onDismissButtonClick = function () {
|
|
|
|
this.toggle( false );
|
|
|
|
this.emit( 'dismiss' );
|
|
|
|
};
|
|
|
|
} )( mediaWiki, jQuery );
|