"use strict";!function(e){"object"==typeof module&&"object"==typeof module.exports?e(require("jquery"),window,document):e(jQuery,window,document)}(function(v,p,f,e){var t=function(e,t){this.$chartContainer=v(e),this.opts=t,this.defaultOptions={nodeTitle:"name",nodeId:"id",toggleSiblingsResp:!1,visibleLevel:999,chartClass:"",exportButton:!1,exportFilename:"OrgChart",exportFileextension:"png",parentNodeSymbol:"fa-users",draggable:!1,direction:"t2b",pan:!1,zoom:!1,zoominLimit:7,zoomoutLimit:.5}};t.prototype={init:function(e){var n=this;this.options=v.extend({},this.defaultOptions,this.opts,e);var t=this.$chartContainer;this.$chart&&this.$chart.remove();var i=this.options.data,s=this.$chart=v("
",{data:{options:this.options},class:"orgchart"+(""!==this.options.chartClass?" "+this.options.chartClass:"")+("t2b"!==this.options.direction?" "+this.options.direction:""),click:function(e){v(e.target).closest(".node").length||s.find(".node.focused").removeClass("focused")}});return"undefined"!=typeof MutationObserver&&this.triggerInitEvent(),"object"===v.type(i)?i instanceof v?this.buildHierarchy(s,this.buildJsonDS(i.children()),0,this.options):this.buildHierarchy(s,this.options.ajaxURL?i:this.attachRel(i,"00")):(s.append(''),v.ajax({url:i,dataType:"json"}).done(function(e,t,i){n.buildHierarchy(s,n.options.ajaxURL?e:n.attachRel(e,"00"),0,n.options)}).fail(function(e,t,i){console.log(i)}).always(function(){s.children(".spinner").remove()})),t.append(s),this.options.exportButton&&!t.find(".oc-export-btn").length&&this.attachExportButton(),this.options.pan&&this.bindPan(),this.options.zoom&&this.bindZoom(),this},triggerInitEvent:function(){var s=this,a=new MutationObserver(function(e){a.disconnect();e:for(var t=0;t",{class:"oc-export-btn"+(""!==this.options.chartClass?" "+this.options.chartClass:""),text:"Export",click:function(e){e.preventDefault(),t.export()}});this.$chartContainer.append(e)},setOptions:function(e,t){return"string"==typeof e&&("pan"===e&&(t?this.bindPan():this.unbindPan()),"zoom"===e&&(t?this.bindZoom():this.unbindZoom())),"object"==typeof e&&(e.data?this.init(e):(void 0!==e.pan&&(e.pan?this.bindPan():this.unbindPan()),void 0!==e.zoom&&(e.zoom?this.bindZoom():this.unbindZoom()))),this},panStartHandler:function(e){var a=v(e.delegateTarget);if(v(e.target).closest(".node").length||e.touches&&1i.zoomoutLimit&&ai.zoomoutLimit&&a').children().not(".spinner").css("opacity",.2),t.data("inAjax",!0),v(".oc-export-btn"+(""!==this.options.chartClass?"."+this.options.chartClass:"")).prop("disabled",!0),!0)},endLoading:function(e){var t=e.parent();e.removeClass("hidden"),t.find(".spinner").remove(),t.children().removeAttr("style"),this.$chart.data("inAjax",!1),v(".oc-export-btn"+(""!==this.options.chartClass?"."+this.options.chartClass:"")).prop("disabled",!1)},isInAction:function(e){return-1';t.closest("tr").next().addBack().children().attr("colspan",a),i.find(".horizontalEdge").length||i.append(o),t.closest("tr").siblings().eq(1).children(":last").before('').end().next().append(i.closest("table").parent());var d=i.closest("table").parent().siblings().find(".node:first");1===d.length&&d.append(o)}else t.append('').parent().attr("colspan",2).parent().after('
').siblings(":last").append(i.find(".horizontalEdge").remove().end().closest("table").parent());var r=parseInt(n.attr("colspan"));if(2").addClass("node "+(i.className||"")+(t>e.visibleLevel?" slide-up":""));e.nodeTemplate?n.append(e.nodeTemplate(i)):n.append('
'+i[e.nodeTitle]+"
").append(void 0!==e.nodeContent?'
'+(i[e.nodeContent]||"")+"
":"");var s=v.extend({},i);delete s.children,n.data("nodeData",s);var a=i.relationship||"";if(e.verticalLevel&&t>=e.verticalLevel){if(t+1>e.verticalLevel&&Number(a.substr(2,1))){var o=t+1>e.visibleLevel?"plus":"minus";n.append('')}}else Number(a.substr(0,1))&&n.append(''),Number(a.substr(1,1))&&n.append(''),Number(a.substr(2,1))&&n.append('').children(".title").prepend('');return n.on("mouseenter mouseleave",this.nodeEnterLeaveHandler.bind(this)),n.on("click",this.nodeClickHandler.bind(this)),n.on("click",".topEdge",this.topEdgeClickHandler.bind(this)),n.on("click",".bottomEdge",this.bottomEdgeClickHandler.bind(this)),n.on("click",".leftEdge, .rightEdge",this.hEdgeClickHandler.bind(this)),n.on("click",".toggleBtn",this.toggleVNodes.bind(this)),e.draggable&&(this.bindDragDrop(n),this.touchHandled=!1,this.touchMoved=!1,this.touchTargetNode=null),e.createNode&&e.createNode(n,i),n},buildHierarchy:function(e,t){var i=this,n=this.options,s=0;s=t.level?t.level:t.level=e.parentsUntil(".orgchart",".nodes").length+1;var a,o=t.children,d=!!o&&o.length;if(2=n.verticalLevel?e.append(r):(a=v(""),e.append(a.append(v("").append(v("").append(r)))))}if(d){var l,h=s+1>n.visibleLevel||t.collapsed?" hidden":"",c=!!(n.verticalLevel&&s+1>=n.verticalLevel);if(c)l=v("
    "),h&&s+1>n.verticalLevel&&l.addClass(h),s+1===n.verticalLevel?e.children("table").append('
').find(".verticalNodes").children().append(l):e.append(l);else{for(var g=v(''),p='',f=1;f';p+='',l=v(''),2===Object.keys(t).length?e.append(g).append(p).append(l):a.append(g).append(p).append(l)}v.each(o,function(){var e=v(c?"
  • ":'
  • ');l.append(e),this.level=s+1,i.buildHierarchy(e,this)})}},buildChildNode:function(e,t){e.find("td:first").attr("colspan",2*t.length),this.buildHierarchy(e,{children:t})},addChildren:function(e,t){this.buildChildNode(e.closest("table"),t),e.children(".bottomEdge").length||e.append(''),e.find(".symbol").length||e.children(".title").prepend(''),this.isInAction(e)&&this.switchVerticalArrow(e.children(".bottomEdge"))},buildParentNode:function(e,t){t.relationship=t.relationship||"001";var i=v("").append(v("").append(v('').append('');this.$chart.prepend(i).children("table:first").append('').children("tr:last").children().append(this.$chart.children("table").last())},addParent:function(e,t){this.buildParentNode(e,t),e.children(".topEdge").length||e.children(".title").after(''),this.isInAction(e)&&this.switchVerticalArrow(e.children(".topEdge"))},complementLine:function(e,t,i){for(var n="",s=0;s';e.parent().prevAll("tr:gt(0)").children().attr("colspan",2*t).end().next().children(":first").after(n)},buildSiblingNode:function(e,t){var i=v.isArray(t)?t.length:t.children.length,n=e.parent().is("td")?e.closest("tr").children().length:1,s=n+i,a=1').append(e)),s,1)},addSiblings:function(e,t){this.buildSiblingNode(e.closest("table"),t),e.closest(".nodes").data("siblingsLoaded",!0),e.children(".leftEdge").length||e.children(".topEdge").after(''),this.isInAction(e)&&(this.switchHorizontalArrow(e),e.children(".topEdge").removeClass("fa-chevron-up").addClass("fa-chevron-down"))},removeNodes:function(e){var t=e.closest("table").parent(),i=t.parent().siblings();t.is("td")?this.getNodeState(e,"siblings").exist?(i.eq(2).children(".topLine:lt(2)").remove(),i.slice(0,2).children().attr("colspan",i.eq(2).children().length),t.remove()):i.eq(0).children().removeAttr("colspan").find(".bottomEdge").remove().end().end().siblings().remove():t.add(t.siblings()).remove()},export:function(r,l){var h=this;if(r=void 0!==r?r:this.options.exportFilename,l=void 0!==l?l:this.options.exportFileextension,v(this).children(".spinner").length)return!1;var c=this.$chartContainer,e=c.find(".mask");e.length?e.removeClass("hidden"):c.append('
    ');var t=c.addClass("canvasContainer").find('.orgchart:not(".hidden")').get(0),i="l2r"===h.options.direction||"r2l"===h.options.direction;html2canvas(t,{width:i?t.clientHeight:t.clientWidth,height:i?t.clientWidth:t.clientHeight,onclone:function(e){v(e).find(".canvasContainer").css("overflow","visible").find('.orgchart:not(".hidden"):first').css("transform","")},onrendered:function(e){if(c.find(".mask").addClass("hidden"),"pdf"===l.toLowerCase()){var t={},i=Math.floor(.2646*e.width),n=Math.floor(.2646*e.height);(t=n'),c.find(d).attr("href",e.toDataURL())[0].click()}}}}).then(function(){c.removeClass("canvasContainer")},function(){c.removeClass("canvasContainer")})}},v.fn.orgchart=function(e){return new t(this,e).init()}}); //# sourceMappingURL=jquery.orgchart.min.js.map
    ').append(this.createNode(t)))).append('