jenkins-bot has submitted this change and it was merged. Change subject: Use confirmCloseWindow from mediawiki-core ......................................................................
Use confirmCloseWindow from mediawiki-core Depends on I5d35b6fddd73cf56371eeda299ee0779cb40397a See the card at http://fab.wmflabs.org/T517 Change-Id: I9411a6d338eb40de622ccab2b07b89c6f60dbebc --- M UploadWizardHooks.php M docs/jsduck-config.json D resources/mw.ConfirmCloseWindow.js M resources/mw.UploadWizardUpload.js 4 files changed, 3 insertions(+), 56 deletions(-) Approvals: Gilles: Looks good to me, approved jenkins-bot: Verified diff --git a/UploadWizardHooks.php b/UploadWizardHooks.php index 0202f06..4f0ed8a 100644 --- a/UploadWizardHooks.php +++ b/UploadWizardHooks.php @@ -37,6 +37,7 @@ 'mediawiki.api.edit', 'mediawiki.api.category', 'mediawiki.api.parse', + 'mediawiki.confirmCloseWindow', 'mediawiki.Title', 'mediawiki.user', 'mediawiki.feedback', @@ -68,7 +69,6 @@ 'resources/mw.canvas.js', 'resources/mw.UtilitiesTime.js', 'resources/mw.ErrorDialog.js', - 'resources/mw.ConfirmCloseWindow.js', // mediawiki-specific interface helper (relies on mediawiki globals) 'resources/jquery/jquery.mwCoolCats.js', diff --git a/docs/jsduck-config.json b/docs/jsduck-config.json index e935552..b24f8a6 100644 --- a/docs/jsduck-config.json +++ b/docs/jsduck-config.json @@ -6,7 +6,6 @@ "--output": "./js", "--": [ "./external.js", - "../resources/mw.ConfirmCloseWindow.js", "../resources/uw/model" ] } diff --git a/resources/mw.ConfirmCloseWindow.js b/resources/mw.ConfirmCloseWindow.js deleted file mode 100644 index 1b92d55..0000000 --- a/resources/mw.ConfirmCloseWindow.js +++ /dev/null @@ -1,53 +0,0 @@ -( function ( mw, $ ) { - /** - * @method confirmCloseWindow - * @member mw - * - * Prevent the closing of a window with a confirm message (the onbeforeunload event seems to - * work in most browsers.) - * - * This supersedes any previous onbeforeunload handler. If there was a handler before, it is - * restored when you execute the returned function. - * - * var allowCloseWindow = mw.confirmCloseWindow(); - * // ... do stuff that can't be interrupted ... - * allowCloseWindow(); - * - * @param {Object} [options] - * @param {Function} [options.message] - * @param {string} options.message.return The string message to show in the confirm dialog. - * @param {Function} [options.test] - * @param {boolean} options.test.return Whether to show the dialog to the user. - * @return {Function} Execute this when you want to allow the user to close the window - */ - mw.confirmCloseWindow = function ( options ) { - function handleBeforeUnload() { - if ( options.test() ) { - // remove the handler while the alert is showing - otherwise breaks caching in Firefox (3?). - // but if they continue working on this page, immediately re-register this handler - window.onbeforeunload = null; - setTimeout( function () { - window.onbeforeunload = handleBeforeUnload; - } ); - - // show an alert with this message - return options.message(); - } - } - - var oldUnloadHandler = window.onbeforeunload, - defaults = { - message: function () { return mw.message( 'mwe-prevent-close' ).text(); }, - test: function () { return true; } - }; - - options = $.extend( defaults, options || {} ); - window.onbeforeunload = handleBeforeUnload; - - // return the function they can use to stop this - return function () { - window.onbeforeunload = oldUnloadHandler; - }; - - }; -} )( mediaWiki, jQuery ); diff --git a/resources/mw.UploadWizardUpload.js b/resources/mw.UploadWizardUpload.js index 5da5b1f..df91715 100644 --- a/resources/mw.UploadWizardUpload.js +++ b/resources/mw.UploadWizardUpload.js @@ -120,7 +120,8 @@ this.wizard.allowCloseWindow = mw.confirmCloseWindow( { message: function () { return mw.message( 'mwe-upwiz-prevent-close', upload.wizard.uploads.length ).escaped(); }, - test: function () { return !upload.wizard.isComplete() && upload.wizard.uploads.length > 0; } + test: function () { return !upload.wizard.isComplete() && upload.wizard.uploads.length > 0; }, + namespace: 'uploadwizard' } ); } this.setTransportProgress(0.0); -- To view, visit https://gerrit.wikimedia.org/r/151127 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I9411a6d338eb40de622ccab2b07b89c6f60dbebc Gerrit-PatchSet: 8 Gerrit-Project: mediawiki/extensions/UploadWizard Gerrit-Branch: master Gerrit-Owner: MarkTraceur <[email protected]> Gerrit-Reviewer: Gilles <[email protected]> Gerrit-Reviewer: Krinkle <[email protected]> Gerrit-Reviewer: MarkTraceur <[email protected]> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
