Uploaded image for project: 'Magnolia'
  1. Magnolia
  2. MAGNOLIA-3986

MgnlDynamicTable move functions

    XMLWordPrintable

Details

    • New Feature
    • Resolution: Won't Fix
    • Neutral
    • None
    • 4.4.4
    • admininterface
    • None
    • Yes

    Description

      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)
      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); 
      }
      
      

      Checklists

        Acceptance criteria

        Attachments

          Activity

            People

              pbaerfuss Philipp Bärfuss
              sbaur Stefan Baur
              Andrew Bernard, Daniel Kummer
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - 1m
                  1m
                  Remaining:
                  Remaining Estimate - 1m
                  1m
                  Logged:
                  Time Spent - Not Specified
                  Not Specified