Skip to content

Commit

Permalink
Update to v0.13.0
Browse files Browse the repository at this point in the history
  • Loading branch information
rniemeyer committed Apr 23, 2016
1 parent 6ee94f7 commit 6032e7a
Show file tree
Hide file tree
Showing 4 changed files with 137 additions and 135 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ Note2: (*Update: 0.9.0 adds code to automatically strip leading/trailing whitesp

* **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`.

* **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`.

* **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`.

* **afterAdd, beforeRemove, afterRender, includeDestroyed, templateEngine, as** - this binding will pass these options on to the template binding.
Expand Down
134 changes: 67 additions & 67 deletions build/knockout-sortable.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,73 +247,73 @@
if (arg && arg.cancelDrop) {
return;
}
//if the strategy option is unset or false, employ the order strategy involving removal and insertion of items
if(!sortable.hasOwnProperty("strategyMove") || sortable.strategyMove === false)
{
//do the actual move
if (targetIndex >= 0) {
if (sourceParent) {
sourceParent.splice(sourceIndex, 1);

//if using deferred updates plugin, force updates
if (ko.processAllDeferredBindingUpdates) {
ko.processAllDeferredBindingUpdates();
}
}

targetParent.splice(targetIndex, 0, item);
}

//rendering is handled by manipulating the observableArray; ignore dropped element
dataSet(el, ITEMKEY, null);
}
else { //employ the strategy of moving items
if (targetIndex >= 0) {
if (sourceParent) {
if (sourceParent !== targetParent) {
// moving from one list to another

sourceParent.splice(sourceIndex, 1);

//if using deferred updates plugin, force updates
if (ko.processAllDeferredBindingUpdates) {
ko.processAllDeferredBindingUpdates();
}

targetParent.splice(targetIndex, 0, item);

//rendering is handled by manipulating the observableArray; ignore dropped element
dataSet(el, ITEMKEY, null);
ui.item.remove();
}
else {
// moving within same list
var underlyingList = unwrap(sourceParent);

// notify 'beforeChange' subscribers
sourceParent.valueWillMutate();

// move from source index ...
underlyingList.splice(sourceIndex, 1);
// ... to target index
underlyingList.splice(targetIndex, 0, item);

// notify subscribers
sourceParent.valueHasMutated();
}
}
else {
// drop new element from outside
targetParent.splice(targetIndex, 0, item);

//rendering is handled by manipulating the observableArray; ignore dropped element
dataSet(el, ITEMKEY, null);
ui.item.remove();
}
}
}

//if the strategy option is unset or false, employ the order strategy involving removal and insertion of items
if (!sortable.hasOwnProperty("strategyMove") || sortable.strategyMove === false) {
//do the actual move
if (targetIndex >= 0) {
if (sourceParent) {
sourceParent.splice(sourceIndex, 1);

//if using deferred updates plugin, force updates
if (ko.processAllDeferredBindingUpdates) {
ko.processAllDeferredBindingUpdates();
}
}

targetParent.splice(targetIndex, 0, item);
}

//rendering is handled by manipulating the observableArray; ignore dropped element
dataSet(el, ITEMKEY, null);
}
else { //employ the strategy of moving items
console.log( "strategy move" );

This comment has been minimized.

Copy link
@mbest

mbest Apr 25, 2016

@rniemeyer Can you remove this console.log?

This comment has been minimized.

Copy link
@rniemeyer

rniemeyer Apr 25, 2016

Author Owner

@mbest - :( I'll take care of it. Thanks

This comment has been minimized.

Copy link
@rniemeyer

rniemeyer Apr 25, 2016

Author Owner

@mbest - fixed in v0.13.1

if (targetIndex >= 0) {
if (sourceParent) {
if (sourceParent !== targetParent) {
// moving from one list to another

sourceParent.splice(sourceIndex, 1);

//if using deferred updates plugin, force updates
if (ko.processAllDeferredBindingUpdates) {
ko.processAllDeferredBindingUpdates();
}

targetParent.splice(targetIndex, 0, item);

//rendering is handled by manipulating the observableArray; ignore dropped element
dataSet(el, ITEMKEY, null);
ui.item.remove();
}
else {
// moving within same list
var underlyingList = unwrap(sourceParent);

// notify 'beforeChange' subscribers
sourceParent.valueWillMutate();

// move from source index ...
underlyingList.splice(sourceIndex, 1);
// ... to target index
underlyingList.splice(targetIndex, 0, item);

// notify subscribers
sourceParent.valueHasMutated();
}
}
else {
// drop new element from outside
targetParent.splice(targetIndex, 0, item);

//rendering is handled by manipulating the observableArray; ignore dropped element
dataSet(el, ITEMKEY, null);
ui.item.remove();
}
}
}

//if using deferred updates plugin, force updates
if (ko.processAllDeferredBindingUpdates) {
ko.processAllDeferredBindingUpdates();
Expand Down
2 changes: 1 addition & 1 deletion build/knockout-sortable.min.js

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

Loading

0 comments on commit 6032e7a

Please sign in to comment.