js.ontology.tree.plugin.min.js Maven / Gradle / Ivy
(function(e,b){var c=new b.RestClient();function d(g,f){var h=[];e.each(g,function(){var i=this.fieldType==="COMPOUND";h.push({key:this.href,title:this.label,tooltip:this.description,folder:i,lazy:i,expanded:!i,selected:f===undefined?a(this):f(this),data:{attribute:this}})});return h}function a(f){return f.selected}e.fn.tree=function(k){var g=this;if(typeof k=="string"){var j=Array.prototype.slice.call(arguments,1);if(j.length===0){return g.data("tree")[k]()}else{if(j.length===1){return g.data("tree")[k](j[0])}else{if(j.length===2){return g.data("tree")[k](j[0],j[1])}}}}if(e(".molgenis-tree",g).fancytree){e(".molgenis-tree",g).fancytree("destroy")}var i=[];i.push('');g.html(i.join(""));var f=e(".molgenis-tree",g);var l=e.extend({},e.fn.tree.defaults,k);g.data("settings",l);g.data("tree",{getSelectedAttributes:function(m){var n=f.fancytree("getTree").getSelectedNodes(true);return e.map(n,function(o){return o.data.attribute})},appendChildNodes:function(m,o){m.expanded=true;var p=e(".molgenis-tree").fancytree("getTree");var n=[];e.each(d(o),function(q,r){if(!p.getNodeByKey(r.key)){n.push(r)}});m.addChildren(n)},getTree:function(){return e(".molgenis-tree").fancytree("getTree")}});var h={selectMode:3,minExpandLevel:1,debugLevel:0,checkbox:true,keyPathSeparator:"|",init:function(){if(l.onInit){l.onInit()}},lazyload:function(n,m){if(l.lazyload!==undefined&&typeof l.lazyload==="function"){l.lazyload(m,d)}else{b.createAlert([{message:"lazyload function is undefined!"}],"error")}},source:d(l.entityMetaData.attributes,function(m){return l.selectedAttributes?e.inArray(m,l.selectedAttributes)!==-1:false}),click:function(n,m){if(m.targetType==="title"||m.targetType==="icon"){if(l.onAttributeClick){l.onAttributeClick(m.node.data.attribute)}}},select:function(n,m){if(l.onAttributesSelect){l.onAttributesSelect({attribute:m.node.data.attribute,select:m.node.selected})}}};f.fancytree(h);e(".tree-select-all-btn",g).click(function(o){o.preventDefault();var n=l.onAttributesSelect;l.onAttributesSelect=null;var m=[];f.fancytree("getRootNode").visit(function(p){if(!p.isSelected()){p.setSelected(true);m.push({attribute:p.data.attribute,select:true})}});l.onAttributesSelect=n;if(m.length>0){l.onAttributesSelect(m)}});e(".tree-deselect-all-btn",g).click(function(o){o.preventDefault();var n=l.onAttributesSelect;l.onAttributesSelect=null;var m=[];f.fancytree("getRootNode").visit(function(p){if(p.isSelected()){p.setSelected(false);m.push({attribute:p.data.attribute,select:false})}});l.onAttributesSelect=n;if(m.length>0){l.onAttributesSelect(m)}});return this};e.fn.tree.defaults={entityMetaData:null,selectedAttributes:null,icon:null,onAttributeClick:null,onAttributesSelect:null}}($,window.top.molgenis=window.top.molgenis||{}));
© 2015 - 2025 Weber Informatics LLC | Privacy Policy