Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthieu Aubry <matt@piwik.org>2015-10-09 05:26:26 +0300
committerMatthieu Aubry <matt@piwik.org>2015-10-09 05:26:26 +0300
commit38e33d6a6c6012304384956301c42542850c697a (patch)
tree4183ee1bc721ec317cd45b617700ed2f25356fe9 /plugins
parentdae91bc3ebf0db4efeeb00ef783d06dadff3c77a (diff)
parent618355eaf13af50032238eb487824cd01cbce4a8 (diff)
Merge pull request #8949 from piwik/5094
When AdBlock Plus is used, suggest user to disable it for Piwik
Diffstat (limited to 'plugins')
-rw-r--r--plugins/CoreHome/angularjs/common/services/piwik-api.js4
-rw-r--r--plugins/CoreHome/lang/en.json3
-rw-r--r--plugins/CoreHome/templates/_adblockDetect.twig36
-rw-r--r--plugins/Morpheus/templates/layout.twig2
4 files changed, 43 insertions, 2 deletions
diff --git a/plugins/CoreHome/angularjs/common/services/piwik-api.js b/plugins/CoreHome/angularjs/common/services/piwik-api.js
index 0b708a1c22..f9e5b225a3 100644
--- a/plugins/CoreHome/angularjs/common/services/piwik-api.js
+++ b/plugins/CoreHome/angularjs/common/services/piwik-api.js
@@ -4,6 +4,10 @@
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
+
+// see https://github.com/piwik/piwik/issues/5094 used to detect an ad blocker
+var hasBlockedContent = false;
+
(function () {
angular.module('piwikApp.service').factory('piwikApi', piwikApiService);
diff --git a/plugins/CoreHome/lang/en.json b/plugins/CoreHome/lang/en.json
index 300c6fe15b..637122effc 100644
--- a/plugins/CoreHome/lang/en.json
+++ b/plugins/CoreHome/lang/en.json
@@ -50,6 +50,7 @@
"UndoPivotBySubtable": "This report has been pivoted %s Undo pivot",
"PivotBySubtable": "This report is not pivoted %s Pivot by %s",
"QuickAccessTitle": "Search for menu entries, segments and websites. Shortcut: Press 'f' to search.",
- "Segments": "Segments"
+ "Segments": "Segments",
+ "AdblockIsMaybeUsed": "In case you are using an ad blocker, please disable it for this site to make sure Piwik works without any issues."
}
}
diff --git a/plugins/CoreHome/templates/_adblockDetect.twig b/plugins/CoreHome/templates/_adblockDetect.twig
new file mode 100644
index 0000000000..ec69ffecf8
--- /dev/null
+++ b/plugins/CoreHome/templates/_adblockDetect.twig
@@ -0,0 +1,36 @@
+<div id="bottomAd" style="font-size: 2px;">&nbsp;</div>
+<script type="text/javascript">
+ if ('undefined' === (typeof hasBlockedContent) || hasBlockedContent !== false) {
+ {# if hasBlockedContent was "false" most likely nothing was blocked #}
+ (function () {
+ {# most likely jQuery is not available, have to use vanilla JS here #}
+ var body = document.getElementsByTagName('body');
+
+ if (!body || !body[0]) {
+ return;
+ }
+
+ var bottomAd = document.getElementById('bottomAd');
+ var wasMostLikelyCausedByAdblock = false;
+
+ if (!bottomAd) {
+ wasMostLikelyCausedByAdblock = true;
+ } else if (bottomAd.style && bottomAd.style.display === 'none') {
+ wasMostLikelyCausedByAdblock = true;
+ } else if ('undefined' !== (typeof bottomAd.clientHeight) && bottomAd.clientHeight === 0) {
+ wasMostLikelyCausedByAdblock = true;
+ }
+
+ if (wasMostLikelyCausedByAdblock) {
+ var warning = document.createElement('h3');
+ warning.innerHTML = '{{ 'CoreHome_AdblockIsMaybeUsed'|translate|e('js') }}';
+
+ body[0].appendChild(warning);
+ warning.style.color = 'red';
+ warning.style.fontWeight = 'bold';
+ warning.style.marginLeft = '16px';
+ warning.style.marginBottom = '16px';
+ }
+ })();
+ }
+</script> \ No newline at end of file
diff --git a/plugins/Morpheus/templates/layout.twig b/plugins/Morpheus/templates/layout.twig
index 1e9f1f0d5c..fa2f480df5 100644
--- a/plugins/Morpheus/templates/layout.twig
+++ b/plugins/Morpheus/templates/layout.twig
@@ -22,7 +22,6 @@
{% include "@CoreHome/_favicon.twig" %}
{% include "_jsGlobalVariables.twig" %}
- {% include "_piwikTag.twig" %}
{% include "_jsCssIncludes.twig" %}
<!--[if IE]>
@@ -49,5 +48,6 @@
{% endblock %}
+ {% include "@CoreHome/_adblockDetect.twig" %}
</body>
</html>