1
1
Fork 0

Some form styling + fixed tag input logic

dev
Jan Kužílek 5 years ago
parent 47add9d8e8
commit 1480d111b1

@ -20,6 +20,24 @@
//"--no-reload" //"--no-reload"
], ],
"jinja": true "jinja": true
},
{
"name": "Python: Flask, Public",
"type": "python",
"request": "launch",
"module": "flask",
"env": {
"FLASK_APP": "yadc",
"FLASK_ENV": "development",
"FLASK_DEBUG": "1"
},
"args": [
"run",
"--host=0.0.0.0",
//"--no-debugger",
//"--no-reload"
],
"jinja": true
} }
] ]
} }

@ -53,6 +53,8 @@ def create_app():
with app.app_context(): with app.app_context():
assets.append_path(os.path.join(app.root_path, 'assets')) assets.append_path(os.path.join(app.root_path, 'assets'))
assets.append_path(os.path.join(app.root_path, 'assets/css'))
assets.append_path(os.path.join(app.root_path, 'assets/js'))
# print(assets.load_path) # print(assets.load_path)
#assets.url = app.static_url_path #assets.url = app.static_url_path
scss = AssetsBundle( scss = AssetsBundle(
@ -61,7 +63,7 @@ def create_app():
assets.register('scss_all', scss) assets.register('scss_all', scss)
js = AssetsBundle( js = AssetsBundle(
'formswitchers.js', 'base.js', 'formswitchers.js', 'base.js',
'search.js', 'taginput.js',
# filters='rjsmin', # filters='rjsmin',
output='all.js') output='all.js')
assets.register('js_all', js) assets.register('js_all', js)

@ -22,6 +22,8 @@
width: 250px; width: 250px;
padding: 10px; padding: 10px;
list-style-type: none;
&:not(:first-child) { &:not(:first-child) {
margin-bottom: 10px; margin-bottom: 10px;
} }
@ -41,16 +43,22 @@
} }
} }
h2 {
margin: 0;
margin-bottom: .5em;
// font-size: 1.3em;
}
h3 { h3 {
margin: 0; margin: 0;
margin-bottom: 1em; margin-bottom: .5em;
font-size: 1.3em; font-size: 1.3em;
} }
h4 { h4 {
margin: 0; margin: 0;
margin-bottom: .8em; margin-bottom: .8em;
margin-top: .4em;
} }
.comment-form { .comment-form {
@ -62,14 +70,14 @@ h4 {
box-shadow: none; box-shadow: none;
} }
textarea { // textarea {
width: 100%; // width: 100%;
background: #444a; // background: #444a;
border: none; // border: none;
color: inherit; // color: inherit;
font: inherit; // font: inherit;
} // }
} }
.editingable { .editingable {
@ -85,49 +93,140 @@ h4 {
} }
} }
input[type=text], textarea { input[type=text], input[type=password], textarea {
background: #444a;
border: 1px solid #444;
color: inherit;
// font: inherit;
display: block;
padding: .5em;
margin: .3em 0;
}
input[type=text], input[type=password] {
width: 100%;
// max-width: 25em;
}
textarea {
resize: vertical; resize: vertical;
width: 100%; width: 100%;
}
input[type=submit] {
background: #444a;
border: 2px solid #666a;
border-radius: 4px;
&.edit, .edit & { &:active {
background: #444a; background: #000a;
border: none; border: 2px solid #444a;
color: inherit; }
font: inherit;
color: inherit;
padding: .4em 1.8em;
}
label {
padding: .4em;
// width: 100%; // DOESN'T WORK?
}
.baseform, .pageform {
input[type=text], input[type=password], textarea {
width: 100%;
}
input[type=checkbox] {
margin: .5em;
}
input[type=submit] {
margin: .2em 0;
}
form > input, form > div {
margin: .8em 0;
}
div.row {
padding: .2em;
display: flex;
align-items: center;
&.stretch {
justify-content: space-between;
}
}
ul {
padding: 0;
margin: 0;
li {
list-style-type: none;
}
} }
} }
.pageform {
// border: 1px solid white;
// padding: 1.5em;
padding: 1em;
form .tag_input, .tag_input form { width: 300px;
margin: 0 auto;
}
form .tag-input, .tag-input form {
.tag-suggester { .tag-suggester {
width: calc(100% - 50px); // width: calc(100% - 50px);
width: 100%;
position: relative; position: relative;
// input[type=text] { // input[type=text] {
// width: 100%; // width: 100%;
// } // }
> .tag_suggest_dropdown { > .suggest-dropdown {
display: flex; display: flex;
flex-flow: column nowrap;
// flex-flow: column nowrap;
align-items: start; align-items: start;
// width: 100%; width: 100%;
top: 100%; top: 100%;
left: 0; // left: 0;
position: absolute; position: absolute;
z-index: 10; z-index: 10;
overflow: auto; overflow: auto;
background-color: #2d2d2de0; background-color: #2d2d2de0;
&:not(:empty) {
padding: .2em;
}
} }
} }
.tag-container { .tag-container {
display: flex; display: flex;
flex-flow: row wrap;
// &:not(:empty) {
// padding: .2em;
// }
&:empty {
display: none;
}
> a { > a {
margin: 2px 2px; margin: .2em;
// margin: 2px 2px;
// padding: .4em .75em; // padding: .4em .75em;
padding: .35em .6em; padding: .35em .6em;
@ -172,7 +271,7 @@ form .tag_input, .tag_input form {
} }
} }
form { // form {
// margin: 0 auto; // margin: 0 auto;
// width: 300px; // width: 300px;
//text-align: center; //text-align: center;
@ -211,13 +310,13 @@ form {
// width: unset; // width: unset;
// } // }
input { // input {
margin: 5px 0; // margin: 5px 0;
//font-size: 1em; //font-size: 1em;
&:not([type=checkbox]):not([type=submit]):not([type=radio]):not([type=file]) { // &:not([type=checkbox]):not([type=submit]):not([type=radio]):not([type=file]) {
// width: 100%; // width: 100%;
} // }
// &[type=file] { // &[type=file] {
// //display: none; // //display: none;
@ -245,7 +344,7 @@ form {
// width: unset; // width: unset;
// margin: .2rem; // margin: .2rem;
// } // }
} // }
// select { // select {
// @extend .fb-select; // @extend .fb-select;
// -moz-appearance: none; // -moz-appearance: none;
@ -253,4 +352,4 @@ form {
// margin: 0; // margin: 0;
// // width: 100%; // // width: 100%;
// } // }
} //}

@ -1,18 +1,12 @@
.main-wrap { .main-wrap {
$bp-desktop: ">=desktop";
$bp-tablet: "<desktop";
margin: 0 auto; margin: 0 auto;
max-width: 1300px; max-width: 1300px;
$main-wrap-padding: 8px;
padding: $main-wrap-padding; padding: $main-wrap-padding;
padding-top: 0; padding-top: 0;
padding-bottom: 0; padding-bottom: 0;
// $sidepanel-width: 14rem;
$sidepanel-width: 18rem;
.important-subwrap { .important-subwrap {
display: flex; display: flex;
@include media($bp-tablet) { @include media($bp-tablet) {
@ -33,23 +27,40 @@
} }
padding: 10px; padding: 10px;
article { article:not(:last-child) {
margin-bottom: 10px; margin-bottom: 10px;
} }
article.tags { article.tags, article.post-edit {
@include media($bp-tablet) { @include media($bp-tablet) {
.tag-container { .tag-container /*:not(.suggest-dropdown)*/ {
flex-flow: row wrap; flex-flow: row wrap;
} }
} }
@include media($bp-desktop) { @include media($bp-desktop) {
.tag-container { .tag-container /*:not(.suggest-dropdown)*/ {
flex-flow: column nowrap; flex-flow: column nowrap;
align-items: start; align-items: start;
} }
.suggest-dropdown {
flex-flow: row wrap;
a {
width: 100%;
}
}
}
}
article.rating {
ul {
padding: 0;
li {
list-style-type: none;
}
} }
} }
@ -199,6 +210,12 @@
} }
} }
} }
section.manage-profile {
@include media($bp-desktop) {
margin-right: $sidepanel-width;
}
}
.pagin { .pagin {
margin: 10px 0; margin: 10px 0;

@ -1,4 +1,5 @@
@import "_include-media"; // @import "_include-media";
@import "vendor/include-media";
$breakpoints: (tablet: 560px, desktop: 900px); $breakpoints: (tablet: 560px, desktop: 900px);
$bg-color: #222; //#20141f; $bg-color: #222; //#20141f;
@ -9,6 +10,13 @@ $ahover-color: #909090;
//$notif-bg-color: #542772d0; //$notif-bg-color: #542772d0;
$notif-bg-color: #000c; $notif-bg-color: #000c;
$bp-desktop: ">=desktop";
$bp-tablet: "<desktop";
$main-wrap-padding: 8px;
// $sidepanel-width: 14rem;
$sidepanel-width: 18rem;
@import "base-types"; @import "base-types";
@import "header"; @import "header";
@import "default"; @import "default";

@ -0,0 +1,211 @@
// https://stackoverflow.com/questions/8486099/how-do-i-parse-a-url-query-parameters-in-javascript
function getJsonFromUrl(url) {
if(!url) url = location.search;
var query = url.substr(1);
var result = {};
query.split("&").forEach(function(part) {
var item = part.split("=");
result[item[0]] = decodeURIComponent(item[1]);
});
return result;
}
function create_selection_tag(tagname) { // CLEAR
let tag = document.createElement("a")
tag.classList.add("tagselected")
tag.dataset.tagname = tagname
tag.insertAdjacentHTML("beforeend", `
<span class="fa fa-tag"></span>
<span class="name"></span>
<span class="fa fa-close close"></span>
`)
tag.querySelector("span.name").textContent = tagname.replace(/_/g, ' ')
// tag.querySelector("input[type=hidden]").setAttribute('name', `tag#${tagname}`)
return tag
}
// Suggestions
function create_suggestion_tag(tagname) { // CLEAR
let tag = document.createElement("a")
tag.classList.add("tagsuggestion")
tag.dataset.tagname = tagname
tag.insertAdjacentHTML("beforeend", `
<span class="fa fa-tag"></span>
<span class="name"></span>
<span class="fa fa-plus plus"></span>
`)
tag.querySelector("span.name").textContent = tagname.replace(/_/g, ' ')
return tag
}
let taginputs = document.querySelectorAll('.tag-input')
taginputs.forEach(function (tinput) {
'use strict'
try {
let selected = tinput.querySelector('.tags-selected')
let predef = tinput.querySelector('.tags-inpage')
let suggestroot = tinput.querySelector('.tag-suggester')
suggestroot.insertAdjacentHTML("beforeend", `<input type="hidden" name="${suggestroot.dataset.inputname}">`)
let hidden_input = suggestroot.querySelector(`input[name=${suggestroot.dataset.inputname}][type=hidden]`)
let suggest_input = suggestroot.querySelector(`input[name=${suggestroot.dataset.inputname}][type=text]`)
suggest_input.removeAttribute('name')
if (suggest_input.hasAttribute('required')) {
suggest_input.removeAttribute('required')
hidden_input.setAttribute('required', '')
}
suggest_input.removeAttribute('value') // Disable prefill by browser
let suggest_dropdown = suggestroot.querySelector('.suggest-dropdown')
function hidden_addtag(tagname) { // 1 reference
let hid_input = hidden_input
let val = hid_input.value.split(' ')
val.push(tagname)
hid_input.value = val.join(' ').trim()
}
function hidden_removetag(tagname) { // 1 reference
let hid_input = hidden_input
let val = hid_input.value.split(' ')
val.splice(val.indexOf(tagname), 1)
hid_input.value = val.join(' ').trim()
}
function add_selected(tagname) { // 2 references
let predf = predef
let sel = selected
if (predf) {
let pagetag = predf.querySelector(`a[data-tagname=${tagname}]`)
if (pagetag) {
pagetag.classList.add('tag_hide')
}
}
let newtag = create_selection_tag(tagname)
newtag.addEventListener('click', (event) => {
remove_selected(event.target.dataset.tagname)
// console.log(`Deselected: ${event.target.dataset.tagname}`)
})
sel.appendChild(newtag)
hidden_addtag(tagname)
}
function remove_selected(tagname) { // 2 references
let predf = predef
let sel = selected
if (predf) {
let pagetag = predf.querySelector(`a[data-tagname=${tagname}]`)
if (pagetag) {
pagetag.classList.remove('tag_hide')
}
}
sel.querySelector(`a[data-tagname=${tagname}]`).remove()
hidden_removetag(tagname)
}
// Page tags click to select
if (predef) {
predef.querySelectorAll("a").forEach(element => {
element.addEventListener('click', (event) => {
add_selected(event.target.dataset.tagname)
event.preventDefault()
})
})
}
// Generate selected by url query
let query = getJsonFromUrl()
if (query['tags']) {
query['tags'].split('+').forEach((tag) => {
add_selected(tag)
})
}
function render_suggestions(data) { // 3 references
let drop = suggest_dropdown
let sel = selected
let sug_input = suggest_input
drop.innerHTML = ''
let tagnames = Array.from(sel.querySelectorAll('a')).map(a => a.dataset.tagname)
let i = 0
data.forEach((el) => {
if (i > 5) return
if (tagnames.includes(el.content)) return
let sugtag = create_suggestion_tag(el.content)
sugtag.addEventListener('click', (event) => {
add_selected(event.target.dataset.tagname)
sug_input.value = ''
render_suggestions([])
event.preventDefault()
})
drop.appendChild(sugtag)
i++
});
}
// Ajax suggestion handler
var ajax_timeout
suggest_input.addEventListener('input', (event) => {
clearTimeout(ajax_timeout)
let value = suggest_input.value.replace(/ /g, '_').trim()
if (value.length < 2) {
render_suggestions([])
return
}
ajax_timeout = setTimeout(() => {
fetch('/post/tags?q='+value).then((response) => {
console.log(response)
return response.json()
}).then((data) => {
// fill suggestions
// console.log(data)
render_suggestions(data)
})
}, 500)
})
// search_input.addEventListener('keypress', (event) => {
// if (event.keyCode == 13) {
// // event.preventDefault()
// }
// })
// search_input.addEventListener('blur', (event) => {
// if (event.explicitOriginalTarget != null) {
// classlist = event.explicitOriginalTarget.parentNode.classList
// if (classlist.contains('tags_selected') || classlist.contains('tags_inpage') || classlist.contains('search_dropdown')) {
// setTimeout(() => search_input.focus(), 2)
// }
// }
// console.log(event)
// })
// page_tags.querySelectorAll('a').forEach((el) => el.removeAttribute('href'))
} catch (error) {
console.log(error)
}
})

@ -34,6 +34,7 @@ def logout():
if fl.current_user.is_authenticated: if fl.current_user.is_authenticated:
fl.current_user.logout() fl.current_user.logout()
flash('Successfully logged out.')
return redirect(nextpage()) return redirect(nextpage())
@bp.route('/reset_password', methods=['GET', 'POST']) @bp.route('/reset_password', methods=['GET', 'POST'])

File diff suppressed because one or more lines are too long

@ -55,26 +55,6 @@ document.getElementById("user-menu").addEventListener('click', (ev) => {
drop.classList.remove("_drop") drop.classList.remove("_drop")
} }
}) })
let tagroot = document.querySelector('.tag_input')
let sel_tags = tagroot.querySelector('div.tags_selected')
let predef_tags = tagroot.querySelector('div.tags_inpage') // Should be optional
let suggestroot = tagroot.querySelector('.tag_suggester')
suggestroot.insertAdjacentHTML("beforeend", `<input type="hidden" name="${suggestroot.dataset.inputname}">`)
let suggest_hidden = suggestroot.querySelector(`input[name=${suggestroot.dataset.inputname}][type=hidden]`)
let suggest_input = suggestroot.querySelector(`input[name=${suggestroot.dataset.inputname}][type=text]`)
suggest_input.removeAttribute('name')
if (suggest_input.hasAttribute('required')) {
suggest_input.removeAttribute('required')
suggest_hidden.setAttribute('required', '')
}
// suggest_input.value = ''
suggest_input.removeAttribute('value')
let tag_suggest_dropdown = suggestroot.querySelector('.tag_suggest_dropdown')
// https://stackoverflow.com/questions/8486099/how-do-i-parse-a-url-query-parameters-in-javascript // https://stackoverflow.com/questions/8486099/how-do-i-parse-a-url-query-parameters-in-javascript
function getJsonFromUrl(url) { function getJsonFromUrl(url) {
if(!url) url = location.search; if(!url) url = location.search;
@ -87,7 +67,7 @@ function getJsonFromUrl(url) {
return result; return result;
} }
function create_selection_tag(tagname) { function create_selection_tag(tagname) { // CLEAR
let tag = document.createElement("a") let tag = document.createElement("a")
tag.classList.add("tagselected") tag.classList.add("tagselected")
tag.dataset.tagname = tagname tag.dataset.tagname = tagname
@ -102,65 +82,8 @@ function create_selection_tag(tagname) {
return tag return tag
} }
function form_addtag(tagname) {
let val = suggest_hidden.value.split(' ')
val.push(tagname)
suggest_hidden.value = val.join(' ').trim()
}
function form_removetag(tagname) {
let val = suggest_hidden.value.split(' ')
val.splice(val.indexOf(tagname), 1)
suggest_hidden.value = val.join(' ').trim()
}
function add_selected(tagname) {
if (predef_tags) {
let pagetag = predef_tags.querySelector(`a[data-tagname=${tagname}]`)
if (pagetag) {
pagetag.classList.add('tag_hide')
}
}
let newtag = create_selection_tag(tagname)
newtag.addEventListener('click', (event) => {
remove_selected(event.target.dataset.tagname)
// console.log(`Deselected: ${event.target.dataset.tagname}`)
})
sel_tags.appendChild(newtag)
form_addtag(tagname)
}
function remove_selected(tagname) {
if (predef_tags) {
let pagetag = predef_tags.querySelector(`a[data-tagname=${tagname}]`)
if (pagetag) {
pagetag.classList.remove('tag_hide')
}
}
sel_tags.querySelector(`a[data-tagname=${tagname}]`).remove()
form_removetag(tagname)
}
// Page tags click to select
if (predef_tags) {
predef_tags.querySelectorAll("a").forEach(element => {
element.addEventListener('click', (event) => {
add_selected(event.target.dataset.tagname)
event.preventDefault()
})
})
}
// Generate selected by url query
let query = getJsonFromUrl()
if (query['tags']) {
query['tags'].split('+').forEach((tag) => {
add_selected(tag)
})
}
// Suggestions // Suggestions
function create_suggestion_tag(tagname) { function create_suggestion_tag(tagname) { // CLEAR
let tag = document.createElement("a") let tag = document.createElement("a")
tag.classList.add("tagsuggestion") tag.classList.add("tagsuggestion")
tag.dataset.tagname = tagname tag.dataset.tagname = tagname
@ -173,66 +96,173 @@ function create_suggestion_tag(tagname) {
tag.querySelector("span.name").textContent = tagname.replace(/_/g, ' ') tag.querySelector("span.name").textContent = tagname.replace(/_/g, ' ')
return tag return tag
} }
function render_suggestions(data) {
tag_suggest_dropdown.innerHTML = ''
let tagnames = Array.from(sel_tags.querySelectorAll('a')).map(a => a.dataset.tagname)
let i = 0
data.forEach((el) => {
if (i > 5) return
if (tagnames.includes(el.content)) return
let sugtag = create_suggestion_tag(el.content)
sugtag.addEventListener('click', (event) => {
add_selected(event.target.dataset.tagname)
suggest_input.value = ''
render_suggestions([])
event.preventDefault()
})
tag_suggest_dropdown.appendChild(sugtag) let taginputs = document.querySelectorAll('.tag-input')
taginputs.forEach(function (tinput) {
'use strict'
i++ try {
}); let selected = tinput.querySelector('.tags-selected')
} let predef = tinput.querySelector('.tags-inpage')
// Ajax suggestion handler let suggestroot = tinput.querySelector('.tag-suggester')
var ajax_timeout
suggest_input.addEventListener('input', (event) => {
clearTimeout(ajax_timeout)
let value = suggest_input.value.replace(/ /g, '_').trim() suggestroot.insertAdjacentHTML("beforeend", `<input type="hidden" name="${suggestroot.dataset.inputname}">`)
let hidden_input = suggestroot.querySelector(`input[name=${suggestroot.dataset.inputname}][type=hidden]`)
if (value.length < 2) { let suggest_input = suggestroot.querySelector(`input[name=${suggestroot.dataset.inputname}][type=text]`)
render_suggestions([]) suggest_input.removeAttribute('name')
return if (suggest_input.hasAttribute('required')) {
} suggest_input.removeAttribute('required')
hidden_input.setAttribute('required', '')
}
suggest_input.removeAttribute('value') // Disable prefill by browser
let suggest_dropdown = suggestroot.querySelector('.suggest-dropdown')
function hidden_addtag(tagname) { // 1 reference
let hid_input = hidden_input
let val = hid_input.value.split(' ')
val.push(tagname)
hid_input.value = val.join(' ').trim()
}
function hidden_removetag(tagname) { // 1 reference
let hid_input = hidden_input
ajax_timeout = setTimeout(() => { let val = hid_input.value.split(' ')
fetch('/post/tags?q='+value).then((response) => { val.splice(val.indexOf(tagname), 1)
console.log(response) hid_input.value = val.join(' ').trim()
return response.json() }
}).then((data) => {
// fill suggestions function add_selected(tagname) { // 2 references
// console.log(data) let predf = predef
render_suggestions(data) let sel = selected
if (predf) {
let pagetag = predf.querySelector(`a[data-tagname=${tagname}]`)
if (pagetag) {
pagetag.classList.add('tag_hide')
}
}
let newtag = create_selection_tag(tagname)
newtag.addEventListener('click', (event) => {
remove_selected(event.target.dataset.tagname)
// console.log(`Deselected: ${event.target.dataset.tagname}`)
})
sel.appendChild(newtag)
hidden_addtag(tagname)
}
function remove_selected(tagname) { // 2 references
let predf = predef
let sel = selected
if (predf) {
let pagetag = predf.querySelector(`a[data-tagname=${tagname}]`)
if (pagetag) {
pagetag.classList.remove('tag_hide')
}
}
sel.querySelector(`a[data-tagname=${tagname}]`).remove()
hidden_removetag(tagname)
}
// Page tags click to select
if (predef) {
predef.querySelectorAll("a").forEach(element => {
element.addEventListener('click', (event) => {
add_selected(event.target.dataset.tagname)
event.preventDefault()
})
})
}
// Generate selected by url query
let query = getJsonFromUrl()
if (query['tags']) {
query['tags'].split('+').forEach((tag) => {
add_selected(tag)
})
}
function render_suggestions(data) { // 3 references
let drop = suggest_dropdown
let sel = selected
let sug_input = suggest_input
drop.innerHTML = ''
let tagnames = Array.from(sel.querySelectorAll('a')).map(a => a.dataset.tagname)
let i = 0
data.forEach((el) => {
if (i > 5) return
if (tagnames.includes(el.content)) return
let sugtag = create_suggestion_tag(el.content)
sugtag.addEventListener('click', (event) => {
add_selected(event.target.dataset.tagname)
sug_input.value = ''
render_suggestions([])
event.preventDefault()
})
drop.appendChild(sugtag)
i++
});
}
// Ajax suggestion handler
var ajax_timeout
suggest_input.addEventListener('input', (event) => {
clearTimeout(ajax_timeout)
let value = suggest_input.value.replace(/ /g, '_').trim()
if (value.length < 2) {
render_suggestions([])
return
}
ajax_timeout = setTimeout(() => {
fetch('/post/tags?q='+value).then((response) => {
console.log(response)
return response.json()
}).then((data) => {
// fill suggestions
// console.log(data)
render_suggestions(data)
})
}, 500)
}) })
}, 500)
// search_input.addEventListener('keypress', (event) => {
// if (event.keyCode == 13) {
// // event.preventDefault()
// }
// })
// search_input.addEventListener('blur', (event) => {
// if (event.explicitOriginalTarget != null) {
// classlist = event.explicitOriginalTarget.parentNode.classList
// if (classlist.contains('tags_selected') || classlist.contains('tags_inpage') || classlist.contains('search_dropdown')) {
// setTimeout(() => search_input.focus(), 2)
// }
// }
// console.log(event)
// })
// page_tags.querySelectorAll('a').forEach((el) => el.removeAttribute('href'))
} catch (error) {
console.log(error)
}
}) })
// search_input.addEventListener('keypress', (event) => {
// if (event.keyCode == 13) {
// // event.preventDefault()
// }
// })
// search_input.addEventListener('blur', (event) => {
// if (event.explicitOriginalTarget != null) {
// classlist = event.explicitOriginalTarget.parentNode.classList
// if (classlist.contains('tags_selected') || classlist.contains('tags_inpage') || classlist.contains('search_dropdown')) {
// setTimeout(() => search_input.focus(), 2)
// }
// }
// console.log(event)
// })
// page_tags.querySelectorAll('a').forEach((el) => el.removeAttribute('href'))

@ -70,14 +70,14 @@
{% endmacro %} {% endmacro %}
{% macro render_tag_input(input_field) %} {% macro render_tag_input(input_field) %}
<div class="tag_input"> <div class="tag-input">
<div class="tag_suggester" data-inputname="{{ input_field.name }}"> <div class="tag-suggester" data-inputname="{{ input_field.name }}">
<!-- <input type="text" name="tags" autocomplete="off" value="{{ request.args.get('tags') }}"> --> {#<input type="text" name="tags" autocomplete="off" value="{{ request.args.get('tags') }}">#}
{{ input_field() }} {{ input_field() }}
<div class="tag_container tag_suggest_dropdown"></div> <div class="tag-container suggest-dropdown"></div>
</div> </div>
<div class="tag_container tags_selected"></div> <div class="tag-container tags-selected"></div>
</div> </div>
{% endmacro %} {% endmacro %}

@ -2,25 +2,26 @@
{% from "_formhelpers.html" import errors %} {% from "_formhelpers.html" import errors %}
{% block content %} {% block content %}
<form action="" method="post"> <div class="pageform">
<h2>Log In</h2> <h2>Log In</h2>
{{ form.csrf_token }} <form action="" method="post">
<div> {{ form.csrf_token }}
{{ form.username(placeholder="Username") }} {{ form.username(placeholder="Username") }}
{{ errors(form.username) }} {{ errors(form.username) }}
</div>
<div>
{{ form.password(placeholder="Password") }} {{ form.password(placeholder="Password") }}
{{ errors(form.password) }} {{ errors(form.password) }}
</div>
<div> <div class="row">
{{ form.remember_me() }} {{ form.remember_me.label }} {{ form.remember_me() }} {{ form.remember_me.label }}
{{ errors(form.remember_me) }} {{ errors(form.remember_me) }}
</div> </div>
<div> <div class="row stretch">
{{ form.submit() }} {{ form.submit() }}
<a href="{{ url_for('auth.reset_password') }}">Forgotten password?</a> <a href="{{ url_for('auth.reset_password') }}">Forgotten password?</a>
</div> </div>
</form> </form>
</div>
{% endblock content %} {% endblock content %}

@ -2,28 +2,27 @@
{% from "_formhelpers.html" import errors %} {% from "_formhelpers.html" import errors %}
{% block content %} {% block content %}
<form action="" method="post"> <div class="pageform">
<h2>Sign Up</h2> <h2>Sign Up</h2>
{{ form.csrf_token }} <form action="" method="post">
<div> {{ form.csrf_token }}
{{ form.username(placeholder="Username") }} {{ form.username(placeholder="Username") }}
{{ errors(form.username) }} {{ errors(form.username) }}
</div>
<div>
{{ form.email(placeholder="Email address") }} {{ form.email(placeholder="Email address") }}
{{ errors(form.email) }} {{ errors(form.email) }}
</div>
<div>
{{ form.password(placeholder="Password") }} {{ form.password(placeholder="Password") }}
{{ errors(form.password) }} {{ errors(form.password) }}
</div>
<div>
{{ form.password_again(placeholder="Repeat password") }} {{ form.password_again(placeholder="Repeat password") }}
{{ errors(form.password_again) }} {{ errors(form.password_again) }}
</div>
<div> <div>
{{ form.submit() }} {{ form.submit() }}
<a href="{{ url_for('auth.login') }}">Already registered?</a> <a href="{{ url_for('auth.login') }}">Already registered?</a>
</div> </div>
</form> </form>
</div>
{% endblock content %} {% endblock content %}

@ -2,18 +2,16 @@
{% from "_formhelpers.html" import errors %} {% from "_formhelpers.html" import errors %}
{% block content %} {% block content %}
<form action="" method="post"> <div class="pageform">
<h2>Reset password</h2> <h2>Reset password</h2>
<p> <form action="" method="post">
Please insert your email address and we will send you a request for password reset. <p>Please insert your email address and we will send you a request for password reset.</p>
</p> {{ form.csrf_token }}
{{ form.csrf_token }}
<div>
{{ form.email(placeholder="Your email address") }} {{ form.email(placeholder="Your email address") }}
{{ errors(form.email) }} {{ errors(form.email) }}
</div>
<div>
{{ form.submit() }} {{ form.submit() }}
</div> </form>
</form> </div>
{% endblock content %} {% endblock content %}

@ -3,13 +3,15 @@
{% block sidebar %} {% block sidebar %}
<article class="rating"> <article class="rating">
<h3>Rating</h3> <h3>Rating</h3>
<div class="rating-input"> <form action="{{ self.search_endpoint() }}" method="get">
{% for rating in ('safe', 'questionable', 'explicit') %} <ul class="rating-input">
<input type="radio" name="rating" id="rating-{{ rating }}" value="{{ rating }}" {% if rating == session.get('index_settings', {}).get('rating', 'safe') %}checked{% endif %} onclick="submit()"> {% for rating in ('safe', 'questionable', 'explicit') %}
<label for="rating-{{ rating }}">{{ rating.capitalize() }}</label> <li>
<br> <input type="radio" name="rating" id="rating-{{ rating }}" value="{{ rating }}" {% if rating == session.get('index_settings', {}).get('rating', 'safe') %}checked{% endif %} onclick="submit()"><label for="rating-{{ rating }}">{{ rating.capitalize() }}</label>
{% endfor %} </li>
</div> {% endfor %}
</ul>
</form>
</article> </article>
<article class="tags tag_input"> <article class="tags tag_input">
<h3>Search</h3> <h3>Search</h3>
@ -17,7 +19,7 @@
<form action="{% block search_endpoint %}{{ url_for('post.posts') }}{% endblock %}" method="get"> <form action="{% block search_endpoint %}{{ url_for('post.posts') }}{% endblock %}" method="get">
<div class="tag-suggester" data-inputname="tags"> <div class="tag-suggester" data-inputname="tags">
<input type="text" name="tags" autocomplete="off" value="{{ request.args.get('tags', '') }}"> <input type="text" name="tags" autocomplete="off" value="{{ request.args.get('tags', '') }}">
<div class="tag-container tag_suggest_dropdown"></div> <div class="tag-container suggest-dropdown"></div>
</div> </div>
<!-- <input type="submit" value="Search"> --> <!-- <input type="submit" value="Search"> -->
@ -36,7 +38,6 @@
</div> </div>
</form> </form>
</div> </div>
<script src="{{ url_for('static', filename="search.js") }}"></script>
</article> </article>
{% endblock %} {% endblock %}

@ -1,5 +1,5 @@
{% extends 'layout/base_sidebar_tags.html' %} {% extends 'layout/base_sidebar_tags.html' %}
{% from '_includes.html' import render_post_edit, render_tag_input with context %} {% from '_includes.html' import render_tag_input %}
{% from "_formhelpers.html" import errors %} {% from "_formhelpers.html" import errors %}
{% block sidebar %} {% block sidebar %}
@ -33,17 +33,17 @@
{% if post.can_edit %} {% if post.can_edit %}
<article class="post-edit"> <article class="post-edit">
<h3>Edit</h3> <h3>Edit</h3>
<div class="post-editform"> <div class="post-editform baseform">
<form action="{{ url_for('post.editpost') }}" method="post"> <form action="{{ url_for('post.editpost') }}" method="post">
{{ editform.csrf_token }} {{ editform.csrf_token }}
{{ editform.id() }} {{ editform.id() }}
{{ render_tag_input(editform.tags) }}
{{ errors(editform.tags) }}
{{ editform.source }} {{ editform.source }}
{{ errors(editform.source) }} {{ errors(editform.source) }}
{{ render_tag_input(editform.tags) }}
{{ errors(editform.tags) }}
{{ editform.edit() }} {{ editform.edit() }}
</form> </form>
</div> </div>

@ -3,28 +3,36 @@
{% from "_includes.html" import render_tag_input %} {% from "_includes.html" import render_tag_input %}
{% block content %} {% block content %}
<form action="" method="post" enctype="multipart/form-data"> <div class="pageform">
<h2>Upload post</h2> <h2>Upload post</h2>
{{ form.csrf_token }} <form action="" method="post" enctype="multipart/form-data">
<div> {{ form.csrf_token }}
{{ form.post_img.label }} {{ form.post_img() }} <div class="">
{#{{ form.post_img.label }}#}
{{ form.post_img() }}
</div>
{{ errors(form.post_img) }} {{ errors(form.post_img) }}
</div>
<div>
{{ form.sauce() }} {{ form.sauce() }}
{{ errors(form.sauce) }} {{ errors(form.sauce) }}
</div>
<div>
{{ render_tag_input(form.tags) }} {{ render_tag_input(form.tags) }}
<!-- {{ form.tags(placeholder="Tags") }} --> <!-- {{ form.tags(placeholder="Tags") }} -->
{{ errors(form.tags) }} {{ errors(form.tags) }}
</div>
<div> <div>
{{ form.rating.label }} {% for r in form.rating %}<br>{{ r() }} {{ r.label }}{% endfor %} {{ form.rating.label }}
<ul>
{% for r in form.rating %}
<li>
{{ r() }}{{ r.label }}
</li>
{% endfor %}
</ul>
</div>
{{ errors(form.rating) }} {{ errors(form.rating) }}
</div>
<div>{{ form.submit() }}</div>
<script src="{{ url_for('static', filename="search.js") }}"></script> {{ form.submit() }}
</form> </form>
</div>
{% endblock content %} {% endblock content %}

@ -2,77 +2,75 @@
{% from "_formhelpers.html" import errors %} {% from "_formhelpers.html" import errors %}
{% block main_content %} {% block main_content %}
<section class="manage_profile"> <section class="manage-profile">
<form action="{{ url_for('user.change_info') }}" method="post"> <div class="pageform">
<h3>Change user info</h3> <h3>Change user info</h3>
{{ userinfo_form.csrf_token }} <form action="{{ url_for('user.change_info') }}" method="post">
<div> {{ userinfo_form.csrf_token }}
{{ userinfo_form.bio() }}
{{ userinfo_form.bio(placeholder="Enter your description") }}
{{ errors(userinfo_form.bio) }} {{ errors(userinfo_form.bio) }}
</div>
<div>
{{ userinfo_form.userinfo_submit() }} {{ userinfo_form.userinfo_submit() }}
</div> </form>
</form> </div>
<form action="{{ url_for('user.change_pass') }}" method="post"> <div class="pageform">
<h3>Change password</h3> <h3>Change password</h3>
{{ pass_form.csrf_token }} <form action="{{ url_for('user.change_pass') }}" method="post">
<div> {{ pass_form.csrf_token }}
{{ pass_form.password_current(placeholder="Current password") }} {{ pass_form.password_current(placeholder="Current password") }}
{{ errors(pass_form.password_current) }} {{ errors(pass_form.password_current) }}
</div>
<div>
{{ pass_form.password(placeholder="Password") }} {{ pass_form.password(placeholder="Password") }}
{{ errors(pass_form.password) }} {{ errors(pass_form.password) }}
</div>
<div>
{{ pass_form.password_again(placeholder="Repeat password") }} {{ pass_form.password_again(placeholder="Repeat password") }}
{{ errors(pass_form.password_again) }} {{ errors(pass_form.password_again) }}
</div>
<div>
{{ pass_form.pass_submit() }} {{ pass_form.pass_submit() }}
</div> </form>
</form> </div>
<form action="{{ url_for('user.change_mail') }}" method="post"> <div class="pageform">
<h3>Change e-mail address</h3> <h3>Change e-mail address</h3>
{{ mail_form.csrf_token }} <form action="{{ url_for('user.change_mail') }}" method="post">
<div> {{ mail_form.csrf_token }}
{{ mail_form.email() }} {{ mail_form.email() }}
{{ errors(mail_form.email) }} {{ errors(mail_form.email) }}
</div>
<div>
{{ mail_form.email_again() }} {{ mail_form.email_again() }}
{{ errors(mail_form.email_again) }} {{ errors(mail_form.email_again) }}
</div>
<div>
{{ mail_form.mail_submit() }} {{ mail_form.mail_submit() }}
</div> </form>
</form> </div>
<form action="{{ url_for('user.change_rating') }}" method="post"> <div class="pageform">
<h3>Preferred rating</h3> <h3>Preferred rating</h3>
{{ rating_form.csrf_token }} <form action="{{ url_for('user.change_rating') }}" method="post">
<div> {{ rating_form.csrf_token }}
{{ rating_form.rating() }} {{ rating_form.rating() }}
{{ errors(rating_form.rating) }} {{ errors(rating_form.rating) }}
</div>
<div> <noscript>{{ rating_form.rating_submit() }}</noscript>
{{ rating_form.rating_submit() }} </form>
</div> </div>
</form> <div class="pageform">
<form action="{{ url_for('user.delete_data') }}" method="post">
<h3>Delete user data</h3> <h3>Delete user data</h3>
{{ delete_form.csrf_token }} <form action="{{ url_for('user.delete_data') }}" method="post">
<div> {{ delete_form.csrf_token }}
{{ delete_form.all_comments() }}{{ delete_form.all_comments.label }} {{ delete_form.all_comments() }}{{ delete_form.all_comments.label }}
{{ errors(delete_form.all_posts) }} {{ errors(delete_form.all_posts) }}
</div>
<div> <div>
{{ delete_form.all_posts() }}{{ delete_form.all_posts.label }} {{ delete_form.all_posts() }}{{ delete_form.all_posts.label }}
{{ errors(delete_form.all_posts) }} {{ errors(delete_form.all_posts) }}
</div> </div>
<div>
{{ delete_form.delete_submit() }} {{ delete_form.delete_submit() }}
</div> </form>
</form> </div>
</section> </section>
{% endblock %} {% endblock %}
Loading…
Cancel
Save