]> _ Git - fluidbook-html5.git/commitdiff
wip #3658 @1.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 5 Jun 2020 15:26:03 +0000 (17:26 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 5 Jun 2020 15:26:03 +0000 (17:26 +0200)
js/libs/fluidbook/fluidbook.links.js
js/libs/fluidbook/fluidbook.stats.js
js/libs/fluidbook/links/fluidbook.links.zoom.js

index 2c8e339e20f0ab634fe1e822a19404deefcc6e3d..5913d5933ae22ad397a39986ed20df7d8bad790d 100644 (file)
@@ -37,7 +37,7 @@ FluidbookLinks.prototype = {
         });
 
         new ClipboardJS('[data-clipboard-text]');
-        $(document).on('click','[data-clipboard-text]',function(){
+        $(document).on('click', '[data-clipboard-text]', function () {
             $this.fluidbook.tooltip.displayTooltip($this.fluidbook.l10n.__('copied!'));
             return true;
         });
@@ -75,11 +75,28 @@ FluidbookLinks.prototype = {
             if (href === undefined) {
                 return true;
             }
-            var external = href.substr(0, 4) === 'http';
+            var external = href.indexOf('http') === 0;
             if (href === '#') {
                 return true;
             }
 
+            console.log(external, $this.fluidbook.stats.relay_url_params, $(this).hasClass('relay_appended'));
+
+            if (external && $this.fluidbook.stats.relay_url_params !== '' && !$(this).hasClass('relay_appended')) {
+                $(this).addClass('relay_appended');
+
+                var u = new URL(href);
+                var s = '';
+                if (u.search === '') {
+                    s = '?';
+                } else {
+                    s = '&';
+                }
+                u.search = s + $this.fluidbook.stats.relay_url_params;
+                $(this).attr('href', u.href);
+                href = u.href;
+            }
+
             if (!navigator.onLine && external && $this.fluidbook.settings.phonegap) {
                 $this.fluidbook.alertInternetRequired();
                 e.preventDefault();
index b919533983de38d3f2206b39a92327827bf3531b..5de6783211c4318543e9fcaa71daa43a34c0e7d2 100644 (file)
@@ -1,7 +1,9 @@
 function FluidbookStats(fluidbook) {\r
+    var $this = this;\r
     this.fluidbook = fluidbook;\r
     this.id = this.fluidbook.settings.id;\r
     this.vid = guid();\r
+    this.relay_url_params = {};\r
     if (this.fluidbook.settings.stats) {\r
         this.worker = new Worker('js/libs/fluidbook/workers/stats.js');\r
     }\r
@@ -19,6 +21,16 @@ function FluidbookStats(fluidbook) {
             this.ga = false;\r
         }\r
     }\r
+    if (this.fluidbook.settings.relay_url_params !== '') {\r
+        var e = this.fluidbook.settings.relay_url_params.split(',');\r
+        var p = [];\r
+        $.each(e, function (k, v) {\r
+            if ($_GET[v] !== undefined && $_GET[v] !== null) {\r
+                p.push(v + '=' + encodeURIComponent($_GET[v]));\r
+            }\r
+        });\r
+        this.relay_url_params = p.join('&');\r
+    }\r
     this.init();\r
 }\r
 \r
index d681d15dc19adaee0a73f73dd4a2c98f2dfb8ad7..4a3d7294646bb47e588d80964187e7f7ec446c8f 100644 (file)
@@ -171,7 +171,6 @@ FluidbookLinksZoom.prototype = {
 
                 for (var i = from; increment === 1 ? i <= to : i >= to; i += increment) {
                     var data = zoomLink.data('d-' + i);
-                    console.log(i, data);
                     if (data !== undefined) {
                         var j = i + 1;
                         var label = $this.fluidbook.settings['product_zoom_label_' + j];
@@ -199,6 +198,7 @@ FluidbookLinksZoom.prototype = {
 
                         if (action === 'link') {
                             menu += 'href="' + data + '"  target="_blank"';
+                            linkClass += ' ext';
                         } else if (action === 'copy') {
                             menu += 'data-clipboard-text="' + escapeHtml(data) + '" ';
                         } else if (action === 'video') {