Line 26: |
Line 26: |
| }); | | }); |
| }); | | }); |
− |
| |
− | `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);
| |
− | }
| |
− | });
| |
− | })`
| |