mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-12-01 01:16:30 +00:00
targets: Fix silly indirection via a global variable
Since we're inside the Target instance, `ve.init.target` refers to this object. Some of the code I'm changing even uses `this` instead of `ve.init.target` on the next or previous line. Most of the mistakes are a result of mass search-and-replace changes (478b0bcb
,e1a887cc
), or moving the code from other classes (d294006d
). But I can't explain the "ve.init.target.getSurface().getDom()" line, it would be good to figure out why it was this way before we change it. Change-Id: I0d7c6a48369242d4c99620fcd775ab537420d84a
This commit is contained in:
parent
2b6857d89a
commit
cc1cb63aca
|
@ -345,7 +345,7 @@ ve.init.mw.DesktopArticleTarget.prototype.loadSuccess = function () {
|
|||
$.cookie( 've-beta-welcome-dialog', 1, { path: '/', expires: 30 } );
|
||||
}
|
||||
} else {
|
||||
ve.init.target.getLocalApi().saveOption( 'visualeditor-hidebetawelcome', '1' );
|
||||
this.getLocalApi().saveOption( 'visualeditor-hidebetawelcome', '1' );
|
||||
mw.user.options.set( 'visualeditor-hidebetawelcome', '1' );
|
||||
}
|
||||
this.suppressNormalStartupDialogs = true;
|
||||
|
@ -461,7 +461,7 @@ ve.init.mw.DesktopArticleTarget.prototype.afterActivate = function () {
|
|||
}
|
||||
// Transfer and initial source range to the surface (e.g. from tempWikitextEditor)
|
||||
if ( this.initialSourceRange && this.getSurface().getMode() === 'source' ) {
|
||||
surfaceModel = ve.init.target.getSurface().getModel();
|
||||
surfaceModel = this.getSurface().getModel();
|
||||
range = surfaceModel.getRangeFromSourceOffsets( this.initialSourceRange.from, this.initialSourceRange.to );
|
||||
surfaceModel.setLinearSelection( range );
|
||||
}
|
||||
|
@ -720,7 +720,7 @@ ve.init.mw.DesktopArticleTarget.prototype.loadFail = function ( code, errorDetai
|
|||
OO.ui.confirm( confirmPromptMessage ).done( function ( confirmed ) {
|
||||
if ( confirmed ) {
|
||||
target.load();
|
||||
} else if ( $( '#wpTextbox1' ).length && !ve.init.target.isModeAvailable( 'source' ) ) {
|
||||
} else if ( $( '#wpTextbox1' ).length && !target.isModeAvailable( 'source' ) ) {
|
||||
// If we're switching from the wikitext editor, just deactivate
|
||||
// don't try to switch back to it fully, that'd discard changes.
|
||||
target.tryTeardown( true );
|
||||
|
@ -1344,7 +1344,7 @@ ve.init.mw.DesktopArticleTarget.prototype.onWindowPopState = function ( e ) {
|
|||
this.currentUri = new mw.Uri( location.href );
|
||||
veaction = this.currentUri.query.veaction;
|
||||
|
||||
if ( ve.init.target.isModeAvailable( 'source' ) && this.active ) {
|
||||
if ( this.isModeAvailable( 'source' ) && this.active ) {
|
||||
if ( veaction === 'editsource' && this.getDefaultMode() === 'visual' ) {
|
||||
this.actFromPopState = true;
|
||||
this.switchToWikitextEditor();
|
||||
|
@ -1526,7 +1526,7 @@ ve.init.mw.DesktopArticleTarget.prototype.switchToVisualEditor = function () {
|
|||
// Parent method
|
||||
ve.init.mw.DesktopArticleTarget.super.prototype.switchToVisualEditor.apply( this, arguments );
|
||||
|
||||
if ( ve.init.target.isModeAvailable( 'visual' ) ) {
|
||||
if ( this.isModeAvailable( 'visual' ) ) {
|
||||
ve.track( 'activity.editor-switch', { action: 'visual-desktop' } );
|
||||
}
|
||||
};
|
||||
|
@ -1538,7 +1538,7 @@ ve.init.mw.DesktopArticleTarget.prototype.switchToWikitextEditor = function () {
|
|||
// Parent method
|
||||
ve.init.mw.DesktopArticleTarget.super.prototype.switchToWikitextEditor.apply( this, arguments );
|
||||
|
||||
if ( ve.init.target.isModeAvailable( 'source' ) ) {
|
||||
if ( this.isModeAvailable( 'source' ) ) {
|
||||
ve.track( 'activity.editor-switch', { action: 'source-nwe-desktop' } );
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1076,7 +1076,7 @@ ve.init.mw.ArticleTarget.prototype.getVisualDiffGeneratorPromise = function () {
|
|||
action: 'visualeditor',
|
||||
paction: 'parsedoc',
|
||||
page: target.getPageName(),
|
||||
wikitext: ve.init.target.getSurface().getDom(),
|
||||
wikitext: target.getSurface().getDom(),
|
||||
pst: true
|
||||
} ).then( function ( response ) {
|
||||
// Use anonymous function to avoid passing through API promise argument
|
||||
|
@ -2266,7 +2266,7 @@ ve.init.mw.ArticleTarget.prototype.maybeShowWelcomeDialog = function () {
|
|||
}
|
||||
|
||||
if ( prefSaysShow ) {
|
||||
ve.init.target.getLocalApi().saveOption( 'visualeditor-hidebetawelcome', '1' );
|
||||
this.getLocalApi().saveOption( 'visualeditor-hidebetawelcome', '1' );
|
||||
mw.user.options.set( 'visualeditor-hidebetawelcome', '1' );
|
||||
|
||||
// No need to set a cookie every time for logged-in users that have already
|
||||
|
@ -2297,7 +2297,7 @@ ve.init.mw.ArticleTarget.prototype.switchToWikitextEditor = function ( modified
|
|||
this.section = null;
|
||||
}
|
||||
|
||||
if ( ve.init.target.isModeAvailable( 'source' ) ) {
|
||||
if ( this.isModeAvailable( 'source' ) ) {
|
||||
if ( !modified ) {
|
||||
dataPromise = mw.libs.ve.targetLoader.requestPageData( 'source', this.getPageName(), {
|
||||
sessionStore: true,
|
||||
|
|
Loading…
Reference in a new issue