Giant entry qr by default for new polls and trials; it slides and grows between the corner and the big spot
This commit is contained in:
+3
-1
@@ -410,6 +410,8 @@ async def create_poll(request: Request):
|
|||||||
questions = [parse_question(q) for q in (d.get("questions") or [])]
|
questions = [parse_question(q) for q in (d.get("questions") or [])]
|
||||||
pid, admin_key, screen_key = db.create_poll(title, interval, scans, bool(d.get("require_code")),
|
pid, admin_key, screen_key = db.create_poll(title, interval, scans, bool(d.get("require_code")),
|
||||||
expected, max_voters, vote_scans, code_style)
|
expected, max_voters, vote_scans, code_style)
|
||||||
|
# the giant entry qr beside the ring is the default: people open the page from the back rows
|
||||||
|
db.update_poll(pid, entry_big=int(d.get("entry_big", True) is not False))
|
||||||
for q in questions:
|
for q in questions:
|
||||||
db.add_question(pid, *q)
|
db.add_question(pid, *q)
|
||||||
codes = int(d.get("codes") or 0)
|
codes = int(d.get("codes") or 0)
|
||||||
@@ -426,7 +428,7 @@ async def create_trial(request: Request):
|
|||||||
pid, _, screen_key = db.create_poll("Essai", 800, 5, False, None, 200, config.DEFAULT_VOTE_SCANS, "ring",
|
pid, _, screen_key = db.create_poll("Essai", 800, 5, False, None, 200, config.DEFAULT_VOTE_SCANS, "ring",
|
||||||
trial=True)
|
trial=True)
|
||||||
db.add_question(pid, "Le vote d'essai fonctionne ?", "single", ["Oui", "Non"], 1, False)
|
db.add_question(pid, "Le vote d'essai fonctionne ?", "single", ["Oui", "Non"], 1, False)
|
||||||
db.update_poll(pid, enrollment_open=1)
|
db.update_poll(pid, enrollment_open=1, entry_big=1)
|
||||||
return JSONResponse({"id": pid, "screen_key": screen_key})
|
return JSONResponse({"id": pid, "screen_key": screen_key})
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -30,8 +30,23 @@ function replay(el, cls) {
|
|||||||
el.classList.add(cls);
|
el.classList.add(cls);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// the entry qr jumps between the corner and the big spot: slide and grow it from where it was (flip)
|
||||||
|
function flip(el, before) {
|
||||||
|
if (!before || el.hidden || matchMedia("(prefers-reduced-motion: reduce)").matches) return;
|
||||||
|
const after = el.getBoundingClientRect();
|
||||||
|
if (!after.width || !after.height) return;
|
||||||
|
const dx = before.left - after.left, dy = before.top - after.top, sx = before.width / after.width, sy = before.height / after.height;
|
||||||
|
if (Math.abs(dx) < 2 && Math.abs(dy) < 2 && Math.abs(sx - 1) < 0.02 && Math.abs(sy - 1) < 0.02) return;
|
||||||
|
el.animate([
|
||||||
|
{ transformOrigin: "0 0", transform: `translate(${dx}px, ${dy}px) scale(${sx}, ${sy})` },
|
||||||
|
{ transformOrigin: "0 0", transform: "none" },
|
||||||
|
], { duration: 600, easing: "cubic-bezier(.2, .7, .2, 1)" });
|
||||||
|
}
|
||||||
|
|
||||||
function layout() {
|
function layout() {
|
||||||
if (!st) return;
|
if (!st) return;
|
||||||
|
const entryEl = $("#entry");
|
||||||
|
const before = !entryEl.hidden && !entryEl.classList.contains("leaving") ? entryEl.getBoundingClientRect() : null;
|
||||||
// qr stays up while enrolling, and during a vote that needs a presence scan
|
// qr stays up while enrolling, and during a vote that needs a presence scan
|
||||||
const qrOn = st.enrollment_open || st.presence;
|
const qrOn = st.enrollment_open || st.presence;
|
||||||
const ring = st.code_style === "ring";
|
const ring = st.code_style === "ring";
|
||||||
@@ -64,6 +79,7 @@ function layout() {
|
|||||||
}
|
}
|
||||||
$("#entry-hint").textContent = big ? "Scannez ici, puis visez le cercle" : "Pas encore sur la page ?";
|
$("#entry-hint").textContent = big ? "Scannez ici, puis visez le cercle" : "Pas encore sur la page ?";
|
||||||
$(".qr-wrap").classList.toggle("ring", ring);
|
$(".qr-wrap").classList.toggle("ring", ring);
|
||||||
|
flip(entryEl, before);
|
||||||
}
|
}
|
||||||
|
|
||||||
function render() {
|
function render() {
|
||||||
|
|||||||
Reference in New Issue
Block a user