]> _ Git - fluidbook-html5.git/commitdiff
Allow SVGs to be used as normal images in menu and fix bug that stopped normal URLs...
authorStephen Cameron <stephen@cubedesigners.com>
Thu, 2 Aug 2018 15:49:29 +0000 (17:49 +0200)
committerStephen Cameron <stephen@cubedesigners.com>
Thu, 2 Aug 2018 15:49:29 +0000 (17:49 +0200)
js/libs/fluidbook/fluidbook.nav.js

index cb8f79b72f066ea857e63fc3ea2304095273b5a5..38cf5b261d2d60b697ade328c01f154c7aa01bf1 100644 (file)
@@ -514,7 +514,7 @@ FluidbookNav.prototype = {
                 if (extraIcon.indexOf('.') === -1) {
                     linkIcon = getSpriteIcon(extraIcon);
                 } else {
-                    if (extraIcon.indexOf('.svg') >= 0) {
+                    if ((extraIcon.indexOf('.svg') >= 0) && (extraType == 'icon')) {
                         if (getSpriteIcon('extra-extra' + n) == '') {
                             var url = 'data/images/' + extraIcon;
                             extraNPerURL[url] = n;
@@ -545,10 +545,12 @@ FluidbookNav.prototype = {
                     }
                 }
 
-                if (extraURL.indexOf(':') === -1) {
+                // Add "link:" prefix if it's an ID but not if it is a relative link
+                if (extraURL.indexOf(':') === -1 && extraURL.indexOf('/') === -1) {
                     extraURL = 'link:' + extraURL;
                 }
 
+                // Process link ID from editor
                 if (extraURL.indexOf('link:') === 0) {
                     var linkId = extraURL.split(':', 2)[1];
                     var foundLink;
@@ -569,6 +571,9 @@ FluidbookNav.prototype = {
                     }
 
                     link = $(link).get(0).outerHTML;
+                } else {
+                    // Normal link
+                    link = '<a href="' + extraURL + '" target="_blank" rel="noopener">' + linkIcon + '</a>';
                 }
                 var nav = this.getNavFromType(navType);
                 nav.find('ul').append('<li>' + link + '</li>');