forked from extern/egroupware
Replace all jquery-ui sortable used in fw
This commit is contained in:
parent
0ac617eb15
commit
1afcc3ebce
@ -13,6 +13,7 @@
|
||||
*/
|
||||
import '../jsapi/egw_inheritance.js';
|
||||
import {et2_IPrint} from "../etemplate/et2_core_interfaces";
|
||||
import "sortablejs/Sortable.min.js";
|
||||
|
||||
window.fw_base = (function(){ "use strict"; return Class.extend(
|
||||
{
|
||||
@ -387,21 +388,24 @@ window.fw_base = (function(){ "use strict"; return Class.extend(
|
||||
// reliable init sidebox, as app.js might initialise earlier
|
||||
if (typeof app[_app.appName] == 'object')
|
||||
{
|
||||
var sidebox = jQuery('#favorite_sidebox_'+_app.appName, this.sidemenuDiv);
|
||||
var sidebox = jQuery('#favorite_sidebox_'+_app.appName, this.sidemenuDiv).getElementsByTagName('ul')[0];
|
||||
var self = this;
|
||||
var currentAppName = _app.appName;
|
||||
// make sidebox
|
||||
sidebox.children().sortable({
|
||||
|
||||
items:'li:not([data-id$="add"])',
|
||||
placeholder:'ui-fav-sortable-placeholder',
|
||||
update: function (event, ui)
|
||||
|
||||
let sortablejs = Sortable.create(sidebox, {
|
||||
ghostClass: 'ui-fav-sortable-placeholder',
|
||||
draggable: 'li:not([data-id$="add"])',
|
||||
delay: 25,
|
||||
dataIdAttr: 'data-id',
|
||||
onSort: function(event)
|
||||
{
|
||||
var favSortedList = jQuery(this).sortable('toArray', {attribute:'data-id'});
|
||||
|
||||
egw().set_preference(currentAppName,'fav_sort_pref',favSortedList);
|
||||
let favSortedList = sortablejs.toArray();
|
||||
self.egw.set_preference(currentAppName, 'fav_sort_pref', favSortedList);
|
||||
self._refresh_fav_nm();
|
||||
}
|
||||
});
|
||||
|
||||
if (sidebox.length) app[_app.appName]._init_sidebox.call(app[_app.appName], sidebox);
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,6 @@
|
||||
|
||||
import "../../../vendor/bower-asset/jquery/dist/jquery.min.js";
|
||||
import "../jquery/jquery.noconflict.js";
|
||||
//import "../../../vendor/bower-asset/jquery-ui/jquery-ui.js";
|
||||
import './fw_base.js';
|
||||
import './fw_browser.js';
|
||||
import './fw_ui.js';
|
||||
|
@ -20,6 +20,7 @@ import {Et2Dialog} from "../etemplate/Et2Dialog/Et2Dialog";
|
||||
import {et2_nextmatch} from "../etemplate/et2_extension_nextmatch";
|
||||
import {et2_favorites} from "../etemplate/et2_widget_favorites";
|
||||
import {EGW_KEY_ENTER} from "../egw_action/egw_action_constants";
|
||||
import "sortablejs/Sortable.min.js";
|
||||
|
||||
/**
|
||||
* Common base class for application javascript
|
||||
@ -613,30 +614,22 @@ export const AppJS = (function(){ "use strict"; return Class.extend(
|
||||
})
|
||||
.addClass("ui-helper-clearfix");
|
||||
|
||||
//Add Sortable handler to sideBox fav. menu
|
||||
jQuery('ul','#favorite_sidebox_'+this.appname).sortable({
|
||||
items:'li:not([data-id$="add"])',
|
||||
placeholder:'ui-fav-sortable-placeholder',
|
||||
delay:250, //(millisecond) delay before the sorting should start
|
||||
helper: function(event, item) {
|
||||
// We'll need to know which app this is for
|
||||
item.attr('data-appname',self.appname);
|
||||
// Create custom helper so it can be dragged to Home
|
||||
var h_parent = item.parent().parent().clone();
|
||||
h_parent.find('li').not('[data-id="'+item.attr('data-id')+'"]').remove();
|
||||
h_parent.appendTo('body');
|
||||
return h_parent;
|
||||
},
|
||||
refreshPositions: true,
|
||||
update: function (event, ui)
|
||||
let el = document.getElementById('favorite_sidebox_' + this.appname)?.getElementsByTagName('ul')[0];
|
||||
if(el && el instanceof HTMLElement)
|
||||
{
|
||||
let sortablejs = Sortable.create(el, {
|
||||
ghostClass: 'ui-fav-sortable-placeholder',
|
||||
draggable: 'li:not([data-id$="add"])',
|
||||
delay: 25,
|
||||
dataIdAttr: 'data-id',
|
||||
onSort: function(event)
|
||||
{
|
||||
var favSortedList = jQuery(this).sortable('toArray', {attribute:'data-id'});
|
||||
|
||||
self.egw.set_preference(self.appname,'fav_sort_pref',favSortedList);
|
||||
|
||||
let favSortedList = sortablejs.toArray();
|
||||
self.egw.set_preference(self.appname, 'fav_sort_pref', favSortedList);
|
||||
self._refresh_fav_nm();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Bind favorite de-select
|
||||
var egw_fw = egw_getFramework();
|
||||
|
Loading…
Reference in New Issue
Block a user