Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/diaspora/diaspora.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorSteffen van Bergerem <svbergerem@online.de>2014-10-08 03:50:14 +0400
committerSteffen van Bergerem <svbergerem@online.de>2014-11-02 03:49:33 +0300
commit25e4e558c58bd54a35efaeb516ce44f4009d6406 (patch)
treeb0ab3c7ef1cf4cfbf955f9bb1bdf61c5251768cd /app
parentaab1e4b5b19a529f22a96aa05b406cea23f8f68e (diff)
Ask for confirmation when leaving a submittable publisher
Diffstat (limited to 'app')
-rw-r--r--app/assets/javascripts/app/views/publisher_view.js23
-rw-r--r--app/views/status_messages/new.html.haml1
2 files changed, 18 insertions, 6 deletions
diff --git a/app/assets/javascripts/app/views/publisher_view.js b/app/assets/javascripts/app/views/publisher_view.js
index 8fcca9316..a79db2cfc 100644
--- a/app/assets/javascripts/app/views/publisher_view.js
+++ b/app/assets/javascripts/app/views/publisher_view.js
@@ -48,6 +48,10 @@ app.views.Publisher = Backbone.View.extend({
// init autoresize plugin
this.el_input.autoResize({ 'extraSpace' : 10, 'maxHeight' : Infinity });
+ // if there is data in the publisher we ask for a confirmation
+ // before the user is able to leave the page
+ $(window).on('beforeunload', _.bind(this._beforeUnload, this));
+
// sync textarea content
if( this.el_hiddenInput.val() == "" ) {
this.el_hiddenInput.val( this.el_input.val() );
@@ -77,14 +81,14 @@ app.views.Publisher = Backbone.View.extend({
this.close();
this.showSpinner(true);
});
-
+
// open publisher on post error
this.on('publisher:error', function() {
this.open();
this.showSpinner(false);
});
- // resetting the poll view
+ // resetting the poll view
this.on('publisher:sync', function() {
this.view_poll_creator.render();
});
@@ -159,7 +163,7 @@ app.views.Publisher = Backbone.View.extend({
if(evt){ evt.preventDefault(); }
// Auto-adding a poll answer always leaves an empty box when the user starts
- // typing in the last box. We'll delete the last one to avoid submitting an
+ // typing in the last box. We'll delete the last one to avoid submitting an
// empty poll answer and failing validation.
this.view_poll_creator.removeLastAnswer();
@@ -378,7 +382,7 @@ app.views.Publisher = Backbone.View.extend({
// enable input
this.setInputEnabled(true);
-
+
// enable buttons
this.setButtonsEnabled(true);
@@ -428,7 +432,7 @@ app.views.Publisher = Backbone.View.extend({
else
this.$('#publisher_spinner').addClass('hidden');
},
-
+
checkSubmitAvailability: function() {
if( this._submittable() ) {
this.setButtonsEnabled(true);
@@ -472,8 +476,15 @@ app.views.Publisher = Backbone.View.extend({
this.el_input.mentionsInput("val", function(value){
self.el_hiddenInput.val(value);
});
- }
+ },
+ _beforeUnload: function(e) {
+ if(this._submittable()){
+ var confirmationMessage = Diaspora.I18n.t("confirm_unload");
+ (e || window.event).returnValue = confirmationMessage; //Gecko + IE
+ return confirmationMessage; //Webkit, Safari, Chrome, etc.
+ }
+ }
});
// jQuery helper for serializing a <form> into JSON
diff --git a/app/views/status_messages/new.html.haml b/app/views/status_messages/new.html.haml
index 1e6008944..20ae77532 100644
--- a/app/views/status_messages/new.html.haml
+++ b/app/views/status_messages/new.html.haml
@@ -14,6 +14,7 @@
app.publisher.open();
$("#publisher").bind('ajax:success', function(){
$("#mentionModal").modal('hide');
+ app.publisher.clear();
location.reload();
});
});