diff --git a/.gitignore b/.gitignore index 1fc882c56..693ce2b05 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ node_modules/ bower_components .idea +public/libs/ diff --git a/CHANGELOG.md b/CHANGELOG.md index a90b082c4..b56d93c19 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). +## v3.0.0 - 13th Feb, 2023 +- Update to bootstrap5 + ## v1.2.0 - 9th May, 2015 ### New Features diff --git a/README.md b/README.md index bfc49a320..4a1d58f18 100644 --- a/README.md +++ b/README.md @@ -14,8 +14,8 @@ A simple and elegant solution to displaying hierarchical tree structures (i.e. a Where provided these are the actual versions patternfly-bootstrap-treeview has been tested against. -- [Bootstrap v4.1.3 (>= 4.0.0)](http://getbootstrap.com/) -- [jQuery v3.2.0 (>= 1.9.0)](http://jquery.com/) +- [Bootstrap v5.2.2 (>= 4.0.0)](http://getbootstrap.com/) +- [jQuery v3.5.0 (>= 1.9.0)](http://jquery.com/) ## Getting Started diff --git a/bower.json b/bower.json index 97571616b..cb2a4bdbc 100644 --- a/bower.json +++ b/bower.json @@ -22,8 +22,8 @@ "tests" ], "dependencies": { - "jquery": ">= 1.9.0", - "bootstrap": ">= 3.4.0" + "jquery": ">= 3.5.0", + "bootstrap": ">= 5.2.2" }, "devDependencies": {} } diff --git a/dist/bootstrap-treeview.js b/dist/bootstrap-treeview.js index d48c467f1..32571c56e 100644 --- a/dist/bootstrap-treeview.js +++ b/dist/bootstrap-treeview.js @@ -1,5 +1,5 @@ /* ========================================================= - * patternfly-bootstrap-treeview.js v2.2.0 + * patternfly-bootstrap-treeview.js v3.0.0 * ========================================================= * Copyright 2013 Jonathan Miles * Project URL : http://www.jondmiles.com/bootstrap-treeview @@ -33,16 +33,16 @@ levels: 2, - expandIcon: 'fa fa-plus', - collapseIcon: 'fa fa-minus', - loadingIcon: 'fa fa-hourglass', - emptyIcon: 'fa', + expandIcon: 'fas fa-plus', + collapseIcon: 'fas fa-minus', + loadingIcon: 'fas fa-hourglass', + emptyIcon: 'fas', nodeIcon: '', selectedIcon: '', checkedIcon: 'far fa-check-square', - partiallyCheckedIcon: 'fa fa-expand', + partiallyCheckedIcon: 'fas fa-expand', uncheckedIcon: 'far fa-square', - tagsClass:'badge badge-primary badge-pill', + tagsClass:'badge bg-primary rounded-pill', color: undefined, backColor: undefined, @@ -122,61 +122,61 @@ options: this._options, // Initialize / destroy methods - init: $.proxy(this._init, this), - remove: $.proxy(this._remove, this), + init: this._init.bind(this), + remove: this._remove.bind(this), // Query methods - findNodes: $.proxy(this.findNodes, this), - getNodes: $.proxy(this.getNodes, this), // todo document + test - getParents: $.proxy(this.getParents, this), - getSiblings: $.proxy(this.getSiblings, this), - getSelected: $.proxy(this.getSelected, this), - getUnselected: $.proxy(this.getUnselected, this), - getExpanded: $.proxy(this.getExpanded, this), - getCollapsed: $.proxy(this.getCollapsed, this), - getChecked: $.proxy(this.getChecked, this), - getUnchecked: $.proxy(this.getUnchecked, this), - getDisabled: $.proxy(this.getDisabled, this), - getEnabled: $.proxy(this.getEnabled, this), + findNodes: this.findNodes.bind(this), + getNodes: this.getNodes.bind(this), // todo document + test + getParents: this.getParents.bind(this), + getSiblings: this.getSiblings.bind(this), + getSelected: this.getSelected.bind(this), + getUnselected: this.getUnselected.bind(this), + getExpanded: this.getExpanded.bind(this), + getCollapsed: this.getCollapsed.bind(this), + getChecked: this.getChecked.bind(this), + getUnchecked: this.getUnchecked.bind(this), + getDisabled: this.getDisabled.bind(this), + getEnabled: this.getEnabled.bind(this), // Tree manipulation methods - addNode: $.proxy(this.addNode, this), - addNodeAfter: $.proxy(this.addNodeAfter, this), - addNodeBefore: $.proxy(this.addNodeBefore, this), - removeNode: $.proxy(this.removeNode, this), - updateNode: $.proxy(this.updateNode, this), + addNode: this.addNode.bind(this), + addNodeAfter: this.addNodeAfter.bind(this), + addNodeBefore: this.addNodeBefore.bind(this), + removeNode: this.removeNode.bind(this), + updateNode: this.updateNode.bind(this), // Select methods - selectNode: $.proxy(this.selectNode, this), - unselectNode: $.proxy(this.unselectNode, this), - toggleNodeSelected: $.proxy(this.toggleNodeSelected, this), + selectNode: this.selectNode.bind(this), + unselectNode: this.unselectNode.bind(this), + toggleNodeSelected: this.toggleNodeSelected.bind(this), // Expand / collapse methods - collapseAll: $.proxy(this.collapseAll, this), - collapseNode: $.proxy(this.collapseNode, this), - expandAll: $.proxy(this.expandAll, this), - expandNode: $.proxy(this.expandNode, this), - toggleNodeExpanded: $.proxy(this.toggleNodeExpanded, this), - revealNode: $.proxy(this.revealNode, this), + collapseAll: this.collapseAll.bind(this), + collapseNode: this.collapseNode.bind(this), + expandAll: this.expandAll.bind(this), + expandNode: this.expandNode.bind(this), + toggleNodeExpanded: this.toggleNodeExpanded.bind(this), + revealNode: this.revealNode.bind(this), // Check / uncheck methods - checkAll: $.proxy(this.checkAll, this), - checkNode: $.proxy(this.checkNode, this), - uncheckAll: $.proxy(this.uncheckAll, this), - uncheckNode: $.proxy(this.uncheckNode, this), - toggleNodeChecked: $.proxy(this.toggleNodeChecked, this), - unmarkCheckboxChanges: $.proxy(this.unmarkCheckboxChanges, this), + checkAll: this.checkAll.bind(this), + checkNode: this.checkNode.bind(this), + uncheckAll: this.uncheckAll.bind(this), + uncheckNode: this.uncheckNode.bind(this), + toggleNodeChecked: this.toggleNodeChecked.bind(this), + unmarkCheckboxChanges: this.unmarkCheckboxChanges.bind(this), // Disable / enable methods - disableAll: $.proxy(this.disableAll, this), - disableNode: $.proxy(this.disableNode, this), - enableAll: $.proxy(this.enableAll, this), - enableNode: $.proxy(this.enableNode, this), - toggleNodeDisabled: $.proxy(this.toggleNodeDisabled, this), + disableAll: this.disableAll.bind(this), + disableNode: this.disableNode.bind(this), + enableAll: this.enableAll.bind(this), + enableNode: this.enableNode.bind(this), + toggleNodeDisabled: this.toggleNodeDisabled.bind(this), // Search methods - search: $.proxy(this.search, this), - clearSearch: $.proxy(this.clearSearch, this) + search: this.search.bind(this), + clearSearch: this.clearSearch.bind(this) }; }; @@ -194,21 +194,21 @@ this._triggerEvent('loading', null, _default.options); this._load(options) - .then($.proxy(function (data) { + .then(function (data) { // load done return this._tree = $.extend(true, [], data); - }, this), $.proxy(function (error) { + }.bind(this), function (error) { // load fail this._triggerEvent('loadingFailed', error, _default.options); - }, this)) - .then($.proxy(function (treeData) { + }.bind(this)) + .then(function (treeData) { // initialize data return this._setInitialStates({ nodes: treeData }, 0); - }, this)) - .then($.proxy(function () { + }.bind(this)) + .then(function () { // render to DOM this._render(); - }, this)); + }.bind(this)); }; Tree.prototype._load = function (options) { @@ -305,7 +305,7 @@ this.$element.on('destroyed', this._options.onDestroyed); } - this.$element.on('click', $.proxy(this._clickHandler, this)); + this.$element.on('click', this._clickHandler.bind(this)); if (typeof (this._options.onNodeChecked) === 'function') { this.$element.on('nodeChecked', this._options.onNodeChecked); @@ -367,12 +367,12 @@ Tree.prototype._setInitialStates = function (node, level) { this._nodes = {}; return $.when.apply(this, this._setInitialState(node, level)) - .done($.proxy(function () { + .done(function () { this._orderedNodes = this._sortNodes(); this._inheritCheckboxChanges(); this._triggerEvent('initialized', this._orderedNodes, _default.options); return; - }, this)); + }.bind(this)); }; Tree.prototype._setInitialState = function (node, level, done) { @@ -381,7 +381,7 @@ done = done || []; var parent = node; - $.each(node.nodes, $.proxy(function (index, node) { + $.each(node.nodes, function (index, node) { var deferred = new $.Deferred(); done.push(deferred.promise()); @@ -468,7 +468,7 @@ // mark task as complete deferred.resolve(); - }, this)); + }.bind(this)); return done; }; @@ -487,9 +487,9 @@ if (a[i] - b[i] < 0) return -1; }; - }), $.proxy(function (value, index) { + }), function (value, index) { return this._nodes[value]; - }, this)); + }.bind(this)); }; Tree.prototype._clickHandler = function (event) { @@ -574,9 +574,9 @@ // Expand children if (node.nodes && options) { - $.each(node.nodes, $.proxy(function (index, node) { + $.each(node.nodes, function (index, node) { this._setVisible(node, true, options); - }, this)); + }.bind(this)); } // Optionally trigger event @@ -596,10 +596,10 @@ // Collapse children if (node.nodes && options) { - $.each(node.nodes, $.proxy(function (index, node) { + $.each(node.nodes, function (index, node) { this._setVisible(node, false, options); this._setExpanded(node, false, options); - }, this)); + }.bind(this)); } // Optionally trigger event @@ -655,9 +655,9 @@ // If multiSelect false, unselect previously selected if (!this._options.multiSelect) { - $.each(this._findNodes('true', 'state.selected'), $.proxy(function (index, node) { + $.each(this._findNodes('true', 'state.selected'), function (index, node) { this._setSelected(node, false, $.extend(options, {unselecting: true}), true); - }, this)); + }.bind(this)); } // Set node state @@ -910,10 +910,10 @@ } var previousNode; - $.each(this._orderedNodes, $.proxy(function (id, node) { + $.each(this._orderedNodes, function (id, node) { this._renderNode(node, previousNode); previousNode = node; - }, this)); + }.bind(this)); this._triggerEvent('rendered', this._orderedNodes, _default.options); }; @@ -935,7 +935,7 @@ if (this._options.showTags && node.tags) { $flexbox = this._template.flex.clone(); node.$el.append($flexbox); - node.$el.addClass('d-flex justify-content-between align-items-center'); + node.$el.addClass('d-flex justify-content-between align-items-start'); } // Set the #id of the node if specified @@ -991,9 +991,14 @@ // Add tags as badges if (this._options.showTags && node.tags) { - $.each(node.tags, $.proxy(function addTag(id, tag) { - node.$el - .append(this._template.badge.clone() + var $tagsbox = node.$el; + if (node.tags.length > 1) { + $tagsbox = this._template.flex.clone(); + node.$el.append($tagsbox); + } + + $.each(node.tags, function addTag(id, tag) { + var badgeNode = this._template.badge.clone() .addClass( (typeof tag === 'object' ? tag.class : undefined) || node.tagsClass @@ -1002,9 +1007,12 @@ .append( (typeof tag === 'object' ? tag.text : undefined) || tag - ) - ); - }, this)); + ); + if (node.tags.length > 1 && id > 0) { + badgeNode.addClass('ms-1'); + } + $tagsbox.append(badgeNode); + }.bind(this)); } // Set various node states @@ -1076,9 +1084,9 @@ if (!node) return; if (node.nodes) { - $.each(node.nodes, $.proxy(function (index, node) { + $.each(node.nodes, function (index, node) { this._removeNodeEl(node); - }, this)); + }.bind(this)); } node.$el.remove(); }; @@ -1087,10 +1095,10 @@ Tree.prototype._expandNode = function (node) { if (!node.nodes) return; - $.each(node.nodes.slice(0).reverse(), $.proxy(function (index, childNode) { + $.each(node.nodes.slice(0).reverse(), function (index, childNode) { childNode.level = node.level + 1; this._renderNode(childNode, node.$el); - }, this)); + }.bind(this)); }; // Add inline style into head @@ -1164,7 +1172,7 @@ } // Node level style overrides - $.each(this._orderedNodes, $.proxy(function (index, node) { + $.each(this._orderedNodes, function (index, node) { if (node.color || node.backColor) { var innerStyle = ''; if (node.color) { @@ -1175,7 +1183,7 @@ } style += '.node-' + this._elementId + '[data-nodeId="' + node.nodeId + '"]{' + innerStyle + '}'; } - }, this)); + }.bind(this)); return this._css + style; }; @@ -1228,12 +1236,12 @@ } var parentNodes = []; - $.each(nodes, $.proxy(function (index, node) { + $.each(nodes, function (index, node) { var parentNode = node.parentId ? this._nodes[node.parentId] : false; if (parentNode) { parentNodes.push(parentNode); } - }, this)); + }.bind(this)); return parentNodes; }; @@ -1248,13 +1256,13 @@ } var siblingNodes = []; - $.each(nodes, $.proxy(function (index, node) { + $.each(nodes, function (index, node) { var parent = this.getParents([node]); var nodes = parent[0] ? parent[0].nodes : this._tree; siblingNodes = nodes.filter(function (obj) { return obj.nodeId !== node.nodeId; }); - }, this)); + }.bind(this)); // flatten possible nested array before returning return $.map(siblingNodes, function (obj) { @@ -1356,19 +1364,19 @@ } // inserting nodes at specified positions - $.each(nodes, $.proxy(function (i, node) { + $.each(nodes, function (i, node) { var insertIndex = (typeof(index) === 'number') ? (index + i) : (targetNodes.length + 1); targetNodes.splice(insertIndex, 0, node); - }, this)); + }.bind(this)); // initialize new state and render changes this._setInitialStates({nodes: this._tree}, 0) - .done($.proxy(function () { + .done(function () { if (parentNode && !parentNode.state.expanded) { this._setExpanded(parentNode, true, options); } this._render(); - }, this)); + }.bind(this)); } /** @@ -1424,7 +1432,7 @@ options = $.extend({}, _default.options, options); var targetNodes, parentNode; - $.each(nodes, $.proxy(function (index, node) { + $.each(nodes, function (index, node) { // remove nodes from tree parentNode = this._nodes[node.parentId]; @@ -1437,7 +1445,7 @@ // remove node from DOM this._removeNodeEl(node); - }, this)); + }.bind(this)); // initialize new state and render changes this._setInitialStates({nodes: this._tree}, 0) @@ -1488,9 +1496,9 @@ options = $.extend({}, _default.options, options); - $.each(nodes, $.proxy(function (index, node) { + $.each(nodes, function (index, node) { this._setSelected(node, true, options); - }, this)); + }.bind(this)); }; /** @@ -1505,9 +1513,9 @@ options = $.extend({}, _default.options, options); - $.each(nodes, $.proxy(function (index, node) { + $.each(nodes, function (index, node) { this._setSelected(node, false, options); - }, this)); + }.bind(this)); }; /** @@ -1522,9 +1530,9 @@ options = $.extend({}, _default.options, options); - $.each(nodes, $.proxy(function (index, node) { + $.each(nodes, function (index, node) { this._toggleSelected(node, options); - }, this)); + }.bind(this)); }; @@ -1546,9 +1554,9 @@ Tree.prototype.collapseNode = function (nodes, options) { options = $.extend({}, _default.options, options); - $.each(nodes, $.proxy(function (index, node) { + $.each(nodes, function (index, node) { this._setExpanded(node, false, options); - }, this)); + }.bind(this)); }; /** @@ -1573,7 +1581,7 @@ options = $.extend({}, _default.options, options); - $.each(nodes, $.proxy(function (index, node) { + $.each(nodes, function (index, node) { // Do not re-expand already expanded nodes if (node.state.expanded) return; @@ -1585,7 +1593,7 @@ if (node.nodes) { this._expandLevels(node.nodes, options.levels-1, options); } - }, this)); + }.bind(this)); }; Tree.prototype._expandLevels = function (nodes, level, options) { @@ -1595,12 +1603,12 @@ options = $.extend({}, _default.options, options); - $.each(nodes, $.proxy(function (index, node) { + $.each(nodes, function (index, node) { this._setExpanded(node, (level > 0) ? true : false, options); if (node.nodes) { this._expandLevels(node.nodes, level-1, options); } - }, this)); + }.bind(this)); }; /** @@ -1615,14 +1623,14 @@ options = $.extend({}, _default.options, options); - $.each(nodes, $.proxy(function (index, node) { + $.each(nodes, function (index, node) { var parentNode = node; var tmpNode; while (tmpNode = this.getParents([parentNode])[0]) { parentNode = tmpNode; this._setExpanded(parentNode, true, options); }; - }, this)); + }.bind(this)); }; /** @@ -1637,9 +1645,9 @@ options = $.extend({}, _default.options, options); - $.each(nodes, $.proxy(function (index, node) { + $.each(nodes, function (index, node) { this._toggleExpanded(node, options); - }, this)); + }.bind(this)); }; @@ -1653,9 +1661,9 @@ var nodes = $.grep(this._orderedNodes, function (node) { return !node.state.checked; }); - $.each(nodes, $.proxy(function (index, node) { + $.each(nodes, function (index, node) { this._setChecked(node, true, options); - }, this)); + }.bind(this)); }; /** @@ -1670,9 +1678,9 @@ options = $.extend({}, _default.options, options); - $.each(nodes, $.proxy(function (index, node) { + $.each(nodes, function (index, node) { this._setChecked(node, true, options); - }, this)); + }.bind(this)); }; /** @@ -1685,9 +1693,9 @@ var nodes = $.grep(this._orderedNodes, function (node) { return node.state.checked || node.state.checked === undefined; }); - $.each(nodes, $.proxy(function (index, node) { + $.each(nodes, function (index, node) { this._setChecked(node, false, options); - }, this)); + }.bind(this)); }; /** @@ -1702,9 +1710,9 @@ options = $.extend({}, _default.options, options); - $.each(nodes, $.proxy(function (index, node) { + $.each(nodes, function (index, node) { this._setChecked(node, false, options); - }, this)); + }.bind(this)); }; /** @@ -1719,9 +1727,9 @@ options = $.extend({}, _default.options, options); - $.each(nodes, $.proxy(function (index, node) { + $.each(nodes, function (index, node) { this._toggleChecked(node, options); - }, this)); + }.bind(this)); }; /** @@ -1743,9 +1751,9 @@ options = $.extend({}, _default.options, options); var nodes = this._findNodes('false', 'state.disabled'); - $.each(nodes, $.proxy(function (index, node) { + $.each(nodes, function (index, node) { this._setDisabled(node, true, options); - }, this)); + }.bind(this)); }; /** @@ -1760,9 +1768,9 @@ options = $.extend({}, _default.options, options); - $.each(nodes, $.proxy(function (index, node) { + $.each(nodes, function (index, node) { this._setDisabled(node, true, options); - }, this)); + }.bind(this)); }; /** @@ -1773,9 +1781,9 @@ options = $.extend({}, _default.options, options); var nodes = this._findNodes('true', 'state.disabled'); - $.each(nodes, $.proxy(function (index, node) { + $.each(nodes, function (index, node) { this._setDisabled(node, false, options); - }, this)); + }.bind(this)); }; /** @@ -1790,9 +1798,9 @@ options = $.extend({}, _default.options, options); - $.each(nodes, $.proxy(function (index, node) { + $.each(nodes, function (index, node) { this._setDisabled(node, false, options); - }, this)); + }.bind(this)); }; /** @@ -1807,9 +1815,9 @@ options = $.extend({}, _default.options, options); - $.each(nodes, $.proxy(function (index, node) { + $.each(nodes, function (index, node) { this._setDisabled(node, !node.state.disabled, options); - }, this)); + }.bind(this)); }; @@ -1840,14 +1848,14 @@ } // Clear previous results no longer matched - $.each(this._diffArray(results, previous), $.proxy(function (index, node) { + $.each(this._diffArray(results, previous), function (index, node) { this._setSearchResult(node, false, options); - }, this)); + }.bind(this)); // Set new results - $.each(this._diffArray(previous, results), $.proxy(function (index, node) { + $.each(this._diffArray(previous, results), function (index, node) { this._setSearchResult(node, true, options); - }, this)); + }.bind(this)); // Reveal hidden nodes if (results && options.revealResults) { @@ -1865,9 +1873,9 @@ Tree.prototype.clearSearch = function (options) { options = $.extend({}, { render: true }, options); - var results = $.each(this._getSearchResults(), $.proxy(function (index, node) { + var results = $.each(this._getSearchResults(), function (index, node) { this._setSearchResult(node, false, options); - }, this)); + }.bind(this)); this._triggerEvent('searchCleared', results, options); }; @@ -1896,12 +1904,12 @@ Tree.prototype._findNodes = function (pattern, attribute, modifier) { attribute = attribute || 'text'; modifier = modifier || 'g'; - return $.grep(this._orderedNodes, $.proxy(function (node) { + return $.grep(this._orderedNodes, function (node) { var val = this._getNodeValue(node, attribute); if (typeof val === 'string') { return val.match(new RegExp(pattern, modifier)); } - }, this)); + }.bind(this)); }; /** diff --git a/dist/bootstrap-treeview.min.js b/dist/bootstrap-treeview.min.js index 58de62d89..eca45cac0 100644 --- a/dist/bootstrap-treeview.min.js +++ b/dist/bootstrap-treeview.min.js @@ -1 +1 @@ -!function(a,b,c,d){"use strict";var e="treeview",f={};f.settings={injectStyle:!0,levels:2,expandIcon:"fa fa-plus",collapseIcon:"fa fa-minus",loadingIcon:"fa fa-hourglass",emptyIcon:"fa",nodeIcon:"",selectedIcon:"",checkedIcon:"far fa-check-square",partiallyCheckedIcon:"fa fa-expand",uncheckedIcon:"far fa-square",tagsClass:"badge badge-primary badge-pill",color:d,backColor:d,borderColor:d,changedNodeColor:"#39A5DC",onhoverColor:"#F5F5F5",selectedColor:"#FFFFFF",selectedBackColor:"#428bca",searchResultColor:"#D9534F",searchResultBackColor:d,highlightSelected:!0,highlightSearchResults:!0,showBorder:!0,showIcon:!0,showImage:!1,showCheckbox:!1,checkboxFirst:!1,highlightChanges:!1,showTags:!1,multiSelect:!1,preventUnselect:!1,allowReselect:!1,hierarchicalCheck:!1,propagateCheckEvent:!1,wrapNodeText:!1,onLoading:d,onLoadingFailed:d,onInitialized:d,onNodeRendered:d,onRendered:d,onDestroyed:d,onNodeChecked:d,onNodeCollapsed:d,onNodeDisabled:d,onNodeEnabled:d,onNodeExpanded:d,onNodeChanged:d,onNodeSelected:d,onNodeUnchecked:d,onNodeUnselected:d,onSearchComplete:d,onSearchCleared:d},f.options={silent:!1,ignoreChildren:!1},f.searchOptions={ignoreCase:!0,exactMatch:!1,revealResults:!0},f.dataUrl={method:"GET",dataType:"json",cache:!1};var g=function(b,c){return this.$element=a(b),this._elementId=b.id,this._styleId=this._elementId+"-style",this._init(c),{options:this._options,init:a.proxy(this._init,this),remove:a.proxy(this._remove,this),findNodes:a.proxy(this.findNodes,this),getNodes:a.proxy(this.getNodes,this),getParents:a.proxy(this.getParents,this),getSiblings:a.proxy(this.getSiblings,this),getSelected:a.proxy(this.getSelected,this),getUnselected:a.proxy(this.getUnselected,this),getExpanded:a.proxy(this.getExpanded,this),getCollapsed:a.proxy(this.getCollapsed,this),getChecked:a.proxy(this.getChecked,this),getUnchecked:a.proxy(this.getUnchecked,this),getDisabled:a.proxy(this.getDisabled,this),getEnabled:a.proxy(this.getEnabled,this),addNode:a.proxy(this.addNode,this),addNodeAfter:a.proxy(this.addNodeAfter,this),addNodeBefore:a.proxy(this.addNodeBefore,this),removeNode:a.proxy(this.removeNode,this),updateNode:a.proxy(this.updateNode,this),selectNode:a.proxy(this.selectNode,this),unselectNode:a.proxy(this.unselectNode,this),toggleNodeSelected:a.proxy(this.toggleNodeSelected,this),collapseAll:a.proxy(this.collapseAll,this),collapseNode:a.proxy(this.collapseNode,this),expandAll:a.proxy(this.expandAll,this),expandNode:a.proxy(this.expandNode,this),toggleNodeExpanded:a.proxy(this.toggleNodeExpanded,this),revealNode:a.proxy(this.revealNode,this),checkAll:a.proxy(this.checkAll,this),checkNode:a.proxy(this.checkNode,this),uncheckAll:a.proxy(this.uncheckAll,this),uncheckNode:a.proxy(this.uncheckNode,this),toggleNodeChecked:a.proxy(this.toggleNodeChecked,this),unmarkCheckboxChanges:a.proxy(this.unmarkCheckboxChanges,this),disableAll:a.proxy(this.disableAll,this),disableNode:a.proxy(this.disableNode,this),enableAll:a.proxy(this.enableAll,this),enableNode:a.proxy(this.enableNode,this),toggleNodeDisabled:a.proxy(this.toggleNodeDisabled,this),search:a.proxy(this.search,this),clearSearch:a.proxy(this.clearSearch,this)}};g.prototype._init=function(b){this._tree=[],this._initialized=!1,this._options=a.extend({},f.settings,b),this._template.icon.empty.addClass(this._options.emptyIcon),this._destroy(),this._subscribeEvents(),this._triggerEvent("loading",null,f.options),this._load(b).then(a.proxy(function(b){return this._tree=a.extend(!0,[],b)},this),a.proxy(function(a){this._triggerEvent("loadingFailed",a,f.options)},this)).then(a.proxy(function(a){return this._setInitialStates({nodes:a},0)},this)).then(a.proxy(function(){this._render()},this))},g.prototype._load=function(b){var c=new a.Deferred;return b.data?this._loadLocalData(b,c):b.dataUrl&&this._loadRemoteData(b,c),c.promise()},g.prototype._loadRemoteData=function(b,c){a.ajax(a.extend(!0,{},f.dataUrl,b.dataUrl)).done(function(a){c.resolve(a)}).fail(function(a,b,d){c.reject(d)})},g.prototype._loadLocalData=function(b,c){c.resolve("string"==typeof b.data?JSON.parse(b.data):a.extend(!0,[],b.data))},g.prototype._remove=function(){this._destroy(),a.removeData(this,e),a("#"+this._styleId).remove()},g.prototype._destroy=function(){this._initialized&&(this._initialized=!1,this._triggerEvent("destroyed",null,f.options),this._unsubscribeEvents(),this.$wrapper.remove(),this.$wrapper=null)},g.prototype._unsubscribeEvents=function(){this.$element.off("loading"),this.$element.off("loadingFailed"),this.$element.off("initialized"),this.$element.off("nodeRendered"),this.$element.off("rendered"),this.$element.off("destroyed"),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("nodeChanged"),this.$element.off("nodeSelected"),this.$element.off("nodeUnchecked"),this.$element.off("nodeUnselected"),this.$element.off("searchComplete"),this.$element.off("searchCleared")},g.prototype._subscribeEvents=function(){this._unsubscribeEvents(),"function"==typeof this._options.onLoading&&this.$element.on("loading",this._options.onLoading),"function"==typeof this._options.onLoadingFailed&&this.$element.on("loadingFailed",this._options.onLoadingFailed),"function"==typeof this._options.onInitialized&&this.$element.on("initialized",this._options.onInitialized),"function"==typeof this._options.onNodeRendered&&this.$element.on("nodeRendered",this._options.onNodeRendered),"function"==typeof this._options.onRendered&&this.$element.on("rendered",this._options.onRendered),"function"==typeof this._options.onDestroyed&&this.$element.on("destroyed",this._options.onDestroyed),this.$element.on("click",a.proxy(this._clickHandler,this)),"function"==typeof this._options.onNodeChecked&&this.$element.on("nodeChecked",this._options.onNodeChecked),"function"==typeof this._options.onNodeCollapsed&&this.$element.on("nodeCollapsed",this._options.onNodeCollapsed),"function"==typeof this._options.onNodeDisabled&&this.$element.on("nodeDisabled",this._options.onNodeDisabled),"function"==typeof this._options.onNodeEnabled&&this.$element.on("nodeEnabled",this._options.onNodeEnabled),"function"==typeof this._options.onNodeExpanded&&this.$element.on("nodeExpanded",this._options.onNodeExpanded),"function"==typeof this._options.onNodeChanged&&this.$element.on("nodeChanged",this._options.onNodeChanged),"function"==typeof this._options.onNodeSelected&&this.$element.on("nodeSelected",this._options.onNodeSelected),"function"==typeof this._options.onNodeUnchecked&&this.$element.on("nodeUnchecked",this._options.onNodeUnchecked),"function"==typeof this._options.onNodeUnselected&&this.$element.on("nodeUnselected",this._options.onNodeUnselected),"function"==typeof this._options.onSearchComplete&&this.$element.on("searchComplete",this._options.onSearchComplete),"function"==typeof this._options.onSearchCleared&&this.$element.on("searchCleared",this._options.onSearchCleared)},g.prototype._triggerEvent=function(b,c,d){d&&!d.silent&&this.$element.trigger(b,a.extend(!0,{},c))},g.prototype._setInitialStates=function(b,c){return this._nodes={},a.when.apply(this,this._setInitialState(b,c)).done(a.proxy(function(){this._orderedNodes=this._sortNodes(),this._inheritCheckboxChanges(),this._triggerEvent("initialized",this._orderedNodes,f.options)},this))},g.prototype._setInitialState=function(b,c,e){if(b.nodes){c+=1,e=e||[];var f=b;return a.each(b.nodes,a.proxy(function(b,g){var h=new a.Deferred;e.push(h.promise()),g.level=c,g.index=b,g.nodeId=f&&f.nodeId?f.nodeId+"."+g.index:c-1+"."+g.index,g.parentId=f.nodeId,g.hasOwnProperty("selectable")||(g.selectable=!0),g.hasOwnProperty("checkable")||(g.checkable=!0),g.state=g.state||{},g.state.hasOwnProperty("checked")||(g.state.checked=!1),this._options.hierarchicalCheck&&"undefined"===g.state.checked&&(g.state.checked=d),g.state.hasOwnProperty("disabled")||(g.state.disabled=!1),g.state.hasOwnProperty("expanded")||(!g.state.disabled&&c0?g.state.expanded=!0:g.state.expanded=!1),g.state.hasOwnProperty("selected")||(g.state.selected=!1),f&&f.state&&f.state.expanded||c<=this._options.levels?g.state.visible=!0:g.state.visible=!1,g.nodes&&(g.nodes.length>0?this._setInitialState(g,c,e):delete g.nodes),this._nodes[g.nodeId]=g,h.resolve()},this)),e}},g.prototype._sortNodes=function(){return a.map(Object.keys(this._nodes).sort(function(a,b){if(a===b)return 0;for(var a=a.split(".").map(function(a){return parseInt(a)}),b=b.split(".").map(function(a){return parseInt(a)}),c=Math.max(a.length,b.length),e=0;e0)return 1;if(a[e]-b[e]<0)return-1}}),a.proxy(function(a,b){return this._nodes[a]},this))},g.prototype._clickHandler=function(b){var c=a(b.target),d=this.targetNode(c);if(d&&!d.state.disabled){var e=c.attr("class")?c.attr("class").split(" "):[];e.indexOf("expand-icon")!==-1?this._toggleExpanded(d,a.extend({},f.options)):e.indexOf("check-icon")!==-1?d.checkable&&this._toggleChecked(d,a.extend({},f.options)):d.selectable?this._toggleSelected(d,a.extend({},f.options)):this._toggleExpanded(d,a.extend({},f.options))}},g.prototype.targetNode=function(a){var b=a.closest("li.list-group-item").attr("data-nodeId"),c=this._nodes[b];return c||console.log("Error: node does not exist"),c},g.prototype._toggleExpanded=function(a,b){a&&("function"==typeof this._options.lazyLoad&&a.lazyLoad?this._lazyLoad(a):this._setExpanded(a,!a.state.expanded,b))},g.prototype._lazyLoad=function(a){a.$el.find("span.expand-icon").removeClass(this._options.expandIcon).addClass(this._options.loadingIcon);var b=this;this._options.lazyLoad(a,function(c){b.addNode(c,a)}),delete a.lazyLoad},g.prototype._setExpanded=function(b,c,d){d&&c===b.state.expanded||(c&&b.nodes?(b.state.expanded=!0,b.$el&&b.$el.find("span.expand-icon").removeClass(this._options.expandIcon).removeClass(this._options.loadingIcon).addClass(this._options.collapseIcon),b.nodes&&d&&a.each(b.nodes,a.proxy(function(a,b){this._setVisible(b,!0,d)},this)),this._triggerEvent("nodeExpanded",b,d)):c||(b.state.expanded=!1,b.$el&&b.$el.find("span.expand-icon").removeClass(this._options.collapseIcon).addClass(this._options.expandIcon),b.nodes&&d&&a.each(b.nodes,a.proxy(function(a,b){this._setVisible(b,!1,d),this._setExpanded(b,!1,d)},this)),this._triggerEvent("nodeCollapsed",b,d)))},g.prototype._setVisible=function(a,b,c){c&&b===a.state.visible||(b?(a.state.visible=!0,a.$el&&(a.$el.removeClass("node-hidden"),a.$el.hasClass("d-none")&&a.$el.removeClass("d-none").addClass("d-flex"))):(a.state.visible=!1,a.$el&&(a.$el.addClass("node-hidden"),a.$el.hasClass("d-flex")&&a.$el.removeClass("d-flex").addClass("d-none"))))},g.prototype._toggleSelected=function(a,b){if(a)return this._setSelected(a,!a.state.selected,b),this},g.prototype._setSelected=function(b,c,d,e){if(!d||c!==b.state.selected){if(c)this._options.multiSelect||a.each(this._findNodes("true","state.selected"),a.proxy(function(b,c){this._setSelected(c,!1,a.extend(d,{unselecting:!0}),!0)},this)),b.state.selected=!0,b.$el&&(b.$el.addClass("node-selected"),(b.selectedIcon||this._options.selectedIcon)&&b.$el.find("span.node-icon").removeClass(b.icon||this._options.nodeIcon).addClass(b.selectedIcon||this._options.selectedIcon)),this._triggerEvent("nodeSelected",b,d),this._triggerEvent("nodeChanged",b,d);else{if(this._options.preventUnselect&&d&&!d.unselecting&&1===this._findNodes("true","state.selected").length)return this._options.allowReselect&&(this._triggerEvent("nodeSelected",b,d),this._triggerEvent("nodeChanged",b,d)),this;b.state.selected=!1,b.$el&&(b.$el.removeClass("node-selected"),(b.selectedIcon||this._options.selectedIcon)&&b.$el.find("span.node-icon").removeClass(b.selectedIcon||this._options.selectedIcon).addClass(b.icon||this._options.nodeIcon)),this._triggerEvent("nodeUnselected",b,d),e||this._triggerEvent("nodeChanged",b,d)}return this}},g.prototype._inheritCheckboxChanges=function(){this._options.showCheckbox&&this._options.highlightChanges&&(this._checkedNodes=a.grep(this._orderedNodes,function(a){return a.state.checked}))},g.prototype._toggleChecked=function(b,c){if(b){if(this._options.hierarchicalCheck){var e,f=a.extend({},c,{silent:c.silent||!this._options.propagateCheckEvent}),g=b;for(b.state.checked=!b.state.checked;g=this._nodes[g.parentId];)e=g.nodes.reduce(function(a,b){return a===b.state.checked?a:d},g.nodes[0].state.checked),this._setChecked(g,e,f);if(b.nodes&&b.nodes.length>0)for(var h,i=b.nodes.slice();i&&i.length>0;)h=i.pop(),this._setChecked(h,b.state.checked,f),h.nodes&&h.nodes.length>0&&(i=i.concat(h.nodes.slice()));b.state.checked=!b.state.checked}this._setChecked(b,!b.state.checked,c)}},g.prototype._setChecked=function(a,b,c){c&&b===a.state.checked||(this._options.highlightChanges&&a.$el.toggleClass("node-check-changed",this._checkedNodes.indexOf(a)==-1==b),b?(a.state.checked=!0,a.$el&&(a.$el.addClass("node-checked").removeClass("node-checked-partial"),a.$el.find("span.check-icon").removeClass(this._options.uncheckedIcon).removeClass(this._options.partiallyCheckedIcon).addClass(this._options.checkedIcon)),this._triggerEvent("nodeChecked",a,c)):b===d&&this._options.hierarchicalCheck?(a.state.checked=d,a.$el&&(a.$el.addClass("node-checked-partial").removeClass("node-checked"),a.$el.find("span.check-icon").removeClass(this._options.uncheckedIcon).removeClass(this._options.checkedIcon).addClass(this._options.partiallyCheckedIcon)),this._triggerEvent("nodeUnchecked",a,c)):(a.state.checked=!1,a.$el&&(a.$el.removeClass("node-checked node-checked-partial"),a.$el.find("span.check-icon").removeClass(this._options.checkedIcon).removeClass(this._options.partiallyCheckedIcon).addClass(this._options.uncheckedIcon)),this._triggerEvent("nodeUnchecked",a,c)))},g.prototype._setDisabled=function(a,b,c){c&&b===a.state.disabled||(b?(a.state.disabled=!0,c&&!c.keepState&&(this._setSelected(a,!1,c),this._setChecked(a,!1,c),this._setExpanded(a,!1,c)),a.$el&&a.$el.addClass("node-disabled"),this._triggerEvent("nodeDisabled",a,c)):(a.state.disabled=!1,a.$el&&a.$el.removeClass("node-disabled"),this._triggerEvent("nodeEnabled",a,c)))},g.prototype._setSearchResult=function(a,b,c){c&&b===a.searchResult||(b?(a.searchResult=!0,a.$el&&a.$el.addClass("node-result")):(a.searchResult=!1,a.$el&&a.$el.removeClass("node-result")))},g.prototype._render=function(){this._initialized||(this.$wrapper=this._template.tree.clone(),this.$element.empty().addClass(e).append(this.$wrapper),this._injectStyle(),this._initialized=!0);var b;a.each(this._orderedNodes,a.proxy(function(a,c){this._renderNode(c,b),b=c},this)),this._triggerEvent("rendered",this._orderedNodes,f.options)},g.prototype._renderNode=function(b,c){if(b){b.$el?b.$el.empty():b.$el=this._newNodeEl(b,c).addClass("node-"+this._elementId),b.$el.addClass(b["class"]);var e=b.$el;this._options.showTags&&b.tags&&(e=this._template.flex.clone(),b.$el.append(e),b.$el.addClass("d-flex justify-content-between align-items-center")),b.id&&b.$el.attr("id",b.id),b.dataAttr&&a.each(b.dataAttr,function(a,c){b.$el.attr("data-"+a,c)}),b.$el.attr("data-nodeId",b.nodeId),b.tooltip&&b.$el.attr("title",b.tooltip);for(var g=0;g '+this._buildStyle()+" ").appendTo("head")},g.prototype._buildStyle=function(){var b=".node-"+this._elementId+"{";if(this._options.color&&(b+="color:"+this._options.color+";"),this._options.backColor&&(b+="background-color:"+this._options.backColor+";"),this._options.showBorder?this._options.borderColor&&(b+="border:1px solid "+this._options.borderColor+";"):b+="border:none;",b+="}",this._options.onhoverColor&&(b+=".node-"+this._elementId+":not(.node-disabled):hover{background-color:"+this._options.onhoverColor+";}"),this._options.highlightSearchResults&&(this._options.searchResultColor||this._options.searchResultBackColor)){var c="";this._options.searchResultColor&&(c+="color:"+this._options.searchResultColor+";"),this._options.searchResultBackColor&&(c+="background-color:"+this._options.searchResultBackColor+";"),b+=".node-"+this._elementId+".node-result{"+c+"}",b+=".node-"+this._elementId+".node-result:hover{"+c+"}"}if(this._options.highlightSelected&&(this._options.selectedColor||this._options.selectedBackColor)){var c="";this._options.selectedColor&&(c+="color:"+this._options.selectedColor+";"),this._options.selectedBackColor&&(c+="background-color:"+this._options.selectedBackColor+";"),b+=".node-"+this._elementId+".node-selected{"+c+"}",b+=".node-"+this._elementId+".node-selected:hover{"+c+"}"}if(this._options.highlightChanges){var c="color: "+this._options.changedNodeColor+";";b+=".node-"+this._elementId+".node-check-changed{"+c+"}"}return a.each(this._orderedNodes,a.proxy(function(a,c){if(c.color||c.backColor){var d="";c.color&&(d+="color:"+c.color+";"),c.backColor&&(d+="background-color:"+c.backColor+";"),b+=".node-"+this._elementId+'[data-nodeId="'+c.nodeId+'"]{'+d+"}"}},this)),this._css+b},g.prototype._template={tree:a('
    '),node:a('
  • '),flex:a('
    '),indent:a(''),icon:{node:a(''),expand:a(''),check:a(''),empty:a('')},image:a(''),badge:a(""),text:a('')},g.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}",g.prototype.findNodes=function(a,b,c){return this._findNodes(a,b,c)},g.prototype.getNodes=function(){return this._orderedNodes},g.prototype.getParents=function(b){b instanceof Array||(b=[b]);var c=[];return a.each(b,a.proxy(function(a,b){var d=!!b.parentId&&this._nodes[b.parentId];d&&c.push(d)},this)),c},g.prototype.getSiblings=function(b){b instanceof Array||(b=[b]);var c=[];return a.each(b,a.proxy(function(a,b){var d=this.getParents([b]),e=d[0]?d[0].nodes:this._tree;c=e.filter(function(a){return a.nodeId!==b.nodeId})},this)),a.map(c,function(a){return a})},g.prototype.getSelected=function(){return this._findNodes("true","state.selected")},g.prototype.getUnselected=function(){return this._findNodes("false","state.selected")},g.prototype.getExpanded=function(){return this._findNodes("true","state.expanded")},g.prototype.getCollapsed=function(){return this._findNodes("false","state.expanded")},g.prototype.getChecked=function(){return this._findNodes("true","state.checked")},g.prototype.getUnchecked=function(){return this._findNodes("false","state.checked")},g.prototype.getDisabled=function(){return this._findNodes("true","state.disabled")},g.prototype.getEnabled=function(){return this._findNodes("false","state.disabled")},g.prototype.addNode=function(b,c,d,e){b instanceof Array||(b=[b]),c instanceof Array&&(c=c[0]),e=a.extend({},f.options,e);var g;g=c&&c.nodes?c.nodes:c?c.nodes=[]:this._tree,a.each(b,a.proxy(function(a,b){var c="number"==typeof d?d+a:g.length+1;g.splice(c,0,b)},this)),this._setInitialStates({nodes:this._tree},0).done(a.proxy(function(){c&&!c.state.expanded&&this._setExpanded(c,!0,e),this._render()},this))},g.prototype.addNodeAfter=function(b,c,d){b instanceof Array||(b=[b]),c instanceof Array&&(c=c[0]),d=a.extend({},f.options,d),this.addNode(b,this.getParents(c)[0],c.index+1,d)},g.prototype.addNodeBefore=function(b,c,d){b instanceof Array||(b=[b]),c instanceof Array&&(c=c[0]),d=a.extend({},f.options,d),this.addNode(b,this.getParents(c)[0],c.index,d)},g.prototype.removeNode=function(b,c){b instanceof Array||(b=[b]),c=a.extend({},f.options,c);var d,e;a.each(b,a.proxy(function(a,b){e=this._nodes[b.parentId],d=e?e.nodes:this._tree,d.splice(b.index,1),this._removeNodeEl(b)},this)),this._setInitialStates({nodes:this._tree},0).done(this._render.bind(this))},g.prototype.updateNode=function(b,c,d){b instanceof Array&&(b=b[0]),d=a.extend({},f.options,d);var e,g=this._nodes[b.parentId];e=g?g.nodes:this._tree,e.splice(b.index,1,c),this._removeNodeEl(b),this._setInitialStates({nodes:this._tree},0).done(this._render.bind(this))},g.prototype.selectNode=function(b,c){b instanceof Array||(b=[b]),c=a.extend({},f.options,c),a.each(b,a.proxy(function(a,b){this._setSelected(b,!0,c)},this))},g.prototype.unselectNode=function(b,c){b instanceof Array||(b=[b]),c=a.extend({},f.options,c),a.each(b,a.proxy(function(a,b){this._setSelected(b,!1,c)},this))},g.prototype.toggleNodeSelected=function(b,c){b instanceof Array||(b=[b]),c=a.extend({},f.options,c),a.each(b,a.proxy(function(a,b){this._toggleSelected(b,c)},this))},g.prototype.collapseAll=function(b){b=a.extend({},f.options,b),b.levels=b.levels||999,this.collapseNode(this._tree,b)},g.prototype.collapseNode=function(b,c){c=a.extend({},f.options,c),a.each(b,a.proxy(function(a,b){this._setExpanded(b,!1,c)},this))},g.prototype.expandAll=function(b){b=a.extend({},f.options,b),b.levels=b.levels||999,this.expandNode(this._tree,b)},g.prototype.expandNode=function(b,c){b instanceof Array||(b=[b]),c=a.extend({},f.options,c),a.each(b,a.proxy(function(a,b){b.state.expanded||("function"==typeof this._options.lazyLoad&&b.lazyLoad&&this._lazyLoad(b),this._setExpanded(b,!0,c),b.nodes&&this._expandLevels(b.nodes,c.levels-1,c))},this))},g.prototype._expandLevels=function(b,c,d){b instanceof Array||(b=[b]),d=a.extend({},f.options,d),a.each(b,a.proxy(function(a,b){this._setExpanded(b,c>0,d),b.nodes&&this._expandLevels(b.nodes,c-1,d)},this))},g.prototype.revealNode=function(b,c){b instanceof Array||(b=[b]),c=a.extend({},f.options,c),a.each(b,a.proxy(function(a,b){for(var d,e=b;d=this.getParents([e])[0];)e=d,this._setExpanded(e,!0,c)},this))},g.prototype.toggleNodeExpanded=function(b,c){b instanceof Array||(b=[b]),c=a.extend({},f.options,c),a.each(b,a.proxy(function(a,b){this._toggleExpanded(b,c)},this))},g.prototype.checkAll=function(b){b=a.extend({},f.options,b);var c=a.grep(this._orderedNodes,function(a){return!a.state.checked});a.each(c,a.proxy(function(a,c){this._setChecked(c,!0,b)},this))},g.prototype.checkNode=function(b,c){b instanceof Array||(b=[b]),c=a.extend({},f.options,c),a.each(b,a.proxy(function(a,b){this._setChecked(b,!0,c)},this))},g.prototype.uncheckAll=function(b){b=a.extend({},f.options,b);var c=a.grep(this._orderedNodes,function(a){return a.state.checked||a.state.checked===d});a.each(c,a.proxy(function(a,c){this._setChecked(c,!1,b)},this))},g.prototype.uncheckNode=function(b,c){b instanceof Array||(b=[b]),c=a.extend({},f.options,c),a.each(b,a.proxy(function(a,b){this._setChecked(b,!1,c)},this))},g.prototype.toggleNodeChecked=function(b,c){b instanceof Array||(b=[b]),c=a.extend({},f.options,c),a.each(b,a.proxy(function(a,b){this._toggleChecked(b,c)},this))},g.prototype.unmarkCheckboxChanges=function(){this._inheritCheckboxChanges(),a.each(this._nodes,function(a,b){b.$el.removeClass("node-check-changed")})},g.prototype.disableAll=function(b){b=a.extend({},f.options,b);var c=this._findNodes("false","state.disabled");a.each(c,a.proxy(function(a,c){this._setDisabled(c,!0,b)},this))},g.prototype.disableNode=function(b,c){b instanceof Array||(b=[b]),c=a.extend({},f.options,c),a.each(b,a.proxy(function(a,b){this._setDisabled(b,!0,c)},this))},g.prototype.enableAll=function(b){b=a.extend({},f.options,b);var c=this._findNodes("true","state.disabled");a.each(c,a.proxy(function(a,c){this._setDisabled(c,!1,b)},this))},g.prototype.enableNode=function(b,c){b instanceof Array||(b=[b]),c=a.extend({},f.options,c),a.each(b,a.proxy(function(a,b){this._setDisabled(b,!1,c)},this))},g.prototype.toggleNodeDisabled=function(b,c){b instanceof Array||(b=[b]),c=a.extend({},f.options,c),a.each(b,a.proxy(function(a,b){this._setDisabled(b,!b.state.disabled,c)},this))},g.prototype.search=function(b,c){c=a.extend({},f.searchOptions,c);var d=this._getSearchResults(),e=[];if(b&&b.length>0){c.exactMatch&&(b="^"+b+"$");var g="g";c.ignoreCase&&(g+="i"),e=this._findNodes(b,"text",g)}return a.each(this._diffArray(e,d),a.proxy(function(a,b){this._setSearchResult(b,!1,c)},this)),a.each(this._diffArray(d,e),a.proxy(function(a,b){this._setSearchResult(b,!0,c)},this)),e&&c.revealResults&&this.revealNode(e),this._triggerEvent("searchComplete",e,c),e},g.prototype.clearSearch=function(b){b=a.extend({},{render:!0},b);var c=a.each(this._getSearchResults(),a.proxy(function(a,c){this._setSearchResult(c,!1,b)},this));this._triggerEvent("searchCleared",c,b)},g.prototype._getSearchResults=function(){return this._findNodes("true","searchResult")},g.prototype._diffArray=function(b,c){var d=[];return a.grep(c,function(c){a.inArray(c,b)===-1&&d.push(c)}),d},g.prototype._findNodes=function(b,c,d){return c=c||"text",d=d||"g",a.grep(this._orderedNodes,a.proxy(function(a){var e=this._getNodeValue(a,c);if("string"==typeof e)return e.match(new RegExp(b,d))},this))},g.prototype._getNodeValue=function(a,b){var c=b.indexOf(".");if(c>0){var e=a[b.substring(0,c)],f=b.substring(c+1,b.length);return this._getNodeValue(e,f)}return a.hasOwnProperty(b)&&a[b]!==d?a[b].toString():d};var h=function(a){b.console&&b.console.error(a)};a.fn[e]=function(b,c){var d;if(0==this.length)throw"No element has been found!";return this.each(function(){var f=a.data(this,e);"string"==typeof b?f?a.isFunction(f[b])&&"_"!==b.charAt(0)?(c instanceof Array||(c=[c]),d=f[b].apply(f,c)):h("No such method : "+b):h("Not initialized, can not call method : "+b):"boolean"==typeof b?d=f:a.data(this,e,new g(this,a.extend(!0,{},b)))}),d||this}}(jQuery,window,document); \ No newline at end of file +!function(a,b,c,d){"use strict";var e="treeview",f={};f.settings={injectStyle:!0,levels:2,expandIcon:"fas fa-plus",collapseIcon:"fas fa-minus",loadingIcon:"fas fa-hourglass",emptyIcon:"fas",nodeIcon:"",selectedIcon:"",checkedIcon:"far fa-check-square",partiallyCheckedIcon:"fas fa-expand",uncheckedIcon:"far fa-square",tagsClass:"badge bg-primary rounded-pill",color:d,backColor:d,borderColor:d,changedNodeColor:"#39A5DC",onhoverColor:"#F5F5F5",selectedColor:"#FFFFFF",selectedBackColor:"#428bca",searchResultColor:"#D9534F",searchResultBackColor:d,highlightSelected:!0,highlightSearchResults:!0,showBorder:!0,showIcon:!0,showImage:!1,showCheckbox:!1,checkboxFirst:!1,highlightChanges:!1,showTags:!1,multiSelect:!1,preventUnselect:!1,allowReselect:!1,hierarchicalCheck:!1,propagateCheckEvent:!1,wrapNodeText:!1,onLoading:d,onLoadingFailed:d,onInitialized:d,onNodeRendered:d,onRendered:d,onDestroyed:d,onNodeChecked:d,onNodeCollapsed:d,onNodeDisabled:d,onNodeEnabled:d,onNodeExpanded:d,onNodeChanged:d,onNodeSelected:d,onNodeUnchecked:d,onNodeUnselected:d,onSearchComplete:d,onSearchCleared:d},f.options={silent:!1,ignoreChildren:!1},f.searchOptions={ignoreCase:!0,exactMatch:!1,revealResults:!0},f.dataUrl={method:"GET",dataType:"json",cache:!1};var g=function(b,c){return this.$element=a(b),this._elementId=b.id,this._styleId=this._elementId+"-style",this._init(c),{options:this._options,init:this._init.bind(this),remove:this._remove.bind(this),findNodes:this.findNodes.bind(this),getNodes:this.getNodes.bind(this),getParents:this.getParents.bind(this),getSiblings:this.getSiblings.bind(this),getSelected:this.getSelected.bind(this),getUnselected:this.getUnselected.bind(this),getExpanded:this.getExpanded.bind(this),getCollapsed:this.getCollapsed.bind(this),getChecked:this.getChecked.bind(this),getUnchecked:this.getUnchecked.bind(this),getDisabled:this.getDisabled.bind(this),getEnabled:this.getEnabled.bind(this),addNode:this.addNode.bind(this),addNodeAfter:this.addNodeAfter.bind(this),addNodeBefore:this.addNodeBefore.bind(this),removeNode:this.removeNode.bind(this),updateNode:this.updateNode.bind(this),selectNode:this.selectNode.bind(this),unselectNode:this.unselectNode.bind(this),toggleNodeSelected:this.toggleNodeSelected.bind(this),collapseAll:this.collapseAll.bind(this),collapseNode:this.collapseNode.bind(this),expandAll:this.expandAll.bind(this),expandNode:this.expandNode.bind(this),toggleNodeExpanded:this.toggleNodeExpanded.bind(this),revealNode:this.revealNode.bind(this),checkAll:this.checkAll.bind(this),checkNode:this.checkNode.bind(this),uncheckAll:this.uncheckAll.bind(this),uncheckNode:this.uncheckNode.bind(this),toggleNodeChecked:this.toggleNodeChecked.bind(this),unmarkCheckboxChanges:this.unmarkCheckboxChanges.bind(this),disableAll:this.disableAll.bind(this),disableNode:this.disableNode.bind(this),enableAll:this.enableAll.bind(this),enableNode:this.enableNode.bind(this),toggleNodeDisabled:this.toggleNodeDisabled.bind(this),search:this.search.bind(this),clearSearch:this.clearSearch.bind(this)}};g.prototype._init=function(b){this._tree=[],this._initialized=!1,this._options=a.extend({},f.settings,b),this._template.icon.empty.addClass(this._options.emptyIcon),this._destroy(),this._subscribeEvents(),this._triggerEvent("loading",null,f.options),this._load(b).then(function(b){return this._tree=a.extend(!0,[],b)}.bind(this),function(a){this._triggerEvent("loadingFailed",a,f.options)}.bind(this)).then(function(a){return this._setInitialStates({nodes:a},0)}.bind(this)).then(function(){this._render()}.bind(this))},g.prototype._load=function(b){var c=new a.Deferred;return b.data?this._loadLocalData(b,c):b.dataUrl&&this._loadRemoteData(b,c),c.promise()},g.prototype._loadRemoteData=function(b,c){a.ajax(a.extend(!0,{},f.dataUrl,b.dataUrl)).done(function(a){c.resolve(a)}).fail(function(a,b,d){c.reject(d)})},g.prototype._loadLocalData=function(b,c){c.resolve("string"==typeof b.data?JSON.parse(b.data):a.extend(!0,[],b.data))},g.prototype._remove=function(){this._destroy(),a.removeData(this,e),a("#"+this._styleId).remove()},g.prototype._destroy=function(){this._initialized&&(this._initialized=!1,this._triggerEvent("destroyed",null,f.options),this._unsubscribeEvents(),this.$wrapper.remove(),this.$wrapper=null)},g.prototype._unsubscribeEvents=function(){this.$element.off("loading"),this.$element.off("loadingFailed"),this.$element.off("initialized"),this.$element.off("nodeRendered"),this.$element.off("rendered"),this.$element.off("destroyed"),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("nodeChanged"),this.$element.off("nodeSelected"),this.$element.off("nodeUnchecked"),this.$element.off("nodeUnselected"),this.$element.off("searchComplete"),this.$element.off("searchCleared")},g.prototype._subscribeEvents=function(){this._unsubscribeEvents(),"function"==typeof this._options.onLoading&&this.$element.on("loading",this._options.onLoading),"function"==typeof this._options.onLoadingFailed&&this.$element.on("loadingFailed",this._options.onLoadingFailed),"function"==typeof this._options.onInitialized&&this.$element.on("initialized",this._options.onInitialized),"function"==typeof this._options.onNodeRendered&&this.$element.on("nodeRendered",this._options.onNodeRendered),"function"==typeof this._options.onRendered&&this.$element.on("rendered",this._options.onRendered),"function"==typeof this._options.onDestroyed&&this.$element.on("destroyed",this._options.onDestroyed),this.$element.on("click",this._clickHandler.bind(this)),"function"==typeof this._options.onNodeChecked&&this.$element.on("nodeChecked",this._options.onNodeChecked),"function"==typeof this._options.onNodeCollapsed&&this.$element.on("nodeCollapsed",this._options.onNodeCollapsed),"function"==typeof this._options.onNodeDisabled&&this.$element.on("nodeDisabled",this._options.onNodeDisabled),"function"==typeof this._options.onNodeEnabled&&this.$element.on("nodeEnabled",this._options.onNodeEnabled),"function"==typeof this._options.onNodeExpanded&&this.$element.on("nodeExpanded",this._options.onNodeExpanded),"function"==typeof this._options.onNodeChanged&&this.$element.on("nodeChanged",this._options.onNodeChanged),"function"==typeof this._options.onNodeSelected&&this.$element.on("nodeSelected",this._options.onNodeSelected),"function"==typeof this._options.onNodeUnchecked&&this.$element.on("nodeUnchecked",this._options.onNodeUnchecked),"function"==typeof this._options.onNodeUnselected&&this.$element.on("nodeUnselected",this._options.onNodeUnselected),"function"==typeof this._options.onSearchComplete&&this.$element.on("searchComplete",this._options.onSearchComplete),"function"==typeof this._options.onSearchCleared&&this.$element.on("searchCleared",this._options.onSearchCleared)},g.prototype._triggerEvent=function(b,c,d){d&&!d.silent&&this.$element.trigger(b,a.extend(!0,{},c))},g.prototype._setInitialStates=function(b,c){return this._nodes={},a.when.apply(this,this._setInitialState(b,c)).done(function(){this._orderedNodes=this._sortNodes(),this._inheritCheckboxChanges(),this._triggerEvent("initialized",this._orderedNodes,f.options)}.bind(this))},g.prototype._setInitialState=function(b,c,e){if(b.nodes){c+=1,e=e||[];var f=b;return a.each(b.nodes,function(b,g){var h=new a.Deferred;e.push(h.promise()),g.level=c,g.index=b,g.nodeId=f&&f.nodeId?f.nodeId+"."+g.index:c-1+"."+g.index,g.parentId=f.nodeId,g.hasOwnProperty("selectable")||(g.selectable=!0),g.hasOwnProperty("checkable")||(g.checkable=!0),g.state=g.state||{},g.state.hasOwnProperty("checked")||(g.state.checked=!1),this._options.hierarchicalCheck&&"undefined"===g.state.checked&&(g.state.checked=d),g.state.hasOwnProperty("disabled")||(g.state.disabled=!1),g.state.hasOwnProperty("expanded")||(!g.state.disabled&&c0?g.state.expanded=!0:g.state.expanded=!1),g.state.hasOwnProperty("selected")||(g.state.selected=!1),f&&f.state&&f.state.expanded||c<=this._options.levels?g.state.visible=!0:g.state.visible=!1,g.nodes&&(g.nodes.length>0?this._setInitialState(g,c,e):delete g.nodes),this._nodes[g.nodeId]=g,h.resolve()}.bind(this)),e}},g.prototype._sortNodes=function(){return a.map(Object.keys(this._nodes).sort(function(a,b){if(a===b)return 0;for(var a=a.split(".").map(function(a){return parseInt(a)}),b=b.split(".").map(function(a){return parseInt(a)}),c=Math.max(a.length,b.length),e=0;e0)return 1;if(a[e]-b[e]<0)return-1}}),function(a,b){return this._nodes[a]}.bind(this))},g.prototype._clickHandler=function(b){var c=a(b.target),d=this.targetNode(c);if(d&&!d.state.disabled){var e=c.attr("class")?c.attr("class").split(" "):[];e.indexOf("expand-icon")!==-1?this._toggleExpanded(d,a.extend({},f.options)):e.indexOf("check-icon")!==-1?d.checkable&&this._toggleChecked(d,a.extend({},f.options)):d.selectable?this._toggleSelected(d,a.extend({},f.options)):this._toggleExpanded(d,a.extend({},f.options))}},g.prototype.targetNode=function(a){var b=a.closest("li.list-group-item").attr("data-nodeId"),c=this._nodes[b];return c||console.log("Error: node does not exist"),c},g.prototype._toggleExpanded=function(a,b){a&&("function"==typeof this._options.lazyLoad&&a.lazyLoad?this._lazyLoad(a):this._setExpanded(a,!a.state.expanded,b))},g.prototype._lazyLoad=function(a){a.$el.find("span.expand-icon").removeClass(this._options.expandIcon).addClass(this._options.loadingIcon);var b=this;this._options.lazyLoad(a,function(c){b.addNode(c,a)}),delete a.lazyLoad},g.prototype._setExpanded=function(b,c,d){d&&c===b.state.expanded||(c&&b.nodes?(b.state.expanded=!0,b.$el&&b.$el.find("span.expand-icon").removeClass(this._options.expandIcon).removeClass(this._options.loadingIcon).addClass(this._options.collapseIcon),b.nodes&&d&&a.each(b.nodes,function(a,b){this._setVisible(b,!0,d)}.bind(this)),this._triggerEvent("nodeExpanded",b,d)):c||(b.state.expanded=!1,b.$el&&b.$el.find("span.expand-icon").removeClass(this._options.collapseIcon).addClass(this._options.expandIcon),b.nodes&&d&&a.each(b.nodes,function(a,b){this._setVisible(b,!1,d),this._setExpanded(b,!1,d)}.bind(this)),this._triggerEvent("nodeCollapsed",b,d)))},g.prototype._setVisible=function(a,b,c){c&&b===a.state.visible||(b?(a.state.visible=!0,a.$el&&(a.$el.removeClass("node-hidden"),a.$el.hasClass("d-none")&&a.$el.removeClass("d-none").addClass("d-flex"))):(a.state.visible=!1,a.$el&&(a.$el.addClass("node-hidden"),a.$el.hasClass("d-flex")&&a.$el.removeClass("d-flex").addClass("d-none"))))},g.prototype._toggleSelected=function(a,b){if(a)return this._setSelected(a,!a.state.selected,b),this},g.prototype._setSelected=function(b,c,d,e){if(!d||c!==b.state.selected){if(c)this._options.multiSelect||a.each(this._findNodes("true","state.selected"),function(b,c){this._setSelected(c,!1,a.extend(d,{unselecting:!0}),!0)}.bind(this)),b.state.selected=!0,b.$el&&(b.$el.addClass("node-selected"),(b.selectedIcon||this._options.selectedIcon)&&b.$el.find("span.node-icon").removeClass(b.icon||this._options.nodeIcon).addClass(b.selectedIcon||this._options.selectedIcon)),this._triggerEvent("nodeSelected",b,d),this._triggerEvent("nodeChanged",b,d);else{if(this._options.preventUnselect&&d&&!d.unselecting&&1===this._findNodes("true","state.selected").length)return this._options.allowReselect&&(this._triggerEvent("nodeSelected",b,d),this._triggerEvent("nodeChanged",b,d)),this;b.state.selected=!1,b.$el&&(b.$el.removeClass("node-selected"),(b.selectedIcon||this._options.selectedIcon)&&b.$el.find("span.node-icon").removeClass(b.selectedIcon||this._options.selectedIcon).addClass(b.icon||this._options.nodeIcon)),this._triggerEvent("nodeUnselected",b,d),e||this._triggerEvent("nodeChanged",b,d)}return this}},g.prototype._inheritCheckboxChanges=function(){this._options.showCheckbox&&this._options.highlightChanges&&(this._checkedNodes=a.grep(this._orderedNodes,function(a){return a.state.checked}))},g.prototype._toggleChecked=function(b,c){if(b){if(this._options.hierarchicalCheck){var e,f=a.extend({},c,{silent:c.silent||!this._options.propagateCheckEvent}),g=b;for(b.state.checked=!b.state.checked;g=this._nodes[g.parentId];)e=g.nodes.reduce(function(a,b){return a===b.state.checked?a:d},g.nodes[0].state.checked),this._setChecked(g,e,f);if(b.nodes&&b.nodes.length>0)for(var h,i=b.nodes.slice();i&&i.length>0;)h=i.pop(),this._setChecked(h,b.state.checked,f),h.nodes&&h.nodes.length>0&&(i=i.concat(h.nodes.slice()));b.state.checked=!b.state.checked}this._setChecked(b,!b.state.checked,c)}},g.prototype._setChecked=function(a,b,c){c&&b===a.state.checked||(this._options.highlightChanges&&a.$el.toggleClass("node-check-changed",this._checkedNodes.indexOf(a)==-1==b),b?(a.state.checked=!0,a.$el&&(a.$el.addClass("node-checked").removeClass("node-checked-partial"),a.$el.find("span.check-icon").removeClass(this._options.uncheckedIcon).removeClass(this._options.partiallyCheckedIcon).addClass(this._options.checkedIcon)),this._triggerEvent("nodeChecked",a,c)):b===d&&this._options.hierarchicalCheck?(a.state.checked=d,a.$el&&(a.$el.addClass("node-checked-partial").removeClass("node-checked"),a.$el.find("span.check-icon").removeClass(this._options.uncheckedIcon).removeClass(this._options.checkedIcon).addClass(this._options.partiallyCheckedIcon)),this._triggerEvent("nodeUnchecked",a,c)):(a.state.checked=!1,a.$el&&(a.$el.removeClass("node-checked node-checked-partial"),a.$el.find("span.check-icon").removeClass(this._options.checkedIcon).removeClass(this._options.partiallyCheckedIcon).addClass(this._options.uncheckedIcon)),this._triggerEvent("nodeUnchecked",a,c)))},g.prototype._setDisabled=function(a,b,c){c&&b===a.state.disabled||(b?(a.state.disabled=!0,c&&!c.keepState&&(this._setSelected(a,!1,c),this._setChecked(a,!1,c),this._setExpanded(a,!1,c)),a.$el&&a.$el.addClass("node-disabled"),this._triggerEvent("nodeDisabled",a,c)):(a.state.disabled=!1,a.$el&&a.$el.removeClass("node-disabled"),this._triggerEvent("nodeEnabled",a,c)))},g.prototype._setSearchResult=function(a,b,c){c&&b===a.searchResult||(b?(a.searchResult=!0,a.$el&&a.$el.addClass("node-result")):(a.searchResult=!1,a.$el&&a.$el.removeClass("node-result")))},g.prototype._render=function(){this._initialized||(this.$wrapper=this._template.tree.clone(),this.$element.empty().addClass(e).append(this.$wrapper),this._injectStyle(),this._initialized=!0);var b;a.each(this._orderedNodes,function(a,c){this._renderNode(c,b),b=c}.bind(this)),this._triggerEvent("rendered",this._orderedNodes,f.options)},g.prototype._renderNode=function(b,c){if(b){b.$el?b.$el.empty():b.$el=this._newNodeEl(b,c).addClass("node-"+this._elementId),b.$el.addClass(b["class"]);var e=b.$el;this._options.showTags&&b.tags&&(e=this._template.flex.clone(),b.$el.append(e),b.$el.addClass("d-flex justify-content-between align-items-start")),b.id&&b.$el.attr("id",b.id),b.dataAttr&&a.each(b.dataAttr,function(a,c){b.$el.attr("data-"+a,c)}),b.$el.attr("data-nodeId",b.nodeId),b.tooltip&&b.$el.attr("title",b.tooltip);for(var g=0;g1&&(i=this._template.flex.clone(),b.$el.append(i)),a.each(b.tags,function(a,c){var e=this._template.badge.clone().addClass(("object"==typeof c?c["class"]:d)||b.tagsClass||this._options.tagsClass).append(("object"==typeof c?c.text:d)||c);b.tags.length>1&&a>0&&e.addClass("ms-1"),i.append(e)}.bind(this))}this._setSelected(b,b.state.selected),this._setChecked(b,b.state.checked),this._setSearchResult(b,b.searchResult),this._setExpanded(b,b.state.expanded),this._setDisabled(b,b.state.disabled),this._setVisible(b,b.state.visible),this._triggerEvent("nodeRendered",b,f.options)}},g.prototype._addCheckbox=function(a,b){!this._options.showCheckbox||a.hideCheckbox!==d&&a.hideCheckbox!==!1||(b?b:a.$el).append(this._template.icon.check.clone())},g.prototype._addIcon=function(a,b){if(this._options.showIcon&&(!this._options.showImage||!a.image)){var c=this._template.icon.node.clone().addClass(a.icon||this._options.nodeIcon);a.iconColor&&c.css("color",a.iconColor),a.iconBackground&&(c.addClass("node-icon-background"),c.css("background",a.iconBackground)),(b?b:a.$el).append(c)}},g.prototype._addImage=function(a,b){this._options.showImage&&a.image&&(b?b:a.$el).append(this._template.image.clone().addClass("node-image").css("background-image","url('"+a.image+"')"))},g.prototype._newNodeEl=function(a,b){var c=this._template.node.clone();return b?b.$el.after(c):this.$wrapper.prepend(c),c},g.prototype._removeNodeEl=function(b){b&&(b.nodes&&a.each(b.nodes,function(a,b){this._removeNodeEl(b)}.bind(this)),b.$el.remove())},g.prototype._expandNode=function(b){b.nodes&&a.each(b.nodes.slice(0).reverse(),function(a,c){c.level=b.level+1,this._renderNode(c,b.$el)}.bind(this))},g.prototype._injectStyle=function(){this._options.injectStyle&&!c.getElementById(this._styleId)&&a('").appendTo("head")},g.prototype._buildStyle=function(){var b=".node-"+this._elementId+"{";if(this._options.color&&(b+="color:"+this._options.color+";"),this._options.backColor&&(b+="background-color:"+this._options.backColor+";"),this._options.showBorder?this._options.borderColor&&(b+="border:1px solid "+this._options.borderColor+";"):b+="border:none;",b+="}",this._options.onhoverColor&&(b+=".node-"+this._elementId+":not(.node-disabled):hover{background-color:"+this._options.onhoverColor+";}"),this._options.highlightSearchResults&&(this._options.searchResultColor||this._options.searchResultBackColor)){var c="";this._options.searchResultColor&&(c+="color:"+this._options.searchResultColor+";"),this._options.searchResultBackColor&&(c+="background-color:"+this._options.searchResultBackColor+";"),b+=".node-"+this._elementId+".node-result{"+c+"}",b+=".node-"+this._elementId+".node-result:hover{"+c+"}"}if(this._options.highlightSelected&&(this._options.selectedColor||this._options.selectedBackColor)){var c="";this._options.selectedColor&&(c+="color:"+this._options.selectedColor+";"),this._options.selectedBackColor&&(c+="background-color:"+this._options.selectedBackColor+";"),b+=".node-"+this._elementId+".node-selected{"+c+"}",b+=".node-"+this._elementId+".node-selected:hover{"+c+"}"}if(this._options.highlightChanges){var c="color: "+this._options.changedNodeColor+";";b+=".node-"+this._elementId+".node-check-changed{"+c+"}"}return a.each(this._orderedNodes,function(a,c){if(c.color||c.backColor){var d="";c.color&&(d+="color:"+c.color+";"),c.backColor&&(d+="background-color:"+c.backColor+";"),b+=".node-"+this._elementId+'[data-nodeId="'+c.nodeId+'"]{'+d+"}"}}.bind(this)),this._css+b},g.prototype._template={tree:a('
      '),node:a('
    • '),flex:a('
      '),indent:a(''),icon:{node:a(''),expand:a(''),check:a(''),empty:a('')},image:a(''),badge:a(""),text:a('')},g.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}",g.prototype.findNodes=function(a,b,c){return this._findNodes(a,b,c)},g.prototype.getNodes=function(){return this._orderedNodes},g.prototype.getParents=function(b){b instanceof Array||(b=[b]);var c=[];return a.each(b,function(a,b){var d=!!b.parentId&&this._nodes[b.parentId];d&&c.push(d)}.bind(this)),c},g.prototype.getSiblings=function(b){b instanceof Array||(b=[b]);var c=[];return a.each(b,function(a,b){var d=this.getParents([b]),e=d[0]?d[0].nodes:this._tree;c=e.filter(function(a){return a.nodeId!==b.nodeId})}.bind(this)),a.map(c,function(a){return a})},g.prototype.getSelected=function(){return this._findNodes("true","state.selected")},g.prototype.getUnselected=function(){return this._findNodes("false","state.selected")},g.prototype.getExpanded=function(){return this._findNodes("true","state.expanded")},g.prototype.getCollapsed=function(){return this._findNodes("false","state.expanded")},g.prototype.getChecked=function(){return this._findNodes("true","state.checked")},g.prototype.getUnchecked=function(){return this._findNodes("false","state.checked")},g.prototype.getDisabled=function(){return this._findNodes("true","state.disabled")},g.prototype.getEnabled=function(){return this._findNodes("false","state.disabled")},g.prototype.addNode=function(b,c,d,e){b instanceof Array||(b=[b]),c instanceof Array&&(c=c[0]),e=a.extend({},f.options,e);var g;g=c&&c.nodes?c.nodes:c?c.nodes=[]:this._tree,a.each(b,function(a,b){var c="number"==typeof d?d+a:g.length+1;g.splice(c,0,b)}.bind(this)),this._setInitialStates({nodes:this._tree},0).done(function(){c&&!c.state.expanded&&this._setExpanded(c,!0,e),this._render()}.bind(this))},g.prototype.addNodeAfter=function(b,c,d){b instanceof Array||(b=[b]),c instanceof Array&&(c=c[0]),d=a.extend({},f.options,d),this.addNode(b,this.getParents(c)[0],c.index+1,d)},g.prototype.addNodeBefore=function(b,c,d){b instanceof Array||(b=[b]),c instanceof Array&&(c=c[0]),d=a.extend({},f.options,d),this.addNode(b,this.getParents(c)[0],c.index,d)},g.prototype.removeNode=function(b,c){b instanceof Array||(b=[b]),c=a.extend({},f.options,c);var d,e;a.each(b,function(a,b){e=this._nodes[b.parentId],d=e?e.nodes:this._tree,d.splice(b.index,1),this._removeNodeEl(b)}.bind(this)),this._setInitialStates({nodes:this._tree},0).done(this._render.bind(this))},g.prototype.updateNode=function(b,c,d){b instanceof Array&&(b=b[0]),d=a.extend({},f.options,d);var e,g=this._nodes[b.parentId];e=g?g.nodes:this._tree,e.splice(b.index,1,c),this._removeNodeEl(b),this._setInitialStates({nodes:this._tree},0).done(this._render.bind(this))},g.prototype.selectNode=function(b,c){b instanceof Array||(b=[b]),c=a.extend({},f.options,c),a.each(b,function(a,b){this._setSelected(b,!0,c)}.bind(this))},g.prototype.unselectNode=function(b,c){b instanceof Array||(b=[b]),c=a.extend({},f.options,c),a.each(b,function(a,b){this._setSelected(b,!1,c)}.bind(this))},g.prototype.toggleNodeSelected=function(b,c){b instanceof Array||(b=[b]),c=a.extend({},f.options,c),a.each(b,function(a,b){this._toggleSelected(b,c)}.bind(this))},g.prototype.collapseAll=function(b){b=a.extend({},f.options,b),b.levels=b.levels||999,this.collapseNode(this._tree,b)},g.prototype.collapseNode=function(b,c){c=a.extend({},f.options,c),a.each(b,function(a,b){this._setExpanded(b,!1,c)}.bind(this))},g.prototype.expandAll=function(b){b=a.extend({},f.options,b),b.levels=b.levels||999,this.expandNode(this._tree,b)},g.prototype.expandNode=function(b,c){b instanceof Array||(b=[b]),c=a.extend({},f.options,c),a.each(b,function(a,b){b.state.expanded||("function"==typeof this._options.lazyLoad&&b.lazyLoad&&this._lazyLoad(b),this._setExpanded(b,!0,c),b.nodes&&this._expandLevels(b.nodes,c.levels-1,c))}.bind(this))},g.prototype._expandLevels=function(b,c,d){b instanceof Array||(b=[b]),d=a.extend({},f.options,d),a.each(b,function(a,b){this._setExpanded(b,c>0,d),b.nodes&&this._expandLevels(b.nodes,c-1,d)}.bind(this))},g.prototype.revealNode=function(b,c){b instanceof Array||(b=[b]),c=a.extend({},f.options,c),a.each(b,function(a,b){for(var d,e=b;d=this.getParents([e])[0];)e=d,this._setExpanded(e,!0,c)}.bind(this))},g.prototype.toggleNodeExpanded=function(b,c){b instanceof Array||(b=[b]),c=a.extend({},f.options,c),a.each(b,function(a,b){this._toggleExpanded(b,c)}.bind(this))},g.prototype.checkAll=function(b){b=a.extend({},f.options,b);var c=a.grep(this._orderedNodes,function(a){return!a.state.checked});a.each(c,function(a,c){this._setChecked(c,!0,b)}.bind(this))},g.prototype.checkNode=function(b,c){b instanceof Array||(b=[b]),c=a.extend({},f.options,c),a.each(b,function(a,b){this._setChecked(b,!0,c)}.bind(this))},g.prototype.uncheckAll=function(b){b=a.extend({},f.options,b);var c=a.grep(this._orderedNodes,function(a){return a.state.checked||a.state.checked===d});a.each(c,function(a,c){this._setChecked(c,!1,b)}.bind(this))},g.prototype.uncheckNode=function(b,c){b instanceof Array||(b=[b]),c=a.extend({},f.options,c),a.each(b,function(a,b){this._setChecked(b,!1,c)}.bind(this))},g.prototype.toggleNodeChecked=function(b,c){b instanceof Array||(b=[b]),c=a.extend({},f.options,c),a.each(b,function(a,b){this._toggleChecked(b,c)}.bind(this))},g.prototype.unmarkCheckboxChanges=function(){this._inheritCheckboxChanges(),a.each(this._nodes,function(a,b){b.$el.removeClass("node-check-changed")})},g.prototype.disableAll=function(b){b=a.extend({},f.options,b);var c=this._findNodes("false","state.disabled");a.each(c,function(a,c){this._setDisabled(c,!0,b)}.bind(this))},g.prototype.disableNode=function(b,c){b instanceof Array||(b=[b]),c=a.extend({},f.options,c),a.each(b,function(a,b){this._setDisabled(b,!0,c)}.bind(this))},g.prototype.enableAll=function(b){b=a.extend({},f.options,b);var c=this._findNodes("true","state.disabled");a.each(c,function(a,c){this._setDisabled(c,!1,b)}.bind(this))},g.prototype.enableNode=function(b,c){b instanceof Array||(b=[b]),c=a.extend({},f.options,c),a.each(b,function(a,b){this._setDisabled(b,!1,c)}.bind(this))},g.prototype.toggleNodeDisabled=function(b,c){b instanceof Array||(b=[b]),c=a.extend({},f.options,c),a.each(b,function(a,b){this._setDisabled(b,!b.state.disabled,c)}.bind(this))},g.prototype.search=function(b,c){c=a.extend({},f.searchOptions,c);var d=this._getSearchResults(),e=[];if(b&&b.length>0){c.exactMatch&&(b="^"+b+"$");var g="g";c.ignoreCase&&(g+="i"),e=this._findNodes(b,"text",g)}return a.each(this._diffArray(e,d),function(a,b){this._setSearchResult(b,!1,c)}.bind(this)),a.each(this._diffArray(d,e),function(a,b){this._setSearchResult(b,!0,c)}.bind(this)),e&&c.revealResults&&this.revealNode(e),this._triggerEvent("searchComplete",e,c),e},g.prototype.clearSearch=function(b){b=a.extend({},{render:!0},b);var c=a.each(this._getSearchResults(),function(a,c){this._setSearchResult(c,!1,b)}.bind(this));this._triggerEvent("searchCleared",c,b)},g.prototype._getSearchResults=function(){return this._findNodes("true","searchResult")},g.prototype._diffArray=function(b,c){var d=[];return a.grep(c,function(c){a.inArray(c,b)===-1&&d.push(c)}),d},g.prototype._findNodes=function(b,c,d){return c=c||"text",d=d||"g",a.grep(this._orderedNodes,function(a){var e=this._getNodeValue(a,c);if("string"==typeof e)return e.match(new RegExp(b,d))}.bind(this))},g.prototype._getNodeValue=function(a,b){var c=b.indexOf(".");if(c>0){var e=a[b.substring(0,c)],f=b.substring(c+1,b.length);return this._getNodeValue(e,f)}return a.hasOwnProperty(b)&&a[b]!==d?a[b].toString():d};var h=function(a){b.console&&b.console.error(a)};a.fn[e]=function(b,c){var d;if(0==this.length)throw"No element has been found!";return this.each(function(){var f=a.data(this,e);"string"==typeof b?f?a.isFunction(f[b])&&"_"!==b.charAt(0)?(c instanceof Array||(c=[c]),d=f[b].apply(f,c)):h("No such method : "+b):h("Not initialized, can not call method : "+b):"boolean"==typeof b?d=f:a.data(this,e,new g(this,a.extend(!0,{},b)))}),d||this}}(jQuery,window,document); \ No newline at end of file diff --git a/package.json b/package.json index 67d3fe622..3b4aad20d 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "patternfly-bootstrap-treeview", "description": "Tree View for Twitter Bootstrap", - "version": "2.2.0", + "version": "3.0.0", "homepage": "https://github.com/patternfly/patternfly-bootstrap-treeview", "author": { "name": "Red Hat" @@ -17,18 +17,19 @@ "main": "dist/bootstrap-treeview.js", "scripts": { "start": "node app", - "test": "grunt test" + "test": "grunt test", + "build": "grunt" }, "engines": { "node": ">= 0.10.0" }, "dependencies": { - "bootstrap": "4.1.x", - "jquery": ">= 3.2.x", - "popper.js": "^1.14.6" + "bootstrap": "5.2.x", + "jquery": ">= 3.5.x", + "@popperjs/core": "^2.11.6" }, "devDependencies": { - "@fortawesome/fontawesome-free": "^5.6.3", + "@fortawesome/fontawesome-free": "^5.15.1", "bower": "^1.8.8", "express": "3.4.x", "grunt": "^1.0.1", diff --git a/public/css/bootstrap-treeview.css b/public/css/bootstrap-treeview.css index 6b51e29cf..2ca8e4c55 100644 --- a/public/css/bootstrap-treeview.css +++ b/public/css/bootstrap-treeview.css @@ -1,5 +1,5 @@ /* ========================================================= - * patternfly-bootstrap-treeview.css v2.1.0 + * patternfly-bootstrap-treeview.css v2.2.0 * ========================================================= * Copyright 2013 Jonathan Miles * Project URL : http://www.jondmiles.com/bootstrap-treeview diff --git a/public/example-dom.html b/public/example-dom.html index f51e239dd..1816d9aed 100644 --- a/public/example-dom.html +++ b/public/example-dom.html @@ -16,7 +16,7 @@

      Bootstrap Tree View - DOM Tree

      - + +