From 6042898fcfa48b3475b0e2c3c2654097420ebbad Mon Sep 17 00:00:00 2001 From: Ed Sanders Date: Fri, 9 Dec 2016 13:50:28 +0000 Subject: [PATCH] Use OOUI for confirm dialog Would be nice to do this for the goto line prompt, but such a OO.ui.prompt doesn't exist yet. Change-Id: I6b24e51b5b106ece80e265ff5417878f108619b7 --- extension.json | 3 ++- modules/jquery.codeEditor.js | 16 ++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/extension.json b/extension.json index 05a33e68..c6d763b2 100644 --- a/extension.json +++ b/extension.json @@ -51,7 +51,8 @@ "mediawiki.api.options", "user.options", "mediawiki.cookie", - "jquery.textSelection" + "jquery.textSelection", + "oojs-ui-windows" ], "messages": [ "codeeditor-next-annotation", diff --git a/modules/jquery.codeEditor.js b/modules/jquery.codeEditor.js index 9a133c88..1ae8ca9e 100644 --- a/modules/jquery.codeEditor.js +++ b/modules/jquery.codeEditor.js @@ -1,6 +1,6 @@ /* Ace syntax-highlighting code editor extension for wikiEditor */ -/* global ace, confirm, prompt */ -( function ( $, mw ) { +/* global ace */ +( function ( $, mw, OO ) { $.wikiEditor.modules.codeEditor = { /** * Core Requirements @@ -74,11 +74,19 @@ paste: returnFalse, ready: returnFalse, codeEditorSubmit: function () { + var form = this; context.evt.codeEditorSync(); if ( hasErrorsOnSave ) { hasErrorsOnSave = false; - return confirm( mw.msg( 'codeeditor-save-with-errors' ) ); + OO.ui.confirm( mw.msg( 'codeeditor-save-with-errors' ) ).done( function ( confirmed ) { + if ( confirmed ) { + // Programmatic submit doesn't retrigger this event listener + form.submit(); + } + } ); + return false; } + return true; }, codeEditorSave: function () { var i, @@ -839,4 +847,4 @@ } }; -}( jQuery, mediaWiki ) ); +}( jQuery, mediaWiki, OO ) );