Get fw sidebox sortable items working with sortablejs and removes the jquery.sortable

This commit is contained in:
Hadi Nategh
2021-08-02 15:36:52 +02:00
parent af7b1a0fe0
commit a63416f6d6
3 changed files with 25 additions and 51 deletions

View File

@ -25,7 +25,7 @@ import './fw_browser.js';
import './fw_ui.js';
import './fw_classes.js';
import '../jsapi/egw_inheritance.js';
import "sortablejs/Sortable.min.js";
/**
*
* @param {DOMWindow} window
@ -48,31 +48,15 @@ import '../jsapi/egw_inheritance.js';
init: function()
{
this._super.apply(this,arguments);
let self = this;
this.setBottomLine(this.parent.entries);
//Make the base Div sortable. Set all elements with the style "egw_fw_ui_sidemenu_entry_header"
//as handle
if(jQuery(this.elemDiv).data('uiSortable'))
{
jQuery(this.elemDiv).sortable("destroy");
}
jQuery(this.elemDiv).sortable({
handle: ".egw_fw_ui_sidemenu_entry_header",
distance: 15,
start: function(event, ui)
{
var parent = ui.item.context._parent;
parent.isDraged = true;
parent.parent.startDrag.call(parent.parent);
Sortable.create(this.elemDiv,{
onSort: function (evt) {
self.parent.isDraged = true;
self.parent.refreshSort();
},
stop: function(event, ui)
{
var parent = ui.item.context._parent;
parent.parent.stopDrag.call(parent.parent);
parent.parent.refreshSort.call(parent.parent);
},
opacity: 0.7,
axis: 'y'
direction: 'vertical'
});
},
@ -107,31 +91,6 @@ import '../jsapi/egw_inheritance.js';
this._super.apply(this,arguments);
this.sortCallback = _sortCallback;
},
/**
*
* @returns {undefined}
*/
startDrag: function()
{
if (this.activeEntry)
{
jQuery(this.activeEntry.marker).show();
jQuery(this.elemDiv).sortable("refresh");
}
},
/**
*
* @returns {undefined}
*/
stopDrag: function()
{
if (this.activeEntry)
{
jQuery(this.activeEntry.marker).hide();
jQuery(this.elemDiv).sortable("refresh");
}
},
/**
* Called by the sidemenu elements whenever they were sorted. An array containing