modules/ve-mw/preinit/ve.init.mw.DesktopArticleTarget.init.js
File ve.init.mw.DesktopArticleTarget.init.js
has 955 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
/*!
* VisualEditor MediaWiki DesktopArticleTarget init.
*
* This file must remain as widely compatible as the base compatibility
* for MediaWiki itself (see mediawiki/core:/resources/startup.js).
Function activateTarget
has 83 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function activateTarget( mode, section, tPromise, modified ) {
let dataPromise;
updateTabs( true, mode, section === 'new' );
Function getTarget
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function getTarget( mode, section ) {
if ( !targetPromise ) {
// The TargetLoader module is loaded in the bottom queue, so it should have been
// requested already but it might not have finished loading yet
targetPromise = mw.loader.using( 'ext.visualEditor.targetLoader' )
Function onEditTabClick
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
onEditTabClick: function ( mode, e ) {
if ( !init.isUnmodifiedLeftClick( e ) ) {
return;
}
if ( !active && mode === 'source' && !init.isWikitextAvailable ) {
Function setupEditLinks
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
setupEditLinks: function () {
// NWE
if ( init.isWikitextAvailable && !isOnlyTabVE() ) {
$(
// Edit section links, except VE ones when both editors visible
Function scrollToSection
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function scrollToSection( section ) {
if ( section === '0' || section === 'new' ) {
return;
}
Consider simplifying this complex logical expression. Open
Open
if (
pageCanLoadEditor &&
showWikitextWelcome &&
// At least one editor is available (T201928)
( init.isVisualAvailable || init.isWikitextAvailable || $( '#wpTextbox1' ).length ) &&
Function setEditorPreference
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function setEditorPreference( editor ) {
// If visual mode isn't available, don't set the editor preference as the
// user has expressed no choice by opening this editor. (T246259)
// Strictly speaking the same thing should happen if visual mode is
// available but source mode isn't, but that is never the case.
Function onEditSectionLinkClick
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
onEditSectionLinkClick: function ( mode, e, section ) {
const link = $( e.target ).closest( 'a' )[ 0 ];
if ( !link || !link.href ) {
// Not a real link, probably added by a gadget or another extension (T328094)
return;
Avoid deeply nested control flow statements. Open
Open
if ( data && data.action === 'prefer-ve' ) {
location.href = veEditUrl;
} else if ( data && data.action === 'multi-tab' ) {
location.reload();
}
Avoid deeply nested control flow statements. Open
Open
if ( section ) {
// switching from visual via the "add section" tab
target.switchToWikitextSection( section );
} else {
target.editSource();
Consider simplifying this complex logical expression. Open
Open
if (
// Modified click (e.g. ctrl+click)
!init.isUnmodifiedLeftClick( e ) ||
// Not an edit action
!( linkUrl.searchParams.has( 'action' ) || linkUrl.searchParams.has( 'veaction' ) ) ||
Avoid too many return
statements within this function. Open
Open
return null;