Verified Commit acd38760 authored by Thibaut Broggi's avatar Thibaut Broggi
Browse files

Add another "randomize" button on small screens

parent aabb7a8f
...@@ -171,16 +171,19 @@ let randomElement = function(selector) { ...@@ -171,16 +171,19 @@ let randomElement = function(selector) {
return elems[Math.trunc(Math.random() * elems.length)]; return elems[Math.trunc(Math.random() * elems.length)];
} }
document.getElementById('randomize').onclick = function(e) { let randomButtons = document.querySelectorAll('.randomize');
randomElement('input[name="bg-color"]').checked = true; for (let i = 0; i < randomButtons.length; ++i) {
do { randomButtons[i].onclick = function(e) {
randomElement('input[name="fg-color"]').checked = true; randomElement('input[name="bg-color"]').checked = true;
} while (document.querySelector('.colorpicker input[type="radio"][name="bg-color"]:checked').value do {
== document.querySelector('.colorpicker input[type="radio"][name="fg-color"]:checked').value); randomElement('input[name="fg-color"]').checked = true;
randomElement('input[name="font"]').checked = true; } while (document.querySelector('.colorpicker input[type="radio"][name="bg-color"]:checked').value
randomElement('input[name="icon"]').checked = true; == document.querySelector('.colorpicker input[type="radio"][name="fg-color"]:checked').value);
document.getElementById('step2value').value = document.getElementById('step2value').innerText = sampleTexts[Math.trunc(Math.random() * sampleTexts.length)]; randomElement('input[name="font"]').checked = true;
if (document.getElementById('signature').value.match(/(\t$|^$)/)) randomElement('input[name="icon"]').checked = true;
document.getElementById('signature').value = sampleSignatures[Math.trunc(Math.random() * sampleSignatures.length)]; document.getElementById('step2value').value = document.getElementById('step2value').innerText = sampleTexts[Math.trunc(Math.random() * sampleTexts.length)];
draw(); if (document.getElementById('signature').value.match(/(\t$|^$)/))
document.getElementById('signature').value = sampleSignatures[Math.trunc(Math.random() * sampleSignatures.length)];
draw();
}
} }
...@@ -170,7 +170,7 @@ div#inputs > div:first-child { ...@@ -170,7 +170,7 @@ div#inputs > div:first-child {
border-bottom: 1px solid #dde5f1; border-bottom: 1px solid #dde5f1;
} }
div#inputs > div:first-child > button#randomize { div#inputs > div:first-child > button.randomize {
width: 60%; width: 60%;
} }
...@@ -239,7 +239,7 @@ body { ...@@ -239,7 +239,7 @@ body {
margin-top: 7vw; margin-top: 7vw;
} }
h2.title-small { h2.title-small, main .randomize {
display: none; display: none;
} }
} }
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
</nav> </nav>
<div id="inputs"> <div id="inputs">
<div> <div>
<button id="randomize" class="white-button">CHOISIR AU HASARD <span class="fa fa-random"></span></button> <button class="randomize white-button">CHOISIR AU HASARD <span class="fa fa-random"></span></button>
</div> </div>
<div id="step1"> <div id="step1">
<h2 class="title-small">Choisissez 2 couleurs</h2> <h2 class="title-small">Choisissez 2 couleurs</h2>
...@@ -217,6 +217,7 @@ ...@@ -217,6 +217,7 @@
<main> <main>
<div> <div>
<canvas id="output" width="600" height="413"></canvas> <canvas id="output" width="600" height="413"></canvas>
<a class="randomize white-button"><span class="fa fa-random"></span></a>
<a id="tweet-button" class="blue-button" target="_blank" href="https://twitter.com/intent/tweet?text=Soutenez La Quadrature du Net !">Tweet <span class="fa fa-twitter"></span></a> <a id="tweet-button" class="blue-button" target="_blank" href="https://twitter.com/intent/tweet?text=Soutenez La Quadrature du Net !">Tweet <span class="fa fa-twitter"></span></a>
<a id="save-image" class="white-button" download="lqdn-slogan.png">Enregistrer <span class="fa fa-save"></span></a> <a id="save-image" class="white-button" download="lqdn-slogan.png">Enregistrer <span class="fa fa-save"></span></a>
</div> </div>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment