Fix some HTML structure and JS formatting

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2021-12-17 14:09:14 +01:00
parent 5a5c233a5e
commit 2c3148fe9e
No known key found for this signature in database
GPG Key ID: A061B9DDE0CA0773
3 changed files with 40 additions and 42 deletions

View File

@ -17,13 +17,13 @@
*/ */
$(document).ready(function () { $(document).ready(function () {
/** /**
* Error check when submitting form * Error check when submitting form
*/ */
$("#formulaire").submit(function (event) { $("#formulaire").submit(function (event) {
var isHidden = $("#hidden").prop('checked'); var isHidden = $("#hidden").prop("checked");
var isOptionAllUserCanModifyEverything = $("#editableByAll").is(":checked"); var isOptionAllUserCanModifyEverything =
$("#editableByAll").is(":checked");
if (isHidden && isOptionAllUserCanModifyEverything) { if (isHidden && isOptionAllUserCanModifyEverything) {
event.preventDefault(); event.preventDefault();
@ -44,22 +44,23 @@ $(document).ready(function () {
} }
}); });
/** /**
* Enable/Disable ValueMax options * Enable/Disable ValueMax options
*/ */
$("#use_ValueMax").change(function () { const useValueMax = document.querySelector("#use_ValueMax");
if ($(this).prop("checked")) { useValueMax.addEventListener("change", function () {
$("#ValueMax").removeClass("hidden"); const valueMaxOptions = document.querySelector("#value_max_options");
if (useValueMax.checked) {
valueMaxOptions.classList.remove("hidden");
} else { } else {
$("#ValueMax").addClass("hidden"); valueMaxOptions.classList.add("hidden");
} }
}); });
/** /**
* Hide/Show password options * Hide/Show password options
*/ */
$("#use_password").change(function(){ $("#use_password").change(function () {
if ($(this).prop("checked")) { if ($(this).prop("checked")) {
$("#password_options").removeClass("hidden"); $("#password_options").removeClass("hidden");
} else { } else {
@ -88,9 +89,12 @@ $(document).ready(function () {
document.getElementById("cookie-warning").setAttribute("style", ""); document.getElementById("cookie-warning").setAttribute("style", "");
} }
var wrapper = new MDEWrapper($('#poll_comments')[0], $('#rich-editor-button'), $('#simple-editor-button')); var wrapper = new MDEWrapper(
if ($('#rich-editor-button').hasClass('active')) { $("#poll_comments")[0],
$("#rich-editor-button"),
$("#simple-editor-button")
);
if ($("#rich-editor-button").hasClass("active")) {
wrapper.enable(); wrapper.enable();
} }
}); });

View File

@ -1,12 +1,12 @@
function myPreviewRender (text) { function myPreviewRender(text) {
text = text.replace(/[\u00A0-\u9999<>\&]/gim, function(i) { text = text.replace(/[\u00A0-\u9999<>\&]/gim, function (i) {
return '&#'+i.charCodeAt(0)+';'; return "&#" + i.charCodeAt(0) + ";";
}); });
text = SimpleMDE.prototype.markdown(text); text = SimpleMDE.prototype.markdown(text);
text = DOMPurify.sanitize(text); text = DOMPurify.sanitize(text);
return text; return text;
}; }
function MDEWrapper(textarea, enableButton, disableButton) { function MDEWrapper(textarea, enableButton, disableButton) {
this.element = textarea; this.element = textarea;

View File

@ -129,36 +129,30 @@
{* Value MAX *} {* Value MAX *}
<div class="form-group {$errors['ValueMax']['class']}"> <div class="form-group {$errors['ValueMax']['class']}">
<label for="use_valueMax" class="col-sm-4 control-label"> <label for="use_valueMax" class="col-sm-4 control-label">
{__('Step 1', 'Value Max')}<br/> {__('Step 1', 'Value Max')}<br/>
</label> </label>
<div class="col-sm-8"> <div class="col-sm-8">
<div class="checkbox"> <div class="checkbox">
<label>
<input id="use_ValueMax" name="use_ValueMax" type="checkbox" {if $use_ValueMax}checked{/if}>
{__('Step 1', "Limit the amount of voters per option")}
</label>
</div>
</div>
</div>
<div class="form-group {$errors['ValueMax']['class']}">
<div id="ValueMax" {if !$use_ValueMax}class="hidden"{/if}>
<div class="col-sm-offset-4 col-sm-8">
<label> <label>
<input id="ValueMax" type="number" min="0" name="ValueMax" value="{$ValueMax|html}" {$errors['ValueMax']['aria']}> <input id="use_ValueMax" name="use_ValueMax" type="checkbox" {if $use_ValueMax}checked{/if} />
{__('Step 1', "Limit the amount of voters per option")}
{__('Step 1', "ValueMax instructions")}
</label> </label>
</div> </div>
</div> </div>
</div> <div id="value_max_options" {if !$use_ValueMax}class="hidden"{/if}>
<div class="col-sm-offset-4 col-sm-8">
<label for="ValueMax">
<input id="ValueMax" type="number" min="0" name="ValueMax" value="{$ValueMax|html}" {$errors['ValueMax']['aria']} />
{__('Step 1', "ValueMax instructions")}
</label>
</div>
</div>
</div>
{if !empty($errors['ValueMax']['msg'])} {if !empty($errors['ValueMax']['msg'])}
<div class="alert alert-danger"> <div class="alert alert-danger">
<p id="poll_customized_url_error"> <p id="poll_value_max_error">
{$errors['ValueMax']['msg']} {$errors['ValueMax']['msg']}
</p> </p>
</div> </div>
@ -209,7 +203,7 @@
{* Password *} {* Password *}
<div class="form-group"> <div class="form-group">
<label for="poll_id" class="col-sm-4 control-label"> <label for="use_password" class="col-sm-4 control-label">
{__('Step 1', 'Poll password')} {__('Step 1', 'Poll password')}
</label> </label>
@ -263,7 +257,7 @@
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="poll_id" class="col-sm-4 control-label"> <label class="col-sm-4 control-label">
{__('Step 1', 'Permissions')} {__('Step 1', 'Permissions')}
</label> </label>
<div class="col-sm-8"> <div class="col-sm-8">