From 63601400e476c6cf43d985f3e7b9864681695ed4 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Fri, 18 Jan 2013 16:46:04 +0100 Subject: Update to MediaWiki 1.20.2 this update includes: * adjusted Arch Linux skin * updated FluxBBAuthPlugin * patch for https://bugzilla.wikimedia.org/show_bug.cgi?id=44024 --- .../Vector/modules/ext.vector.editWarning.js | 61 ++++++++-------------- 1 file changed, 23 insertions(+), 38 deletions(-) (limited to 'extensions/Vector/modules/ext.vector.editWarning.js') diff --git a/extensions/Vector/modules/ext.vector.editWarning.js b/extensions/Vector/modules/ext.vector.editWarning.js index e6ee5c60..e128fd45 100644 --- a/extensions/Vector/modules/ext.vector.editWarning.js +++ b/extensions/Vector/modules/ext.vector.editWarning.js @@ -11,22 +11,11 @@ $( '#wpTextbox1, #wpSummary' ).each( function () { $(this).data( 'origtext', $(this).val() ); }); - // Attach our own handler for onbeforeunload which respects the current one - var otherOnBeforeUnload = window.onbeforeunload; - function ourOnBeforeUnload() { - var fallbackResult, retval; + var savedWindowOnBeforeUnload; + $( window ) + .on( 'beforeunload.editwarning', function () { + var retval; - // Check if someone already set an onbeforeunload hook - if ( otherOnBeforeUnload ) { - // Get the result of their onbeforeunload hook - fallbackResult = otherOnBeforeUnload(); - } - - // Check if their onbeforeunload hook returned something - if ( fallbackResult !== undefined ) { - // Exit here, returning their message - retval = fallbackResult; - } else { // Check if the current values of some form elements are the same as // the original values if ( @@ -37,33 +26,29 @@ // Return our message retval = mw.msg( 'vector-editwarning-warning' ); } - } - - // Unset the onbeforeunload handler so we don't break page caching in Firefox - window.onbeforeunload = null; - if ( retval !== undefined ) { - // ...but if the user chooses not to leave the page, we need to rebind it - setTimeout( function () { - window.onbeforeunload = ourOnBeforeUnload; - }, 1 ); - return retval; - } - } - - // Do the first binding now - window.onbeforeunload = ourOnBeforeUnload; - function pageShowHandler() { - // Re-add onbeforeunload handler on pageshow. - window.onbeforeunload = ourOnBeforeUnload; - } - - $( window ).on( 'pageshow', pageShowHandler ); + // Unset the onbeforeunload handler so we don't break page caching in Firefox + savedWindowOnBeforeUnload = window.onbeforeunload; + window.onbeforeunload = null; + if ( retval !== undefined ) { + // ...but if the user chooses not to leave the page, we need to rebind it + setTimeout( function () { + window.onbeforeunload = savedWindowOnBeforeUnload; + }, 1 ); + return retval; + } + } ) + .on( 'pageshow.editwarning', function () { + // Re-add onbeforeunload handler + if ( window.onbeforeunload == null ) { + window.onbeforeunload = savedWindowOnBeforeUnload; + } + } ); // Add form submission handler $( '#editform' ).submit( function () { - // Restore whatever previous onbeforeload hook existed - window.onbeforeunload = otherOnBeforeUnload; + // Unbind our handlers + $( window ).off( '.editwarning' ); }); }); -- cgit v1.2.3-54-g00ecf