|
247 | 247 | if (arg && arg.cancelDrop) { |
248 | 248 | return; |
249 | 249 | } |
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 | + |
317 | 317 | //if using deferred updates plugin, force updates |
318 | 318 | if (ko.processAllDeferredBindingUpdates) { |
319 | 319 | ko.processAllDeferredBindingUpdates(); |
|
0 commit comments