summaryrefslogtreecommitdiff
blob: 6404cbb9406884d0dff0018844eec5462a18d982 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
( function () {
	var warningDialog = new OO.ui.MessageDialog(),
		windowManager = new OO.ui.WindowManager(),
		dialogOptions = {
			title: mw.msg( 'tps-edit-sourcepage-ve-warning-title' ),
			message: mw.msg( 'tps-edit-sourcepage-ve-warning-text' ),
			actions: [
				{
					action: 'accept',
					label: mw.msg( 'tps-edit-sourcepage-ve-warning-button' ),
					flags: [ 'primary', 'progressive' ]
				}
			]
		},
		isWarningShown = false;

	$( 'body' ).append( windowManager.$element );
	windowManager.addWindows( [ warningDialog ] );

	$( function () {
		mw.hook( 've.activationComplete' ).add( function () {
			// eslint-disable-next-line no-undef
			var surface = ve.init.target.getSurface();
			if ( surface.getMode() === 'visual' ) {
				// Visual mode
				showWarning();
			}
		} );
	} );

	function showWarning() {
		if ( isWarningShown ) {
			return;
		}
		isWarningShown = true;
		windowManager.openWindow( warningDialog, dialogOptions );
	}
}() );