2023-05-10 14:23:42 +00:00
|
|
|
/*!
|
|
|
|
* VisualEditor EditCheckContextItem class.
|
|
|
|
*
|
2023-12-01 16:06:11 +00:00
|
|
|
* @copyright See AUTHORS.txt
|
2023-05-10 14:23:42 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Context item shown after a rich text paste.
|
|
|
|
*
|
|
|
|
* @class
|
|
|
|
* @extends ve.ui.PersistentContextItem
|
|
|
|
*
|
|
|
|
* @constructor
|
|
|
|
* @param {ve.ui.LinearContext} context Context the item is in
|
|
|
|
* @param {ve.dm.Model} model Model the item is related to
|
|
|
|
* @param {Object} [config]
|
|
|
|
*/
|
|
|
|
ve.ui.EditCheckContextItem = function VeUiEditCheckContextItem() {
|
|
|
|
// Parent constructor
|
|
|
|
ve.ui.EditCheckContextItem.super.apply( this, arguments );
|
|
|
|
|
|
|
|
// Initialization
|
|
|
|
this.$element.addClass( 've-ui-editCheckContextItem' );
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Inheritance */
|
|
|
|
|
|
|
|
OO.inheritClass( ve.ui.EditCheckContextItem, ve.ui.PersistentContextItem );
|
|
|
|
|
|
|
|
/* Static Properties */
|
|
|
|
|
2023-08-14 16:07:00 +00:00
|
|
|
ve.ui.EditCheckContextItem.static.name = 'editCheckReferences';
|
2023-05-10 14:23:42 +00:00
|
|
|
|
|
|
|
ve.ui.EditCheckContextItem.static.icon = 'quotes';
|
|
|
|
|
|
|
|
ve.ui.EditCheckContextItem.static.label = OO.ui.deferMsg( 'editcheck-dialog-addref-title' );
|
|
|
|
|
|
|
|
/* Methods */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
ve.ui.EditCheckContextItem.prototype.renderBody = function () {
|
2024-03-14 17:17:36 +00:00
|
|
|
const $actions = $( '<div>' ).addClass( 've-ui-editCheckContextItem-actions' );
|
2023-05-10 14:23:42 +00:00
|
|
|
|
2024-03-14 17:17:36 +00:00
|
|
|
this.data.action.getChoices().forEach( ( choice ) => {
|
|
|
|
const button = new OO.ui.ButtonWidget( choice );
|
|
|
|
button.connect( this, {
|
|
|
|
click: () => {
|
|
|
|
this.onChoiceClick( choice.action );
|
|
|
|
}
|
|
|
|
} );
|
|
|
|
$actions.append( button.$element );
|
|
|
|
} );
|
2023-05-10 14:23:42 +00:00
|
|
|
|
|
|
|
// HACK: Suppress close button on mobile context
|
|
|
|
if ( this.context.isMobile() ) {
|
|
|
|
this.context.closeButton.toggle( false );
|
|
|
|
}
|
|
|
|
|
|
|
|
this.$body.append(
|
2024-03-14 17:17:36 +00:00
|
|
|
$( '<p>' ).text( this.data.action.getDescription() ),
|
|
|
|
$actions
|
2023-05-10 14:23:42 +00:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
ve.ui.EditCheckContextItem.prototype.close = function ( data ) {
|
|
|
|
// HACK: Un-suppress close button on mobile context
|
|
|
|
if ( this.context.isMobile() ) {
|
|
|
|
this.context.closeButton.toggle( true );
|
|
|
|
}
|
2024-02-22 17:45:12 +00:00
|
|
|
this.data.callback( data, this.data );
|
2023-05-10 14:23:42 +00:00
|
|
|
};
|
|
|
|
|
2024-03-14 17:17:36 +00:00
|
|
|
ve.ui.EditCheckContextItem.prototype.onChoiceClick = function ( choice ) {
|
|
|
|
this.data.action.check.act( choice, this.data.action, this );
|
2023-05-10 14:23:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Registration */
|
|
|
|
|
|
|
|
ve.ui.contextItemFactory.register( ve.ui.EditCheckContextItem );
|