Ticket #266: composite.diff

File composite.diff, 2.5 KB (added by idbr, 2 years ago)

Diff of composite.js

  • composite.js

     
    8989 
    9090        var type = this.getType(); 
    9191        var memberTypes = type.getMemberTypes(); 
     92         
     93        if (!type.containerElement && !type.itemElement && !type.itemLabelElement) { 
     94          // if no custom layout elements are specified, use default dl-dd-dt 
     95          type.containerElement = "dl"; 
     96          type.itemElement = "dd"; 
     97          type.itemLabelElement = "dt"; 
     98        } else { 
     99          if (!type.containerElement) { 
     100            type.containerElement = "div"; 
     101          } 
     102          if (!type.itemElement) { 
     103            type.itemElement = "div"; 
     104          } 
     105          if (!type.itemLabelElement) { 
     106            type.itemLabelElement = "div"; 
     107          } 
     108        } 
    92109 
    93110        for ( var memberName in memberTypes) { 
    94111            var memberType = memberTypes[memberName]; 
     
    98115    } 
    99116     
    100117    CompositeControl.prototype.createChildElements = function (id, container, layout) { 
     118        var type = this.getType(); 
    101119        if (!container) { 
    102120             throw "[CompositeControl#createChildElements] No container to work with.";            
    103         } else if (!container.is("dl")) { 
    104             container = $("<dl/>").appendTo(container); 
     121        } else if (!container.is(type.containerElement)) { 
     122            container = $("<" + type.containerElement + "/>").appendTo(container); 
    105123            this.setElement(kf.ControlElements.REV_CONTAINER, container); 
    106124        } 
    107125         
     126        if(type.containerClass) { 
     127          container.addClass(type.containerClass); 
     128        } 
     129 
    108130        // since there is no layout we will use our own default layout 
    109         var item = $("<dt kauri-role='label'/><dd kauri-role='item'/>").appendTo(container); 
     131        var item = $("<" + type.itemLabelElement + " kauri-role='label'/><" + type.itemElement + " kauri-role='item'/>").appendTo(container); 
     132         
     133        if (type.itemClass) { 
     134          $(item.filter(type.itemElement+"[kauri-role='item']")).addClass(type.itemClass); 
     135        } 
     136        if (type.itemLabelClass) { 
     137          $(item.filter(type.itemLabelElement+"[kauri-role='label']")).addClass(type.itemLabelClass); 
     138        } 
     139         
     140        if (type.itemWrapElement) { 
     141          var $itemWrap = $("<" + type.itemWrapElement + "/>"); 
     142          if (type.itemWrapClass) { 
     143            $itemWrap.addClass(type.itemWrapClass); 
     144          } 
     145          item.wrapAll($itemWrap); 
     146        } 
    110147        return item; 
    111148    } 
    112149