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

Version Path
active_scaffold-sequel-0.7.1 app/assets/javascripts/jquery/draggable_lists.js
active_scaffold-sequel-0.7.0 app/assets/javascripts/jquery/draggable_lists.js
active_scaffold-sequel-0.6.2 app/assets/javascripts/jquery/draggable_lists.js
active_scaffold-sequel-0.6.1 app/assets/javascripts/jquery/draggable_lists.js
active_scaffold-sequel-0.6.0 app/assets/javascripts/jquery/draggable_lists.js
active_scaffold-3.2.20 app/assets/javascripts/jquery/draggable_lists.js
active_scaffold-3.2.19 app/assets/javascripts/jquery/draggable_lists.js
active_scaffold-3.3.0.rc app/assets/javascripts/jquery/draggable_lists.js
active_scaffold-3.2.17 app/assets/javascripts/jquery/draggable_lists.js
active_scaffold-3.2.16 app/assets/javascripts/jquery/draggable_lists.js
active_scaffold-3.2.15 app/assets/javascripts/jquery/draggable_lists.js
active_scaffold-3.2.14 app/assets/javascripts/jquery/draggable_lists.js
active_scaffold-3.2.13 app/assets/javascripts/jquery/draggable_lists.js
active_scaffold-3.2.12 app/assets/javascripts/jquery/draggable_lists.js
active_scaffold-3.2.11 app/assets/javascripts/jquery/draggable_lists.js
active_scaffold-3.2.10 app/assets/javascripts/jquery/draggable_lists.js
active_scaffold-3.2.9 app/assets/javascripts/jquery/draggable_lists.js
active_scaffold-3.2.8 app/assets/javascripts/jquery/draggable_lists.js
active_scaffold-3.2.7 app/assets/javascripts/jquery/draggable_lists.js
active_scaffold-3.2.6 app/assets/javascripts/jquery/draggable_lists.js