From 0e296bc0aa4f99e5b7193ee7ed8a816acd6d4a24 Mon Sep 17 00:00:00 2001 From: sgiehl Date: Mon, 29 Oct 2012 20:08:09 +0000 Subject: fixes #3487, refs #3359 refactoring ajax requests to use a global method to query for module actions git-svn-id: http://dev.piwik.org/svn/trunk@7322 59fd770c-687e-43c8-a1e3-f5a4ff64c105 --- plugins/Transitions/templates/transitions.js | 78 +++++++++++++++------------- 1 file changed, 43 insertions(+), 35 deletions(-) (limited to 'plugins/Transitions') diff --git a/plugins/Transitions/templates/transitions.js b/plugins/Transitions/templates/transitions.js index f37788ec3c..bf2f3bed90 100644 --- a/plugins/Transitions/templates/transitions.js +++ b/plugins/Transitions/templates/transitions.js @@ -1391,41 +1391,49 @@ Piwik_Transitions_Ajax.prototype.callApi = function(method, params, callback) { params.format = 'JSON'; - piwikHelper.ajaxCallApi(method, params, callback, function(errorName) { - var showError = function() { - var errorTitle, errorMessage, errorBack; - if (typeof Piwik_Transitions_Translations[errorName] == 'undefined') { - errorTitle = 'Exception'; - errorMessage = errorName; - errorBack = '<<<'; - } else { - errorTitle = Piwik_Transitions_Translations[errorName]; - errorMessage = Piwik_Transitions_Translations[errorName + 'Details']; - errorBack = Piwik_Transitions_Translations[errorName + 'Back']; - } - - if (typeof params.actionName != 'undefined') { - var url = params.actionName; - url = piwikHelper.addBreakpointsToUrl(url); - errorTitle = errorTitle.replace(/%s/, '' + url + ''); - } - - errorMessage = errorMessage.replace(/%s/g, '
'); - Piwik_Popover.showError(errorTitle, errorMessage, errorBack); - }; - - if (typeof Piwik_Transitions_Translations == 'undefined') { - self.callApi('Transitions.getTranslations', {}, function(response) { - if (typeof response[0] == 'object') { - Piwik_Transitions_Translations = response[0]; - } else { - Piwik_Transitions_Translations = {}; - } - showError(); - }); - } else { - showError(); - } + piwikHelper.ajaxCallApi(method, params, function(result) { + if (typeof result.result != 'undefined' && result.result == 'error') + { + var errorName = result.message; + var showError = function() { + var errorTitle, errorMessage, errorBack; + if (typeof Piwik_Transitions_Translations[errorName] == 'undefined') { + errorTitle = 'Exception'; + errorMessage = errorName; + errorBack = '<<<'; + } else { + errorTitle = Piwik_Transitions_Translations[errorName]; + errorMessage = Piwik_Transitions_Translations[errorName + 'Details']; + errorBack = Piwik_Transitions_Translations[errorName + 'Back']; + } + + if (typeof params.actionName != 'undefined') { + var url = params.actionName; + url = piwikHelper.addBreakpointsToUrl(url); + errorTitle = errorTitle.replace(/%s/, '' + url + ''); + } + + errorMessage = errorMessage.replace(/%s/g, '
'); + Piwik_Popover.showError(errorTitle, errorMessage, errorBack); + }; + + if (typeof Piwik_Transitions_Translations == 'undefined') { + self.callApi('Transitions.getTranslations', {}, function(response) { + if (typeof response[0] == 'object') { + Piwik_Transitions_Translations = response[0]; + } else { + Piwik_Transitions_Translations = {}; + } + showError(); + }); + } else { + showError(); + } + } + else + { + callback(result); + } }); }; -- cgit v1.2.3