mirror of
https://github.com/jackyzha0/quartz.git
synced 2025-12-24 13:24:05 -06:00
add jstree library
This commit is contained in:
parent
7db81d0173
commit
4bcf769a4e
@ -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 + ' <a href="' + value.href + '">'+ value.name+'</a><br/>'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return structure
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
10881
assets/js/jquery.js
vendored
Normal file
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
8681
assets/js/jstree.js
Normal file
File diff suppressed because it is too large
Load Diff
1150
assets/styles/jstree-dark.scss
Normal file
1150
assets/styles/jstree-dark.scss
Normal file
File diff suppressed because it is too large
Load Diff
1106
assets/styles/jstree-default.scss
Normal file
1106
assets/styles/jstree-default.scss
Normal file
File diff suppressed because it is too large
Load Diff
@ -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>
|
||||||
|
|||||||
@ -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 -->
|
||||||
@ -121,7 +127,7 @@
|
|||||||
|
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
// draw graph in modal // not working
|
// draw graph in modal // not working
|
||||||
|
|
||||||
// const containerModal = document.getElementById("graph-container-modal")
|
// const containerModal = document.getElementById("graph-container-modal")
|
||||||
// // retry if the graph is not ready
|
// // retry if the graph is not ready
|
||||||
@ -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
BIN
static/32px.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.5 KiB |
BIN
static/40px.png
Normal file
BIN
static/40px.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.2 KiB |
BIN
static/themes/default-dark/32px.png
Normal file
BIN
static/themes/default-dark/32px.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.5 KiB |
BIN
static/themes/default-dark/40px.png
Normal file
BIN
static/themes/default-dark/40px.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.4 KiB |
BIN
static/themes/default-dark/throbber.gif
Normal file
BIN
static/themes/default-dark/throbber.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
BIN
static/throbber.gif
Normal file
BIN
static/throbber.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
Loading…
Reference in New Issue
Block a user