Unverified Commit 2c3148fe authored by Thomas Citharel's avatar Thomas Citharel
Browse files

Fix some HTML structure and JS formatting


Signed-off-by: default avatarThomas Citharel <tcit@tcit.fr>
parent 5a5c233a
......@@ -17,13 +17,13 @@
*/
$(document).ready(function () {
/**
* Error check when submitting form
*/
$("#formulaire").submit(function (event) {
var isHidden = $("#hidden").prop('checked');
var isOptionAllUserCanModifyEverything = $("#editableByAll").is(":checked");
var isHidden = $("#hidden").prop("checked");
var isOptionAllUserCanModifyEverything =
$("#editableByAll").is(":checked");
if (isHidden && isOptionAllUserCanModifyEverything) {
event.preventDefault();
......@@ -44,22 +44,23 @@ $(document).ready(function () {
}
});
/**
/**
* Enable/Disable ValueMax options
*/
$("#use_ValueMax").change(function () {
if ($(this).prop("checked")) {
$("#ValueMax").removeClass("hidden");
const useValueMax = document.querySelector("#use_ValueMax");
useValueMax.addEventListener("change", function () {
const valueMaxOptions = document.querySelector("#value_max_options");
if (useValueMax.checked) {
valueMaxOptions.classList.remove("hidden");
} else {
$("#ValueMax").addClass("hidden");
valueMaxOptions.classList.add("hidden");
}
});
/**
* Hide/Show password options
*/
$("#use_password").change(function(){
$("#use_password").change(function () {
if ($(this).prop("checked")) {
$("#password_options").removeClass("hidden");
} else {
......@@ -88,9 +89,12 @@ $(document).ready(function () {
document.getElementById("cookie-warning").setAttribute("style", "");
}
var wrapper = new MDEWrapper($('#poll_comments')[0], $('#rich-editor-button'), $('#simple-editor-button'));
if ($('#rich-editor-button').hasClass('active')) {
var wrapper = new MDEWrapper(
$("#poll_comments")[0],
$("#rich-editor-button"),
$("#simple-editor-button")
);
if ($("#rich-editor-button").hasClass("active")) {
wrapper.enable();
}
});
function myPreviewRender (text) {
text = text.replace(/[\u00A0-\u9999<>\&]/gim, function(i) {
return '&#'+i.charCodeAt(0)+';';
function myPreviewRender(text) {
text = text.replace(/[\u00A0-\u9999<>\&]/gim, function (i) {
return "&#" + i.charCodeAt(0) + ";";
});
text = SimpleMDE.prototype.markdown(text);
text = DOMPurify.sanitize(text);
return text;
};
}
function MDEWrapper(textarea, enableButton, disableButton) {
this.element = textarea;
......
......@@ -129,36 +129,30 @@
{* Value MAX *}
<div class="form-group {$errors['ValueMax']['class']}">
<label for="use_valueMax" class="col-sm-4 control-label">
{__('Step 1', 'Value Max')}<br/>
<label for="use_valueMax" class="col-sm-4 control-label">
{__('Step 1', 'Value Max')}<br/>
</label>
<div class="col-sm-8">
<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 class="col-sm-8">
<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>
</div>
<div id="value_max_options" {if !$use_ValueMax}class="hidden"{/if}>
<div class="col-sm-offset-4 col-sm-8">
<label>
<input id="ValueMax" type="number" min="0" name="ValueMax" value="{$ValueMax|html}" {$errors['ValueMax']['aria']}>
<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>
</div>
{if !empty($errors['ValueMax']['msg'])}
<div class="alert alert-danger">
<p id="poll_customized_url_error">
<p id="poll_value_max_error">
{$errors['ValueMax']['msg']}
</p>
</div>
......@@ -209,7 +203,7 @@
{* Password *}
<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')}
</label>
......@@ -263,7 +257,7 @@
</div>
<div class="form-group">
<label for="poll_id" class="col-sm-4 control-label">
<label class="col-sm-4 control-label">
{__('Step 1', 'Permissions')}
</label>
<div class="col-sm-8">
......
Supports Markdown
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