mediawiki-extensions-WikiEd.../modules/realtimepreview/init.js
hmonroy 090929cf1d Realtime preview: disable preview when screen is small
Disable preview functionality when screen is less than 600px.

Bug: T293337
Change-Id: I4615f629a0c97fb325721bbddee5c9eb074c3a5c
2022-05-02 15:26:20 -07:00

21 lines
619 B
JavaScript

mw.hook( 'wikiEditor.toolbarReady' ).add( function ( $textarea ) {
var RealtimePreview = require( './RealtimePreview.js' );
var realtimePreview = new RealtimePreview();
$textarea.wikiEditor( 'addToToolbar', {
section: 'secondary',
group: 'default',
tools: {
realtimepreview: {
type: 'element',
element: function ( context ) {
return realtimePreview.getToolbarButton( context ).$element;
}
}
}
} );
if ( realtimePreview.getUserPref() && realtimePreview.isScreenWideEnough() ) {
realtimePreview.setEnabled();
mw.hook( 'ext.WikiEditor.realtimepreview.inuse' ).fire( this );
}
} );