]> source.dussan.org Git - nextcloud-server.git/commitdiff
Don't popup meaningless alerts when dialog called on page leave
authorThomas Tanghus <thomas@tanghus.net>
Wed, 11 Sep 2013 14:02:12 +0000 (16:02 +0200)
committerThomas Tanghus <thomas@tanghus.net>
Wed, 11 Sep 2013 14:02:12 +0000 (16:02 +0200)
core/js/oc-dialogs.js

index f184a1022bcf870132d793d94f21077169766bb4..a3516f866d1d3ed7a9bccf22564312b3c20ef34b 100644 (file)
@@ -139,8 +139,14 @@ var OCdialogs = {
                                }
                        });
                })
-               .fail(function() {
-                       alert(t('core', 'Error loading file picker template'));
+               .fail(function(status, error) {
+                       // If the method is called while navigating away
+                       // from the page, it is probably not needed ;)
+                       if(status === 0) {
+                               return;
+                       } else {
+                               alert(t('core', 'Error loading file picker template: {error}', {error: error}));
+                       }
                });
        },
        /**
@@ -206,8 +212,14 @@ var OCdialogs = {
                        });
                        OCdialogs.dialogs_counter++;
                })
-               .fail(function() {
-                       alert(t('core', 'Error loading file picker template'));
+               .fail(function(status, error) {
+                       // If the method is called while navigating away from
+                       // the page, we still want to deliver the message.
+                       if(status === 0) {
+                               alert(title + ': ' + content);
+                       } else {
+                               alert(t('core', 'Error loading message template: {error}', {error: error}));
+                       }
                });
        },
        _getFilePickerTemplate: function() {
@@ -219,8 +231,8 @@ var OCdialogs = {
                                self.$listTmpl = self.$filePickerTemplate.find('.filelist li:first-child').detach();
                                defer.resolve(self.$filePickerTemplate);
                        })
-                       .fail(function() {
-                               defer.reject();
+                       .fail(function(jqXHR, textStatus, errorThrown) {
+                               defer.reject(jqXHR.status, errorThrown);
                        });
                } else {
                        defer.resolve(this.$filePickerTemplate);
@@ -231,12 +243,12 @@ var OCdialogs = {
                var defer = $.Deferred();
                if(!this.$messageTemplate) {
                        var self = this;
-                       $.get(OC.filePath('core', 'templates', 'message.html'), function(tmpl) {
+                       $.get(OC.filePath('core', 'templates', 'message.htm'), function(tmpl) {
                                self.$messageTemplate = $(tmpl);
                                defer.resolve(self.$messageTemplate);
                        })
-                       .fail(function() {
-                               defer.reject();
+                       .fail(function(jqXHR, textStatus, errorThrown) {
+                               defer.reject(jqXHR.status, errorThrown);
                        });
                } else {
                        defer.resolve(this.$messageTemplate);