$(document).ready(
$(function() {
$('.want div').addClass('ui-widget-content');
$('tr').selectable({
filter: 'div',
start: function(event, ui) {
//deselect all currently selected elements on page
$(document).find('.ui-selected').each(function() {
$(this).removeClass('ui-selected');
});
},
selected: function(event, ui) {
//make each selected element draggable
$(ui.selected).draggable({
containment: 'document',
axis: 'y',
snap: true,
snapMode: 'inner',
opacity: 0.8,
drag: function(e, ui) {
$('.ui-selected').css({ //TODO: Make this ONLY select '.ui-selected' within same table row
top: ui.position.top //brings all of the selected blocks with it
});
},
start: function() {
$('.ui-selected').each(function() {
//sets data for the original point for the blocks, in case a revert is needed
$(this).data('x', $(this).offset().left); //not really necessary, since blocks only move on y-axis
$(this).data('y', $(this).offset().top);
});
},
stop: function() {
$('.ui-selected').each(function() {
var drop = document.elementFromPoint($(this).offset().left, $(this).offset().top); //TODO: This needs to get the element being hovered over, not the element being dragged around
if ($(this).hasClass('confirmed') && $(this).offset().left == $(this).data('x')) //TODO: true when 'drop' is empty/required && the draggable element isn't moving along the x-axis
{
//TODO: append $(this) to drop
} else {
...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Fiddle Pages
Your fiddles accessible under a custom domain and a vanity path - the simplest hosting for your personal project.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Get Fiddle Pages with PRO
Your fiddles accessible under a custom domain and a vanity path - the simplest hosting for your personal project.