small fixes

This commit is contained in:
teldra 2022-06-13 00:59:41 +02:00
parent 66124b6a2d
commit c6e0df5018
3 changed files with 16 additions and 32 deletions

View File

@ -19,39 +19,11 @@ forms:
input_type: text
name: "Beschreibung/Summary"
placeholder: "Wir feiern die 300jährige Tour und können das mit ca 30 Worten umreissen."
- title: headline
input_type: buttons
name: "Überschrift"
target: "content"
- title: url
input_type: buttons
name: "URL"
target: "content"
- title: pic
input_type: buttons
name: "Bild"
target: "content"
- title: bold
input_type: buttons
name: "Fett"
target: "content"
- title: paragraph
input_type: buttons
name: "Absatz"
target: "content"
- title: newline
input_type: buttons
name: "Neue Zeile"
target: "content"
- title: more
input_type: buttons
name: "More"
target: "content"
- title: content
input_type: textarea
name: "Inhalt"
buttons: "headline,Überschrift;url,URL;pic,Bild;bold,Fett;paragraph,Absatz;newline,Neue Zeile;more,Mehr"
button_target: content
required: true
placeholder: "Einfach losschreiben. Der erste Absatz wird die Zusammenfassung in Artikelübersichten. Denke an die Formatierungshilfe hinter dem Link oben."
- title: categories

View File

@ -27,6 +27,15 @@
{{ else if eq .input_type "textarea" }}
<div class="w100 {{ if .group }} visibleIf margin_left_1rem" data-visibleif-rule="{{ .group }}group == 'true' {{ end }}">
<label class="w100 {{ if $pageform.names }}sr-only{{ end }}" for="{{ .title }}">{{- $name -}}{{- if .required -}}{{- " *" -}}{{- end -}}</label>
{{ $button_target := .button_target }}
{{ range split .buttons ";"}}
{{ $b := split . ","}}
{{ $name := index $b 0 }}
{{ $translation := index $b 1 }}
{{ $nn := printf "%s-%s" $button_target $name}}
{{ $nn }}
<button onclick="button({{ $nn }})" value="{{ $name }}">{{ $translation }}</button>
{{ end }}
<textarea class="w100" name="{{ .title }}" id="{{ .title }}" rows="10" {{ if .placeholder }}placeholder="{{ .placeholder }}"{{ end }}></textarea>
</div>
{{ else if eq .input_type "radio" }}

View File

@ -28,8 +28,10 @@ function typeInTextarea(newText, el = document.getElementById('content')) {
el.setRangeText(newText, start, end);
}
function button(x) {
const id = document.getElementById('content');
function button(str) {
const arr = str.split("-");
let target = arr[0];
let x = arr[1];
if (x == "url") {
let url = prompt("Please enter URL", "https://wikipedia.org");
if (url != null) {
@ -63,6 +65,7 @@ function button(x) {
}
if (out != null) {
typeInTextarea(out);
const id = document.getElementById(target);
const end = id.value.length;
id.setSelectionRange(end, end);
id.focus();