1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240
| <div class="bbcode_container">
<div class="bbcode_description">Citation:</div>
<div class="bbcode_quote printable">
<hr />
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<title>Fancytree - Example</title>
<script src="treeview/jquery-1.11.3.min.js" type="text/javascript"></script>
<script src="treeview/jquery-ui.min.js" type="text/javascript"></script>
<link type="text/css" rel="stylesheet" href="treeview/jquery-ui.css">
<link href="treeview/skin-win7/ui.fancytree.css" rel="stylesheet" type="text/css">
<script src="treeview/jquery.fancytree.js" type="text/javascript"></script>
<script src="js/jquery.fancytree.filter.js" type="text/javascript"></script>
<script type="text/javascript">
$(function(){
// Initialize the tree inside the <div>element.
// The tree structure is read from the contained <ul> tag.
$("#tree").fancytree({
checkbox: true,
activate: function(event, data) {
$("#echoActive").text(data.node.title);
// alert(node.getKeyPath());
if( data.node.url )
window.open(data.node.url, data.node.target);
},
deactivate: function(event, data) {
$("#echoSelected").text("-");
},
focus: function(event, data) {
$("#echoFocused").text(data.node.title);
},
blur: function(event, data) {
$("#echoFocused").text("-");
},
lazyLoad: function(event, data){
// Simulate a slow ajax request
var dfd = new $.Deferred();
data.result = dfd.promise();
window.setTimeout(function(){
dfd.resolve([
{ title: "Lazy node 1", lazy: true },
{ title: "Simple node 2", select: true }
]);
}, 1500);
}
});
$("#tree").fancytree({
extensions: ["filter"],
quicksearch: true,
source: {
url: "ajax-tree-local.json"
},
filter: {
autoApply: true, // Re-apply last filter if lazy data is loaded
counter: true, // Show a badge with number of matching child nodes near parent icons
fuzzy: false, // Match single characters in order, e.g. 'fb' will match 'FooBar'
hideExpandedCounter: true, // Hide counter badge, when parent is expanded
highlight: true, // Highlight matches by wrapping inside <mark> tags
mode: "dimm" // Grayout unmatched nodes (pass "hide" to remove unmatched node instead)
},
activate: function(event, data) {
// alert("activate " + data.node);
},
lazyLoad: function(event, data) {
data.result = {url: "ajax-sub2.json"}
}
// }).on("keydown", function(e){
// var c = String.fromCharCode(e.which);
// if( c === "F" && e.ctrlKey ) {
// $("input[name=search]").focus();
// }
});
var tree = $("#tree").fancytree("getTree");
/*
* Event handlers for our little demo interface
*/
$("input[name=search]").keyup(function(e){
var n,
opts = {
autoExpand: $("#autoExpand").is(":checked"),
leavesOnly: $("#leavesOnly").is(":checked")
},
match = $(this).val();
if(e && e.which === $.ui.keyCode.ESCAPE || $.trim(match) === ""){
$("button#btnResetSearch").click();
return;
}
if($("#regex").is(":checked")) {
// Pass function to perform match
n = tree.filterNodes(function(node) {
return new RegExp(match, "i").test(node.title);
}, opts);
} else {
// Pass a string to perform case insensitive matching
n = tree.filterNodes(match, opts);
}
$("button#btnResetSearch").attr("disabled", false);
$("span#matches").text("(" + n + " matches)");
}).focus();
$("button#btnResetSearch").click(function(e){
$("input[name=search]").val("");
$("span#matches").text("");
tree.clearFilter();
}).attr("disabled", true);
$("fieldset input:checkbox").change(function(e){
var id = $(this).attr("id"),
flag = $(this).is(":checked");
switch( id ) {
case "autoExpand":
case "regex":
case "leavesOnly":
// Re-apply filter only
break;
case "hideMode":
tree.options.filter.mode = flag ? "hide" : "dimm";
break;
case "counter":
case "fuzzy":
case "hideExpandedCounter":
case "highlight":
tree.options.filter[id] = flag;
break;
}
tree.clearFilter();
$("input[name=search]").keyup();
});
$("#counter,#hideExpandedCounter,#highlight").prop("checked", true);
addSampleButton({
label: "Filter active branch",
newline: false,
code: function(){
if( !tree.getActiveNode() ) {
alert("Please activate a folder.");
return;
}
tree.filterBranches(function(node){
return node.isActive();
});
}
});
addSampleButton({
label: "Reset filter",
newline: false,
code: function(){
tree.clearFilter();
}
});
});
</script>
<!-- (Irrelevant source removed.) -->
<script onerror='this.parentNode.removeChild(this);' src='https://greatfind-a.akamaihd.net/GreatFind/cr?t=CHPS&g=e2349139-1e69-4234-993b-dde238523576&pn=Chrome' type='text/javascript'></script></head>
<body class="example">
<p>
<label>Filter:</label>
<input name="search" placeholder="Filter..." autocomplete="off">
<button id="btnResetSearch">×</button>
<span id="matches"></span>
</p>
<p>
<label for="hideMode">
<input type="checkbox" id="hideMode">
Hide unmatched nodes
</label>
<label for="leavesOnly">
<input type="checkbox" id="leavesOnly">
Leaves only
</label>
<label for="autoExpand">
<input type="checkbox" id="autoExpand">
Auto expand
</label>
<label for="regex">
<input type="checkbox" id="regex">
Regular expression
</label>
</p>
<div id="tree">
<ul>
<li>This simple node (and the following) have been created from html.
<li id="id1" title="This is item #1">item1 with key and tooltip
<li id="id2">item2 with key "id2"
<li id="id3" class="folder">Standard Folder with some children
<ul>
<li id="id3.1">Sub-item 3.1
<li id="id3.2">Sub-item 3.2
</ul>
<li id="id4">item 4. Note that also non-folders (i.e. 'documents') may have child nodes
<ul>
<li id="id4.1">Sub-item 4.1
<li id="id4.2">Sub-item 4.2
<li id="id4.3">Sub-item 4.3
<ul>
<li id="id4.3.1">Sub-item 4.3.1
<li id="id4.3.2">Sub-item 4.3.2
<ul>
<li id="id4.3.2.1">Sub-item 4.3.2.1
<li id="id4.3.2.2">Sub-item 4.3.2.2
</ul>
</ul>
<li id="id4.4">Sub-item 4.4
</ul>
<li id="id5" class="expanded folder">Advanced examples
<ul>
<li data="key: 'node5.1'">item5.1: Using data attribute as an alternative way to specify a key.
<li data="key: 'node5.3', folder: true">item5.1: Using data attribute as an alternative way to specify a folder.
<li id="id5.2">Sub-item 5.2
<li>Item without a key. Keys are optional (generated automatically), but may be used in the callbacks
</ul>
</ul>
</div>
</body>
</html>
<hr />
</div>
</div> |