Matthias Mullie has uploaded a new change for review.
https://gerrit.wikimedia.org/r/62982
Change subject: (bug 37510) Clicking 'donate to Wikipedia' gives no warning
message before leaving the page <OH-AFT>
......................................................................
(bug 37510) Clicking 'donate to Wikipedia' gives no warning message before
leaving the page <OH-AFT>
This will ask for confirmation if moving away from the page once a user has
started writing feedback, but has not yet submitted it.
Bug: 37510
Change-Id: Icdcb0ad36da12bd2efbc2e16a2301946bac315df
---
M ArticleFeedbackv5.i18n.php
M ArticleFeedbackv5.php
M modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.js
3 files changed, 17 insertions(+), 2 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ArticleFeedbackv5
refs/changes/82/62982/1
diff --git a/ArticleFeedbackv5.i18n.php b/ArticleFeedbackv5.i18n.php
index f44d4fb..12a1b26 100644
--- a/ArticleFeedbackv5.i18n.php
+++ b/ArticleFeedbackv5.i18n.php
@@ -587,6 +587,7 @@
'articlefeedbackv5-section-linktext' => 'feedback',
'articlefeedbackv5-toolbox-view' => 'View feedback',
'articlefeedbackv5-toolbox-add' => 'Add your feedback',
+ 'articlefeedbackv5-leave-warning' => 'Data you have entered may not be
saved.',
/* Special:Preferences */
'articlefeedbackv5-disable-preference' => "Don't show the Article
feedback widget on pages",
@@ -1656,6 +1657,7 @@
{{Identical|Feedback}}',
'articlefeedbackv5-toolbox-view' => 'This link will take users to the
feedback page of article currently being read',
'articlefeedbackv5-toolbox-add' => 'This link will scroll down the
screen and make the form flash, pointing users to the feedback form',
+ 'articlefeedbackv5-leave-warning' => 'Warning message to be displayed
if a user attempts to leave the page after having started writing feedback and
not having submitted it.',
'articlefeedbackv5-disable-preference' => 'Preference name/description
for disabling AFTv5',
'right-aft-reader' => '{{doc-right|aft-reader}}
Permission to post feedback & mark as (un)helpful (see
http://www.mediawiki.org/wiki/Article_feedback/Version_5/Feature_Requirements#Access_and_permissions)',
diff --git a/ArticleFeedbackv5.php b/ArticleFeedbackv5.php
index 6535c6a..2b2ebb2 100644
--- a/ArticleFeedbackv5.php
+++ b/ArticleFeedbackv5.php
@@ -663,6 +663,7 @@
'articlefeedbackv5-bucket6-form-success',
'articlefeedbackv5-bucket6-form-submit',
'articlefeedbackv5-bucket6-backlink-text',
+ 'articlefeedbackv5-leave-warning',
'articlefeedbackv5-error',
'articlefeedbackv5-help-tooltip-title',
'articlefeedbackv5-help-tooltip-info',
diff --git a/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.js
b/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.js
index 91169e8..cd03c7f 100644
--- a/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.js
+++ b/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.js
@@ -764,6 +764,17 @@
// add character-countdown on feedback-field
$( document )
.on( 'keyup',
'.articleFeedbackv5-comment textarea', function () {
+
+ /*
+ * If people have started
writing feedback, inform them
+ * that leaving the page will
result in lost data.
+ */
+ if ( typeof
window.onbeforeunload != 'function' ) {
+ $( window ).on(
'beforeunload', function() {
+ return mw.msg(
'articlefeedbackv5-leave-warning' );
+ } );
+ }
+
$.articleFeedbackv5.unlockForm();
$.articleFeedbackv5.currentBucket().countdown( $( this ) );
} );
@@ -780,6 +791,9 @@
.click( function ( e ) {
e.preventDefault();
$.articleFeedbackv5.submitForm();
+
+ // unbind confirmation message
before leaving page
+ $( window ).off( 'beforeunload'
);
} );
},
@@ -3054,7 +3068,6 @@
* Locks the form
*/
$.articleFeedbackv5.lockForm = function () {
- var bucket = $.articleFeedbackv5.currentBucket();
$.articleFeedbackv5.enableSubmission( false );
$.articleFeedbackv5.$holder.find( '.articleFeedbackv5-lock'
).show();
};
@@ -3066,7 +3079,6 @@
* Unlocks the form
*/
$.articleFeedbackv5.unlockForm = function () {
- var bucket = $.articleFeedbackv5.currentBucket();
$.articleFeedbackv5.enableSubmission( true );
$.articleFeedbackv5.$holder.find( '.articleFeedbackv5-lock'
).hide();
};
--
To view, visit https://gerrit.wikimedia.org/r/62982
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Icdcb0ad36da12bd2efbc2e16a2301946bac315df
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ArticleFeedbackv5
Gerrit-Branch: master
Gerrit-Owner: Matthias Mullie <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits