/*
* author: Lin Xiao Dong <1071322670@qq.com>
* update: 2021.04.21
* website: http://www.openwbs.com/
*/
var OWTree,OWTree_Class=function(a){var c=function(a){var d,b=c.defaults;a=a||{},("string"==typeof a||1===a.nodeType)&&(a={content:a});for(d in b)void 0===a[d]&&(a[d]=b[d]);return new c.fn.constructor(a)};c.fn=c.prototype={constructor:function(a){var b;return this.config=a,this.dom=b=this.dom||this.init(a),this},init:function(b){var d,e,f,g,h,i,k,l,m,o,p,q,r,s,t,u,v,c={};if(c.root=b.root,d=b.root,e=b.treeId,f=b.data,f.length>0)for(v=0;v<f.length;v++)o=f[v].id||0,r=f[v].pId||0,s=f[v].name||"",t=f[v].depth||1,u="level-"+t,q=e+"_"+o,i=a(document.createElement("span")).addClass("node "+u+" switch"),l=a(document.createElement("input")).attr("type","checkbox").val(o),k=a(document.createElement("span")).addClass("node-checkbox").append(l),$nodeIcon=a(document.createElement("span")).addClass("node-icon"),$nodeName=a(document.createElement("span")).addClass("node-name").append(s),m=a(document.createElement("a")).addClass("a-node-name "+u).attr("href","javascript:;"),1==b.icon&&m.append($nodeIcon),m.append($nodeName),h=a(document.createElement("li")).attr("id",q).append(i),1==b.checkbox&&h.append(k),h.append(m),t>1?(p=e+"_"+r+"_ul",g=a("ul#"+p),(""==g.attr("id")||void 0==g.attr("id"))&&(g=a(document.createElement("ul")).addClass(u).addClass("line").attr("id",p),q=e+"_"+r,a("li#"+q).append(g)),g.append(h)):d.append(h);return c},parseRootTop:function(){var b=this,c=this.dom.root,d=c.find("li");d.each(function(c){var g,d=a(this).attr("order",c+1),e=a(this).find("ul"),f=a(this).find("span.node");b.config.icon&&(g=a(this).find("span.node-icon")),e.length>0?(f.unbind("click").click(function(){b.nodeSwitch(a(this))}),void 0==a(this).next("li").attr("id")?(e.removeClass("line"),f.attr({type:"folder",node:"bottom"}).addClass("bottom-open")):1==d.attr("order")?f.attr({type:"folder",node:"root"}).addClass("root-open"):f.attr({type:"folder",node:"center"}).addClass("center-open")):(b.config.icon&&g.addClass("file"),void 0==a(this).next("li").attr("id")?f.attr({type:"file",node:"bottom"}).addClass("bottom-docu"):1==d.attr("order")?f.attr({type:"file",node:"root"}).addClass("root-docu"):f.attr({type:"file",node:"center"}).addClass("center-docu"))})},nodeSwitch:function(a){var b=a,c=a.parent().find("ul:first"),d=b.attr("node");"none"==c.css("display")?(b.removeClass(d+"-close").addClass(d+"-open"),c.show(200)):(b.removeClass(d+"-open").addClass(d+"-close"),c.hide(200))},parseCheckbox:function(){var b=this.dom.root,c=b.find("input:checkbox");c.click(function(){var b=a(this).parent().parent().find("ul");1==a(this).attr("checked")?b.find("input:checkbox").attr("checked",!0):b.find("input:checkbox").attr("checked",!1)})}},c.fn.constructor.prototype=c.fn,c.defaults={treeId:"",checkbox:!0,icon:!0,beforeAsync:null,beforeClick:null,onExpand:null},OWTree=c};OWTree_Class(this.jQuery,this);