add jstree library

This commit is contained in:
DhammaCharts 2022-07-10 09:30:03 +01:00
parent 7db81d0173
commit 4bcf769a4e
13 changed files with 21843 additions and 29 deletions

View File

@ -25,7 +25,9 @@ for (let path in content) {
id: pageId, id: pageId,
parentId: parentFolderId, parentId: parentFolderId,
name: pageTitle, name: pageTitle,
text: pageTitle,
type: 'page', type: 'page',
a_attr : {href : pathBase.slice(0, pathBase.length - 1) + path} ,
href: pathBase.slice(0, pathBase.length - 1) + path href: pathBase.slice(0, pathBase.length - 1) + path
}) })
@ -43,6 +45,7 @@ for (let path in content) {
id: '_' + folderId + '_', id: '_' + folderId + '_',
parentId: parentId, parentId: parentId,
name: folderId.replace(/-/g, ' '), name: folderId.replace(/-/g, ' '),
text: folderId.replace(/-/g, ' '),
type: 'folder', type: 'folder',
// type : Tree.FOLDER, // type : Tree.FOLDER,
level: level level: level
@ -82,33 +85,17 @@ tree.forEach((el) => {
const structure = root.children; const structure = root.children;
// a temporary function to traverse the tree and allowing to display something $(function () {
function* traverse(o, path = []) { $('#jstree')
for (var i in o) { .on('click', function (e) {
const itemPath = path.concat(i); $('#jstree').jstree(true).toggle_node(e.target);
yield [i, o[i], itemPath, o]; })
if (o[i] !== null && typeof o[i] == "object") { .jstree({
//going one step down in the object tree!! core : {
yield* traverse(o[i], itemPath); dblclick_toggle : false,
} 'data' : structure},
} "plugins" : [ "wholerow" ]
} });
});
// console.log(structure)
for (var [key, value, path] of traverse(structure)) {
// console.log(key);
// console.log(value);
// console.log(path);
// console.log("---");
let doc = document.getElementById("tree").innerHTML
if (value?.type == "folder") {
document.getElementById("tree").innerHTML = doc + '<h3>'+value.name + '</h3>'
}
if (value?.type == "page") {
document.getElementById("tree").innerHTML = doc + '&emsp;<a href="' + value.href + '">'+ value.name+'</a><br/>'
}
}
return structure
} }

10881
assets/js/jquery.js vendored Normal file

File diff suppressed because it is too large Load Diff

8681
assets/js/jstree.js Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -52,6 +52,7 @@
<aside data-sm1-2 data-md1-2 data-lg1-4 data-lg1 data-m1 data-sm2 data-xs3 class="singlePage"> <aside data-sm1-2 data-md1-2 data-lg1-4 data-lg1 data-m1 data-sm2 data-xs3 class="singlePage">
<div class="sticky page-end vertical"> <div class="sticky page-end vertical">
<h3> Menu </h3> <h3> Menu </h3>
<div id="jstree"></div>
<div id="tree"></div> <div id="tree"></div>
</div> </div>
</aside> </aside>

View File

@ -63,6 +63,12 @@
{{ if $.Site.Data.config.enableColumnLayout }} {{ if $.Site.Data.config.enableColumnLayout }}
{{ $drawTree := resources.Get "js/drawTree.js" | resources.Fingerprint "md5" | resources.Minify }} {{ $drawTree := resources.Get "js/drawTree.js" | resources.Fingerprint "md5" | resources.Minify }}
<script src="{{$drawTree.Permalink}}"></script> <script src="{{$drawTree.Permalink}}"></script>
{{ $jquery := resources.Get "js/jquery.js" | resources.Fingerprint "md5" | resources.Minify }}
<script src="{{$jquery.Permalink}}"></script>
{{ $jstree := resources.Get "js/jstree.js" | resources.Fingerprint "md5" | resources.Minify }}
<script src="{{$jstree.Permalink}}"></script>
{{ end }} {{ end }}
<!-- Preload page vars --> <!-- Preload page vars -->
@ -179,6 +185,8 @@
const pathBase = siteBaseURL.pathname; const pathBase = siteBaseURL.pathname;
drawTree(pathBase) drawTree(pathBase)
// Get the modal // Get the modal
var modal = document.getElementById("myModal"); var modal = document.getElementById("myModal");

BIN
static/32px.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

BIN
static/40px.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
static/throbber.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB