magix-components
Version:
1 lines • 1.89 kB
JavaScript
define("mx-tree/index",["magix","./branch"],function(e,t,i){e("./branch");var r=e("magix"),p=function(e,t,i){t=t||"id",i=i||"pId";for(var p={},n={},a=[],l=0,x=e.length;l<x;l++){var d=r.mix({},e[l]);p[d[t]]=d,n[d[t]]&&(d.children=n[d[t]]),r.has(d,i)&&""!==d[i]?p[d[i]]?(p[d[i]].children||(p[d[i]].children=[])).push(d):n[d[i]]?n[d[i]].push(d):n[d[i]]=[d]:a.push(d)}return{list:a,map:p}};r.applyStyle("J",'.fv{padding-left:15px}.fw{line-height:22px;padding:0 4px;position:relative;border-left:1px solid #e6e6e6}.fw:before{content:"";position:absolute;border-top:1px solid #e6e6e6;width:12px;left:0;top:10px}.fx{width:14px;height:14px;float:left;text-align:center;font-weight:800;margin-left:-11px;margin-top:-2px;position:relative;z-index:2}.fy{display:inline-block;background-color:#fff;width:10px;height:10px;line-height:6px;border:1px solid #e6e6e6;font-size:11px}.fz{margin-left:10px}.fA{padding:0}.fB{border-left-color:transparent}.fB:after{border-left:1px solid #e6e6e6;top:-2px}.fB:after,.fC:after{content:"";position:absolute;left:-1px;width:1px;height:13px}.fC:after{border-left:1px solid #fff;top:-3px}'),i.exports=r.View.extend({tmpl:{html:'<div mx-guid="g0" id="tree_<%=$$.id%>" mx-view="mx-tree/branch?valueKey=<%!$eu($$.valueKey)%>&textKey=<%!$eu($$.textKey)%>&parentKey=<%!$eu($$.parentKey)%>&fromTop=<%@true%>&list=<%@$$.list%>"></div>',subs:[{keys:["id","valueKey","textKey","parentKey","list"],path:'div[mx-guid="g0"]',attr:'id="tree_<%=$$.id%>" mx-view="mx-tree/branch?valueKey=<%!$eu($$.valueKey)%>&textKey=<%!$eu($$.textKey)%>&parentKey=<%!$eu($$.parentKey)%>&fromTop=<%@true%>&list=<%@$$.list%>"',attrs:[{n:"id",p:1},{n:"mx-view",v:1}]}]},init:function(e){this.$extra=e},render:function(){var e=this,t=e.$extra,i=p(t.list,t.valueKey,t.parentKey);e.updater.digest({id:e.id,valueKey:t.valueKey||"id",parentKey:t.parentKey||"pId",textKey:t.textKey||"text",list:i.list})}})});