Skip to content

Commit 6032e7a

Browse files
committed
Update to v0.13.0
1 parent 6ee94f7 commit 6032e7a

File tree

4 files changed

+137
-135
lines changed

4 files changed

+137
-135
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ Note2: (*Update: 0.9.0 adds code to automatically strip leading/trailing whitesp
7272

7373
* **isEnabled** - specify whether the sortable widget should be enabled. If this is an observable, then it will enable/disable the widget when the observable's value changes. This option can be passed in the binding or configured globally by setting `ko.bindingHandlers.sortable.isEnabled`.
7474

75+
* **strategyMove** - specify whether dropping an item within the same list should move the same item to the new index rather than removing and re-adding the item in the new location (which is the default and causes the item to be re-rendered). This option can be passed in the binding or configured globally by setting `ko.bindingHandlers.sortable.strategyMove`. The default value is `false`.
76+
7577
* **options** - specify any additional options to pass on to the `.sortable` jQuery UI call. These options can be specified in the binding or specified globally by setting `ko.bindingHandlers.sortable.options`.
7678

7779
* **afterAdd, beforeRemove, afterRender, includeDestroyed, templateEngine, as** - this binding will pass these options on to the template binding.

build/knockout-sortable.js

Lines changed: 67 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -247,73 +247,73 @@
247247
if (arg && arg.cancelDrop) {
248248
return;
249249
}
250-
251-
//if the strategy option is unset or false, employ the order strategy involving removal and insertion of items
252-
if(!sortable.hasOwnProperty("strategyMove") || sortable.strategyMove === false)
253-
{
254-
//do the actual move
255-
if (targetIndex >= 0) {
256-
if (sourceParent) {
257-
sourceParent.splice(sourceIndex, 1);
258-
259-
//if using deferred updates plugin, force updates
260-
if (ko.processAllDeferredBindingUpdates) {
261-
ko.processAllDeferredBindingUpdates();
262-
}
263-
}
264-
265-
targetParent.splice(targetIndex, 0, item);
266-
}
267-
268-
//rendering is handled by manipulating the observableArray; ignore dropped element
269-
dataSet(el, ITEMKEY, null);
270-
}
271-
else { //employ the strategy of moving items
272-
if (targetIndex >= 0) {
273-
if (sourceParent) {
274-
if (sourceParent !== targetParent) {
275-
// moving from one list to another
276-
277-
sourceParent.splice(sourceIndex, 1);
278-
279-
//if using deferred updates plugin, force updates
280-
if (ko.processAllDeferredBindingUpdates) {
281-
ko.processAllDeferredBindingUpdates();
282-
}
283-
284-
targetParent.splice(targetIndex, 0, item);
285-
286-
//rendering is handled by manipulating the observableArray; ignore dropped element
287-
dataSet(el, ITEMKEY, null);
288-
ui.item.remove();
289-
}
290-
else {
291-
// moving within same list
292-
var underlyingList = unwrap(sourceParent);
293-
294-
// notify 'beforeChange' subscribers
295-
sourceParent.valueWillMutate();
296-
297-
// move from source index ...
298-
underlyingList.splice(sourceIndex, 1);
299-
// ... to target index
300-
underlyingList.splice(targetIndex, 0, item);
301-
302-
// notify subscribers
303-
sourceParent.valueHasMutated();
304-
}
305-
}
306-
else {
307-
// drop new element from outside
308-
targetParent.splice(targetIndex, 0, item);
309-
310-
//rendering is handled by manipulating the observableArray; ignore dropped element
311-
dataSet(el, ITEMKEY, null);
312-
ui.item.remove();
313-
}
314-
}
315-
}
316-
250+
251+
//if the strategy option is unset or false, employ the order strategy involving removal and insertion of items
252+
if (!sortable.hasOwnProperty("strategyMove") || sortable.strategyMove === false) {
253+
//do the actual move
254+
if (targetIndex >= 0) {
255+
if (sourceParent) {
256+
sourceParent.splice(sourceIndex, 1);
257+
258+
//if using deferred updates plugin, force updates
259+
if (ko.processAllDeferredBindingUpdates) {
260+
ko.processAllDeferredBindingUpdates();
261+
}
262+
}
263+
264+
targetParent.splice(targetIndex, 0, item);
265+
}
266+
267+
//rendering is handled by manipulating the observableArray; ignore dropped element
268+
dataSet(el, ITEMKEY, null);
269+
}
270+
else { //employ the strategy of moving items
271+
console.log( "strategy move" );
272+
if (targetIndex >= 0) {
273+
if (sourceParent) {
274+
if (sourceParent !== targetParent) {
275+
// moving from one list to another
276+
277+
sourceParent.splice(sourceIndex, 1);
278+
279+
//if using deferred updates plugin, force updates
280+
if (ko.processAllDeferredBindingUpdates) {
281+
ko.processAllDeferredBindingUpdates();
282+
}
283+
284+
targetParent.splice(targetIndex, 0, item);
285+
286+
//rendering is handled by manipulating the observableArray; ignore dropped element
287+
dataSet(el, ITEMKEY, null);
288+
ui.item.remove();
289+
}
290+
else {
291+
// moving within same list
292+
var underlyingList = unwrap(sourceParent);
293+
294+
// notify 'beforeChange' subscribers
295+
sourceParent.valueWillMutate();
296+
297+
// move from source index ...
298+
underlyingList.splice(sourceIndex, 1);
299+
// ... to target index
300+
underlyingList.splice(targetIndex, 0, item);
301+
302+
// notify subscribers
303+
sourceParent.valueHasMutated();
304+
}
305+
}
306+
else {
307+
// drop new element from outside
308+
targetParent.splice(targetIndex, 0, item);
309+
310+
//rendering is handled by manipulating the observableArray; ignore dropped element
311+
dataSet(el, ITEMKEY, null);
312+
ui.item.remove();
313+
}
314+
}
315+
}
316+
317317
//if using deferred updates plugin, force updates
318318
if (ko.processAllDeferredBindingUpdates) {
319319
ko.processAllDeferredBindingUpdates();

build/knockout-sortable.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)