diff options
author | sgiehl <stefangiehl@gmail.com> | 2012-11-20 02:00:41 +0400 |
---|---|---|
committer | sgiehl <stefangiehl@gmail.com> | 2012-11-20 02:00:41 +0400 |
commit | 99793151cd6d4f318b7a011509bd421685f0537a (patch) | |
tree | 623b9521c3551d32d5eb808f57511ed38fe8e19a /plugins/Transitions | |
parent | df1c54f0f7e50dfd670ab294d908e44ed4dbac44 (diff) |
refs #3359 moving ajax requests to a new ajax helper with more functionality as the old functions
git-svn-id: http://dev.piwik.org/svn/trunk@7489 59fd770c-687e-43c8-a1e3-f5a4ff64c105
Diffstat (limited to 'plugins/Transitions')
-rw-r--r-- | plugins/Transitions/templates/transitions.js | 100 |
1 files changed, 53 insertions, 47 deletions
diff --git a/plugins/Transitions/templates/transitions.js b/plugins/Transitions/templates/transitions.js index dfc4d32114..c3a186249a 100644 --- a/plugins/Transitions/templates/transitions.js +++ b/plugins/Transitions/templates/transitions.js @@ -1389,64 +1389,70 @@ Piwik_Transitions_Ajax.prototype.loadTotalNbPageviews = function(callback) { }; Piwik_Transitions_Ajax.prototype.callTransitionsController = function(action, callback) { - piwikHelper.queueAjaxRequest($.post('index.php', { - module: 'Transitions', - action: action, - date: piwik.currentDateString, - idSite: piwik.idSite, - period: piwik.period - }, callback)); + var ajaxRequest = new ajaxHelper(); + ajaxRequest.addParams({ + module: 'Transitions', + action: action + }, 'get'); + ajaxRequest.setCallback(callback); + ajaxRequest.setFormat('html'); + ajaxRequest.send(false); }; Piwik_Transitions_Ajax.prototype.callApi = function(method, params, callback) { var self = this; params.format = 'JSON'; - - 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]; + params.module = 'API'; + params.method = method; + + var ajaxRequest = new ajaxHelper(); + ajaxRequest.addParams(params, 'get'); + ajaxRequest.setCallback( + 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 { - Piwik_Transitions_Translations = {}; + 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 { - showError(); + } + } + else { + callback(result); } } - else - { - callback(result); - } - }); + ); + ajaxRequest.send(false); }; |