diff options
author | sgiehl <stefangiehl@gmail.com> | 2012-10-30 00:08:09 +0400 |
---|---|---|
committer | sgiehl <stefangiehl@gmail.com> | 2012-10-30 00:08:09 +0400 |
commit | 0e296bc0aa4f99e5b7193ee7ed8a816acd6d4a24 (patch) | |
tree | 5912386955f3bd6296a0cf6fa14a1d8c3f5fb4f5 /plugins/Transitions | |
parent | af0bb50a5464df629925998e20d73e864c3978cf (diff) |
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
Diffstat (limited to 'plugins/Transitions')
-rw-r--r-- | plugins/Transitions/templates/transitions.js | 78 |
1 files changed, 43 insertions, 35 deletions
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/, '<span>' + url + '</span>'); - } - - errorMessage = errorMessage.replace(/%s/g, '<br />'); - 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/, '<span>' + url + '</span>'); + } + + errorMessage = errorMessage.replace(/%s/g, '<br />'); + 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); + } }); }; |