jquery.collection.js
function (collection, settings, elements, element, oldIndex, newIndex) {
            if (1 === Math.abs(newIndex - oldIndex)) {
                elements = swapElements(collection, elements, oldIndex, newIndex);
                if (!(newIndex - oldIndex > 0 ? trueOrUndefined(settings.after_up(collection, element)) : trueOrUndefined(settings.after_down(collection, element)))) {
                    elements = swapElements(collection, elements, newIndex, oldIndex);
                }
            } else {
                if (oldIndex < newIndex) {
                    elements = swapElementsUp(collection, elements, settings, oldIndex, newIndex);
                    if (!(newIndex - oldIndex > 0 ? trueOrUndefined(settings.after_up(collection, element)) : trueOrUndefined(settings.after_down(collection, element)))) {
                        elements = swapElementsDown(collection, elements, settings, newIndex, oldIndex);
                    }
                } else {
                    elements = swapElementsDown(collection, elements, settings, oldIndex, newIndex);
                    if (!(newIndex - oldIndex > 0 ? trueOrUndefined(settings.after_up(collection, element)) : trueOrUndefined(settings.after_down(collection, element)))) {
                        elements = swapElementsUp(collection, elements, settings, newIndex, oldIndex);
                    }
                }
            }
            dumpCollectionActions(collection, settings, false);

            if (settings.position_field_selector) {
                return doRewritePositions(settings, elements);
            }

            return elements;
        }
function (collection, settings, elements, element, oldIndex, newIndex) {
            if (1 === Math.abs(newIndex - oldIndex)) {
                elements = swapElements(collection, elements, oldIndex, newIndex);
                if (!(newIndex - oldIndex > 0 ? trueOrUndefined(settings.after_up(collection, element)) : trueOrUndefined(settings.after_down(collection, element)))) {
                    elements = swapElements(collection, elements, newIndex, oldIndex);
                }
            } else {
                if (oldIndex < newIndex) {
                    elements = swapElementsUp(collection, elements, settings, oldIndex, newIndex);
                    if (!(newIndex - oldIndex > 0 ? trueOrUndefined(settings.after_up(collection, element)) : trueOrUndefined(settings.after_down(collection, element)))) {
                        elements = swapElementsDown(collection, elements, settings, newIndex, oldIndex);
                    }
                } else {
                    elements = swapElementsDown(collection, elements, settings, oldIndex, newIndex);
                    if (!(newIndex - oldIndex > 0 ? trueOrUndefined(settings.after_up(collection, element)) : trueOrUndefined(settings.after_down(collection, element)))) {
                        elements = swapElementsUp(collection, elements, settings, newIndex, oldIndex);
                    }
                }
            }
            dumpCollectionActions(collection, settings, false);

            if (settings.position_field_selector) {
                return doRewritePositions(settings, elements);
            }

            return elements;
        }
function ( collection , settings , elements , element , oldIndex , newIndex ) { if ( 1 === Math . abs ( newIndex - oldIndex ) ) { elements = swapElements ( collection , elements , oldIndex , newIndex ) ; if ( ! ( newIndex - oldIndex > 0 ? trueOrUndefined ( settings . after_up ( collection , element ) ) : trueOrUndefined ( settings . after_down ( collection , element ) ) ) ) { elements = swapElements ( collection , elements , newIndex , oldIndex ) ; } } else { if ( oldIndex < newIndex ) { elements = swapElementsUp ( collection , elements , settings , oldIndex , newIndex ) ; if ( ! ( newIndex - oldIndex > 0 ? trueOrUndefined ( settings . after_up ( collection , element ) ) : trueOrUndefined ( settings . after_down ( collection , element ) ) ) ) { elements = swapElementsDown ( collection , elements , settings , newIndex , oldIndex ) ; } } else { elements = swapElementsDown ( collection , elements , settings , oldIndex , newIndex ) ; if ( ! ( newIndex - oldIndex > 0 ? trueOrUndefined ( settings . after_up ( collection , element ) ) : trueOrUndefined ( settings . after_down ( collection , element ) ) ) ) { elements = swapElementsUp ( collection , elements , settings , newIndex , oldIndex ) ; } } } dumpCollectionActions ( collection , settings , false ) ; if ( settings . position_field_selector ) { return doRewritePositions ( settings , elements ) ; } return elements ; }
move an element from a position to an arbitrary new position
move an element from a position to an arbitrary new position