MgnlDynamicTable move functions
-------------------------------

                 Key: MAGNOLIA-3986
                 URL: http://jira.magnolia-cms.com/browse/MAGNOLIA-3986
             Project: Magnolia
          Issue Type: New Feature
      Security Level: Public
          Components: admininterface
    Affects Versions: 4.4.4
            Reporter: Stefan Baur
            Assignee: Philipp Bärfuss


I have created move functions for the MgnlDynamicTable javascript lib. 
The following functions can be added to 
/mgnl-resources/js-classes/mgnl/controls/DynamicTable.js

The functions have been tested on 
 - Safari 5.1.2 (Win7x64)
 - FF 10 (Win7x64)
 - Chrome 17.0.963.56 (Win7x64)
 - IE 9 (Win7x64)
 - IE 6 & 7 (WinXP, separate in a VM, not with multipleIE)


{code:javascript|title=DynamicTable.js}

/* ###################################
### Move an Object from one index to another. includes savety checks
################################### */

MgnlDynamicTable.prototype.move = function (from, to){
    if(from == to || from == null || from == 'undefined' || to == null || to == 
'undefined') {
        //do nothing 
    } else if (from < to) { //move down
        var index = from;
        var objectToMove = this.objects[from];
        var to = Math.min(to, this.objects.length-1); //safety...
        while(index < to) {
            var nextIndex = index+1;
            var nextObject = this.objects[nextIndex];
            this.set(index, nextObject);
            index = nextIndex;
        }
        this.set(to, objectToMove);
    } else { //move up
        var index = from;
        var objectToMove = this.objects[from]; 
        var to = Math.max(to, 0); //safety...
        while(index > to) {
            var nextIndex = index-1;
            var nextObject = this.objects[nextIndex];
            this.set(index, nextObject);
            index = nextIndex;
        }
        this.set(to, objectToMove);
    }
}


/* ###################################
### Move an Object up
################################### */

MgnlDynamicTable.prototype.moveUp = function (index){
    this.move(index, index-1); 
}


/* ###################################
### Move an Object down
################################### */

MgnlDynamicTable.prototype.moveDown = function (index){
    this.move(index, index+1); 
}

{code}

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.magnolia-cms.com/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       


----------------------------------------------------------------
For list details, see: http://www.magnolia-cms.com/community/mailing-lists.html
Alternatively, use our forums: http://forum.magnolia-cms.com/
To unsubscribe, E-mail to: <[email protected]>
----------------------------------------------------------------

Reply via email to