Fixed #730, #733: problems with saving
authorRadek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Thu, 22 Jul 2010 12:10:11 +0000 (14:10 +0200)
committerRadek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Thu, 22 Jul 2010 12:10:11 +0000 (14:10 +0200)
Added an option to hide the saving process, allowing the user to
save their work locally in case of connection problems.

apps/wiki/templates/wiki/document_details_base.html
redakcja/static/css/master.css
redakcja/static/js/wiki/dialog_save.js
redakcja/static/js/wiki/wikiapi.js

index 28567e1..f86f936 100644 (file)
@@ -38,6 +38,7 @@
         | {% trans "Version" %}: <span id="document-revision">{% trans "Unknown" %}</span>
                {% if not readonly %}
             | <button style="margin-left: 6px" id="save-button">{% trans "Save" %}</button>
+                       <span id='save-attempt-info'>{% trans "Save attempt in progress" %}</span>
                {% endif %}
     </div>
     <ol id="tabs">
index c14a3dc..fd05daa 100644 (file)
@@ -87,6 +87,20 @@ body {
     font-weight: bold;
 }
 
+#header.saving {
+       background-color: #E1C1C1;
+}
+#header.saving #save-button {
+    display: none;
+}
+#save-attempt-info {
+    color: #801000;
+    display: none;
+}
+.saving #save-attempt-info {
+    display: inline;
+}
+
 #header h1, #header h1 a {
     margin: 0;
     padding: 0;
index 916f326..aa9258d 100644 (file)
                        var self = this;
 
                        self.$elem.block({
-                               message: "Zapisywanie...",
+                               message: "Zapisywanie... <br/><button id='save-hide'>ukryj</button>",
                                fadeIn: 0,
                        });
+            $.wiki.blocking = self.$elem;
 
                        try {
 
index ad31af3..b6388f1 100644 (file)
                        success: function(data) {
                                var changed = false;
 
+                $('#header').removeClass('saving');
+
                                if (data.text) {
                                        self.text = data.text;
                                        self.revision = data.revision;
                                params['success'](self, changed, ((changed && "Udało się zapisać :)") || "Twoja wersja i serwera jest identyczna"));
                        },
                        error: function(xhr) {
-                               try {
-                                       params['failure'](self, $.parseJSON(xhr.responseText));
-                               }
-                               catch (e) {
-                                       params['failure'](self, {
-                                               "__message": "<p>Nie udało się zapisać - błąd serwera.</p>"
-                                       });
-                               };
+                if ($('#header').hasClass('saving')) {
+                    $('#header').removeClass('saving');
+                    $.blockUI({
+                        message: "<p>Nie udało się zapisać zmian. <br/><button onclick='$.unblockUI()'>OK</button></p>"
+                    })
+                }
+                else {
+                    try {
+                        params['failure'](self, $.parseJSON(xhr.responseText));
+                    }
+                    catch (e) {
+                        params['failure'](self, {
+                            "__message": "<p>Nie udało się zapisać - błąd serwera.</p>"
+                        });
+                    };
+                }
 
                        }
                });
+
+        $('#save-hide').click(function(){
+            $('#header').addClass('saving');
+            $.unblockUI();
+            $.wiki.blocking.unblock();
+        });
        }; /* end of save() */
 
        WikiDocument.prototype.publish = function(params) {