diff options
author | Nathan Sollenberger <nathan@spacenate.com> | 2018-06-26 00:09:21 +0300 |
---|---|---|
committer | diosmosis <diosmosis@users.noreply.github.com> | 2018-06-26 00:09:21 +0300 |
commit | 1a76568aa7f85920e8f4b58e0aa2fd32f64de8ad (patch) | |
tree | aa42c06e404515df3b71ca5d000c2e3679be28a9 /plugins/CoreHome/angularjs/common | |
parent | b83d12f4176b47b5190b635b098cf0564afc62ac (diff) |
Remove date from page title in dashboard twig template. Add logic in CoreHome javascript to update page title with date string. (#12222)
Correctly set date in page title when period changed via period selector
Diffstat (limited to 'plugins/CoreHome/angularjs/common')
-rw-r--r-- | plugins/CoreHome/angularjs/common/services/piwik.js | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/plugins/CoreHome/angularjs/common/services/piwik.js b/plugins/CoreHome/angularjs/common/services/piwik.js index d9eaaf5d8c..364d90c03a 100644 --- a/plugins/CoreHome/angularjs/common/services/piwik.js +++ b/plugins/CoreHome/angularjs/common/services/piwik.js @@ -10,9 +10,11 @@ piwikService.$inject = ['piwikPeriods']; function piwikService(piwikPeriods) { + var originalTitle; piwik.helper = piwikHelper; piwik.broadcast = broadcast; piwik.updatePeriodParamsFromUrl = updatePeriodParamsFromUrl; + piwik.updateDateInTitle = updateDateInTitle; return piwik; function updatePeriodParamsFromUrl() { @@ -35,6 +37,8 @@ piwik.startDateString = $.datepicker.formatDate('yy-mm-dd', dateRange[0]); piwik.endDateString = $.datepicker.formatDate('yy-mm-dd', dateRange[1]); + updateDateInTitle(date, period); + // do not set anything to previous7/last7, as piwik frontend code does not // expect those values. if (piwik.period === 'range') { @@ -61,6 +65,15 @@ return false; } } + + function updateDateInTitle( date, period ) { + // Cache server-rendered page title + originalTitle = originalTitle || document.title; + var titleParts = originalTitle.split('-'); + var dateString = ' ' + piwikPeriods.parse(period, date).getPrettyString() + ' '; + titleParts.splice(1, 0, dateString); + document.title = titleParts.join('-'); + } } angular.module('piwikApp.service').run(initPiwikService); |