UNPKG

magix-components

Version:
1 lines 5.13 kB
define("mx-linkage/index",["magix","$","../mx-monitor/index"],function(e,t,i){var d=e("magix"),r=e("$"),s=e("../mx-monitor/index");d.applyStyle("t",".dI{height:32px;padding:0 9px;position:relative;border:1px solid #e6e6e6;border-radius:4px;width:340px;line-height:32px}.dI:hover{border-color:#ccc}.dJ{cursor:not-allowed;background-color:#fbfbfb}.dJ:hover{border-color:#e6e6e6}.dK{color:#999;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.dL{position:absolute;border:1px solid #e6e6e6;font-size:14px;max-height:260px;overflow:auto;list-style:none;border-radius:4px;background-color:#fff;z-index:10;padding:3px 0;line-height:1.8;left:-1px;right:-1px}.dM{border-bottom:1px solid #e6e6e6;margin:0 10px;padding-bottom:3px}.dN{cursor:pointer;display:inline-block;padding:0 12px;height:29px;line-height:29px;border-radius:4px}.dN:active,.dN:focus,.dN:hover{color:#333;background-color:#f0f0f0}.dO{margin:0 10px;padding-top:3px}.dP{width:32%;float:left;margin:0 0 2px 2px;color:#666;display:block;cursor:pointer;padding:0 12px;height:29px;line-height:29px;border-radius:4px}.dP:active,.dP:focus,.dP:hover{color:#333;background-color:#f0f0f0}.dQ{margin-left:-1px}.dR{float:left;height:24px;line-height:24px;padding:0 1px;max-width:31%;overflow:hidden;margin-top:3px}.dS{cursor:pointer;border-radius:4px}.dS:active,.dS:focus,.dS:hover{color:#333;background-color:#f0f0f0}.dJ .dQ{cursor:not-allowed}.dJ .dS:active,.dJ .dS:focus,.dJ .dS:hover{background-color:transparent;cursor:not-allowed}.dT,.dT:active,.dT:focus,.dT:hover{color:#fff;background-color:#6363e6}");var a=function(e,t,i){t=t||"id",i=i||"pId";for(var r={},s={},a=[],l=0,c=e.length;l<c;l++){var o=d.mix({},e[l]);r[o[t]]=o,s[o[t]]&&(o.children=s[o[t]]),d.has(o,i)&&""!==o[i]?r[o[i]]?(r[o[i]].children||(r[o[i]].children=[])).push(o):s[o[i]]?s[o[i]].push(o):s[o[i]]=[o]:a.push(o)}return{list:a,map:r}};i.exports=d.View.extend({tmpl:{html:'<div mx-guid="g0" class="ah <%if($$.texts.length){%>dQ ag<%}else{%>dK<%}%>" mx-click="__e()">1</div><div class="ah af dL" id="db_<%=$$.viewId%>"><div mx-guid="g2" class="dM">3</div><div mx-guid="g3" class="dO">4</div></div>',subs:[{keys:["texts","placeholder"],path:'div[mx-guid="g0"]',tmpl:'<%if($$.texts.length){for(var a=0;a<$$.texts.length;a++){%><div class="dR aj dS" title="<%=$$.texts[a]%>" mx-click="__ct({i:<%!a%>})"><%=$$.texts[a]%></div><%if(a<$$.texts.length-1){%><div mx-guid="g1" class="dR">2</div><%}}}else{%> <%=$$.placeholder%> <%}%>',s:"1",attr:'class="ah <%if($$.texts.length){%>dQ ag<%}else{%>dK<%}%>"',attrs:[{n:"class",p:1,f:"className"}],mask:"31"},{keys:["splitter"],path:'div[mx-guid="g1"]',pKeys:["texts","placeholder"],tmpl:"<%=$$.splitter%>",s:"2"},{keys:["headers","active"],path:'div[mx-guid="g2"]',tmpl:'<%for(var b=0;b<$$.headers.length;b++){var c=$$.headers[b]%><span title="<%=c%>" class="dN<%if(b==$$.active){%> dT<%}%>" <%if(b!==$$.active){%> mx-click="__ct({i:<%!b%>})" <%}%>><%=c%></span><%}%>',s:"3"},{keys:["list","selected","active","valueKey","textKey"],path:'div[mx-guid="g3"]',tmpl:"<%if($$.list&&$$.list.length){var d=$$.selected[$$.active]%><ul><%for(var e=0,f=$$.list;e<f.length;e++){var g=f[e];%><li class=\"dP aj<%if((g[$$.valueKey]+'')==(d+'')){%> dT<%}%>\" title=\"<%=g[$$.textKey]%>\" mx-click=\"__bz({o:'<%@g%>'})\"><%=g[$$.textKey]%></li><%}%></ul><%}%>",s:"4"}]},init:function(e){var t=this;t.assign(e),s.__d(),t.on("destroy",function(){s.__f(t),s.__g()})},assign:function(e){var t=this;t.__cj=e.placeholder;var i=e.valueKey||"id",r=e.parentKey||"pId",s=e.parentKey||"text",l=a(e.list,i,r);t.__ck=l,t.__cl=e.headers,t.__cm=0;var c=d.has(e,"selected")?e.selected:"";return c=c?(c+"").split(","):[],t.__bm=c,t.__br=e.disabled+""=="true",t.$u.set({splitter:e.splitter||"/",textKey:s,valueKey:i,selected:c}),!0},render:function(){var e=this;e.$u.digest({placeholder:e.__cj,headers:e.__cl,viewId:e.id,texts:e.__cn(),active:e.__cm,list:e.__co()});var t=r("#"+e.id);t.addClass("dI"),t[e.__br?"addClass":"removeClass"]("dJ"),e.__h=t,e.__cp=r("#db_"+e.id)},__cn:function(){for(var e=this,t=[],i=e.__ck,d=e.__bm,r=e.$u.get("textKey"),s=0,a=d;s<a.length;s++){var l=a[s];t.push(i.map[l][r])}return t},__co:function(){var e=this,t=e.__ck,i=e.__bm,d=e.__cm;if(0===d)return t.list;var r=i[d-1];return r?t.map[r].children:null},__cq:function(e){var t=this;t.$u.digest({active:t.__cm=e,list:t.__co(),selected:t.__bm})},__i:function(e){return d.inside(e,this.id)},__a:function(){var e=this;e.__j&&(e.__j=!1,s.__f(e),e.__cp.hide(),e.__cq(0))},__e:function(){var e=this;if(!e.__j){e.__j=!0,s.__k(e);var t=e.__h.position();e.__cp.show().css({left:t.left+e.__cr,top:e.__h.outerHeight()+10})}},__cs:function(){var e=this;e.$u.digest({placeholder:e.__cj,texts:e.__cn()})},"__e<click>":function(){var e=this;e.__h.hasClass("dJ")||e.__e()},"__ct<click>":function(e){this.__cq(e.params.i)},"__bz<click>":function(e){var t=this,i=t.__cm,d=t.__cl,r=t.__bm,s=t.$u.get("valueKey"),a=e.params.o[s];(r=r.slice(0,i)).push(a),i++;var l=t.__ck;t.__bm=r,i<d.length&&l.map[a].children?t.__cq(i):(t.__cs(),t.__a(),t.__h.trigger({type:"change",selected:r}))}})});