Commit ae00a8d4 authored by Denis Salem's avatar Denis Salem
Browse files

use VenC-Tree in doc, add class names to this scripts + minor optimizations

parent 40103fa0
authors: 'Denis Salem'
categories: ''
tags: ''
title: Modules Javascript
chapter: 4.6.3
---VENC-BEGIN-PREVIEW---
---VENC-END-PREVIEW---
VenC fournit quelques modules Javascript qui sont utilisé dans les thèmes
par défaut, mais que vous pouvez utiliser dans vos thèmes à vous. Ce
chapitre présente ces modules et en explique le fonctionnement.
authors: 'Denis Salem'
categories: ''
tags: ''
title: Arbre
chapter: 4.6.3.2
---VENC-BEGIN-PREVIEW---
---VENC-END-PREVIEW---
/*
* Copyright 2016, 2020 Denis Salem
*
* This file is part of VenC.
*
* VenC is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* VenC is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VenC. If not, see <http://www.gnu.org/licenses/>.
*/
var VENC_ON_LOAD_CALLBACK_REGISTER = [];
function VENC_ON_LOAD_CALLBACK() {
var i;
for (i = 0; i < VENC_ON_LOAD_CALLBACK_REGISTER.length; i++) {
VENC_ON_LOAD_CALLBACK_REGISTER[i]();
}
}
window.onload = VENC_ON_LOAD_CALLBACK
/*
* Copyright 2016, 2020 Denis Salem
*
* This file is part of VenC.
*
* VenC is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* VenC is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VenC. If not, see <http://www.gnu.org/licenses/>.
*/
var VENC_TREE = {
button_show: '+',
button_hide: '-',
button_disabled: ''
}
function VENC_TREE_ON_CLICK() {
ul = this.parentElement.children[2];
if (this.innerHTML == VENC_TREE.button_show) {
if (ul != undefined) {
ul.style.transition = "0.25s ease all";
ul.style.height = "auto";
ul.style.opacity = "1";
ul.style.padding = "5px";
}
for (i = 0; i < ul.children.length; i++) {
child = ul.children[i];
if (child.children[1] != undefined) {
if (child.children[0].className != "__VENC_TREE_BUTTON_SHOW__" && child.children[0].className != "__VENC_TREE_BUTTON_HIDE__" && child.children[0].className != "__VENC_TREE_BUTTON_DISABLED__") {
child.innerHTML = "<a href=\"\" class=\"__VENC_TREE_BUTTON_SHOW__\">"+VENC_TREE.button_show+"</a>"+ child.innerHTML;
child.children[0].onclick = VENC_TREE_ON_CLICK;
}
}
else {
child.innerHTML = "<span class=\"__VENC_TREE_BUTTON_DISABLED__\">"+VENC_TREE.button_disabled+"</span>"+ child.innerHTML;
}
}
this.innerHTML = VENC_TREE.button_hide;
}
else {
ul.style.height = "0px";
ul.style.overflow = "hidden";
ul.style.opacity = "0";
ul.style.padding = "0px";
this.innerHTML = VENC_TREE.button_show;
}
return false;
}
function VENC_TREE_HIDE(nodes) {
for (k = 1; k < nodes.length; k++) {
nodes[k].style.height = "0px";
nodes[k].style.overflow = "hidden";
nodes[k].style.opacity = "0";
nodes[k].style.padding = "0px";
}
}
function VENC_TREE_ON_LOAD() {
roots = document.getElementsByClassName("__VENC_TREE_ROOT__");
console.log("Roots:",roots.length);
for (i = 0; i < roots.length; i++) {
console.log("Root index", i);
nodes = roots[i].getElementsByClassName("__VENC_TREE_NODE__");
console.log("Nodes:",nodes.length);
VENC_TREE_HIDE(nodes);
for (j = 0; j < nodes[0].children.length; j++) {
child = nodes[0].children[j];
if (child.children[1] != undefined) {
child.innerHTML = "<a href=\"\" class=\"__VENC_TREE_BUTTON_SHOW__\">"+VENC_TREE.button_show+"</a>"+ child.innerHTML;
child.children[0].onclick = VENC_TREE_ON_CLICK;
}
else {
child.innerHTML = "<span class=\"__VENC_TREE_BUTTON_DISABLED__\">"+VENC_TREE.button_disabled+"</span>"+child.innerHTML;
}
}
}
}
VENC_ON_LOAD_CALLBACK_REGISTER.push(VENC_TREE_ON_LOAD);
......@@ -91,7 +91,8 @@ code
width: 74%;
top:0%;
left:25%;
min-height: 100%;}
min-height: 100%;
padding-bottom: 1em;}
#content h1,
#content h2,
......@@ -105,3 +106,6 @@ code
#content ul
{list-style-type: square;}
.__VENC_TREE_BUTTON_DISABLED__
{margin-left:0.5em;}
......@@ -9,12 +9,19 @@
.:GetStyleSheets:.
<link rel="stylesheet" href=".:GetRelativeOrigin:.style.css" type="text/css">
<link rel="alternate" type="application/rss+xml" title=".:GetBlogName:." href="./feed.xml" />
<script type="text/javascript" src=".:GetRelativeOrigin:.VenC-Scripts-Bootstrap-0.0.0.js"></script>
<script type="text/javascript" src=".:GetRelativeOrigin:.VenC-Tree-0.1.0.js"></script>
<script type="text/javascript">
VENC_TREE.button_disabled = '';
</script>
</head>
<body>
<aside>
<header>
<h1><a href=".:GetRootPage:."><img src=".:GetRelativeOrigin:.logo.png" alt=".:GetBlogName:." title=".:GetBlogName:." /></a></h1>
</header>
.:GetChapters::<ul class="chapter-level{level}">::<li>{index}. <a href="{path}">{title}</a>::</li>::</ul>:.
<div class="__VENC_TREE_ROOT__">
.:GetChapters::<ul class="chapter-level{level} __VENC_TREE_NODE__">::<li>{index}. <a href="{path}">{title}</a>::</li>::</ul>:.
</div>
</aside>
<div id="content">
......@@ -206,7 +206,6 @@
TODO | Access {count} and {weight} from LeavesForEntrycategories.
TODO | Add Yaml comments in blog configuration.
TODO | Add nice 404 errors page.
TODO | Improve Feed.
TODO | Warn about entry title duplicates.
TODO | Handle missing args in case of unknown number of args (Pattern).
TODO | Add configuration field type check.
......
......@@ -33,14 +33,15 @@ function VENC_TREE_ON_CLICK() {
ul.style.padding = "5px";
}
for (i = 0; i < ul.children.length; i++) {
if (ul.children[i].children[1] != undefined) {
if (ul.children[i].children[0].className != "__VENC_TREE_BUTTON__") {
ul.children[i].innerHTML = "<a href=\"\" class=\"__VENC_TREE_BUTTON__\">"+VENC_TREE.button_show+"</a>"+ ul.children[i].innerHTML;
ul.children[i].children[0].onclick = VENC_TREE_ON_CLICK;
child = ul.children[i];
if (child.children[1] != undefined) {
if (child.children[0].className != "__VENC_TREE_BUTTON_SHOW__" && child.children[0].className != "__VENC_TREE_BUTTON_HIDE__" && child.children[0].className != "__VENC_TREE_BUTTON_DISABLED__") {
child.innerHTML = "<a href=\"\" class=\"__VENC_TREE_BUTTON_SHOW__\">"+VENC_TREE.button_show+"</a>"+ child.innerHTML;
child.children[0].onclick = VENC_TREE_ON_CLICK;
}
}
else {
ul.children[i].innerHTML = "<span class=\"__VENC_TREE_BUTTON__\">"+VENC_TREE.button_disabled+"</span>"+ ul.children[i].innerHTML;
child.innerHTML = "<span class=\"__VENC_TREE_BUTTON_DISABLED__\">"+VENC_TREE.button_disabled+"</span>"+ child.innerHTML;
}
}
this.innerHTML = VENC_TREE.button_hide;
......@@ -74,12 +75,13 @@ function VENC_TREE_ON_LOAD() {
console.log("Nodes:",nodes.length);
VENC_TREE_HIDE(nodes);
for (j = 0; j < nodes[0].children.length; j++) {
if (nodes[0].children[j].children[1] != undefined) {
nodes[0].children[j].innerHTML = "<a href=\"\" class=\"__VENC_TREE_BUTTON__\">"+VENC_TREE.button_show+"</a>"+ nodes[0].children[j].innerHTML;
nodes[0].children[j].children[0].onclick = VENC_TREE_ON_CLICK;
child = nodes[0].children[j];
if (child.children[1] != undefined) {
child.innerHTML = "<a href=\"\" class=\"__VENC_TREE_BUTTON_SHOW__\">"+VENC_TREE.button_show+"</a>"+ child.innerHTML;
child.children[0].onclick = VENC_TREE_ON_CLICK;
}
else {
nodes[0].children[j].innerHTML = "<span class=\"__VENC_TREE_BUTTON__\">"+VENC_TREE.button_disabled+"</span>"+ nodes[0].children[j].innerHTML;
child.innerHTML = "<span class=\"__VENC_TREE_BUTTON_DISABLED__\">"+VENC_TREE.button_disabled+"</span>"+child.innerHTML;
}
}
}
......
......@@ -101,7 +101,7 @@ def handle_markup_language_error(message, line=None, string=None):
def parse_markup_language(string, markup_language, ressource):
if markup_language == "Markdown":
string = markdown.markdown(string)
string = markdown.markdown(string, extras=["header-ids"])
elif markup_language == "reStructuredText":
string = publish_parts(string, writer_name='html', settings_overrides={'doctitle_xform':False, 'halt_level': 2, 'traceback': True, "warning_stream":"/dev/null"})['html_body']
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment