Debian Codegraph @

extensions/VisualEditor/modules/ve-mw/ui/commands/ve.ui.MWWikitextWarningCommand.js

raw symbols SCIP
1 /*!
2 * VisualEditor UserInterface MediaWiki WikitextWarningCommand class.
3 *
4 * @copyright See AUTHORS.txt
5 */
6
7 /**
8 * Wikitext warning command.
9 *
10 * @class
11 * @extends ve.ui.Command
12 *
13 * @constructor
14 */
15 ve.ui.MWWikitextWarningCommand = function VeUiMWWikitextWarningCommand() {
16 // Parent constructor
17 ve.ui.MWWikitextWarningCommand.super.call(
18 this, 'mwWikitextWarning'
19 );
20 this.warning = null;
21 };
22
23 /* Inheritance */
24
25 OO.inheritClass( ve.ui.MWWikitextWarningCommand, ve.ui.Command );
26
27 /* Methods */
28
29 /**
30 * @inheritdoc
31 */
32 ve.ui.MWWikitextWarningCommand.prototype.execute = function () {
33 if ( this.warning && this.warning.isOpen ) {
34 return false;
35 }
36 // eslint-disable-next-line no-jquery/no-html
37 const $message = $( '<div>' ).html( ve.init.platform.getParsedMessage( 'visualeditor-wikitext-warning' ) );
38 ve.targetLinksToNewWindow( $message[ 0 ] );
39 ve.init.platform.notify(
40 $message.contents(),
41 ve.msg( 'visualeditor-wikitext-warning-title' ),
42 { tag: 'visualeditor-wikitext-warning' }
43 ).then( ( message ) => {
44 this.warning = message;
45 } );
46 return true;
47 };
48
49 /* Registration */
50
51 ve.ui.commandRegistry.register( new ve.ui.MWWikitextWarningCommand() );