Changes

Jump to navigation Jump to search
704 bytes added ,  16:43, 5 August 2021
jQuery UI Dragging Test
Line 25: Line 25:  
$(this).css("background-image", 'url(' + ')');
 
$(this).css("background-image", 'url(' + ')');
 
});
 
});
 +
 +
`mw.loader.load('jquery.ui').then(function(){
 +
jQuery.fn.swap = function(b){
 +
b = jQuery(b)[0];
 +
var a = this[0];
 +
var t = a.parentNode.insertBefore(document.createTextNode(''), a);
 +
b.parentNode.insertBefore(a, b);
 +
t.parentNode.insertBefore(b, t);
 +
t.parentNode.removeChild(t);
 +
return this;
 +
};
 +
 +
$( ".wagon-slot" ).draggable({helper: "clone"});
 +
$( ".wagon-slot" ).droppable({
 +
accept: ".wagon-slot",
 +
activeClass: "ui-state-hover",
 +
hoverClass: "ui-state-active",
 +
drop: function(event, ui){
 +
var draggable = ui.draggable, droppable = $(this),
 +
dragPos = draggable.position(), dropPos = droppable.position();
 +
draggable.swap(droppable);
 +
}
 +
});
 +
})`
 
});
 
});

Navigation menu