this.contextMenuPosition = null;
+ this.dropTypes = [4, 7, 12, 15, 16, 17, 18, 25, 30, 31];
+
this.init();
}
}
});
+ var commonDragAndDropEvent = function (e) {
+ e.originalEvent.dataTransfer.dropEffect = "copy";
+ e.preventDefault();
+ }
+
+ $(document).on('dragententer dragover', '#linkeditor-main', function (e) {
+ $('#linkeditor-main').addClass('dropfile');
+ commonDragAndDropEvent(e);
+ }).on('dragleave', '#linkeditor-main', function (e) {
+ $('#linkeditor-main').removeClass('dropfile');
+ commonDragAndDropEvent(e);
+ });
+
+ $(document).on('dragenter dragover', '.link.dropfile', function (e) {
+ commonDragAndDropEvent(e);
+ $(this).addClass('dragging');
+ });
+ $(document).on('dragleave', '.link.dropfile', function (e) {
+ commonDragAndDropEvent(e);
+ $(this).removeClass('dragging');
+ });
+ $(document).on('drop', '.link.dropfile', function (e) {
+ let link = this;
+ $this.deselectAllLinks();
+
+ commonDragAndDropEvent(e);
+ let uid = $(this).attr('fb-uid');
+ var fd = new FormData();
+ fd.append('entity', 'App\\Models\\FluidbookPublication');
+ fd.append('entry_id', FLUIDBOOK_DATA.id);
+ fd.append('attribute', 'linksAssets');
+ fd.append('file', e.originalEvent.dataTransfer.files[0]);
+ $.ajax({
+ url: '/filesorurlupload',
+ type: 'post',
+ data: fd,
+ contentType: false,
+ processData: false,
+ dataType: 'json',
+ success: function (response) {
+ $(link).attr('fb-to', response[0]);
+ $this.selectLink(link);
+ }
+ });
+ $(this).removeClass('dragging');
+ $('#linkeditor-main').removeClass('dropfile');
+ });
+
+
$.contextMenu({
selector: '#linkeditor-canvas,.link,#linkeditor-panel-layers, #linkeditor-panel-layers label',
events: {
attrs['fb-ref'] = "editor";
attrs['fb-update'] = "1";
+
let e = $('<div class="link" fb-ref="editor" fb-update="1"></div>');
$(e).attr(attrs);
+ if (this.dropTypes.indexOf(parseInt(link.type)) >= 0) {
+ $(e).addClass('dropfile');
+ }
$("#linkeditor-links").append(e);
if (triggerChange && change) {
this.linkeditor.rulers.updateMagnetValues();