]> _ Git - fluidbook-html5.git/commitdiff
fix #1763 @3
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 13 Nov 2017 17:31:26 +0000 (18:31 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 13 Nov 2017 17:31:26 +0000 (18:31 +0100)
js/libs/fluidbook/fluidbook.js
js/libs/fluidbook/fluidbook.links.js
js/main.js

index 1e07f9ce4663dbce72105987e2d54faac7ee5440..5a029ec391623925bf924a5aec2f3e4eaf000c52 100644 (file)
@@ -1009,20 +1009,25 @@ Fluidbook.prototype = {
             options = '';
         }
 
+        var locationdefault = 'yes';
         var mtarget = target;
+        var replace = true;
         if (this.datas.phonegap) {
-            if(target=='_unique' || target=='_new') {
+            if (target == '_unique' || target == '_new') {
                 mtarget = '_blank';
             }
         } else {
             if (target == '_new') {
-                mtarget = 'fb_' + $this.fluidbook.datas.id + '_' + Math.round(Math.random() * 10000000);
+                mtarget = 'fb_' + this.datas.id + '_' + Math.round(Math.random() * 10000000);
+                options += ',scrollbars=yes'
             } else if (target == '_unique') {
-                mtarget = 'fb_' + $this.fluidbook.datas.id;
+                mtarget = 'fb_' + this.datas.id;
+                options += ',scrollbars=yes'
+            } else {
+
             }
         }
 
-        var locationdefault = 'yes';
         if (this.datas.phonegap) {
             locationdefault = 'yes';
         }
@@ -1033,9 +1038,18 @@ Fluidbook.prototype = {
             options += ',location=' + locationdefault;
         }
 
-        if (this.datas.phonegap && mtarget=='_blank') {
+        if (this.datas.phonegap && mtarget == '_blank') {
             options += ',zoom=yes,enableViewportScale=yes'
         }
-        window.open(url, mtarget, options);
+        // Open the window
+        var w = window.open(url, mtarget, options, replace);
+        try {
+            // Attempt to focus opened windows (useful for already opened windows)
+            if (target == '_new' || target == '_unique') {
+                w.focus();
+            }
+        } catch (e) {
+
+        }
     }
 }
\ No newline at end of file
index 7448715cfbaf1b50df744e7f56627a7e42cece66..66a006fc8deda70ff3dff5629838b52ac62859d2 100644 (file)
@@ -37,16 +37,40 @@ FluidbookLinks.prototype = {
             return false;
         });
 
-        $(document).on('click', 'a[href^="http"]', function (e) {
-            if (!navigator.onLine && $this.fluidbook.datas.phonegap) {
+        $(document).on('click', 'a', function () {
+            console.log('click link ');
+            console.log($(this));
+            var target = $(this).attr('target');
+            if (!target) {
+                target = '_self';
+            }
+            var href = $(this).attr('href');
+            var external = href.substr(0, 4) == 'http';
+            if (href == '#') {
+                return true;
+            }
+
+            if (!navigator.onLine && external && $this.fluidbook.datas.phonegap) {
                 $this.fluidbook.alertInternetRequired();
                 e.preventDefault();
                 e.stopPropagation();
                 e.stopImmediatePropagation();
+                return false;
             }
-            return true;
+
+            if ($(this).data('type') == 16 && external) {
+                target = '_system';
+            }
+
+            if (target == '_self') {
+                return true;
+            }
+            fluidbook.wopen($(this).attr('href'), target);
+            return false;
+
         });
 
+
         $(document).on('click touchend', '[data-action]', function () {
             var map = {'pdf': 'print', 'fullScreen': "fullscreen", 'locales': 'localesContainers'};
             var action = $(this).data('action');
index aa8edfab23c0a28b061f3d056f8657d708b94b4a..84e182413974eb74122f0c8a70632cc153f2dae6 100644 (file)
@@ -380,21 +380,6 @@ try {
             return false;
         });
 
-        $(document).on('click', 'a', function () {
-            if (!DATAS.phonegap) {
-                return true;
-            }
-            var target = $(this).attr('target');
-            if ($(this).data('type') == 16 && $(this).attr('href').substr(0, 4) == 'http') {
-                target = '_system';
-            }
-            if (target == '_blank' || target == '_system' || target=='_unique' || target=='_new') {
-                fluidbook.wopen($(this).attr('href'), target);
-                return false;
-            }
-            return true;
-        });
-
         $(document).trigger('fluidbookready');
         $(this).trigger('fluidbook.ready');