From: Radek Czajka Date: Thu, 22 Jul 2010 12:10:11 +0000 (+0200) Subject: Fixed #730, #733: problems with saving X-Git-Url: https://git.mdrn.pl/redakcja.git/commitdiff_plain/13584ed72497d3d447595a5a930ecc8a0051be44 Fixed #730, #733: problems with saving Added an option to hide the saving process, allowing the user to save their work locally in case of connection problems. --- diff --git a/apps/wiki/templates/wiki/document_details_base.html b/apps/wiki/templates/wiki/document_details_base.html index 28567e1f..f86f936c 100644 --- a/apps/wiki/templates/wiki/document_details_base.html +++ b/apps/wiki/templates/wiki/document_details_base.html @@ -38,6 +38,7 @@ | {% trans "Version" %}: {% trans "Unknown" %} {% if not readonly %} | + {% trans "Save attempt in progress" %} {% endif %}
    diff --git a/redakcja/static/css/master.css b/redakcja/static/css/master.css index c14a3dca..fd05daa7 100644 --- a/redakcja/static/css/master.css +++ b/redakcja/static/css/master.css @@ -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; diff --git a/redakcja/static/js/wiki/dialog_save.js b/redakcja/static/js/wiki/dialog_save.js index 916f3260..aa9258d5 100644 --- a/redakcja/static/js/wiki/dialog_save.js +++ b/redakcja/static/js/wiki/dialog_save.js @@ -28,9 +28,10 @@ var self = this; self.$elem.block({ - message: "Zapisywanie...", + message: "Zapisywanie...
    ", fadeIn: 0, }); + $.wiki.blocking = self.$elem; try { diff --git a/redakcja/static/js/wiki/wikiapi.js b/redakcja/static/js/wiki/wikiapi.js index ad31af3f..b6388f11 100644 --- a/redakcja/static/js/wiki/wikiapi.js +++ b/redakcja/static/js/wiki/wikiapi.js @@ -222,6 +222,8 @@ success: function(data) { var changed = false; + $('#header').removeClass('saving'); + if (data.text) { self.text = data.text; self.revision = data.revision; @@ -233,17 +235,31 @@ 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": "

    Nie udało się zapisać - błąd serwera.

    " - }); - }; + if ($('#header').hasClass('saving')) { + $('#header').removeClass('saving'); + $.blockUI({ + message: "

    Nie udało się zapisać zmian.

    " + }) + } + else { + try { + params['failure'](self, $.parseJSON(xhr.responseText)); + } + catch (e) { + params['failure'](self, { + "__message": "

    Nie udało się zapisać - błąd serwera.

    " + }); + }; + } } }); + + $('#save-hide').click(function(){ + $('#header').addClass('saving'); + $.unblockUI(); + $.wiki.blocking.unblock(); + }); }; /* end of save() */ WikiDocument.prototype.publish = function(params) {