mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/CodeEditor
synced 2024-11-14 19:14:41 +00:00
Ask for confirmation when saving document with errors
Bug: 63202 Change-Id: Ifbdf976f3c0f27da67d7cf034c040d4279d62217
This commit is contained in:
parent
27249af1cc
commit
262bfde28e
|
@ -49,7 +49,8 @@ $wgResourceModules['jquery.codeEditor'] = array(
|
|||
'jquery.ui.resizable'
|
||||
),
|
||||
'messages' => array(
|
||||
'codeeditor-toolbar-toggle'
|
||||
'codeeditor-toolbar-toggle',
|
||||
'codeeditor-save-with-errors'
|
||||
)
|
||||
) + $tpl;
|
||||
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
{
|
||||
"@metadata": {
|
||||
"authors": [
|
||||
"Brion Vibber"
|
||||
"Brion Vibber",
|
||||
"Derk-Jan Hartman"
|
||||
]
|
||||
},
|
||||
"codeeditor-desc": "Syntax-highlighted editing for JavaScript and CSS pages using [http://ace.ajax.org/ Ace editor]",
|
||||
"codeeditor-toolbar-toggle": "Toggle code editor"
|
||||
}
|
||||
"codeeditor-toolbar-toggle": "Toggle code editor",
|
||||
"codeeditor-save-with-errors": "The document contains errors. Are you sure you want to save?"
|
||||
}
|
||||
|
|
|
@ -2,9 +2,11 @@
|
|||
"@metadata": {
|
||||
"authors": [
|
||||
"Purodha",
|
||||
"Shirayuki"
|
||||
"Shirayuki",
|
||||
"Derk-Jan Hartman"
|
||||
]
|
||||
},
|
||||
"codeeditor-desc": "{{desc|name=Code Editor|url=http://www.mediawiki.org/wiki/Extension:CodeEditor}}",
|
||||
"codeeditor-toolbar-toggle": "Used as label for toolbar button."
|
||||
}
|
||||
"codeeditor-toolbar-toggle": "Used as label for toolbar button.",
|
||||
"codeeditor-save-with-errors": "Used as message in a dialog before saving a document with errors."
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* Ace syntax-highlighting code editor extension for wikiEditor */
|
||||
/*global require, ace */
|
||||
/*global require, ace, confirm */
|
||||
(function ( $, mw ) {
|
||||
$.wikiEditor.modules.codeEditor = {
|
||||
/**
|
||||
|
@ -60,7 +60,23 @@
|
|||
'ready': function ( ) {
|
||||
},
|
||||
'codeEditorSubmit': function ( ) {
|
||||
context.evt.codeEditorSync();
|
||||
var i,
|
||||
hasError = false,
|
||||
annotations = context.codeEditor.getSession().getAnnotations();
|
||||
for( i = 0; i < annotations.length; i++ ) {
|
||||
if ( annotations[i].type === 'error' ) {
|
||||
hasError = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( hasError ) {
|
||||
return confirm( mw.msg( 'codeeditor-save-with-errors' ) );
|
||||
}
|
||||
},
|
||||
'codeEditorSync': function ( ) {
|
||||
context.$textarea.val( context.$textarea.textSelection( 'getContents' ) );
|
||||
|
||||
}
|
||||
} );
|
||||
|
||||
|
|
Loading…
Reference in a new issue