public function getBookSurface()
{
- $s = $this->width * $this->height;
- return $s;
+ return $this->width * $this->height;
}
protected function _sortLinksByDepth($a, $b)
{
$options = ['interactive', 'inline'];
$combi = [];
+ $configs = [];
foreach (self::types() as $type) {
if (!isset($type['class'])) {
continue;
if ($field instanceof SelectFromArray) {
$optionsChoices[$option] = array_keys($field->getAttribute('options'));
} else if ($field instanceof Checkbox) {
- $optionsChoices[$option] = [false, true];
+ $optionsChoices[$option] = [0, 1];
} else {
}
$optionsChoices['alternative'] = ['file.jpg', 'file.zip'];
}
+ $configs[$type['type']] = $optionsChoices;
+
foreach ($optionsChoices as $option => $choices) {
foreach ($choices as $k => $v) {
$optionsChoices[$option][$k] = $option . '|' . $v;
$combi[$type['type']] = self::_combinations(array_values($optionsChoices));
}
+
$id = 1;
$base = ['top' => 1, 'left' => 1, 'width' => 1, 'height' => 1, 'to' => '-', 'inline' => 'inline', 'page' => 2, 'target' => '_blank', 'extra' => '', 'alternative' => '', 'interactive' => false];
$compiler = new FluidbookCompiler($fluidbook);
/** @var Link $instances */
$instances = [];
- $iconfigs = [];
foreach ($combi as $type => $config) {
if (!count($config)) {
$ee = explode('|', $item);
$c[$ee[0]] = $ee[1];
}
- $iconfigs[$type . '/' . $settings] = ['type' => $type] + $c + $base;
-
$instances[$type . '/' . $settings] = Link::getInstance(base64_encode($id), ['type' => $type] + $c + $base, $compiler);
$id++;
}
}
$res[$k] = $depth;
}
- return $res;
+ return ['depths' => $res, 'configs' => $configs];
}
/**
this.fs = 1;
this.mx = 0;
this.my = 0;
+ this.bookSurface = this.pw * this.ph;
this.fluidbookRect = null;
this.canvasRect = null;
+const {parse} = require("../../../public/packages/tinymce");
+
function LinkeditorLayers(linkeditor) {
this.linkeditor = linkeditor;
}
if ($this.maskCheckEvents) {
return;
}
- var link=$('#linkeditor-links [fb-uid="'+$(this).attr('name')+'"]');
- if($(this).prop('checked')){
+ var link = $('#linkeditor-links [fb-uid="' + $(this).attr('name') + '"]');
+ if ($(this).prop('checked')) {
$this.linkeditor.links.selectLink(link);
- }else{
+ } else {
$this.linkeditor.links.deselectLink(link);
}
}
var $this = this;
this.container.html('');
+ var layers = [];
$('#linkeditor-links .link:not(.pendingCreate)').each(function () {
let type = $(this).attr('fb-type');
let dest;
default:
dest = $(this).attr('fb-to');
}
- if (dest == '') {
+ if (dest === '') {
dest = '<em>' + TRANSLATIONS.empty + '</em>';
}
var l = '<label class="layer" fb-type="' + type + '"><input name="' + $(this).attr('fb-uid') + '" type="checkbox"> ' + dest + '</label>';
- $this.container.append(l);
+ layers.push({
+ level: Math.round(parseInt($(this).attr('fb-calc-depth')) / 10),
+ zindex: parseInt($(this).attr('fb-calc-zindex')),
+ html: l
+ });
+ });
+ layers.sort(function (a, b) {
+ return b.zindex - a.zindex;
+ });
+ var seenLevels = {};
+ $.each(layers, function (k, v) {
+ if (seenLevels[v.level] === undefined) {
+ seenLevels[v.level] = true;
+ $this.container.append('<h3>' + TRANSLATIONS.level + ' #' + v.level + '</h3>');
+ }
+ $this.container.append(v.html);
});
+
+
this.updateSelection();
},
$(link).addClass('pendingCreate');
this.startResizeLink('se');
this.linkeditor.form.updateLinkForm();
- this.linkeditor.layers.update();
+ this.updateLayers();
},
startResizeLink: function (corner) {
LINKS[id][k] = v;
});
this.linkeditor.rulers.updateMagnetValues();
- this.linkeditor.layers.update();
+ this.updateLayers();
},
startDragLink: function () {
}
$this.addLink(link, side);
});
- this.linkeditor.layers.update();
+ this.updateLayers();
},
addLink: function (link) {
this.deselectAllLinks();
this.selectLink($(link));
this.linkeditor.form.updateFormData();
- this.linkeditor.layers.update();
+
return $(link);
},
+ updateLayers: function () {
+ this.updateDepths();
+ this.linkeditor.layers.update();
+ },
+
deleteSelection: function () {
var $this = this;
this.linkeditor.form.emptyForm();
if (triggerChange === true) {
this.linkeditor.hasChanged();
}
- this.linkeditor.layers.update();
+ this.updateLayers();
},
selectAll: function () {
this.linkeditor.layers.updateSelection();
},
+ updateDepths: function () {
+ var $this = this;
+ $("#linkeditor-links .link").each(function () {
+ let calcDepth = parseInt($(this).attr('fb-zindex'));
+ if (calcDepth === -1) {
+ calcDepth = $this.findDefaultLinkDepth($(this));
+ }
+ let linkWidth = parseFloat($(this).attr('fb-width'));
+ let linkHeight = parseFloat($(this).attr('fb-height'));
+ let zindex = ((calcDepth + 1) * 10000) - Math.min(9999, Math.max(1, Math.round(9999 * ((linkWidth * linkHeight) / $this.linkeditor.bookSurface))));
+ $(this).attr('fb-calc-depth', calcDepth);
+ $(this).attr('fb-calc-zindex', zindex);
+ $(this).css('z-index', zindex);
+ });
+ },
+
+ findDefaultLinkDepth: function (link) {
+ var conf = DEPTH.configs[$(link).attr('fb-type')];
+ var key = $(link).attr('fb-type');
+ var settings = [];
+ $.each(conf, function (k, v) {
+ let val = $(link).attr('fb-' + k);
+ if (k === 'alternative') {
+ let e = val.split('.');
+ let ext = e.pop().toLowerCase();
+ val = (['png', 'jpg', 'jpeg', 'gif', 'webp', 'avif', 'svg'].indexOf(ext) >= 0) ? 'file.jpg' : 'file.zip';
+ }
+ settings.push(k + '|' + val);
+ });
+ if (settings.length > 0) {
+ key += '/' + settings.join(',');
+ }
+ return DEPTH.depths[key];
+ },
+
clear: function () {
$("#linkeditor-links").html('');
},
@include dark-theme
color: $color-dark
+ h3
+ border-bottom: 1px solid currentColor
+ padding: 3px 10px
+ font-style: italic
+ font-weight: 500
+ background-color: rgba(0,0,0,0.5)
+ color: $color-dark
+ @include dark-theme
+ background-color: rgba(255,255,255,0.5)
+ color: $color
+
label
display: block
border-bottom: 1px solid currentColor
&.selected
cursor: move
+ z-index: 1000000 !important
.corners
visibility: visible
'error_open_image_link'=>__('Impossible d\'ajouter des liens au contenu de ce lien'),
'empty'=>__('Vide'),
'copy_link_id'=>__('Copier l\'identifiant unique'),
+ 'level'=>__('Niveau'),
];
$rulers=!count($rulers)?'{}':json_encode($rulers);