mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Linter
synced 2024-11-24 16:04:00 +00:00
a51f750f83
Depending on the user's internet connection, the code that sets up mw.libs.ve.tempWikitextEditor may be completely skipped if the normal editor code loads fast enough. Refactor the code to handle all three cases using the same function. Bug: T185279 Change-Id: I003b27f838d1986ed8d238089efd657b96e8ec91
24 lines
732 B
JavaScript
24 lines
732 B
JavaScript
$( function () {
|
|
var location = mw.config.get( 'wgLinterErrorLocation' );
|
|
|
|
function highlightPosition( $textbox ) {
|
|
$textbox.trigger( 'focus' ).textSelection( 'setSelection', { start: location[ 0 ], end: location[ 1 ] } );
|
|
$textbox.textSelection( 'scrollToCaretPosition' );
|
|
}
|
|
|
|
if ( location ) {
|
|
// eslint-disable-next-line no-jquery/no-global-selector
|
|
highlightPosition( $( '#wpTextbox1' ) );
|
|
|
|
mw.hook( 've.wikitextInteractive' ).add( function () {
|
|
if ( mw.libs.ve.tempWikitextEditor ) {
|
|
highlightPosition( mw.libs.ve.tempWikitextEditor.$element );
|
|
} else {
|
|
// VE dummy textbox
|
|
// eslint-disable-next-line no-jquery/no-global-selector
|
|
highlightPosition( $( '#wpTextbox1' ) );
|
|
}
|
|
} );
|
|
}
|
|
} );
|