/*! jquery.treeselect.js 2014-07-18 */ !function(a){jQuery.fn.moreorless=function(b,c,d){b=b||100,c=c||"more",d=d||"less",this.each(function(){this.element=a(this),this.div_height=0,this.forceHeight=!1,this.link||(this.link=a(document.createElement("div")).css({cursor:"pointer"}),this.link.addClass("moreorless_link")),this.content||(this.content=this.element.wrap("
").parent(),this.content.addClass("moreorless_content expanded")),this.wrapper||(this.wrapper=this.content.wrap("").parent(),this.wrapper.addClass("moreorless_wrapper").css("position","relative")),this.expand=function(a){return this.link.remove(),a?(this.link.html(d),a!=this.div_expanded&&this.content.addClass("expanded").animate({height:this.div_height},function(a){return function(){a.css("overflow","").height("inherit")}}(this.content)),this.forceHeight&&this.content.after(this.link)):(this.link.html(c),a!=this.div_expanded&&this.content.removeClass("expanded").animate({height:b},function(a){return function(){a.css("overflow","hidden")}}(this.content)),this.content.after(this.link)),this.link.unbind().bind("click",function(a){return function(b){b.preventDefault(),b.stopPropagation();var c=!a.content.hasClass("expanded");a.forceHeight=c,a.expand(c)}}(this)),this.div_expanded=a,this.content},this.checkHeight=function(){this.forceHeight=!1,this.div_height=this.element.height(),this.expand(this.div_heightg;g++)a.call(e,c[g])&&h.push(c[g]);return h}}()),a.fn.treeselect=function(b){b=a.extend({colwidth:18,default_value:{},selected:null,treeloaded:null,load:null,searcher:null,deepLoad:!1,onbuild:null,postbuild:null,inputName:"treeselect",autoSelectChildren:!0,showRoot:!1,selectAll:!1,selectAllText:"Select All"},b);var c={},d="treebusy-loading",e="treebusy-loading-all",f="treebusy-selecting",g=function(b,c){this.root=!!c,b.title=b.title||"anonymous",a.extend(this,{id:0,nodeloaded:!1,allLoaded:!1,value:0,title:"",url:"",has_children:!0,children:[],data:{},level:0,odd:!1,checked:!1,busy:!1,display:a(),input:a(),link:a(),span:a(),childlist:a(),exclude:{}},b),this.isTreeNode=!0,this.loading=!1,this.loadqueue=[]};return g.prototype.setBusy=function(a,b){if(a!=this.span.hasClass(b))if(this.busy=a,a)this.span.addClass(b),this.span.addClass("treebusy");else{this.span.removeClass(b);var c=b==d?f:d;this.span.hasClass(c)||this.span.removeClass("treebusy")}},g.prototype.isLoaded=function(){var a=this.nodeloaded;return a|=c.hasOwnProperty(this.id),a|=!this.has_children,a|=this.has_children&&this.children.length>0},g.prototype.loadNode=function(a,e){if(this.loading)return void(a&&this.loadqueue.push(a));var f=function(){a&&a(this);for(var b in this.loadqueue)this.loadqueue[b](this);this.loadqueue.length=0,e||this.setBusy(!1,d)};this.loading=!0,b.load&&!this.isLoaded()?(e||this.setBusy(!0,d),b.load(this,function(a){return function(b){a.nodeloaded?f.call(a):(a=jQuery.extend(a,b),a.nodeloaded=!0,c[a.id]=a.id,a.build(function(){f.call(a)}))}}(this))):a&&f.call(this),this.loading=!1},g.prototype.loadAll=function(a,b,c,d){d=d||{},this.loadNode(function(f){b&&b(f);var g=f.children.length,h=g;if(!g||d.hasOwnProperty(f.id))return void(a&&a.call(f,f));d[f.id]=f.id,c||f.setBusy(!0,e);for(var i=function(g){return function(){f.children[g].loadAll(function(){h--,h||(a&&a.call(f,f),c||f.setBusy(!1,e))},b,c,d)}};g--;)setTimeout(i(g),2)})},g.prototype.expand=function(a){a?(this.link.removeClass("collapsed").addClass("expanded"),this.span.removeClass("collapsed").addClass("expanded"),this.childlist.show("fast"),!b.deepLoad&&this.checked&&this.include_children&&(this.include_children=!1,this.selectChildren(!0))):this.span.length>0&&(this.link.removeClass("expanded").addClass("collapsed"),this.span.removeClass("expanded").addClass("collapsed"),this.childlist.hide("fast")),a&&!this.isLoaded()&&this.loadNode(function(a){a.checked&&a.selectChildren(a.checked),a.expand(!0)})},g.prototype.selectChildren=function(c,d,e){var g="object"==typeof c,h=function(){e||(b.selected&&b.selected(this,!0),d&&d.call(this))};if(b.deepLoad)this.loadAll(function(){this.setBusy(!1,f),h.call(this)},function(a){var b=c;g&&(b=c.hasOwnProperty(a.value),b|=c.hasOwnProperty(a.id)),a.select(b)});else{this.select(c);var i=b.inputName+"-"+this.value;if(a('input[name="'+i+'-include-below"]').attr("name",i),this.root===!0||c===!1&&!this.include_children||void 0!==this.link&&void 0!==this.link[0]&&-1!==this.link[0].className.indexOf("expanded")){this.include_children=!1,this.expand(c);for(var j=this.children.length;j--;)this.children[j].selectChildren(c,d,!0)}else this.has_children>0&&c&&(this.include_children=!0,a('input[name="'+i+'"]').attr("name",i+"-include-below"));h.call(this)}},g.prototype.selectDefaults=function(c,d){var e=Object.keys(c).length,f=[];for(f.push(this);e>0&&f.length>0;){var g=f.shift(),h=!1;c.hasOwnProperty(g.value)&&(delete c[g.value],h=!0,e--),c.hasOwnProperty(g.id)&&(delete c[g.id],h=!0,e--),c.hasOwnProperty(g.value+"-include-below")&&(delete c[g.value+"-include-below"],g.include_children=!0,h=!0,e--),c.hasOwnProperty(g.id+"-include-below")&&(delete c[g.id+"-include-below"],g.include_children=!0,h=!0,e--),g.select(h);var i=b.inputName+"-"+g.value;if(a('input[name="'+i+'-include-below"]').attr("name",i),!g.root&&h&&g.include_children)a('input[name="'+i+'"]').attr("name",i+"-include-below");else if(e>0)for(var j=g.children.length;j--;)f.push(g.children[j]);else g.root&&g.include_children&&g.selectChildren(!0)}b.selected&&b.selected(this,!0),d&&d.call(this)},g.prototype.setChecked=function(a){this.checked=a,this.input.eq(0)[0].checked=a,this.input.change()},g.prototype.select=function(a){this.input.hasClass("treenode-no-select")||(a=!!a,(a||!this.root||this.showRoot&&this.has_children)&&(this.setChecked(a),b.selected&&b.selected(this)))},g.prototype.build_treenode=function(){var b=a();return b=a(document.createElement(this.root?"div":"li")),b.addClass("treenode"),b.addClass(this.odd?"odd":"even"),b},g.prototype.build_input=function(c){if(b.inputName){if("undefined"!=typeof this.exclude[this.id]||"group_finder"==b.inputName&&!this.data.roles_enabled)this.input=a(document.createElement("div")),this.input.addClass("treenode-no-select");else{this.input=a(document.createElement("input"));var d=this.value||this.id;this.input.attr({type:"checkbox",value:d,name:b.inputName+"-"+d,id:"choice_"+this.id}).addClass("treenode-input"),this.setChecked(this.checked),this.input.bind("click",function(a){return function(c){a.checked=c.target.checked,b.autoSelectChildren&&((!a.checked||b.deepLoad)&&a.expand(a.checked),a.selectChildren(a.checked))}}(this)),this.root&&!b.showRoot&&this.input.hide()}this.input.css("left",c+"px")}return this.input},g.prototype.build_link=function(b){return b.css("cursor","pointer").addClass("collapsed"),b.bind("click",{node:this},function(b){b.preventDefault(),b.data.node.expand(a(b.target).hasClass("collapsed"))}),b},g.prototype.build_span=function(b){return this.root&&!this.showRoot||!this.has_children||(this.span=this.build_link(a(document.createElement("span")).attr({"class":"treeselect-expand"})),this.span.css("left",b+"px")),this.span},g.prototype.build_title=function(b){return this.root&&!this.showRoot||!this.title||(this.nodeLink=a(document.createElement("a")).attr({"class":"treeselect-title",href:this.url,target:"_blank"}).css("marginLeft",b+"px").text(this.title),this.link=this.has_children?this.build_link(this.nodeLink.clone()):a(document.createElement("div")).attr({"class":"treeselect-title"}).css("marginLeft",b+"px").text(this.title)),this.link},g.prototype.build_children=function(b){if(this.childlist=a(),this.children.length>0){this.childlist=a(document.createElement("ul"));var c=this.odd,d=this.children.length,e=function(a,c){return function(){a.children[c].build(function(c){d--,a.childlist.append(c.display),d||b.call(a,a.childlist)})}};for(var f in this.children)if(this.children.hasOwnProperty(f)){var h=this.children[f];c=!c;var i=this.checked;h.hasOwnProperty("checked")&&(i=h.checked),this.children[f]=new g(a.extend(h,{level:this.level+1,odd:c,checked:i,exclude:this.exclude})),setTimeout(e(this,f),2)}}else b.call(this,this.childlist)},g.prototype.build=function(c){var d=5,e=null;if(0===this.display.length)this.display=this.build_treenode();else if(this.root){var f=this.build_treenode();this.display.append(f),this.display=f}0===this.input.length&&(e=this.build_input(d))&&e.length>0&&(this.display.append(e),d+=b.colwidth),0===this.span.length&&(this.display.append(this.build_span(d)),d+=b.colwidth),0===this.link.length&&this.display.append(this.build_title(d));var g=function(){b.onbuild&&b.onbuild(this),this.searchItem=this.display.clone(),a(".treeselect-expand",this.searchItem).remove();var d=a("div.treeselect-title",this.searchItem);d.length>0&&d.replaceWith(this.nodeLink),b.postbuild&&b.postbuild(this),"undefined"!=typeof this.exclude[this.id]&&0===a(".treenode-input",this.display).length&&this.display.hide(),c&&c.call(this,this)};0===this.childlist.length?this.build_children(function(a){a.length>0&&this.display.append(a),g.call(this)}):g.call(this)},g.prototype.getSelectAll=function(){return this.root&&this.selectAll?this.selectAllText:!1},g.prototype.search=function(a,d){if(a){var e={};a=a.toLowerCase(),b.searcher?b.searcher(this,a,function(a,b){var f=Object.keys(a).length;0===f&&d(e,!0);var h=function(a){return function(b){f--,e[a]=b,f||d(e,!0)}};for(var i in a){var j=new g(b?b(a[i]):a[i]);j.nodeloaded=!0,c[j.id]=j.id,j.build(h(i))}}):this.loadAll(function(){d&&d(e,!0)},function(b){b.root||-1===b.title.toLowerCase().search(a)||(e[b.id]=b)},!0)}else d&&d(this.children,!1)},a(this).each(function(){var c=a.extend(b,{display:a(this)}),d=this.treenode=new g(c,!0),e=d.getSelectAll();if(e!==!1&&!d.showRoot){var f=!1,h=b.default_value;h.hasOwnProperty(d.value+"-include-below")&&(f=!0);var i=a(document.createElement("input")).attr({type:"checkbox"});if(i.eq(0)[0].checked=f,i.bind("click",function(a){d.selectChildren(a.target.checked)}),d.display.append(i),e){var j=a(document.createElement("span")).attr({"class":"treeselect-select-all"}).html(e);d.display.append(j)}}var k=a(document.createElement("span")).addClass("treebusy");d.display.append(k.css("display","block"));var l=function(){k.remove(),b.treeloaded&&b.treeloaded(this)};d.loadNode(function(a){0===a.children.length&&a.display.hide(),a.expand(!0),a.select(a.checked);var c=a.checked;jQuery.isEmptyObject(b.default_value)||(c=b.default_value),c?b.deepLoad?a.selectChildren(c,function(){l.call(a)}):a.selectDefaults(c,function(){l.call(a)}):l.call(a)}),d.has_children||(this.parentElement.style.display="none")})}}(jQuery),function(a){a.fn.chosentree=function(b){return b=a.extend({inputId:"chosentree-select",label:"",description:"",input_placeholder:"Select Item",input_type:"text",autosearch:!1,search_text:"Search",no_results_text:"No results found",min_height:100,more_text:"+%num% more",loaded:null,collapsed:!0,showtree:!1},b),a(this).each(function(){var c=null,d=null,e=null,f=null,g=null,h=null,i=null,j=null,k=null,l=null,m=function(a,b){b=b||"fast",!a||l&&!l.has_children?k.removeClass("treevisible").hide("fast"):k.addClass("treevisible").show("fast")};if(c=a(document.createElement("div")),c.addClass("chzntree-container"),"search"==b.input_type?(c.addClass("chzntree-container-single"),e=a(document.createElement("div")),e.addClass("chzntree-search")):(c.addClass("chzntree-container-multi"),d=a(document.createElement("ul")),d.addClass("chzntree-choices chosentree-choices"),e=a(document.createElement("li")),e.addClass("search-field")),h=a(document.createElement("label")),h.attr({"for":b.inputId}),h.text(b.label),i=a(document.createElement("div")),i.attr({"class":"description"}),i.text(b.description),b.input_placeholder){if(f=a(document.createElement("input")),f.attr({type:"text",placeholder:b.input_placeholder,autocomplete:"off"}),!b.showtree&&b.collapsed&&f.focus(function(){m(!0)}),"search"==b.input_type){f.addClass("chosentree-search");var n=function(a){return!f.hasClass("searching")&&1!==a.length&&l?(f.addClass("searching"),l.search(a,function(a,c){f.removeClass("searching");var d=0;l.childlist.children().detach(),c?l.childlist.addClass("chzntree-search-results"):l.childlist.removeClass("chzntree-search-results"),""!==b.inputName?l.childlist.addClass("input-enabled"):l.childlist.removeClass("input-enabled");for(var e in a)d++,l.childlist.append(c?a[e].searchItem:a[e].display);if(!d){var g="