Merge "Use OOUI confirmation dialog rather than native confirm() for switching to source editing"

This commit is contained in:
jenkins-bot 2014-05-19 20:50:31 +00:00 committed by Gerrit Code Review
commit cd3264889c
4 changed files with 24 additions and 10 deletions

View file

@ -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',

View file

@ -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",

View file

@ -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.",

View file

@ -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 );
}
} );
};
/**