jenkins-bot has submitted this change and it was merged.
Change subject: Prompt the user to confirm a page change while an LQT edit form
is open
......................................................................
Prompt the user to confirm a page change while an LQT edit form is open
Bug: 46040
Change-Id: I6234a7651f70034f8a17ad242ddcf5793f0b899d
---
M LiquidThreads.php
M i18n/Lqt.i18n.php
M lqt.js
3 files changed, 17 insertions(+), 0 deletions(-)
Approvals:
Nikerabbit: Looks good to me, approved
jenkins-bot: Verified
diff --git a/LiquidThreads.php b/LiquidThreads.php
index 4560cab..2cbf9c7 100644
--- a/LiquidThreads.php
+++ b/LiquidThreads.php
@@ -59,6 +59,7 @@
'lqt-preview-signature',
'lqt_contents_title',
'lqt-empty-text',
+ 'lqt-pagechange-editformopen',
);
// ResourceLoader
diff --git a/i18n/Lqt.i18n.php b/i18n/Lqt.i18n.php
index 3b66cad..9446bcd 100644
--- a/i18n/Lqt.i18n.php
+++ b/i18n/Lqt.i18n.php
@@ -305,6 +305,8 @@
// Reply subpage name
'lqt-reply-subpage' => 'reply',
+ 'lqt-pagechange-editformopen' => 'You have unsaved text open on this
page. You may lose it if you go away from this page.',
+
// Tabs in skins
'nstab-thread' => 'Thread',
'nstab-summary' => 'Summary',
@@ -703,6 +705,7 @@
'lqt-reply-subpage' => 'Part of the page title when a LiquidThread
answer is given. Should probably be translated as a noun and not as a verb.
{{Identical|Reply}}',
+ 'lqt-pagechange-editformopen' => 'Shown as a JavaScript confirmation
dialog to the user when they try to leave the page while an LQT editing form is
open.',
'nstab-thread' => 'Used as tab title of the Thread namespace.
{{Identical|Thread}}',
'nstab-summary' => 'Used as tab title for the Summary namespace.
diff --git a/lqt.js b/lqt.js
index 0992770..8a5248d 100644
--- a/lqt.js
+++ b/lqt.js
@@ -1596,6 +1596,19 @@
// Set up periodic update checking
setInterval( liquidThreads.checkForUpdates, 60000 );
+
+ $( window ).bind( 'beforeunload', function() {
+ var confirmExitPage = false;
+ $( '.lqt-edit-form' ).each( function( index, element ) {
+ var textArea = $( element ).children( 'form' ).find(
'textarea' );
+ if ( element.style.display !== 'none' && textArea.val()
!== '' ) {
+ confirmExitPage = true;
+ }
+ } );
+ if ( confirmExitPage ) {
+ return mw.msg( 'lqt-pagechange-editformopen' );
+ }
+ } );
} );
}( mediaWiki, jQuery ) );
--
To view, visit https://gerrit.wikimedia.org/r/59159
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I6234a7651f70034f8a17ad242ddcf5793f0b899d
Gerrit-PatchSet: 6
Gerrit-Project: mediawiki/extensions/LiquidThreads
Gerrit-Branch: master
Gerrit-Owner: Alex Monk <[email protected]>
Gerrit-Reviewer: Alex Monk <[email protected]>
Gerrit-Reviewer: Kaldari <[email protected]>
Gerrit-Reviewer: Krinkle <[email protected]>
Gerrit-Reviewer: Nemo bis <[email protected]>
Gerrit-Reviewer: Nikerabbit <[email protected]>
Gerrit-Reviewer: Nischayn22 <[email protected]>
Gerrit-Reviewer: Trevor Parscal <[email protected]>
Gerrit-Reviewer: Werdna <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits