All Downloads are FREE. Search and download functionalities are using the official Maven repository.

external.bootstrap.treeview.1.2.0.bootstrap-treeview.min.js Maven / Gradle / Ivy

The newest version!
(function(c,l,p,g){var m,k,n;m={injectStyle:!0,levels:2,expandIcon:"glyphicon glyphicon-plus",collapseIcon:"glyphicon glyphicon-minus",emptyIcon:"glyphicon",nodeIcon:"",selectedIcon:"",checkedIcon:"glyphicon glyphicon-check",uncheckedIcon:"glyphicon glyphicon-unchecked",color:g,backColor:g,borderColor:g,onhoverColor:"#F5F5F5",selectedColor:"#FFFFFF",selectedBackColor:"#428bca",searchResultColor:"#D9534F",searchResultBackColor:g,enableLinks:!1,highlightSelected:!0,highlightSearchResults:!0,showBorder:!0,
showIcon:!0,showCheckbox:!1,showTags:!1,multiSelect:!1,onNodeChecked:g,onNodeCollapsed:g,onNodeDisabled:g,onNodeEnabled:g,onNodeExpanded:g,onNodeSelected:g,onNodeUnchecked:g,onNodeUnselected:g,onSearchComplete:g,onSearchCleared:g};k={silent:!1,ignoreChildren:!1};n={ignoreCase:!0,exactMatch:!1,revealResults:!0};var e=function(a,b){this.$element=c(a);this.elementId=a.id;this.styleId=this.elementId+"-style";this.init(b);return{options:this.options,init:c.proxy(this.init,this),remove:c.proxy(this.remove,
this),getNode:c.proxy(this.getNode,this),getParent:c.proxy(this.getParent,this),getSiblings:c.proxy(this.getSiblings,this),getSelected:c.proxy(this.getSelected,this),getUnselected:c.proxy(this.getUnselected,this),getExpanded:c.proxy(this.getExpanded,this),getCollapsed:c.proxy(this.getCollapsed,this),getChecked:c.proxy(this.getChecked,this),getUnchecked:c.proxy(this.getUnchecked,this),getDisabled:c.proxy(this.getDisabled,this),getEnabled:c.proxy(this.getEnabled,this),selectNode:c.proxy(this.selectNode,
this),unselectNode:c.proxy(this.unselectNode,this),toggleNodeSelected:c.proxy(this.toggleNodeSelected,this),collapseAll:c.proxy(this.collapseAll,this),collapseNode:c.proxy(this.collapseNode,this),expandAll:c.proxy(this.expandAll,this),expandNode:c.proxy(this.expandNode,this),toggleNodeExpanded:c.proxy(this.toggleNodeExpanded,this),revealNode:c.proxy(this.revealNode,this),checkAll:c.proxy(this.checkAll,this),checkNode:c.proxy(this.checkNode,this),uncheckAll:c.proxy(this.uncheckAll,this),uncheckNode:c.proxy(this.uncheckNode,
this),toggleNodeChecked:c.proxy(this.toggleNodeChecked,this),disableAll:c.proxy(this.disableAll,this),disableNode:c.proxy(this.disableNode,this),enableAll:c.proxy(this.enableAll,this),enableNode:c.proxy(this.enableNode,this),toggleNodeDisabled:c.proxy(this.toggleNodeDisabled,this),search:c.proxy(this.search,this),clearSearch:c.proxy(this.clearSearch,this)}};e.prototype.init=function(a){this.tree=[];this.nodes=[];a.data&&("string"===typeof a.data&&(a.data=c.parseJSON(a.data)),this.tree=c.extend(!0,
[],a.data),delete a.data);this.options=c.extend({},m,a);this.destroy();this.subscribeEvents();this.setInitialStates({nodes:this.tree},0);this.render()};e.prototype.remove=function(){this.destroy();c.removeData(this,"treeview");c("#"+this.styleId).remove()};e.prototype.destroy=function(){this.initialized&&(this.$wrapper.remove(),this.$wrapper=null,this.unsubscribeEvents(),this.initialized=!1)};e.prototype.unsubscribeEvents=function(){this.$element.off("click");this.$element.off("nodeChecked");this.$element.off("nodeCollapsed");
this.$element.off("nodeDisabled");this.$element.off("nodeEnabled");this.$element.off("nodeExpanded");this.$element.off("nodeSelected");this.$element.off("nodeUnchecked");this.$element.off("nodeUnselected");this.$element.off("searchComplete");this.$element.off("searchCleared")};e.prototype.subscribeEvents=function(){this.unsubscribeEvents();this.$element.on("click",c.proxy(this.clickHandler,this));if("function"===typeof this.options.onNodeChecked)this.$element.on("nodeChecked",this.options.onNodeChecked);
if("function"===typeof this.options.onNodeCollapsed)this.$element.on("nodeCollapsed",this.options.onNodeCollapsed);if("function"===typeof this.options.onNodeDisabled)this.$element.on("nodeDisabled",this.options.onNodeDisabled);if("function"===typeof this.options.onNodeEnabled)this.$element.on("nodeEnabled",this.options.onNodeEnabled);if("function"===typeof this.options.onNodeExpanded)this.$element.on("nodeExpanded",this.options.onNodeExpanded);if("function"===typeof this.options.onNodeSelected)this.$element.on("nodeSelected",
this.options.onNodeSelected);if("function"===typeof this.options.onNodeUnchecked)this.$element.on("nodeUnchecked",this.options.onNodeUnchecked);if("function"===typeof this.options.onNodeUnselected)this.$element.on("nodeUnselected",this.options.onNodeUnselected);if("function"===typeof this.options.onSearchComplete)this.$element.on("searchComplete",this.options.onSearchComplete);if("function"===typeof this.options.onSearchCleared)this.$element.on("searchCleared",this.options.onSearchCleared)};e.prototype.setInitialStates=
function(a,b){if(a.nodes){b+=1;var d=this;c.each(a.nodes,function(c,f){f.nodeId=d.nodes.length;f.parentId=a.nodeId;f.hasOwnProperty("selectable")||(f.selectable=!0);f.state=f.state||{};f.state.hasOwnProperty("checked")||(f.state.checked=!1);f.state.hasOwnProperty("disabled")||(f.state.disabled=!1);f.state.hasOwnProperty("expanded")||(f.state.expanded=!f.state.disabled&&b '+this.buildStyle()+" ").appendTo("head")};e.prototype.buildStyle=function(){var a=".node-"+this.elementId+"{";this.options.color&&(a+="color:"+this.options.color+";");this.options.backColor&&(a+=
"background-color:"+this.options.backColor+";");this.options.showBorder?this.options.borderColor&&(a+="border:1px solid "+this.options.borderColor+";"):a+="border:none;";a+="}";this.options.onhoverColor&&(a+=".node-"+this.elementId+":not(.node-disabled):hover{background-color:"+this.options.onhoverColor+";}");return this.css+a};e.prototype.template={list:'
    ',item:'
  • ',indent:'',icon:'', link:'',badge:''};e.prototype.css=".treeview .list-group-item{cursor:pointer}.treeview span.indent{margin-left:10px;margin-right:10px}.treeview span.icon{width:12px;margin-right:5px}.treeview .node-disabled{color:silver;cursor:not-allowed}";e.prototype.getNode=function(a){return this.nodes[a]};e.prototype.getParent=function(a){a=this.identifyNode(a);return this.nodes[a.parentId]};e.prototype.getSiblings=function(a){var b=this.identifyNode(a); a=this.getParent(b);return(a?a.nodes:this.tree).filter(function(a){return a.nodeId!==b.nodeId})};e.prototype.getSelected=function(){return this.findNodes("true","g","state.selected")};e.prototype.getUnselected=function(){return this.findNodes("false","g","state.selected")};e.prototype.getExpanded=function(){return this.findNodes("true","g","state.expanded")};e.prototype.getCollapsed=function(){return this.findNodes("false","g","state.expanded")};e.prototype.getChecked=function(){return this.findNodes("true", "g","state.checked")};e.prototype.getUnchecked=function(){return this.findNodes("false","g","state.checked")};e.prototype.getDisabled=function(){return this.findNodes("true","g","state.disabled")};e.prototype.getEnabled=function(){return this.findNodes("false","g","state.disabled")};e.prototype.selectNode=function(a,b){this.forEachIdentifier(a,b,c.proxy(function(a,b){this.setSelectedState(a,!0,b)},this));this.render()};e.prototype.unselectNode=function(a,b){this.forEachIdentifier(a,b,c.proxy(function(a, b){this.setSelectedState(a,!1,b)},this));this.render()};e.prototype.toggleNodeSelected=function(a,b){this.forEachIdentifier(a,b,c.proxy(function(a,b){this.toggleSelectedState(a,b)},this));this.render()};e.prototype.collapseAll=function(a){var b=this.findNodes("true","g","state.expanded");this.forEachIdentifier(b,a,c.proxy(function(a,b){this.setExpandedState(a,!1,b)},this));this.render()};e.prototype.collapseNode=function(a,b){this.forEachIdentifier(a,b,c.proxy(function(a,b){this.setExpandedState(a, !1,b)},this));this.render()};e.prototype.expandAll=function(a){if((a=c.extend({},k,a))&&a.levels)this.expandLevels(this.tree,a.levels,a);else{var b=this.findNodes("false","g","state.expanded");this.forEachIdentifier(b,a,c.proxy(function(a,b){this.setExpandedState(a,!0,b)},this))}this.render()};e.prototype.expandNode=function(a,b){this.forEachIdentifier(a,b,c.proxy(function(a,b){this.setExpandedState(a,!0,b);a.nodes&&b&&b.levels&&this.expandLevels(a.nodes,b.levels-1,b)},this));this.render()};e.prototype.expandLevels= function(a,b,d){d=c.extend({},k,d);c.each(a,c.proxy(function(a,c){this.setExpandedState(c,0




    © 2015 - 2024 Weber Informatics LLC | Privacy Policy