diff options
Diffstat (limited to 'plugins/CoreHome/angularjs/reporting-page/reportingpage.controller.js')
-rw-r--r-- | plugins/CoreHome/angularjs/reporting-page/reportingpage.controller.js | 37 |
1 files changed, 32 insertions, 5 deletions
diff --git a/plugins/CoreHome/angularjs/reporting-page/reportingpage.controller.js b/plugins/CoreHome/angularjs/reporting-page/reportingpage.controller.js index 3fe5955dc7..8bf2590abe 100644 --- a/plugins/CoreHome/angularjs/reporting-page/reportingpage.controller.js +++ b/plugins/CoreHome/angularjs/reporting-page/reportingpage.controller.js @@ -15,6 +15,18 @@ var currentCategory = null; var currentSubcategory = null; + var currentPeriod = null; + var currentDate = null; + var currentSegment = null; + + function renderInitialPage() + { + var $search = $location.search(); + currentPeriod = $search.period; + currentDate = $search.date; + currentSegment = $search.segment; + $scope.renderPage($search.category, $search.subcategory); + } $scope.renderPage = function (category, subcategory) { if (!category || !subcategory) { @@ -23,6 +35,8 @@ return; } + $rootScope.$emit('piwikPageChange', {}); + currentCategory = category; currentSubcategory = subcategory; @@ -45,19 +59,32 @@ } $scope.loading = true; // we only set loading on initial load - - $scope.renderPage($location.search().category, $location.search().subcategory); + + renderInitialPage(); $rootScope.$on('$locationChangeSuccess', function () { + var $search = $location.search(); + // should be handled by $route - var category = $location.search().category; - var subcategory = $location.search().subcategory; + var category = $search.category; + var subcategory = $search.subcategory; + var period = $search.period; + var date = $search.date; + var segment = $search.segment; - if (category === currentCategory && subcategory === currentSubcategory) { + if (category === currentCategory + && subcategory === currentSubcategory + && period === currentPeriod + && date === currentDate + && segment === currentSegment) { // this page is already loaded return; } + currentPeriod = period; + currentDate = date; + currentSegment = segment; + $scope.renderPage(category, subcategory); }); |