Sha256: b2eb4980aff9fa39e8c94ea057c85e2dffe4f4adceff87914168e065c597938e
Contents?: true
Size: 1.18 KB
Versions: 33
Compression:
Stored size: 1.18 KB
Contents
jQuery.fn.draggable_lists = function() { this.addClass('draggable-list'); var list_selected = jQuery(this.get(0).cloneNode(false)).addClass('selected'); list_selected.attr('id', list_selected.attr('id') + '_selected').insertAfter(this); this.find('input:checkbox').each(function(index, item) { var li = jQuery(item).closest('li').addClass('draggable-item'); li.children('label').removeAttr('for'); if (jQuery(item).is(':checked')) li.appendTo(list_selected); li.draggable({appendTo: 'body', helper: 'clone'}); }); jQuery([this, list_selected]).droppable({ hoverClass: 'hover', accept: function(draggable) { var parent_id = draggable.parent().attr('id'), id = jQuery(this).attr('id'), requested_id = jQuery(this).hasClass('selected') ? id.replace('_selected', '') : id + '_selected'; return parent_id == requested_id; }, drop: function(event, ui) { jQuery(this).append(ui.draggable); var input = jQuery('input:checkbox', ui.draggable); if (jQuery(this).hasClass('selected')) input.attr('checked', 'checked'); else input.removeAttr('checked'); ui.draggable.css({left: '0px', top: '0px'}); } }); return this; };
Version data entries
33 entries across 33 versions & 2 rubygems