2015-04-05 18:36:43 +02:00
|
|
|
/**
|
|
|
|
* This software is governed by the CeCILL-B license. If a copy of this license
|
|
|
|
* is not distributed with this file, you can obtain one at
|
|
|
|
* http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt
|
|
|
|
*
|
|
|
|
* Authors of STUdS (initial project): Guilhem BORGHESI (borghesi@unistra.fr) and Raphaël DROZ
|
2016-08-04 22:26:37 +02:00
|
|
|
* Authors of Framadate/OpenSondage: Framasoft (https://github.com/framasoft)
|
2015-04-05 18:36:43 +02:00
|
|
|
*
|
|
|
|
* =============================
|
|
|
|
*
|
|
|
|
* Ce logiciel est régi par la licence CeCILL-B. Si une copie de cette licence
|
|
|
|
* ne se trouve pas avec ce fichier vous pouvez l'obtenir sur
|
|
|
|
* http://www.cecill.info/licences/Licence_CeCILL-B_V1-fr.txt
|
|
|
|
*
|
|
|
|
* Auteurs de STUdS (projet initial) : Guilhem BORGHESI (borghesi@unistra.fr) et Raphaël DROZ
|
|
|
|
* Auteurs de Framadate/OpenSondage : Framasoft (https://github.com/framasoft)
|
|
|
|
*/
|
|
|
|
|
|
|
|
$(document).ready(function () {
|
|
|
|
|
2015-04-09 17:53:00 +02:00
|
|
|
/**
|
|
|
|
* Error check when submitting form
|
|
|
|
*/
|
2015-04-05 18:36:43 +02:00
|
|
|
$("#formulaire").submit(function (event) {
|
|
|
|
var isHidden = $("#hidden").prop('checked');
|
|
|
|
var isOptionAllUserCanModifyEverything = $("#editableByAll").is(":checked");
|
|
|
|
|
|
|
|
if (isHidden && isOptionAllUserCanModifyEverything) {
|
|
|
|
event.preventDefault();
|
|
|
|
$("#hiddenWithBadEditionModeError").removeClass("hidden");
|
|
|
|
} else {
|
|
|
|
$("#hiddenWithBadEditionModeError").addClass("hidden");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2015-12-05 16:03:01 +01:00
|
|
|
/**
|
2016-08-04 21:44:31 +02:00
|
|
|
* Enable/Disable custom url options
|
2015-12-05 16:03:01 +01:00
|
|
|
*/
|
2016-08-04 21:44:31 +02:00
|
|
|
$("#use_customized_url").change(function () {
|
2015-12-05 16:03:01 +01:00
|
|
|
if ($(this).prop("checked")) {
|
2016-08-04 21:44:31 +02:00
|
|
|
$("#customized_url_options").removeClass("hidden");
|
2018-04-22 12:29:37 +02:00
|
|
|
// Check url pattern
|
|
|
|
$('#customized_url').on('input', function() {
|
|
|
|
var regex_url = /^[a-zA-Z0-9-]*$/
|
|
|
|
if (! regex_url.test(this.value)) {
|
|
|
|
$(this).parent(".input-group").addClass("has-error");
|
|
|
|
$(this).attr("aria-invalid", "true");
|
|
|
|
} else {
|
|
|
|
$(this).parent(".input-group").removeClass("has-error");
|
|
|
|
$(this).attr("aria-invalid", "false");
|
|
|
|
}
|
|
|
|
});
|
2015-12-05 16:03:01 +01:00
|
|
|
} else {
|
2016-08-04 21:44:31 +02:00
|
|
|
$("#customized_url_options").addClass("hidden");
|
2015-12-05 16:03:01 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-02-20 13:06:58 +01:00
|
|
|
/**
|
|
|
|
* Enable/Disable ValueMax options
|
|
|
|
*/
|
|
|
|
$("#use_ValueMax").change(function () {
|
|
|
|
if ($(this).prop("checked")) {
|
2018-05-25 17:37:48 +02:00
|
|
|
$("#valueMaxWrapper").removeClass("hidden");
|
2018-02-20 13:06:58 +01:00
|
|
|
} else {
|
2018-05-25 17:37:48 +02:00
|
|
|
$("#valueMaxWrapper").addClass("hidden");
|
2018-02-20 13:06:58 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2015-04-09 17:53:00 +02:00
|
|
|
/**
|
|
|
|
* Hide/Show password options
|
|
|
|
*/
|
2015-10-30 21:50:44 +01:00
|
|
|
$("#use_password").change(function(){
|
|
|
|
if ($(this).prop("checked")) {
|
2015-04-09 17:53:00 +02:00
|
|
|
$("#password_options").removeClass("hidden");
|
|
|
|
} else {
|
|
|
|
$("#password_options").addClass("hidden");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-03-18 10:40:38 +01:00
|
|
|
/**
|
|
|
|
* Hide/Show Warning collect_users_mail + editable by all
|
|
|
|
*/
|
2018-05-08 15:03:22 +02:00
|
|
|
$("input[name='collect_users_mail']").change(function(){
|
|
|
|
if (($("input[name='collect_users_mail']:checked").val() != 0) && ($("input[name='editable']:checked").val() == 1)) {
|
2018-03-18 10:40:38 +01:00
|
|
|
$("#collect_warning").removeClass("hidden");
|
|
|
|
} else {
|
|
|
|
$("#collect_warning").addClass("hidden");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
$("input[name='editable']").change(function(){
|
2018-05-08 15:03:22 +02:00
|
|
|
if ($("input[name='collect_users_mail']:checked").val() != 0 && $("input[name='editable']:checked").val() == 1) {
|
2018-03-18 10:40:38 +01:00
|
|
|
$("#collect_warning").removeClass("hidden");
|
|
|
|
} else {
|
|
|
|
$("#collect_warning").addClass("hidden");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2015-04-05 18:36:43 +02:00
|
|
|
// Check cookies are enabled too
|
|
|
|
var cookieEnabled = function () {
|
|
|
|
var cookieEnabled = navigator.cookieEnabled;
|
|
|
|
|
|
|
|
// if not IE4+ nor NS6+
|
|
|
|
if (!cookieEnabled && typeof navigator.cookieEnabled === "undefined") {
|
|
|
|
document.cookie = "testcookie";
|
|
|
|
cookieEnabled = document.cookie.indexOf("testcookie") != -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return cookieEnabled;
|
|
|
|
};
|
|
|
|
|
|
|
|
if (cookieEnabled()) {
|
|
|
|
// Show the form block
|
|
|
|
document.getElementById("form-block").setAttribute("style", "");
|
|
|
|
} else {
|
|
|
|
// Show the warning about cookies
|
|
|
|
document.getElementById("cookie-warning").setAttribute("style", "");
|
|
|
|
}
|
|
|
|
|
2016-05-12 16:20:47 +02:00
|
|
|
var wrapper = new MDEWrapper($('#poll_comments')[0], $('#rich-editor-button'), $('#simple-editor-button'));
|
2016-06-27 12:24:12 +02:00
|
|
|
if ($('#rich-editor-button').hasClass('active')) {
|
|
|
|
wrapper.enable();
|
|
|
|
}
|
2016-05-11 17:38:34 +02:00
|
|
|
|
2016-08-04 21:44:31 +02:00
|
|
|
});
|