$.extend($.expr[":"],{containsIN:function(e,t,s,n){return(e.textContent||e.innerText||"").toLowerCase().indexOf((s[3]||"").toLowerCase())>=0}});var treefilter=function(e,t){var s={offsetLeft:20,searcher:null,expanded:!1,expanded:!1,multiselect:!1},n=this,l=[];n.settings={};var i=function(){n.settings=$.extend({},s,t),n.el=e,e.addClass("tf-tree"),e.find("li").addClass("tf-child-true"),e.find("li").css("padding-left",n.settings.offsetLeft),e.find("li div:only-child").parent().removeClass("tf-child-true"),e.find("li div:only-child").parent().addClass("tf-child-false"),e.find("input[type=checkbox]").click(function(e){e.stopPropagation()}),e.find("li.tf-child-true").children("div").click(function(e){(e.metaKey||e.ctrlKey)&&($(this).parent().hasClass("tf-open")?$(this).parent().find("li.tf-child-true").removeClass("tf-open"):$(this).parent().find("li.tf-child-true").addClass("tf-open")),$(this).parent().toggleClass("tf-open")}),e.find("li.tf-child-false").click(function(){1!=n.settings.multiSelect&&e.find("li.tf-selected").removeClass("tf-selected"),$(this).toggleClass("tf-selected")}),n.settings.searcher&&f()};n.openAll=function(){n.el.find("li.tf-child-true").parent().addClass("tf-open")},n.closeAll=function(){n.el.find("li.tf-child-true").parent().removeClass("tf-open")};var f=function(){$(n.settings.searcher).keyup(function(){0==$(this).val().length?(n.el.find(".tf-search-result").removeClass("tf-search-result"),a("out",l)):(n.closeAll(),n.el.find("li.tf-open").removeClass("tf-open"),n.el.find("li.tf-search-result").removeClass("tf-search-result"),n.el.find("li:containsIN('"+$(this).val()+"')").addClass("tf-search-result"),n.el.find("li.tf-search-result").parent().addClass("tf-search-result"))}),$(n.settings.searcher).keydown(function(){0==$(this).val().length&&a("in",l)})},a=function(e){"in"==e?(l=[],n.el.find("li").each(function(){l.push($(this).hasClass("tf-open"))})):"out"==e&&n.el.find("li").each(function(e){l[e]?$(this).addClass("tf-open"):$(this).removeClass("tf-open")})};i()};