Skip to content
This repository has been archived by the owner on Jan 13, 2020. It is now read-only.

Added "clone" and "insertable" properties #168

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions jquery.nestable.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@
collapseBtnHTML : '<button data-action="collapse" type="button">Collapse</button>',
group : 0,
maxDepth : 5,
threshold : 20
threshold : 20,
clone : false,
insertable : true
};

function Plugin(element, options)
Expand All @@ -62,6 +64,7 @@
list.reset();

list.el.data('nestable-group', this.options.group);
list.el.data('nestable-insertable', this.options.insertable);

list.placeEl = $('<div class="' + list.options.placeClass + '"/>');

Expand Down Expand Up @@ -265,9 +268,16 @@
this.dragEl = $(document.createElement(this.options.listNodeName)).addClass(this.options.listClass + ' ' + this.options.dragClass);
this.dragEl.css('width', dragItem.width());

dragItem.after(this.placeEl);
dragItem[0].parentNode.removeChild(dragItem[0]);
dragItem.appendTo(this.dragEl);
if(this.options.insertable){
dragItem.after(this.placeEl);
}
if(this.options.clone){
dragItem.clone().appendTo(this.dragEl);
} else {
/* appendTo(obj) also remove obj
dragItem[0].parentNode.removeChild(dragItem[0]); */
dragItem.appendTo(this.dragEl);
}

$(document.body).append(this.dragEl);
this.dragEl.css({
Expand Down Expand Up @@ -416,6 +426,10 @@
var pointElRoot = this.pointEl.closest('.' + opt.rootClass),
isNewRoot = this.dragRootEl.data('nestable-id') !== pointElRoot.data('nestable-id');

if(!pointElRoot.data('nestable-insertable')) {
return;
}

/**
* move vertical
*/
Expand Down