Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/vjeantet/hugo-theme-docport.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvjeantet <valere.jeantet@gmail.com>2020-11-06 01:30:56 +0300
committervjeantet <valere.jeantet@gmail.com>2020-11-06 01:30:56 +0300
commitb43c043a7b9153e5cf6a1a30b057d143b1cedc52 (patch)
tree468fe0ce643f24e92c0ed06e6dc587eb52a62c13 /layouts
parent4b0cf57d5be417ddb3167d0bd0b4c09a35c1e62b (diff)
fix some cssHEADmaster
Diffstat (limited to 'layouts')
-rw-r--r--layouts/partials/_checklist-footer.html8
-rw-r--r--layouts/partials/_checklist-header.html16
-rw-r--r--layouts/partials/_menu.html4
-rw-r--r--layouts/partials/_skwad-footer.html21
-rw-r--r--layouts/partials/_skwad-header.html181
-rw-r--r--layouts/partials/body-article-content.html4
-rw-r--r--layouts/shortcodes/c/show.html4
7 files changed, 207 insertions, 31 deletions
diff --git a/layouts/partials/_checklist-footer.html b/layouts/partials/_checklist-footer.html
deleted file mode 100644
index 009e6fc..0000000
--- a/layouts/partials/_checklist-footer.html
+++ /dev/null
@@ -1,8 +0,0 @@
-{{if .Params.checklist}}
- </form>
- <div class="checklist-footer">
- <button type="button"
- onclick="downloadFile('6d2ab01b-fad4-4e70-83a8-b910ca848fec');"
- class="btn btn-success"><i class="fas fa-download"></i>&nbsp;{{T "checklist-download-answers"}}</button>
- </div>
-{{end}}
diff --git a/layouts/partials/_checklist-header.html b/layouts/partials/_checklist-header.html
deleted file mode 100644
index 4426680..0000000
--- a/layouts/partials/_checklist-header.html
+++ /dev/null
@@ -1,16 +0,0 @@
-{{if .Params.checklist}}
- {{ $formID := .File.UniqueID }}
- <link rel="stylesheet" href='{{ (resources.Get "sass/checklist.scss" | resources.ExecuteAsTemplate "css/checklist.main.scss" . | toCSS).Permalink }}'>
- <form name="{{$formID}}" id="6d2ab01b-fad4-4e70-83a8-b910ca848fec" ref="{{with $.Params.Ref}}{{.}}{{else}}{{printf "%s-%s" $.CurrentSection.Title $formID}}{{end}}">
- <script src='{{"js/checklist.js" | relURL}}'></script>
- <script type="text/javascript">
- $( document ).ready(function() {
- listenFormChange('6d2ab01b-fad4-4e70-83a8-b910ca848fec')
- });
- </script>
-
- <div class="form-group checklist-header">
- <label class="sr-only" for="inputFile">File Upload</label>
- <input type="file" class="form-control-file text-primary font-weight-bold" id="inputFile" accept="application/json" onchange="onChooseFile(event,fillForm('6d2ab01b-fad4-4e70-83a8-b910ca848fec'))" data-title="{{T "checklist-load-answers"}}">
- </div>
-{{end}} \ No newline at end of file
diff --git a/layouts/partials/_menu.html b/layouts/partials/_menu.html
index 658274e..148bb6d 100644
--- a/layouts/partials/_menu.html
+++ b/layouts/partials/_menu.html
@@ -20,8 +20,7 @@
{{if lt $level $maxlevel }}
{{- with .sect}}
{{- if and .IsSection (or (not .Params.hidden) $.showhidden)}}
- {{- $numberOfPages := (len .Sections) }}
- {{- $numberOfPages := (len (where .Sections "Params.subpage" "ne" true)) }}
+ {{- $numberOfPages := (len (where (where .Sections "Params.subpage" "ne" true) "Params.hidden" "ne" true )) }}
{{- safeHTML .Params.head}}
<li data-nav-id="{{.Permalink}}" class="dd-item
{{- if .IsAncestor $currentNode}} parent{{end}}
@@ -37,7 +36,6 @@
{{if gt $level 0 }}
<a href="{{ .RelPermalink}}">{{safeHTML .Params.Pre}}{{$menuTitle}}{{safeHTML .Params.Post}}</a>
{{end}}
-
{{- if and (ne $numberOfPages 0) (lt (add $level 1) $maxlevel) }}
{{- if or (.IsAncestor $currentNode) (.Params.alwaysopen) }}
<i class="fas fa-chevron-down ddexp"></i>
diff --git a/layouts/partials/_skwad-footer.html b/layouts/partials/_skwad-footer.html
new file mode 100644
index 0000000..da9c5bd
--- /dev/null
+++ b/layouts/partials/_skwad-footer.html
@@ -0,0 +1,21 @@
+{{if .Params.skwad}}
+ <span></span>
+
+ {{if ne nil .Params.skwad.mode }}
+ <div class="checklist-footer">
+ <button type="submit" class="btn btn-primary">{{T "checklist-post-answers"}}</button>
+ <p>&nbsp;</p>
+ </div>
+ {{end}}
+
+ </form>
+ {{if eq true .Params.skwad.clientside}}
+ {{if .Params.skwad.url }}
+ <div class="checklist-footer">
+ <button type="button"
+ onclick="skwad.saveDocumentAsFile(skwad.form.getAttribute('ref'));"
+ class="btn btn-success"><i class="fas fa-download"></i>&nbsp;{{T "checklist-download-answers"}}</button>
+ </div>
+ {{end}}
+ {{end}}
+{{end}} \ No newline at end of file
diff --git a/layouts/partials/_skwad-header.html b/layouts/partials/_skwad-header.html
new file mode 100644
index 0000000..b0d2877
--- /dev/null
+++ b/layouts/partials/_skwad-header.html
@@ -0,0 +1,181 @@
+{{if .Params.skwad}}
+ {{ $formID := .File.UniqueID }}
+ <link rel="stylesheet" href='{{ (resources.Get "sass/checklist.scss" | resources.ExecuteAsTemplate "css/checklist.main.scss" . | toCSS).Permalink }}'>
+
+ {{if .Params.skwad.url }}
+ <script src="{{.Params.skwad.url }}x/skwad.js"></script>
+ <script type="text/javascript">
+ skwad_api_url = "/";
+ skawd_form_id = "";
+
+ $(document).ready(function () {
+ skwad.InitWithConfig({
+ formID: "{{$formID}}", // default is the first form
+ {{if eq "api" .Params.skwad.mode }}
+ {{with .Params.skwad.url}}url: "{{.}}",{{end}}
+ {{with .Params.skwad.spaceName}}spaceName: "{{.}}", {{end}} // default null, use form attribute action when not set
+ {{end}}
+ // networkIndicatorID: "skwad_spinner", // loader HTLML DOM ID
+ // documentKey: "forms/test", // when set, skwad.UseDocument('forms/flksdjml')
+ // documentKeyInParam: "_k", // when set, skwad.UseDocumentWithURLParam('_k')
+ // onSaveError: skwad.redirectTo("error.html"), // Trigger this func on Error
+ // onSaveSuccess: skwad.redirectTo("confirm.html"), // Trigger this func on Success
+ onUseDocumentError: function (err) {
+ console.log("Document not found ! error is : " + err.message);
+ },
+ //beforeFormSubmit:function(e,s){alert("before",e,s);e.preventDefault();return false},
+ //formChangeHooks: [YourFunc],
+ });
+
+ function YourFunc(progress, form) {
+ // Remove all from ul
+ // console.debug(progress)
+ $("#TableOfContents > ul li").remove();
+ let inputs;
+ for (const section in progress) {
+ inputs = progress[section].inputs;
+ const pct = Math.round(
+ (progress[section].status.valued /
+ progress[section].status.count) *
+ 100
+ );
+ const li = $("<li/>").attr("progres", pct).appendTo($("#TableOfContents > ul"));
+ // if (!isNaN(pct)) {
+ // const chk = $(
+ // '<input type="checkbox" disabled="" readonly="">'
+ // ).appendTo(li);
+ // if (pct === 100) {
+ // chk.prop("checked", true);
+ // li.addClass('cl-done');
+ // } else if (pct > 0) {
+ // chk.prop("indeterminate", true);
+ // li.addClass('cl-doing');
+ // } else {
+ // chk.prop("checked", false);
+ // li.addClass('cl-ready');
+ // }
+ // }
+
+
+
+ if (!isNaN(pct)) {
+ const chk = $(
+ '<i class="fas">'
+ ).appendTo(li);
+ if (pct === 100) {
+ chk.addClass('fa-check-circle');
+ } else if (pct > 0) {
+ chk.addClass('fa-dot-circle');
+ } else {
+ chk.prop("checked", false);
+ chk.addClass('fa-circle-notch');
+ }
+ }
+
+ // <i class="fas fa-check-circle"></i>
+ // <i class="fas fa-dot-circle"></i>
+ // <i class="fas fa-exclamation-circle"></i>
+ // <i class="fas fa-circle-notch"></i>
+
+
+ $("<a/>")
+ .attr("id", "toc-" + progress[section].id)
+ .attr("href", "#" + progress[section].ref)
+ .text(progress[section].title)
+ .appendTo(li);
+ }
+ }
+ skwad.HookOnFormChange(YourFunc);
+
+ (function scrollSpy() {
+ var OFFSET = 10;
+ var timer;
+ var headingsCache;
+
+ var findHeadings = function findHeadings() {
+ // return headingsCache || document.querySelectorAll('.TableOfContents li > a');
+ return document.querySelectorAll('.TableOfContents li > a');
+ };
+
+ var onScroll = function onScroll() {
+ if (timer) {
+ // throttle
+ return;
+ }
+
+ timer = setTimeout(function() {
+ timer = null;
+ var activeNavFound = false;
+ var headings = findHeadings(); // toc nav anchors
+
+ /**
+ * On every call, try to find header right after <-- next header
+ * the one whose content is on the current screen <-- highlight this
+ */
+
+ for (var i = 0; i < headings.length; i++) {
+ // headings[i] is current element
+ // if an element is already active, then current element is not active
+ // if no element is already active, then current element is active
+ var currNavActive = !activeNavFound;
+ /**
+ * Enter the following check up only when an active nav header is not yet found
+ * Then, check the bounding rectangle of the next header
+ * The headers that are scrolled passed will have negative bounding rect top
+ * So the first one with positive bounding rect top will be the nearest next header
+ */
+
+ if (currNavActive && i < headings.length - 1) {
+ var heading = headings[i + 1];
+ var next = decodeURIComponent(heading.href.split('#')[1]);
+ var nextHeader = document.getElementById(next);
+
+ if (nextHeader) {
+ var top = nextHeader.getBoundingClientRect().top;
+ currNavActive = top > OFFSET;
+ } else {
+ console.error('Can not find header element', {
+ id: next,
+ heading: heading,
+ });
+ }
+ }
+ /**
+ * Stop searching once a first such header is found,
+ * this makes sure the highlighted header is the most current one
+ */
+
+ if (currNavActive) {
+ activeNavFound = true;
+ headings[i].parentElement.classList.add('active');
+ } else {
+ headings[i].parentElement.classList.remove('active');
+ }
+ }
+ }, 100);
+ };
+
+ document.addEventListener('scroll', onScroll);
+ document.addEventListener('resize', onScroll);
+ // document.addEventListener('DOMContentLoaded', function() {
+ // // Cache the headings once the page has fully loaded.
+ // headingsCache = findHeadings();
+ // onScroll();
+ // });
+ })();
+ });
+ </script>
+ {{end}}
+ <form
+ method="POST" {{if eq "form" .Params.skwad.mode}}action="{{.Params.skwad.url}}"{{end}}
+ id="{{$formID}}" ref="{{with $.Params.Ref}}{{.}}{{else}}{{printf "%s-%s" $.CurrentSection.Title $formID}}{{end}}">
+
+
+ {{if eq true .Params.skwad.clientside}}
+ <div class="form-group checklist-header">
+ <label class="sr-only" for="inputFile">File Upload</label>
+ <input type="file" class="form-control-file text-primary font-weight-bold" id="inputFile" accept="application/json"
+ onchange="skwad.UseDocumentWithFile(this)" data-title="{{T "checklist-load-answers"}}">
+ </div>
+ {{end}}
+{{end}} \ No newline at end of file
diff --git a/layouts/partials/body-article-content.html b/layouts/partials/body-article-content.html
index 73f2abf..93e1dfb 100644
--- a/layouts/partials/body-article-content.html
+++ b/layouts/partials/body-article-content.html
@@ -75,9 +75,9 @@
<div class="content">
{{- with .Content -}}
- {{ partial "_checklist-header.html" $ }}
+ {{ partial "_skwad-header.html" $ }}
{{ . | replaceRE "(<h[1-9]) id=\"([^\"]+)\"(.+)(</h[1-9]+>)" `${1} ref="${2}" ${3}${4}<a class="anchor" id="${2}"></a>` | safeHTML }}
- {{ partial "_checklist-footer.html" $ }}
+ {{ partial "_skwad-footer.html" $ }}
{{- else -}}
{{with index .Pages 0}}
<meta http-equiv = "refresh" content = "0; url = {{.RelPermalink}}"/>
diff --git a/layouts/shortcodes/c/show.html b/layouts/shortcodes/c/show.html
index 830c784..8f854bd 100644
--- a/layouts/shortcodes/c/show.html
+++ b/layouts/shortcodes/c/show.html
@@ -1,13 +1,13 @@
{{ $random := delimit (shuffle (split (md5 .Page.File.UniqueID) "" )) "" }}
{{ $id := printf "dp-show-%s" $random}}
{{ $condition := trim (.Get 0) " "}}
-{{ $regFormValue := printf "formValue('$1')"}}
+{{ $regFormValue := printf "skwad.fValue('$1')"}}
{{ $conditionFix := replaceRE `{(\w+)}` $regFormValue $condition }}
{{ $conditionFix = replace $conditionFix ` and ` ` && ` }}
{{ $conditionFix = replace $conditionFix ` or ` ` || ` }}
{{ $conditionFix = replaceRE `[^)]+has\s+('\w+')` ".includes($1)" $conditionFix }}
-<div id="{{$id}}" class="baz" style="display:none" cond="{{$conditionFix | safeHTMLAttr}}">
+<div id="{{$id}}" class="baz" style="display:none" v-if="{{$conditionFix | safeHTMLAttr}}">
{{with .Get 1}}
<input type="hidden" value="true" name="{{.}}">
{{end}}