Improve Javascript (allow toggling of deletion and highlight "Save and Update" button on deletion) and :codacy:

Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
DL6ER
2017-10-21 12:08:00 +02:00
parent b70e43f8ba
commit a1d96e4e63
2 changed files with 13 additions and 13 deletions

View File

@@ -152,21 +152,21 @@ $(document).ready(function(){
// Handle list deletion
$("button[id^='adlist-btn-']").on("click", function (e) {
var idstring = $(this).context.id;
var id = parseInt(idstring.replace(/[^0-9\.]/g, ''), 10);
var id = parseInt($(this).context.id.replace(/[^0-9\.]/g, ""), 10);
e.preventDefault();
var status = $("input[id='adlist-del-"+id+"']").is(":checked");
var status = $("input[name=\"adlist-del-"+id+"\"]").is(":checked");
var textType = status ? "none" : "line-through";
console.log("idstring: "+idstring);
console.log("id: "+id);
console.log("status: "+status);
console.log("textType: "+textType);
$("input[name='adlist-del-"+id+"']").prop("checked", !status);
$("input[name='adlist-enable-"+id+"']").prop("disabled", !status);
$("button[id='adlist-btn-"+id+"']").prop("disabled", true);
$("a[id='adlist-text-"+id+"']").css("text-decoration", textType);
// Check hidden delete box (or reset)
$("input[name=\"adlist-del-"+id+"\"]").prop("checked", !status);
// Untick and disable check box (or reset)
$("input[name=\"adlist-enable-"+id+"\"]").prop("checked", status).prop("disabled", !status);
// Strink through text (or reset)
$("a[id=\"adlist-text-"+id+"\"]").css("text-decoration", textType);
// Highlight that the button has to be clicked in order to make the change live
$("button[id=\"blockinglistsaveupdate\"]").addClass("btn-danger").css("font-weight", "bold");
});
// Javascript to go to specified tab on save or hyperlink