From 799c5c2c9b3fdfd4c4d407e352c9dff494d86cc0 Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Wed, 11 Sep 2013 16:02:12 +0200 Subject: [PATCH 1/3] Don't popup meaningless alerts when dialog called on page leave --- core/js/oc-dialogs.js | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/core/js/oc-dialogs.js b/core/js/oc-dialogs.js index f184a1022bc..a3516f866d1 100644 --- a/core/js/oc-dialogs.js +++ b/core/js/oc-dialogs.js @@ -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); From 1f8f0e61d89036e9c51befbd88404cbe9af6e664 Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Wed, 11 Sep 2013 21:11:35 +0200 Subject: [PATCH 2/3] Remove test error :P --- core/js/oc-dialogs.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/js/oc-dialogs.js b/core/js/oc-dialogs.js index a3516f866d1..26173ffeb69 100644 --- a/core/js/oc-dialogs.js +++ b/core/js/oc-dialogs.js @@ -243,7 +243,7 @@ var OCdialogs = { var defer = $.Deferred(); if(!this.$messageTemplate) { var self = this; - $.get(OC.filePath('core', 'templates', 'message.htm'), function(tmpl) { + $.get(OC.filePath('core', 'templates', 'message.html'), function(tmpl) { self.$messageTemplate = $(tmpl); defer.resolve(self.$messageTemplate); }) From 08225a60c8e7535ae94726189a090679886ea47d Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Wed, 11 Sep 2013 21:15:32 +0200 Subject: [PATCH 3/3] Save two lines --- core/js/oc-dialogs.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/core/js/oc-dialogs.js b/core/js/oc-dialogs.js index 26173ffeb69..db8cb5d8cf9 100644 --- a/core/js/oc-dialogs.js +++ b/core/js/oc-dialogs.js @@ -142,9 +142,7 @@ var OCdialogs = { .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 { + if(status !== 0) { alert(t('core', 'Error loading file picker template: {error}', {error: error})); } });