From f0e70a5180bb7cf3c9394c4b2c0915313a285371 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Tue, 13 Sep 2022 13:11:21 +0200 Subject: [PATCH] wait #5450 @2 --- app/Models/ToolSVGSprite.php | 12 +++-- resources/tools/svgsprite/svgsprite.js | 38 ++++++++++++++++ .../link_editor.blade.php | 34 +++++++++++++- .../link_editor_icons.blade.php | 44 +++++++++++++++++++ 4 files changed, 123 insertions(+), 5 deletions(-) create mode 100644 resources/tools/svgsprite/svgsprite.js create mode 100644 resources/views/fluidbook_publication/link_editor_icons.blade.php diff --git a/app/Models/ToolSVGSprite.php b/app/Models/ToolSVGSprite.php index 3f0623399..153e6ab3d 100644 --- a/app/Models/ToolSVGSprite.php +++ b/app/Models/ToolSVGSprite.php @@ -46,14 +46,20 @@ class ToolSVGSprite extends ToolboxModel public function generate() { - $res = ''; + $res = ''; + $res .= '' . "\n"; + $res .= ''; + return $res; } diff --git a/resources/tools/svgsprite/svgsprite.js b/resources/tools/svgsprite/svgsprite.js new file mode 100644 index 000000000..5d88ba35e --- /dev/null +++ b/resources/tools/svgsprite/svgsprite.js @@ -0,0 +1,38 @@ +function getSpriteIcon(icon, attrs, dimensions) { + var a = []; + var iconSymbol = $('svg symbol[id="' + icon + '"]'); + if (iconSymbol.length > 1) { + $('svg symbol[id="' + icon + '"]:not(:last)').remove(); + iconSymbol = $('svg symbol[id="' + icon + '"]'); + } + + if (iconSymbol.length == 0) { + return ''; // Bail out because symbol doesn't exist + } + + if (attrs == undefined) { + attrs = {}; + } + if (attrs.viewBox == null) { + attrs.viewBox = iconSymbol.get(0).attributes.viewBox.value; + } + if (dimensions === true) { + var vb = attrs.viewBox.split(' '); + attrs.x = vb[0]; + attrs.y = vb[1]; + attrs.width = vb[2]; + attrs.height = vb[3]; + } + if (attrs.class == null) { + attrs.class = icon; + } else { + attrs.class += ' ' + icon; + } + + attrs.class += ' nav-icon svg-icon'; // Common class for all icons + + $.each(attrs, function (k, v) { + a.push(k + '="' + v + '"'); + }); + return ''; +} diff --git a/resources/views/fluidbook_publication/link_editor.blade.php b/resources/views/fluidbook_publication/link_editor.blade.php index 9eea3b4fe..ea618d2b4 100644 --- a/resources/views/fluidbook_publication/link_editor.blade.php +++ b/resources/views/fluidbook_publication/link_editor.blade.php @@ -1,15 +1,44 @@ @php $title='#'.$id.' - '.__('Editeur de liens'); $fluidbook->getLinksAndRulers($links,$rulers); + $fbdata=$fluidbook->getPageData()->getRawData(); @endphp @extends('layouts.empty') +@include('fluidbook_publication.link_editor_icons') + @section('content')
- + + +
@@ -30,9 +59,10 @@
@endsection + @push('after_scripts') diff --git a/resources/views/fluidbook_publication/link_editor_icons.blade.php b/resources/views/fluidbook_publication/link_editor_icons.blade.php new file mode 100644 index 000000000..c1fd75b2d --- /dev/null +++ b/resources/views/fluidbook_publication/link_editor_icons.blade.php @@ -0,0 +1,44 @@ + +@push('after_scripts') + +@endpush -- 2.39.5