scroll into view the next step

This commit is contained in:
crunk 2022-03-04 21:10:06 +01:00
parent fc4b1a5c75
commit 0cb57548fa
9 changed files with 49 additions and 10 deletions

View File

@ -1,12 +1,9 @@
from flask_wtf import FlaskForm
from wtforms import SubmitField, SelectField
from distribusimodel import Distribusis
from usermodel import User
from flask_login import current_user
class SelectorForm(FlaskForm):
distribusis = SelectField(u'Your existing distribusi:')
distribusis = SelectField("Your existing distribusi:")
new = SubmitField("new")

View File

@ -43,6 +43,7 @@ from upload import UploadUpdatedFiles
# UserPengguna
from statuspengguna.helper import IsZipUploaded
from statuspengguna.helper import IsCssSelected
from statuspengguna.helper import CurrentDistribusi
from statuspengguna.helper import ResetUserState
from statuspengguna.loginuser import LoginUser
@ -86,6 +87,7 @@ def distribusi():
selectorvisible = SelectorVisible()
current_distribusi = CurrentDistribusi()
files_uploaded = IsZipUploaded(current_distribusi)
css_selected = IsCssSelected(current_distribusi)
user = User.query.filter_by(email=current_user.email).first()
distribusi = Distribusis.query.filter_by(
distribusiname=current_distribusi
@ -122,6 +124,7 @@ def distribusi():
themeform=themeform,
selectorform=selectorform,
files_uploaded=files_uploaded,
css_selected=css_selected,
selectorvisible=selectorvisible,
)
return template
@ -143,7 +146,7 @@ def upload():
else:
uploadform = UploadUpdatedFiles(APP.config["UPLOAD_FOLDER"])
files_uploaded = IsZipUploaded(uploadform.sitename.data)
css_selected = IsCssSelected(current_distribusi)
template = render_template(
"distribusi.html",
uploadform=uploadform,
@ -151,6 +154,7 @@ def upload():
themeform=themeform,
selectorform=selectorform,
files_uploaded=files_uploaded,
css_selected=css_selected,
selectorvisible=selectorvisible,
)
return template
@ -168,7 +172,7 @@ def theme():
selectorvisible = SelectorVisible()
current_distribusi = CurrentDistribusi()
files_uploaded = IsZipUploaded(current_distribusi)
css_selected = IsCssSelected(current_distribusi)
if themeform.validate_on_submit():
newuserfolder = os.path.join("stash", current_distribusi)
copycssfile = os.path.join(
@ -176,6 +180,7 @@ def theme():
"{}.css".format(themeform.theme.data),
)
shutil.copy(copycssfile, newuserfolder)
css_selected = IsCssSelected(current_distribusi)
template = render_template(
"distribusi.html",
@ -184,6 +189,7 @@ def theme():
themeform=themeform,
selectorform=selectorform,
files_uploaded=files_uploaded,
css_selected=css_selected,
selectorvisible=selectorvisible,
)
return template
@ -242,6 +248,7 @@ def selector():
uploadform.tags.data = distribusi.tags
files_uploaded = IsZipUploaded(current_distribusi)
css_selected = IsCssSelected(current_distribusi)
selectorvisible = SelectorVisible()
template = render_template(
@ -251,6 +258,7 @@ def selector():
themeform=themeform,
selectorform=selectorform,
files_uploaded=files_uploaded,
css_selected=css_selected,
selectorvisible=selectorvisible,
)
return template

View File

@ -37,7 +37,6 @@ div#upload form {
margin-top: 1em;
padding: 0.5em;
width: 30em;
border: 3px solid #E0B0FF;
background-color:#383C4A;
text-decoration: none;
scroll-behavior: smooth;

View File

@ -1,5 +1,24 @@
console.log("everything is still smooth")
function scrollToTheme() {
var uploadsuccessful = document.getElementById("uploadsuccessful");
if(uploadsuccessful){
const theme = document.getElementById('theme')
theme.scrollIntoView({ behavior: 'smooth', block: 'start' });
}
}
function scrollToLaunch() {
var cssSelected = document.getElementById("cssSelected");
if(cssSelected){
const launch = document.getElementById('launch')
launch.scrollIntoView({ behavior: 'smooth', block: 'end' });
}
}
document.addEventListener("DOMContentLoaded", scrollToTheme);
document.addEventListener("DOMContentLoaded", scrollToLaunch);
// function(e) {
// (e.keyCode === 13 || e.keyCode === 32) && $(this).trigger("click")
// }

View File

@ -17,6 +17,16 @@ def IsZipUploaded(distribusiname):
return False
def IsCssSelected(distribusiname):
userfolder = os.path.join("stash", distribusiname)
if os.path.exists(userfolder):
for file in os.listdir(userfolder):
if file.endswith(".css"):
return True
print("distribusi folder has no css file")
return False
def HasDistribusi():
user = User.query.filter_by(email=current_user.email).first()
distribusi = Distribusis.query.filter_by(userid=user.id).first()

View File

@ -35,4 +35,7 @@
{% endblock launch%}
{%endif%}
</div>
{% if css_selected %}
<p id="cssSelected" hidden>css selected</p>
{% endif %}
{% endblock main %}

View File

@ -1,6 +1,6 @@
<div id="distribusi" class="workflow">
<div id="launch" class="workflow">
<h3>Step 4: Distribusi</h3>
<p>run distribusi on your files, this will generate your website and make
<p>Run distribusi on your files, this will generate your website and make
your content public.</p>
<form method="POST" enctype="multipart/form-data" action="{{ url_for('distribusi') }}">
{{ distribusiform.csrf_token }}

View File

@ -13,14 +13,17 @@
</div>
</fieldset>
<fieldset class="button required multiselect">
{{ selectorform.update.label }}
{{ selectorform.update }}
</fieldset>
<fieldset class="button required multiselect warning">
{{ selectorform.delete.label }}
{{ selectorform.delete }}
</fieldset>
<p>Alternatively you can make a new site</p>
<fieldset class="button required multiselect">
{{ selectorform.new.label }}
{{ selectorform.new }}
</fieldset>
</form>

View File

@ -54,6 +54,6 @@
</fieldset>
</form>
{% if files_uploaded %}
<p>Your files have been uploaded successfully</p>
<p id="uploadsuccessful">Your files have been uploaded successfully</p>
{% endif %}
</div>