import LinkeditorForm from './linkeditor.form';
import LinkeditorVersions from './linkeditor.versions';
import LinkeditorPopup from './linkeditor.popup';
+import LinkeditorLayers from "./linkeditor.layers";
window.$ = window.jQuery = require('jquery');
window.key = require('keymaster-reloaded');
import 'select2/dist/css/select2.css';
import 'select2-bootstrap-theme/dist/select2-bootstrap.css';
+
window.MD5 = require("crypto-js/md5");
$.ajaxSetup({
this.form = new LinkeditorForm(this);
this.settings = new LinkeditorSettings(this);
this.versions = new LinkeditorVersions(this);
+ this.layers = new LinkeditorLayers(this);
this.popup = new LinkeditorPopup(this);
this.initEvents();
--- /dev/null
+function LinkeditorLayers(linkeditor) {
+ this.linkeditor = linkeditor;
+}
+
+LinkeditorLayers.prototype = {
+ init: function () {
+ var $this = this;
+
+ this.container = $("#linkeditor-panel-layers");
+ this.maskCheckEvents = false;
+
+ $(document).on('change', "#linkeditor-panel-layers :checkbox", function () {
+ if ($this.maskCheckEvents) {
+ return;
+ }
+ var link=$('#linkeditor-links [fb-uid="'+$(this).attr('name')+'"]');
+ if($(this).prop('checked')){
+ $this.linkeditor.links.selectLink(link);
+ }else{
+ $this.linkeditor.links.deselectLink(link);
+ }
+
+ });
+
+ this.update();
+ },
+
+ update: function () {
+ if (this.container === undefined) {
+ return;
+ }
+ if (!this.container.hasClass('open')) {
+ return;
+ }
+ var $this = this;
+ this.container.html('');
+ $('#linkeditor-links .link:not(.pendingCreate)').each(function () {
+ let type = $(this).attr('fb-type');
+ let dest;
+ switch (type) {
+ case '6':
+ dest = $(this).attr('fb-alternative');
+ break;
+ default:
+ dest = $(this).attr('fb-to');
+ }
+ 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);
+ });
+ this.updateSelection();
+ },
+
+ updateSelection() {
+ var $this = this;
+ this.maskCheckEvents = true;
+ setTimeout(function () {
+ $this.maskCheckEvents = false;
+ }, 100);
+ $('#linkeditor-links .link').each(function () {
+ let checkbox = $this.container.find('input[name=' + $(this).attr('fb-uid') + ']');
+ checkbox.prop('checked', $(this).is('.selected'));
+ });
+ },
+
+ resize: function () {
+
+ },
+};
+module.exports = LinkeditorLayers;
});
$.contextMenu({
- selector: '#linkeditor-canvas,.link',
-
+ selector: '#linkeditor-canvas,.link,#linkeditor-panel-layers, #linkeditor-panel-layers label',
events: {
preShow: function (e) {
if ($(e).is('.link:not(.selected)')) {
$this.deselectAllLinks();
$this.selectLink(e);
}
+ if ($(e).is('#linkeditor-panel-layers label')) {
+ let input = $(e).find('input');
+ if (!input.prop('checked')) {
+ $this.deselectAllLinks();
+ $this.selectLink($('.link[fb-uid=' + input.attr('name') + ']'));
+ }
+ }
},
},
build: function ($triggerElement, e) {
},
}
};
- if (hasSelection && !multiple && selection.is('[fb-type=6]')) {
+ if (hasSelection && !multiple) {
res.items = $.extend(res.items, {
- 'sep_image_link': '---------',
- "image_link": {
+ 'sep_link': '---------',
+ 'copy_link_id': {
+ isHtmlName: true,
+ name: TRANSLATIONS.copy_link_id,
+ callback: function () {
+ navigator.clipboard.writeText(selection.attr('fb-uid'));
+ },
+ }
+ });
+ if (selection.is('[fb-type=6]')) {
+ res.items.image_link = {
isHtmlName: true,
name: TRANSLATIONS.edit_image_link + ' <kbd>Ctrl+L</kbd>', callback: function () {
$this.openImageLink();
}
- },
- });
+ };
+ }
}
if (hasSelection) {
res.items = $.extend(res.items, {
}
this.deselectAllLinks();
this.selectLink($(link));
+ this.linkeditor.layers.updateSelection();
this.linkeditor.form.focusAndSelectDestinationField();
},
if (this.getCurrentSelection().length === 0) {
return this.selectFirstLink();
}
- return this.selectLinkAndSelectToField(this._getLinkByIndexOffset(1));
+ this.selectLinkAndSelectToField(this._getLinkByIndexOffset(1));
},
_getLinkByIndexOffset(way) {
$(link).addClass('pendingCreate');
this.startResizeLink('se');
this.linkeditor.form.updateLinkForm();
+ this.linkeditor.layers.update();
},
startResizeLink: function (corner) {
LINKS[id][k] = v;
});
this.linkeditor.rulers.updateMagnetValues();
+ this.linkeditor.layers.update();
},
startDragLink: function () {
this.linkeditor.form.updateLinkForm();
this.lastSelectedLink = l;
+ this.linkeditor.layers.updateSelection();
},
checkLastSelectedLink: function () {
this.linkeditor.form.saveFormDataInLink();
this.linkeditor.form.updateLinkForm();
$(".link.selected").removeClass('selected');
+ this.linkeditor.layers.updateSelection();
+ },
+
+ deselectLink: function (link) {
+ $(link).removeClass('selected');
},
offsetSelectedLinks: function (dim, value) {
}
$this.addLink(link, side);
});
+ this.linkeditor.layers.update();
},
addLink: function (link) {
this.deselectAllLinks();
this.selectLink($(link));
this.linkeditor.form.updateFormData();
+ this.linkeditor.layers.update();
return $(link);
},
if (triggerChange === true) {
this.linkeditor.hasChanged();
}
+ this.linkeditor.layers.update();
},
selectAll: function () {
$('.link').each(function () {
$this.selectLink($(this));
});
+ this.linkeditor.layers.updateSelection();
},
clear: function () {
$.each(panels, function (k, panel) {
$("#linkeditor-" + side + " nav").append($("#linkeditor-icon-" + panel));
- if($('#linkeditor-panel-' + panel).length>0){
+ if ($('#linkeditor-panel-' + panel).length > 0) {
panelsContainer.append($('#linkeditor-panel-' + panel));
- }else {
+ } else {
panelsContainer.append('<div id="linkeditor-panel-' + panel + '"></div>');
}
- $('#linkeditor-panel-' + panel).attr('data-panel',panel).addClass('linkeditor-panel');
+ $('#linkeditor-panel-' + panel).attr('data-panel', panel).addClass('linkeditor-panel');
});
var tool = $this.linkeditor.settings.get(side + '_tool', panels[0]);
$this.setPanelState(tool, true);
}
});
+
+ this.linkeditor.layers.init();
+
this.linkeditor.resize.resize();
$(document).on('mousedown', ".linkeditor-sidebar .handle", function (e) {
$this.linkeditor.setMouseCoordinates(e);
},
togglePanel: function (panel) {
this.setPanelState(panel, 'toggle');
+ this.linkeditor.layers.update();
},
setPanelState: function (panel, newState) {
var $this = this;
if (newState) {
this.linkeditor.settings.set(side + '_tool', panel);
}
+ this.linkeditor.layers.update();
this.linkeditor.settings.set(side + '_open', newState);
this.linkeditor.resize.resize();
},
+.context-menu-list
+ z-index: 100000 !important
+
.context-menu-item
kbd
float: right
input[type="checkbox"]
margin-right: 8px
+ appearance: none
+ position: relative
+ cursor: pointer
+
+ &::before
+ content: ''
+ display: inline-block
+ width: 14px
+ height: 14px
+ border: 1px solid currentColor
+ border-radius: 2px
+ vertical-align: baseline
+
+ &:checked
+ &::after
+ content: ''
+ display: block
+ width: 12px
+ height: 12px
+ position: absolute
+ top: 1px
+ left: 1px
+ clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%)
+ background-color: currentColor
+
input[type=number]
&, &:hover
--- /dev/null
+#linkeditor-panel-layers
+ font-size: 11px
+ color: $color
+ @include dark-theme
+ color: $color-dark
+
+ label
+ display: block
+ border-bottom: 1px solid currentColor
+ padding: 5px 10px
+ cursor: pointer
+
+ input
+ color: #fff
+ position: relative
+ top: 2px
+
+ &::before
+ border: 0
@import "inc/_versions"
@import "inc/_popup"
@import "inc/_contextmenu"
+@import "inc/_layers"
'delete_selection'=>__('Supprimer la sélection'),
'select_all'=>__('Tout sélectionner'),
'error_open_image_link'=>__('Impossible d\'ajouter des liens au contenu de ce lien'),
+ 'empty'=>__('Vide'),
+ 'copy_link_id'=>__('Copier l\'identifiant unique'),
];
$rulers=!count($rulers)?'{}':json_encode($rulers);
background-color: {{\Cubist\Util\Graphics\Color::colorToCSS($type['color'],0.25)}};
}
- .linkeditor-linktype[data-type="{{$type['type']}}"]::before {
+ .linkeditor-linktype[data-type="{{$type['type']}}"]::before, label[fb-type="{{$type['type']}}"] input[type="checkbox"]::before {
background-color: {{$type['color']}};
}
@endif