mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-24 22:35:41 +00:00
Merge "Remove switch confirm dialogs"
This commit is contained in:
commit
53722cb92a
|
@ -1429,7 +1429,6 @@
|
|||
"visualeditor-mweditmodesource-tool-current",
|
||||
"visualeditor-mweditmodesource-tool-unavailable",
|
||||
"visualeditor-mweditmodesource-warning-cancel",
|
||||
"visualeditor-mweditmodesource-warning-switch",
|
||||
"visualeditor-mweditmodesource-warning-switch-discard",
|
||||
"visualeditor-mweditmodeve-popup-body",
|
||||
"visualeditor-mweditmodeve-popup-title",
|
||||
|
@ -1482,7 +1481,6 @@
|
|||
"modules/ve-mw/ui/dialogs/ve.ui.MWExtensionDialog.js",
|
||||
"modules/ve-mw/ui/dialogs/ve.ui.MWExtensionPreviewDialog.js",
|
||||
"modules/ve-mw/ui/dialogs/ve.ui.MWCommandHelpDialog.js",
|
||||
"modules/ve-mw/ui/dialogs/ve.ui.MWWikitextSwitchConfirmDialog.js",
|
||||
"modules/ve-mw/ui/widgets/ve.ui.MWPreTextInputWidget.js",
|
||||
"modules/ve-mw/ui/dialogs/ve.ui.MWPreDialog.js",
|
||||
"modules/ve-mw/ui/dialogs/ve.ui.MWTableDialog.js",
|
||||
|
@ -1575,10 +1573,7 @@
|
|||
"visualeditor-help-link",
|
||||
"visualeditor-help-title",
|
||||
"visualeditor-mweditmodesource-progress",
|
||||
"visualeditor-mweditmodesource-title",
|
||||
"visualeditor-mweditmodesource-warning",
|
||||
"visualeditor-mweditmodesource-warning-cancel",
|
||||
"visualeditor-mweditmodesource-warning-switch",
|
||||
"visualeditor-mweditmodesource-warning-switch-discard",
|
||||
"visualeditor-mweditmodeve-progress",
|
||||
"visualeditor-pagemenu-tooltip",
|
||||
|
|
|
@ -250,12 +250,9 @@
|
|||
"visualeditor-meta-tool": "Options",
|
||||
"visualeditor-mweditmode-tooltip": "Switch editor",
|
||||
"visualeditor-mweditmodesource-progress": "Switching to source editing…",
|
||||
"visualeditor-mweditmodesource-title": "Switch to source editing?",
|
||||
"visualeditor-mweditmodesource-tool-current": "Source editing",
|
||||
"visualeditor-mweditmodesource-tool-unavailable": "Source editing is not available here",
|
||||
"visualeditor-mweditmodesource-warning": "You are switching to source editing.\nDo you want to continue?",
|
||||
"visualeditor-mweditmodesource-warning-cancel": "Cancel",
|
||||
"visualeditor-mweditmodesource-warning-switch": "Switch",
|
||||
"visualeditor-mweditmodesource-warning-switch-discard": "Discard my changes and switch",
|
||||
"visualeditor-mweditmodeve-popup-body": "You can switch back to visual editing at any time by clicking on this icon.",
|
||||
"visualeditor-mweditmodeve-popup-title": "You have switched to source editing",
|
||||
|
|
|
@ -266,12 +266,9 @@
|
|||
"visualeditor-meta-tool": "Text of tool in the toolbar the lets users set categories, language links and other page settings.\n{{Identical|Options}}",
|
||||
"visualeditor-mweditmode-tooltip": "Tooltip text for editor switching menu.",
|
||||
"visualeditor-mweditmodesource-progress": "Title of progress bar shown while switching to source mode.",
|
||||
"visualeditor-mweditmodesource-title": "Title of dialog to confirm switching to source mode.",
|
||||
"visualeditor-mweditmodesource-tool-current": "Label for tool that changes edit mode to source editing (or describes the mode if the user is already in that mode).",
|
||||
"visualeditor-mweditmodesource-tool-unavailable": "'''Please translate \"Source\" as meaning \"Source codes\", not source of references.''' Label for tool that changes edit mode to source editing when it is not available.",
|
||||
"visualeditor-mweditmodesource-warning": "Warning message show before changing edit mode to source editing. It may allow the user to keep the changes using the message {{msg-mw|Visualeditor-mweditmodesource-warning-switch}} or cancel.",
|
||||
"visualeditor-mweditmodesource-warning-cancel": "Label for the button on the confirmation dialog for switching to source editing to cancel and return to editing.\n{{Identical|Cancel}}",
|
||||
"visualeditor-mweditmodesource-warning-switch": "Label for the button on the confirmation dialog for switching to source editing to continue and switch editors.\n{{Identical|Switch}}",
|
||||
"visualeditor-mweditmodesource-warning-switch-discard": "Label for the button on the confirmation dialog for switching to visual editing to continue and switch editors when doing so will throw away your changes.",
|
||||
"visualeditor-mweditmodeve-popup-body": "Body text of popup shown after switching to source mode from visual mode",
|
||||
"visualeditor-mweditmodeve-popup-title": "Title of popup shown after switching to source mode from visual mode",
|
||||
|
@ -350,7 +347,7 @@
|
|||
"visualeditor-mwpredialog-convert": "Label for a button which will convert the preformatted text block into a form which can have text styles applied (e.g. bold, italic, links).",
|
||||
"visualeditor-mwpredialog-title": "Title for the preformatted text dialog. It appears when clicking on a <nowiki><pre></nowiki> element.",
|
||||
"visualeditor-mwsignature-tool": "Used as name of the tool for inserting signatures.",
|
||||
"visualeditor-pagemenu-tooltip": "Tooltip text for the page menu which has the following items:\n* {{msg-mw|visualeditor-meta-tool}}\n* {{msg-mw|visualeditor-settings-tool}}\n* {{msg-mw|visualeditor-advancedsettings-tool}}\n* {{msg-mw|visualeditor-categories-tool}}\n* {{msg-mw|visualeditor-languages-tool}}\n* {{msg-mw|visualeditor-mweditmodesource-title}}\n* {{msg-mw|visualeditor-dialog-command-help-title}}",
|
||||
"visualeditor-pagemenu-tooltip": "Tooltip text for the page menu which has the following items:\n* {{msg-mw|visualeditor-meta-tool}}\n* {{msg-mw|visualeditor-settings-tool}}\n* {{msg-mw|visualeditor-advancedsettings-tool}}\n* {{msg-mw|visualeditor-categories-tool}}\n* {{msg-mw|visualeditor-languages-tool}}\n* {{msg-mw|visualeditor-dialog-command-help-title}}",
|
||||
"visualeditor-pagetranslationwarning": "Edit notice shown when VisualEditor loads, warning users editing a translated page that it is not officially supported.",
|
||||
"visualeditor-parameter-input-placeholder": "Placeholder text label for an input for adding a parameter to a template.\n{{Identical|Field name}}",
|
||||
"visualeditor-parameter-search-more": "Label for item in parameter list that, when clicked, reveals additional parameters that had been truncated to save space.\n\nParameters:\n* $1 - number of fields (parameters)",
|
||||
|
@ -423,7 +420,7 @@
|
|||
"visualeditor-usernamespacepagelink": "Name of a page describing the user namespace (NS2) in this project.\n{{doc-important|Do not translate \"Project\"; it is automatically converted to the wiki's project namespace.}}",
|
||||
"visualeditor-version-label": "Label text for version number\n{{Identical|Version}}",
|
||||
"visualeditor-wikitext-progress": "Label for progress bar shown while converting pasted wikitext.",
|
||||
"visualeditor-wikitext-warning": "Contents of notification displayed when Wikitext has been detected.\n\nRefers to:\n* {{msg-mw|Visualeditor-wikitext-warning-link}}\n* {{msg-mw|Visualeditor-toolbar-cancel}}\n* {{msg-mw|Visualeditor-mweditmodesource-title}}\nSee also:\n* {{msg-mw|Visualeditor-beta-warning}}",
|
||||
"visualeditor-wikitext-warning": "Contents of notification displayed when Wikitext has been detected.\n\nRefers to:\n* {{msg-mw|Visualeditor-wikitext-warning-link}}\n* {{msg-mw|Visualeditor-toolbar-cancel}}\nSee also:\n* {{msg-mw|Visualeditor-beta-warning}}",
|
||||
"visualeditor-wikitext-warning-link": "Link to page describing what Wikitext is.\n\nUsed in:\n* {{msg-mw|Visualeditor-wikitext-warning}}.\n\nTranslate to a title where most wikis in the language you're translating to have one such help page; if they don't have one, you can use [[mw:Special:MyLanguage/Help:Formatting]] as target.",
|
||||
"visualeditor-wikitext-warning-title": "Title of notification displayed when Wikitext has been detected",
|
||||
"visualeditor-wikitextconvert-title": "Title of prompt displayed when rich markup is pasted into a source mode editor.",
|
||||
|
|
|
@ -868,7 +868,14 @@
|
|||
activateVe: function ( mode ) {
|
||||
var wikitext = $( '#wpTextbox1' ).textSelection( 'getContents' ),
|
||||
sectionVal = $( 'input[name=wpSection]' ).val(),
|
||||
section = sectionVal !== '' && sectionVal !== undefined ? +sectionVal : null;
|
||||
section = sectionVal !== '' && sectionVal !== undefined ? +sectionVal : null,
|
||||
config = mw.config.get( 'wgVisualEditorConfig' ),
|
||||
canSwitch = config.fullRestbaseUrl || config.allowLossySwitching,
|
||||
modified = mw.config.get( 'wgAction' ) === 'submit' ||
|
||||
(
|
||||
mw.config.get( 'wgAction' ) === 'edit' &&
|
||||
wikitext !== initialWikitext
|
||||
);
|
||||
|
||||
// Close any open jQuery.UI dialogs (e.g. WikiEditor's find and replace)
|
||||
if ( $.fn.dialog ) {
|
||||
|
@ -880,18 +887,10 @@
|
|||
$( window ).off( 'beforeunload.editwarning' );
|
||||
}
|
||||
|
||||
if (
|
||||
mw.config.get( 'wgAction' ) === 'submit' ||
|
||||
(
|
||||
mw.config.get( 'wgAction' ) === 'edit' &&
|
||||
wikitext !== initialWikitext
|
||||
)
|
||||
) {
|
||||
if ( modified && !canSwitch ) {
|
||||
mw.loader.using( 'ext.visualEditor.switching' ).done( function () {
|
||||
var windowManager = new OO.ui.WindowManager(),
|
||||
switchWindow = new mw.libs.ve.SwitchConfirmDialog();
|
||||
// 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.
|
||||
|
||||
$( document.body ).append( windowManager.$element );
|
||||
windowManager.addWindows( [ switchWindow ] );
|
||||
|
@ -899,10 +898,7 @@
|
|||
.closed.then( function ( data ) {
|
||||
var oldUri;
|
||||
// TODO: windowManager.destroy()?
|
||||
if ( data && data.action === 'keep' ) {
|
||||
releaseOldEditWarning();
|
||||
activatePageTarget( mode, section, true );
|
||||
} else if ( data && data.action === 'discard' ) {
|
||||
if ( data && data.action === 'discard' ) {
|
||||
releaseOldEditWarning();
|
||||
setEditorPreference( 'visualeditor' );
|
||||
oldUri = veEditUri.clone();
|
||||
|
@ -913,7 +909,7 @@
|
|||
} );
|
||||
} else {
|
||||
releaseOldEditWarning();
|
||||
activatePageTarget( mode, section, false );
|
||||
activatePageTarget( mode, section, modified );
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -1033,8 +1033,6 @@ ve.init.mw.DesktopArticleTarget.prototype.serializeFail = function ( jqXHR, stat
|
|||
|
||||
OO.ui.alert( ve.msg( 'visualeditor-serializeerror', status ) );
|
||||
|
||||
this.getSurface().getDialogs().closeWindow( 'wikitextswitchconfirm' );
|
||||
|
||||
// It's possible to get here while the save dialog has never been opened (if the user uses
|
||||
// the switch to source mode option)
|
||||
if ( this.saveDialog ) {
|
||||
|
|
|
@ -38,59 +38,25 @@ mw.libs.ve.SwitchConfirmDialog.static.actions = [
|
|||
{
|
||||
action: 'cancel',
|
||||
label: mw.msg( 'visualeditor-mweditmodesource-warning-cancel' ),
|
||||
flags: [ 'safe', 'back' ],
|
||||
modes: [ 'restbase', 'simple' ]
|
||||
flags: [ 'safe', 'back' ]
|
||||
},
|
||||
{
|
||||
action: 'discard',
|
||||
label: mw.msg( 'visualeditor-mweditmodesource-warning-switch-discard' ),
|
||||
flags: 'destructive',
|
||||
modes: [ 'simple' ]
|
||||
},
|
||||
{
|
||||
action: 'keep',
|
||||
label: mw.msg( 'visualeditor-mweditmodesource-warning-switch' ),
|
||||
flags: [ 'progressive', 'primary' ],
|
||||
modes: [ 'restbase' ]
|
||||
flags: 'destructive'
|
||||
}
|
||||
];
|
||||
|
||||
/* Methods */
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
mw.libs.ve.SwitchConfirmDialog.prototype.getSetupProcess = function ( data ) {
|
||||
return mw.libs.ve.SwitchConfirmDialog.super.prototype.getSetupProcess.apply( this, arguments )
|
||||
.next( function () {
|
||||
var
|
||||
config = mw.config.get( 'wgVisualEditorConfig' ),
|
||||
canSwitch = config.fullRestbaseUrl || config.allowLossySwitching;
|
||||
if ( data && data.mode ) {
|
||||
this.actions.setMode( data.mode );
|
||||
} else if ( canSwitch ) {
|
||||
this.actions.setMode( 'restbase' );
|
||||
} else {
|
||||
this.actions.setMode( 'simple' );
|
||||
}
|
||||
}, this );
|
||||
};
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
mw.libs.ve.SwitchConfirmDialog.prototype.getActionProcess = function ( action ) {
|
||||
if ( action === 'keep' ) {
|
||||
if ( action === 'discard' ) {
|
||||
return new OO.ui.Process( function () {
|
||||
this.getActions()
|
||||
.setAbilities( { cancel: false, discard: false } )
|
||||
.get( { actions: 'keep' } )[ 0 ].pushPending();
|
||||
this.close( { action: 'keep' } );
|
||||
}, this );
|
||||
} else if ( action === 'discard' ) {
|
||||
return new OO.ui.Process( function () {
|
||||
this.getActions()
|
||||
.setAbilities( { cancel: false, keep: false } )
|
||||
.setAbilities( { cancel: false } )
|
||||
.get( { actions: 'discard' } )[ 0 ].pushPending();
|
||||
this.close( { action: 'discard' } );
|
||||
}, this );
|
||||
|
|
|
@ -1201,12 +1201,7 @@ ve.init.mw.ArticleTarget.prototype.clearState = function () {
|
|||
ve.init.mw.ArticleTarget.prototype.editSource = function () {
|
||||
var modified = this.fromEditedState || this.getSurface().getModel().hasBeenModified();
|
||||
|
||||
if ( ve.init.target.isModeAvailable( 'source' ) || !modified ) {
|
||||
this.switchToWikitextEditor( modified );
|
||||
} else {
|
||||
ve.ui.actionFactory.create( 'window', this.getSurface() )
|
||||
.open( 'wikitextswitchconfirm', { target: this } );
|
||||
}
|
||||
this.switchToWikitextEditor( modified );
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,83 +0,0 @@
|
|||
/*!
|
||||
* VisualEditor user interface MWWikitextSwitchConfirmDialog class.
|
||||
*
|
||||
* @copyright 2011-2019 VisualEditor Team and others; see AUTHORS.txt
|
||||
* @license The MIT License (MIT); see LICENSE.txt
|
||||
*/
|
||||
|
||||
/**
|
||||
* Dialog for letting the user choose how to switch to wikitext mode.
|
||||
*
|
||||
* @class
|
||||
* @extends OO.ui.MessageDialog
|
||||
*
|
||||
* @constructor
|
||||
* @param {Object} [config] Configuration options
|
||||
*/
|
||||
ve.ui.MWWikitextSwitchConfirmDialog = function VeUiMWWikitextSwitchConfirmDialog( config ) {
|
||||
// Parent constructor
|
||||
ve.ui.MWWikitextSwitchConfirmDialog.super.call( this, config );
|
||||
};
|
||||
|
||||
/* Inheritance */
|
||||
|
||||
OO.inheritClass( ve.ui.MWWikitextSwitchConfirmDialog, OO.ui.MessageDialog );
|
||||
|
||||
/* Static Properties */
|
||||
|
||||
ve.ui.MWWikitextSwitchConfirmDialog.static.name = 'wikitextswitchconfirm';
|
||||
|
||||
ve.ui.MWWikitextSwitchConfirmDialog.static.title =
|
||||
OO.ui.deferMsg( 'visualeditor-mweditmodesource-title' );
|
||||
|
||||
ve.ui.MWWikitextSwitchConfirmDialog.static.message =
|
||||
OO.ui.deferMsg( 'visualeditor-mweditmodesource-warning' );
|
||||
|
||||
ve.ui.MWWikitextSwitchConfirmDialog.static.actions = [
|
||||
{
|
||||
action: 'cancel',
|
||||
label: OO.ui.deferMsg( 'visualeditor-mweditmodesource-warning-cancel' ),
|
||||
flags: [ 'safe', 'back' ]
|
||||
},
|
||||
{
|
||||
action: 'switch',
|
||||
label: OO.ui.deferMsg( 'visualeditor-mweditmodesource-warning-switch' ),
|
||||
flags: [ 'progressive', 'primary' ]
|
||||
}
|
||||
];
|
||||
|
||||
/* Methods */
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
ve.ui.MWWikitextSwitchConfirmDialog.prototype.getActionProcess = function ( action ) {
|
||||
if ( action === 'switch' ) {
|
||||
return new OO.ui.Process( function () {
|
||||
this.getActions().setAbilities( { cancel: false } );
|
||||
this.getActions().get()[ 1 ].pushPending();
|
||||
this.target.switchToWikitextEditor( true );
|
||||
}, this );
|
||||
} else if ( action === 'cancel' ) {
|
||||
return new OO.ui.Process( function () {
|
||||
this.close( { action: action } );
|
||||
}, this );
|
||||
}
|
||||
|
||||
// Parent method
|
||||
return ve.ui.MWWikitextSwitchConfirmDialog.super.prototype.getActionProcess.call( this, action );
|
||||
};
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
**/
|
||||
ve.ui.MWWikitextSwitchConfirmDialog.prototype.setup = function ( data ) {
|
||||
this.target = data.target;
|
||||
|
||||
// Parent method
|
||||
return ve.ui.MWWikitextSwitchConfirmDialog.super.prototype.setup.call( this, data );
|
||||
};
|
||||
|
||||
/* Registration */
|
||||
|
||||
ve.ui.windowFactory.register( ve.ui.MWWikitextSwitchConfirmDialog );
|
Loading…
Reference in a new issue