]> _ Git - fluidbook-html5.git/commitdiff
#1762 @2
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 21 Dec 2017 17:47:53 +0000 (18:47 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 21 Dec 2017 17:47:53 +0000 (18:47 +0100)
js/libs/fluidbook/fluidbook.nav.js
js/libs/fluidbook/fluidbook.utils.js
style/nav-horizontal.less

index 01883c45d5099ef3830e1d59c954bc847c288355..bed1937acab9e987d4ece06f5b1835ca921522eb 100644 (file)
@@ -473,10 +473,38 @@ FluidbookNav.prototype = {
                     continue;
                 }
                 var linkIcon;
+
                 if (extraIcon.indexOf('.') === -1) {
                     linkIcon = getSpriteIcon(extraIcon);
                 } else {
-                    linkIcon = '<img class="nav-icon" src="data/images/' + extraIcon + '">';
+                    if (extraIcon.indexOf('.svg') >= 0) {
+                        if (getSpriteIcon('extra-extra' + n) == '') {
+                            $.ajax({
+                                url: 'data/images/' + extraIcon,
+                                type: 'GET',
+                                dataType: 'xml',
+                                success: function (data) {
+                                    var svg = $(data).find('svg');
+                                    var viewbox = $(svg).attr('viewBox');
+                                    var maing = $(svg).children('g').eq(0);
+                                    if ($("#extra-extra" + n).length == 0) {
+                                        $("#svg-container").append('<svg xmlns="http://www.w3.org/2000/svg" style="display: none;"><symbol id="extra-extra' + n + '" viewBox="' + viewbox + '">' + maing.html() + '</symbol></svg>');
+                                    }
+                                    $('#spare_extra' + n).replaceWith(getSpriteIcon('extra-extra' + n));
+                                },
+                            });
+
+                            linkIcon = '<div id="spare_extra' + n + '"></div>';
+                        } else {
+                            linkIcon = getSpriteIcon('extra-extra' + n);
+                        }
+                    } else {
+                        linkIcon = '<img class="nav-icon" src="data/images/' + extraIcon + '">';
+                    }
+                }
+
+                if (extraURL.indexOf(':') === -1) {
+                    extraURL = 'link:' + extraURL;
                 }
 
                 if (extraURL.indexOf('link:') === 0) {
@@ -492,11 +520,13 @@ FluidbookNav.prototype = {
                     if (foundLink == undefined) {
                         continue;
                     }
+                    console.log(foundLink);
                     link = $(foundLink).find('a').append(linkIcon);
                     if (navType == 'menu') {
                         var tooltip = $(link).data('tooltip');
                         $(link).append('<span class="menu-item-title">' + $(link).data('tooltip') + '</span>');
                     }
+
                     link = $(link).get(0).outerHTML;
                 }
 
index 0c52a7a2317d6aea68daf9a1513c69e8e2544275..9ff2ff9e72fb2029d0edb2fa0ef188605d0f5259 100644 (file)
@@ -56,7 +56,7 @@ function getSpriteIcon(icon, attrs) {
         iconSymbol = $('svg symbol#' + icon);
 
     if (iconSymbol.length == 0) {
-        console.warn('Unable to find sprite icon: ' + icon);
+        //console.warn('Unable to find sprite icon: ' + icon);
         return ''; // Bail out because symbol doesn't exist
     }
 
index 2c074fbf12ef41aec8fbeb5c32b51f7502475f53..8cdfcf48053fa74295d10e1728c6393574e5020c 100644 (file)
@@ -71,9 +71,9 @@
                }
        }
 
-       .svg-icon {
-               width: 25px;
+       img, .svg-icon {
                height: 25px;
+               width: auto;
 
                margin: 0 17px;
                color: @icon-color;