Browse Source

fix: aplica um lazy loading no sortable do jquery ui pelo evento mouseenter.

pull/3737/head
joaohortsenado 7 months ago
parent
commit
7e17c82f4b
  1. 24
      frontend/src/__apps/compilacao/js/old/compilacao_edit.js

24
frontend/src/__apps/compilacao/js/old/compilacao_edit.js

@ -1,4 +1,3 @@
const _$ = window.$ const _$ = window.$
window.DispositivoEdit = function () { window.DispositivoEdit = function () {
@ -500,7 +499,11 @@ window.DispositivoEdit = function () {
} }
instance.reloadFunctionsDraggables = function () { instance.reloadFunctionsDraggables = function () {
_$('.dpt-alts').sortable({ const dptAlts = _$('.dpt-alts')
if (dptAlts.length > 0) {
dptAlts.sortable({
connectWith: '.dpt-alts',
items: '.sorting-initialize',
revert: true, revert: true,
distance: 15, distance: 15,
start: function (event, ui) { start: function (event, ui) {
@ -511,11 +514,14 @@ window.DispositivoEdit = function () {
const url = pk + '/refresh?action=json_drag_move_dpt_alterado&index=' + ui.item.index() + '&bloco_pk=' + bloco_pk const url = pk + '/refresh?action=json_drag_move_dpt_alterado&index=' + ui.item.index() + '&bloco_pk=' + bloco_pk
_$.get(url).done(function (data) { _$.get(url).done(function (data) {
// console.log(pk + ' - ' + bloco_pk) // handle data if needed
// reloadFunctionsForObjectsOfCompilacao();
}) })
} }
}) })
dptAlts.find('.dpt').one('mouseenter', function () {
$(this).addClass('sorting-initialize')
dptAlts.sortable('refresh')
})
_$('.dpt-alts .dpt').draggable({ _$('.dpt-alts .dpt').draggable({
connectToSortable: '.dpt-alts', connectToSortable: '.dpt-alts',
@ -523,7 +529,6 @@ window.DispositivoEdit = function () {
zIndex: 1, zIndex: 1,
distance: 15, distance: 15,
drag: function (event, ui) { drag: function (event, ui) {
// _$('.dpt-comp-selected').removeClass('dpt-comp-selected');
_$('.dpt-alts').addClass('drag') _$('.dpt-alts').addClass('drag')
}, },
stop: function (event, ui) { stop: function (event, ui) {
@ -531,7 +536,10 @@ window.DispositivoEdit = function () {
} }
}) })
_$('.dpt-alts').disableSelection() dptAlts.disableSelection()
} else {
console.warn("No '.dpt-alts' elements found to make sortable/draggable.")
}
} }
instance.scrollTo = function (dpt) { instance.scrollTo = function (dpt) {
try { try {
@ -570,7 +578,9 @@ window.DispositivoEdit = function () {
instance.triggerBtnDptEdit(href[1]) instance.triggerBtnDptEdit(href[1])
} }
_$('main').click(function (event) { _$('main').click(function (event) {
if (event.target === this || event.target === this.firstElementChild) { instance.clearEditSelected() } if (event.target === this || event.target === this.firstElementChild) {
instance.clearEditSelected()
}
}) })
instance.waitHide() instance.waitHide()
} }

Loading…
Cancel
Save