mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-24 22:35:41 +00:00
Merge "Use OOUI confirmation dialog rather than native confirm() for switching to source editing"
This commit is contained in:
commit
cd3264889c
|
@ -672,6 +672,8 @@ $wgResourceModules += array(
|
|||
'visualeditor-help-title',
|
||||
'visualeditor-mweditmodesource-title',
|
||||
'visualeditor-mweditmodesource-warning',
|
||||
'visualeditor-mweditmodesource-warning-switch',
|
||||
'visualeditor-mweditmodesource-warning-cancel',
|
||||
'visualeditor-pagemenu-tooltip',
|
||||
'visualeditor-pagetranslationwarning',
|
||||
'visualeditor-savedialog-error-badtoken',
|
||||
|
|
|
@ -180,6 +180,8 @@
|
|||
"visualeditor-mwalienextensioninspector-title": "MediaWiki extension",
|
||||
"visualeditor-mweditmodesource-title": "Switch to source editing",
|
||||
"visualeditor-mweditmodesource-warning": "You are about to switch to source editing.\nAny changes you've made to this document will be kept, but you will not be able switch back to VisualEditor without saving or reloading the page.\nDo you want to continue?",
|
||||
"visualeditor-mweditmodesource-warning-switch": "Yes, switch",
|
||||
"visualeditor-mweditmodesource-warning-cancel": "No, cancel",
|
||||
"visualeditor-mwgalleryinspector-placeholder": "Example.jpg|Caption for image",
|
||||
"visualeditor-mwgalleryinspector-title": "Gallery",
|
||||
"visualeditor-mwhieroinspector-title": "Hieroglyphics",
|
||||
|
|
|
@ -185,6 +185,8 @@
|
|||
"visualeditor-mwalienextensioninspector-title": "Used as title for unknown MediaWiki extensions.\n{{Identical|MediaWiki extension}}",
|
||||
"visualeditor-mweditmodesource-title": "Label for changing edit mode to source editing.",
|
||||
"visualeditor-mweditmodesource-warning": "Warning message show before changing edit mode to source editing.",
|
||||
"visualeditor-mweditmodesource-warning-switch": "Label for the OK button on the confirmation dialog for switching to source editing.",
|
||||
"visualeditor-mweditmodesource-warning-cancel": "Label for the cancel button on the confirmation dialog for switching to source editing.",
|
||||
"visualeditor-mwgalleryinspector-placeholder": "Placeholder text for the gallery inspector demonstrating how gallery syntax works.",
|
||||
"visualeditor-mwgalleryinspector-title": "Used as title for the gallery inspector.\n{{Identical|Gallery}}",
|
||||
"visualeditor-mwhieroinspector-title": "Used as title for the hieroglyphics inspector.",
|
||||
|
|
|
@ -891,19 +891,27 @@ ve.init.mw.ViewPageTarget.prototype.saveDocument = function () {
|
|||
* @method
|
||||
*/
|
||||
ve.init.mw.ViewPageTarget.prototype.editSource = function () {
|
||||
var doc = this.surface.getModel().getDocument();
|
||||
var confirmDialog = this.surface.dialogs.getWindow( 'confirm' );
|
||||
|
||||
this.$document.css( 'opacity', 0.5 );
|
||||
|
||||
if ( !confirm( ve.msg( 'visualeditor-mweditmodesource-warning' ) ) ) {
|
||||
this.$document.css( 'opacity', 1 );
|
||||
return;
|
||||
}
|
||||
// Get Wikitext from the DOM
|
||||
this.serialize(
|
||||
this.docToSave || ve.dm.converter.getDomFromModel( doc ),
|
||||
ve.bind( this.submitWithSaveFields, this, { 'wpDiff': 1, 'veswitched': 1 } )
|
||||
);
|
||||
confirmDialog.open( {
|
||||
'prompt': ve.msg( 'visualeditor-mweditmodesource-warning' ),
|
||||
'okLabel': ve.msg( 'visualeditor-mweditmodesource-warning-switch' ),
|
||||
'cancelLabel': ve.msg( 'visualeditor-mweditmodesource-warning-cancel' )
|
||||
} );
|
||||
confirmDialog.connect( this, {
|
||||
'ok': function () {
|
||||
// Get Wikitext from the DOM
|
||||
this.serialize(
|
||||
this.docToSave || ve.dm.converter.getDomFromModel( this.surface.getModel().getDocument() ),
|
||||
ve.bind( this.submitWithSaveFields, this, { 'wpDiff': 1, 'veswitched': 1 } )
|
||||
);
|
||||
},
|
||||
'cancel': function () {
|
||||
this.$document.css( 'opacity', 1 );
|
||||
}
|
||||
} );
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue