Browse Source

Merge branch 'dev' into gh-pages

pull/191/head
RubaXa 10 years ago
parent
commit
88e90e2bd3
  1. 5
      README.md
  2. 25
      Sortable.js

5
README.md

@ -306,6 +306,10 @@ sortable.sort(order.reverse()); // apply
``` ```
##### save()
Save the current sorting (see [store](#store))
##### destroy() ##### destroy()
Removes the sortable functionality completely. Removes the sortable functionality completely.
@ -313,6 +317,7 @@ Removes the sortable functionality completely.
--- ---
<a name="store"></a>
### Store ### Store
Saving and restoring of the sort. Saving and restoring of the sort.

25
Sortable.js

@ -105,7 +105,8 @@
dataTransfer.setData('Text', dragEl.textContent); dataTransfer.setData('Text', dragEl.textContent);
} }
}, },
group;
group = options.group;
// Set default options // Set default options
@ -114,10 +115,9 @@
} }
if (!options.group.name) { if (!group || typeof group != 'object') {
options.group = { name: options.group }; group = options.group = { name: group };
} }
group = options.group;
['pull', 'put'].forEach(function (key) { ['pull', 'put'].forEach(function (key) {
@ -450,7 +450,10 @@
isOwner = (activeGroup === group), isOwner = (activeGroup === group),
canSort = options.sort; canSort = options.sort;
(evt.stopPropagation !== void 0) && evt.stopPropagation(); if (evt.preventDefault !== void 0) {
evt.preventDefault();
evt.stopPropagation();
}
if (!_silent && activeGroup && if (!_silent && activeGroup &&
(isOwner (isOwner
@ -638,7 +641,7 @@
Sortable.active = null; Sortable.active = null;
// Save sorting // Save sorting
this.options.store && this.options.store.set(this); this.save()
} }
}, },
@ -693,7 +696,6 @@
} }
}, this); }, this);
order.forEach(function (id) { order.forEach(function (id) {
if (items[id]) { if (items[id]) {
rootEl.removeChild(items[id]); rootEl.removeChild(items[id]);
@ -703,6 +705,15 @@
}, },
/**
* Save the current sorting
*/
save: function () {
var store = this.options.store;
store && store.set(this);
},
/** /**
* For each element in the set, get the first element that matches the selector by testing the element itself and traversing up through its ancestors in the DOM tree. * For each element in the set, get the first element that matches the selector by testing the element itself and traversing up through its ancestors in the DOM tree.
* @param {HTMLElement} el * @param {HTMLElement} el

Loading…
Cancel
Save