Alex Monk has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/59159


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, 16 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/LiquidThreads 
refs/changes/59/59159/1

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 b6c2660..4b6d30c 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' => 'Dynamic editing form(s) are open. You 
may loose your text if you continue.',
+
        // Tabs in skins
        'nstab-thread' => 'Thread',
        'nstab-summary' => 'Summary',
@@ -698,6 +700,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..986ce1e 100644
--- a/lqt.js
+++ b/lqt.js
@@ -1596,6 +1596,18 @@
 
        // Set up periodic update checking
        setInterval( liquidThreads.checkForUpdates, 60000 );
+
+       $( window ).bind( 'beforeunload', function( e ) {
+               var confirmExitPage = false;
+               $( '.lqt-edit-form' ).each( function( index, element ) {
+                       if ( element.style.display != 'none' && 
element.innerHTML.length != 0 ) {
+                               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: newchange
Gerrit-Change-Id: I6234a7651f70034f8a17ad242ddcf5793f0b899d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/LiquidThreads
Gerrit-Branch: master
Gerrit-Owner: Alex Monk <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to