save timeout
authorRadek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Fri, 21 May 2010 13:56:21 +0000 (15:56 +0200)
committerRadek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Fri, 21 May 2010 13:56:21 +0000 (15:56 +0200)
redakcja/static/js/wiki/base.js
redakcja/static/js/wiki/wikiapi.js

index 61a3949..3fa47cc 100644 (file)
                reportErrors: function(errors) {
                        var global = $("*[data-ui-error-for='__all__']", this.$elem);
                        var unassigned = [];
                reportErrors: function(errors) {
                        var global = $("*[data-ui-error-for='__all__']", this.$elem);
                        var unassigned = [];
+                       var unassigned_text = '';
 
                        for (var field_name in errors)
                        {
 
                        for (var field_name in errors)
                        {
 
                                if(!span.length) {
                                        unassigned.push(field_name);
 
                                if(!span.length) {
                                        unassigned.push(field_name);
+                                       unassigned_text += errors[field_name];
                                        continue;
                                }
 
                                        continue;
                                }
 
                        }
 
                        if(unassigned.length > 0)
                        }
 
                        if(unassigned.length > 0)
-                               global.text( global.text() + 'W formularzu wystąpiły błędy');
+                               global.text( global.text() + unassigned_text);
                }
        };
 
                }
        };
 
index 27ab97e..26732bd 100644 (file)
                        type: "POST",
                        dataType: "json",
                        data: data,
                        type: "POST",
                        dataType: "json",
                        data: data,
+                       timeout: 5000,
                        success: function(data) {
                                var changed = false;
 
                        success: function(data) {
                                var changed = false;
 
 
                                params['success'](self, changed, ((changed && "Udało się zapisać :)") || "Twoja wersja i serwera jest identyczna"));
                        },
 
                                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) {
+                       error: function(xhr, msg) {
+                               if (msg == 'timeout') {
                                        params['failure'](self, {
                                        params['failure'](self, {
-                                               "__message": "<p>Nie udało się zapisać - błąd serwera.</p>"
-                                       });
-                               };
-
+                        "__message": "Przekroczony czas połączenia. Zmiany nie zostały zapisane."
+                    });
+                               }
+                               else {
+                    try {
+                        params['failure'](self, $.parseJSON(xhr.responseText));
+                    }
+                    catch (e) {
+                        params['failure'](self, {
+                            "__message": "Nie udało się zapisać - błąd serwera."
+                        });
+                    };
+                               }
                        }
                });
        }; /* end of save() */
                        }
                });
        }; /* end of save() */