Alex Monk has uploaded a new change for review.
https://gerrit.wikimedia.org/r/250719
Change subject: Use mw.loader.using instead of weird hacks to load OOjs UI on
action=edit
......................................................................
Use mw.loader.using instead of weird hacks to load OOjs UI on action=edit
Change-Id: If03dab6130aed7662b04000b809884a514bb2762
---
M VisualEditor.hooks.php
M extension.json
M modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.init.js
3 files changed, 24 insertions(+), 44 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor
refs/changes/19/250719/1
diff --git a/VisualEditor.hooks.php b/VisualEditor.hooks.php
index 1962b80..4b65639 100644
--- a/VisualEditor.hooks.php
+++ b/VisualEditor.hooks.php
@@ -45,9 +45,6 @@
'ext.visualEditor.desktopArticleTarget.init',
'ext.visualEditor.targetLoader'
) );
- if ( in_array( Action::getActionName( RequestContext::getMain()
), array( 'edit', 'submit' ) ) ) {
- $output->addModules( 'ext.visualEditor.switching' );
- }
$output->addModuleStyles( array(
'ext.visualEditor.desktopArticleTarget.noscript' ) );
// add scroll offset js variable to output
$veConfig = ConfigFactory::getDefaultInstance()->makeConfig(
'visualeditor' );
diff --git a/extension.json b/extension.json
index 8701829..96d5258 100644
--- a/extension.json
+++ b/extension.json
@@ -968,28 +968,6 @@
"mobile"
]
},
- "ext.visualEditor.switching": {
- "scripts": [
-
"modules/ve-mw/ui/dialogs/ve.ui.MWVESwitchConfirmDialog.js"
- ],
- "dependencies": [
- "oojs",
- "oojs-ui",
- "ext.visualEditor.core"
- ],
- "messages": [
- "visualeditor-mweditmodeve-title",
- "visualeditor-mweditmodeve-tool",
- "visualeditor-mweditmodeve-warning",
- "visualeditor-mweditmodesource-warning-cancel",
- "visualeditor-mweditmodesource-warning-switch",
-
"visualeditor-mweditmodesource-warning-switch-discard"
- ],
- "targets": [
- "desktop",
- "mobile"
- ]
- },
"ext.visualEditor.mwcore": {
"scripts": [
"modules/ve-mw/dm/nodes/ve.dm.MWEntityNode.js",
@@ -1016,6 +994,7 @@
"modules/ve-mw/ui/dialogs/ve.ui.MWCommandHelpDialog.js",
"modules/ve-mw/ui/dialogs/ve.ui.MWCancelConfirmDialog.js",
"modules/ve-mw/ui/dialogs/ve.ui.MWWikitextSwitchConfirmDialog.js",
+
"modules/ve-mw/ui/dialogs/ve.ui.MWVESwitchConfirmDialog.js",
"modules/ve-mw/ui/elements/ve.ui.MWExpandableErrorElement.js",
"modules/ve-mw/ui/tools/ve.ui.MWEditModeTool.js",
"modules/ve-mw/ui/tools/ve.ui.MWPopupTool.js",
@@ -1053,8 +1032,7 @@
"jquery.byteLimit",
"mediawiki.skinning.content.parsoid",
"mediawiki.language.specialCharacters",
- "mediawiki.widgets",
- "ext.visualEditor.switching"
+ "mediawiki.widgets"
],
"messages": [
"visualeditor-beta-label",
@@ -1079,6 +1057,9 @@
"visualeditor-mweditmodesource-warning-cancel",
"visualeditor-mweditmodesource-warning-switch",
"visualeditor-mweditmodesource-warning-switch-discard",
+ "visualeditor-mweditmodeve-title",
+ "visualeditor-mweditmodeve-tool",
+ "visualeditor-mweditmodeve-warning",
"visualeditor-pagemenu-tooltip",
"visualeditor-pagetranslationwarning",
"visualeditor-savedialog-error-badtoken",
diff --git a/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.init.js
b/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.init.js
index 672ea79..d51c427 100644
--- a/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.init.js
+++ b/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.init.js
@@ -503,8 +503,7 @@
},
onEditTabClick: function ( e ) {
- var wikitextModified = $( '#wpTextbox1' ).val() !==
initialWikitext,
- windowManager, switchWindow;
+ var wikitextModified = $( '#wpTextbox1' ).val() !==
initialWikitext;
// Default mouse button is normalised by jQuery to key
code 1.
// Only do our handling if no keys are pressed, mouse
button is 1
@@ -515,24 +514,27 @@
}
if ( !isViewPage && ( mw.config.get( 'wgAction' ) ===
'submit' || wikitextModified ) ) {
- // Prompt if either we're on action=submit (the
user has previewed) or
- // the wikitext hash is different to the value
observed upon page load.
+ mw.loader.using( [
'ext.visualEditor.mediawiki', 'ext.visualEditor.mwcore' ] )
+ .done( function () {
+ var windowManager = new
OO.ui.WindowManager(),
+ switchWindow = new
ve.ui.MWVESwitchConfirmDialog();
+ // Prompt if either we're on
action=submit (the user has previewed) or
+ // the wikitext hash is
different to the value observed upon page load.
- windowManager = new OO.ui.WindowManager();
- $( 'body' ).append( windowManager.$element );
- switchWindow = new
ve.ui.MWVESwitchConfirmDialog();
- windowManager.addWindows( [ switchWindow ] );
- windowManager.openWindow( switchWindow ).done(
function ( opened ) {
- opened.done( function ( closing ) {
- closing.done( function ( data )
{
- if ( data &&
data.action === 'keep' ) {
-
activatePageTarget();
- } else if ( data &&
data.action === 'discard' ) {
- location.href =
veEditUri;
- }
+ $( 'body' ).append(
windowManager.$element );
+ windowManager.addWindows( [
switchWindow ] );
+ windowManager.openWindow(
switchWindow ).done( function ( opened ) {
+ opened.done( function (
closing ) {
+ closing.done(
function ( data ) {
+ if (
data && data.action === 'keep' ) {
+
activatePageTarget();
+ } else
if ( data && data.action === 'discard' ) {
+
location.href = veEditUri;
+ }
+ } );
+ } );
} );
} );
- } );
} else {
activatePageTarget();
}
--
To view, visit https://gerrit.wikimedia.org/r/250719
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: If03dab6130aed7662b04000b809884a514bb2762
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Alex Monk <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits