mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/CodeEditor
synced 2024-11-15 11:30:52 +00:00
Merge "Ask for confirmation when saving document with errors"
This commit is contained in:
commit
ecff4f5837
|
@ -49,7 +49,8 @@ $wgResourceModules['jquery.codeEditor'] = array(
|
||||||
'jquery.ui.resizable'
|
'jquery.ui.resizable'
|
||||||
),
|
),
|
||||||
'messages' => array(
|
'messages' => array(
|
||||||
'codeeditor-toolbar-toggle'
|
'codeeditor-toolbar-toggle',
|
||||||
|
'codeeditor-save-with-errors'
|
||||||
)
|
)
|
||||||
) + $tpl;
|
) + $tpl;
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
{
|
{
|
||||||
"@metadata": {
|
"@metadata": {
|
||||||
"authors": [
|
"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-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": {
|
"@metadata": {
|
||||||
"authors": [
|
"authors": [
|
||||||
"Purodha",
|
"Purodha",
|
||||||
"Shirayuki"
|
"Shirayuki",
|
||||||
|
"Derk-Jan Hartman"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"codeeditor-desc": "{{desc|name=Code Editor|url=http://www.mediawiki.org/wiki/Extension:CodeEditor}}",
|
"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 */
|
/* Ace syntax-highlighting code editor extension for wikiEditor */
|
||||||
/*global require, ace */
|
/*global require, ace, confirm */
|
||||||
(function ( $, mw ) {
|
(function ( $, mw ) {
|
||||||
$.wikiEditor.modules.codeEditor = {
|
$.wikiEditor.modules.codeEditor = {
|
||||||
/**
|
/**
|
||||||
|
@ -60,7 +60,23 @@
|
||||||
'ready': function ( ) {
|
'ready': function ( ) {
|
||||||
},
|
},
|
||||||
'codeEditorSubmit': 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' ) );
|
context.$textarea.val( context.$textarea.textSelection( 'getContents' ) );
|
||||||
|
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue