Index: src/webapp/components/reorderer/js/GeometricManager.js =================================================================== --- src/webapp/components/reorderer/js/GeometricManager.js (revision 8950) +++ src/webapp/components/reorderer/js/GeometricManager.js (working copy) @@ -450,20 +450,55 @@ }; }; - function getRelativeElement(element, direction, elements) { + // this function moves a list element forward or backward + // the new 4th parameter wrapSwitch allows to turn wrapping OFF + function getRelativeElement(element, direction, elements, wrapSwitch) { + // determine the direction (1 or -1) var folded = fluid.directionSign(direction); + // add direction in var folded var index = $(elements).index(element) + folded; + + // if wrapping is off make sure the index is not getting + // smaller than 0 and not bigger or equal than the length + if (wrapSwitch === "wrapOFF") { + if (index < 0) { + index = 0; + } + if (index >= elements.length) { + index = (elements.length - 1); + } + } + /* no else necessary since function is not changed if wrapping stays on */ + + // enable wrapping backwards (add number of elements + // to negative index to add the element at the end of list) if (index < 0) { index += elements.length; } + // enable wrapping forward (modulo by length always has a + // remainder that is equal to index except for index getting + // bigger than length. This sets index to 0) index %= elements.length; return elements[index]; } + // this function is called to have a list that does not wrap during move that.logicalFrom = function (element, direction, includeLocked) { - var orderables = that.getOwningSpan(element, fluid.position.INTERLEAVED, includeLocked); - return {element: getRelativeElement(element, direction, orderables), + return that.logicalFromFusion (element, direction, includeLocked, "wrapON"); + }; + + // this function is called to have a list that does wrap during move + that.logicalNoWrapFrom = function (element, direction, includeLocked) { + return that.logicalFromFusion (element, direction, includeLocked, "wrapOFF"); + }; + + // function to avoid the duplication of code. Instead this function is called by + // logicalFrom and logicalWrapFrom with false or true to turn wrapping during move off/on + that.logicalFromFusion = function (element, direction, includeLocked, wrapSwitch) { + var orderables = that.getOwningSpan(element, fluid.position.INTERLEAVED, includeLocked); + // wrappingOn string not necessary, but consistent and better understandable + return {element: getRelativeElement(element, direction, orderables, wrapSwitch), position: fluid.position.REPLACE}; }; Index: src/webapp/components/reorderer/js/Reorderer.js =================================================================== --- src/webapp/components/reorderer/js/Reorderer.js (revision 8950) +++ src/webapp/components/reorderer/js/Reorderer.js (working copy) @@ -576,6 +576,7 @@ fluid.reorderer.SHUFFLE_GEOMETRIC_STRATEGY = "shuffleProjectFrom"; fluid.reorderer.GEOMETRIC_STRATEGY = "projectFrom"; fluid.reorderer.LOGICAL_STRATEGY = "logicalFrom"; + fluid.reorderer.NOWRAP_LOGICAL_STRATEGY = "logicalNoWrapFrom"; fluid.reorderer.WRAP_LOCKED_STRATEGY = "lockedWrapFrom"; fluid.reorderer.NO_STRATEGY = null; @@ -650,16 +651,24 @@ {orientation: fluid.orientation.VERTICAL, containerRole: fluid.reorderer.roles.LIST, selectablesTabindex: -1, - sentinelize: true + sentinelize: true, + wrapDuringMove: true }); // Public layout handlers. fluid.listLayoutHandler = function (container, options, dropManager, dom) { var that = {}; - that.getRelativePosition = - fluid.reorderer.relativeInfoGetter(options.orientation, - fluid.reorderer.LOGICAL_STRATEGY, null, dropManager, dom); + if (options.wrapDuringMove) { + that.getRelativePosition = + fluid.reorderer.relativeInfoGetter(options.orientation, + fluid.reorderer.LOGICAL_STRATEGY, null, dropManager, dom); + } + else { + that.getRelativePosition = + fluid.reorderer.relativeInfoGetter(options.orientation, + fluid.reorderer.NOWRAP_LOGICAL_STRATEGY, null, dropManager, dom); + } that.getGeometricInfo = geometricInfoGetter(options.orientation, options.sentinelize, dom);