diff options
Diffstat (limited to 'plugins/CoreHome/angularjs/widget-loader/widgetloader.directive.js')
-rw-r--r-- | plugins/CoreHome/angularjs/widget-loader/widgetloader.directive.js | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/plugins/CoreHome/angularjs/widget-loader/widgetloader.directive.js b/plugins/CoreHome/angularjs/widget-loader/widgetloader.directive.js index bda6b5d3b9..d741ac22e8 100644 --- a/plugins/CoreHome/angularjs/widget-loader/widgetloader.directive.js +++ b/plugins/CoreHome/angularjs/widget-loader/widgetloader.directive.js @@ -19,9 +19,9 @@ (function () { angular.module('piwikApp').directive('piwikWidgetLoader', piwikWidgetLoader); - piwikWidgetLoader.$inject = ['piwik', 'piwikUrl', '$http', '$compile', '$q', '$location', 'notifications', '$rootScope', '$timeout']; + piwikWidgetLoader.$inject = ['piwik', 'piwikUrl', '$http', '$compile', '$q', '$location', 'notifications', '$rootScope', '$timeout', 'piwikComparisonsService']; - function piwikWidgetLoader(piwik, piwikUrl, $http, $compile, $q, $location, notifications, $rootScope, $timeout){ + function piwikWidgetLoader(piwik, piwikUrl, $http, $compile, $q, $location, notifications, $rootScope, $timeout, piwikComparisonsService){ return { restrict: 'A', transclude: true, @@ -71,6 +71,10 @@ var $urlParams = $location.search(); + delete $urlParams['comparePeriods[]']; + delete $urlParams['compareDates[]']; + delete $urlParams['compareSegments[]']; + if ($.isEmptyObject($urlParams) || !$urlParams || !$urlParams['idSite']) { // happens eg in exported widget etc when URL does not have #?... $urlParams = {idSite: 'idSite', period: 'period',date: 'date'}; @@ -93,6 +97,17 @@ } }); + if (piwikComparisonsService.isComparisonEnabled()) { + ['comparePeriods', 'compareDates', 'compareSegments'].forEach(function (paramName) { + var value = piwikUrl.getSearchParam(paramName); + if (value) { + var map = {}; + map[paramName] = value; + url += '&' + $.param(map); + } + }); + } + if (!parameters || !('showtitle' in parameters)) { url += '&showtitle=1'; } |