Skip to content

Commit

Permalink
* group.put — can be an array
Browse files Browse the repository at this point in the history
  • Loading branch information
RubaXa committed Nov 8, 2014
1 parent eef660d commit 8a4bff0
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Sortable.create(el);
### Options
```js
var sortabel = new Sortable(el, {
group: "name", // or { name: "..", pull: [true, false, clone], put: true }
group: "name", // or { name: "..", pull: [true, false, clone], put: [true, false, array] }
sort: true, // sorting inside list
store: null, // @see Store
animation: 150, // ms, animation speed moving items when sorting, `0` — without animation
Expand Down Expand Up @@ -65,6 +65,16 @@ var sortabel = new Sortable(el, {
---


### `group` option

* name:`string` — group name
* pull:`true|false|'clone'` — ability to move from the list. `clone` — cloning drag item when moving from the list.
* put:`true|false|["foo", "bar"]` — the possibility of adding an element from the other list, or an array of names groups, which can be taken.


---


### Method

##### closest(el:`String`[, selector:`HTMLElement`]):`HTMLElement|null`
Expand Down
8 changes: 6 additions & 2 deletions Sortable.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
options.group = { name: options.group };
}


['pull', 'put'].forEach(function (key) {
if (!(key in options.group)) {
options.group[key] = true;
Expand Down Expand Up @@ -356,11 +357,12 @@
revert,
options = this.options,
group = options.group,
groupPut = group.put,
isOwner = (activeGroup === group);

if( !_silent &&
(activeGroup.name === group.name) &&
(isOwner && (options.sort || (revert = !rootEl.contains(dragEl))) || group.put && activeGroup.pull) &&
(activeGroup.name === group.name || groupPut && groupPut.indexOf && groupPut.indexOf(activeGroup.name) > -1) &&
(isOwner && (options.sort || (revert = !rootEl.contains(dragEl))) || groupPut && activeGroup.pull) &&
(evt.rootEl === void 0 || evt.rootEl === this.el)
){
target = _closest(evt.target, this.options.draggable, el);
Expand Down Expand Up @@ -492,6 +494,8 @@
_dispatchEvent(dragEl, 'end');
}

cloneEl.parentNode.removeChild(cloneEl);

// Set NULL
rootEl =
dragEl =
Expand Down
2 changes: 1 addition & 1 deletion Sortable.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ <h1 data-force="40" data-force-y="2.5">The JavaScript library for modern browser
pull: false,
put: true
}].forEach(function (opts, i) {
new Sortable(document.getElementById(opts.name + '-' + (i + 1)), {
new Sortable(document.getElementById('advanced-' + (i + 1)), {
group: opts,
animation: 150
});
Expand Down

0 comments on commit 8a4bff0

Please sign in to comment.