diff options
-rw-r--r-- | lang/en.json | 4 | ||||
-rw-r--r-- | plugins/UserCountryMap/UserCountryMap.php | 9 | ||||
-rw-r--r-- | plugins/UserCountryMap/javascripts/visitor-map.js | 21 | ||||
-rw-r--r-- | plugins/UserCountryMap/stylesheets/visitor-map.less | 5 |
4 files changed, 34 insertions, 5 deletions
diff --git a/lang/en.json b/lang/en.json index dcb349cdb3..369a116204 100644 --- a/lang/en.json +++ b/lang/en.json @@ -2093,7 +2093,9 @@ "ShowingVisits": "Geo-located visits of last", "Unlocated": "<b>%s<\/b> %p of the visits from %c couldn't be geo located.", "VisitorMap": "Visitor Map", - "WorldWide": "World-Wide" + "WorldWide": "World-Wide", + "WithUnknownRegion": "%s with unknown region", + "WithUnknownCity": "%s with unknown city" }, "UserSettings": { "BrowserFamilies": "Browser families", diff --git a/plugins/UserCountryMap/UserCountryMap.php b/plugins/UserCountryMap/UserCountryMap.php index 75df3df8c9..2ff43f1bbb 100644 --- a/plugins/UserCountryMap/UserCountryMap.php +++ b/plugins/UserCountryMap/UserCountryMap.php @@ -50,7 +50,8 @@ class UserCountryMap extends \Piwik\Plugin { $hooks = array( 'AssetManager.getJavaScriptFiles' => 'getJsFiles', - 'AssetManager.getStylesheetFiles' => 'getStylesheetFiles' + 'AssetManager.getStylesheetFiles' => 'getStylesheetFiles', + 'Translate.getClientSideTranslationKeys' => 'getClientSideTranslationKeys' ); return $hooks; } @@ -70,4 +71,10 @@ class UserCountryMap extends \Piwik\Plugin $stylesheets[] = "plugins/UserCountryMap/stylesheets/visitor-map.less"; $stylesheets[] = "plugins/UserCountryMap/stylesheets/realtime-map.less"; } + + public function getClientSideTranslationKeys(&$translationKeys) + { + $translationKeys[] = 'UserCountryMap_WithUnknownRegion'; + $translationKeys[] = 'UserCountryMap_WithUnknownCity'; + } } diff --git a/plugins/UserCountryMap/javascripts/visitor-map.js b/plugins/UserCountryMap/javascripts/visitor-map.js index 48b9e33c3b..1c7322c651 100644 --- a/plugins/UserCountryMap/javascripts/visitor-map.js +++ b/plugins/UserCountryMap/javascripts/visitor-map.js @@ -643,7 +643,7 @@ return groupBy ? groups : groups.X; } - function displayUnlocatableCount(unlocated, total) { + function displayUnlocatableCount(unlocated, total, regionOrCity) { $('.unlocated-stats').html( $('.unlocated-stats').data('tpl') .replace('%s', unlocated) @@ -651,6 +651,21 @@ .replace('%c', UserCountryMap.countriesByIso[self.lastSelected].name) ); $('.UserCountryMap-info-btn').show(); + + var zoomTitle = ''; + if (regionOrCity == 'region') { + zoomTitle = ' ' + _pk_translate('UserCountryMap_WithUnknownRegion', [unlocated]); + } else if (regionOrCity == 'city') { + zoomTitle = ' ' + _pk_translate('UserCountryMap_WithUnknownCity', [unlocated]); + } + + if (unlocated && zoomTitle) { + if ($('.map-stats .unlocatableCount').length) { + $('.map-stats .unlocatableCount').html(zoomTitle); + } else { + $('.map-stats').append('<small class="unlocatableCount">' + zoomTitle + '</small>'); + } + } } /* @@ -724,7 +739,7 @@ $.each(regionDict, function (key, region) { if (regionExistsInMap(key)) unlocated -= region.nb_visits; }); - displayUnlocatableCount(unlocated, totalCountryVisits); + displayUnlocatableCount(unlocated, totalCountryVisits, 'region'); // create color scale colscale = getColorScale(regionDict, 'curMetric', null, true); @@ -820,7 +835,7 @@ })); }); - displayUnlocatableCount(unlocated, totalCountryVisits); + displayUnlocatableCount(unlocated, totalCountryVisits, 'city'); // sort by current metric cities.sort(function (a, b) { return b.curMetric - a.curMetric; }); diff --git a/plugins/UserCountryMap/stylesheets/visitor-map.less b/plugins/UserCountryMap/stylesheets/visitor-map.less index 9ef1328a22..37c0fd9ae6 100644 --- a/plugins/UserCountryMap/stylesheets/visitor-map.less +++ b/plugins/UserCountryMap/stylesheets/visitor-map.less @@ -8,6 +8,11 @@ background: #D5D3C8; } +.UserCountryMap .unlocatableCount { + font-size: 11px; + color: @color-silver-l60; +} + .UserCountryMap .loadingPiwik { position: absolute !important; top: 42% !important; |