first commit
This commit is contained in:
@@ -0,0 +1,113 @@
|
||||
#nsc_bar_admin_title {
|
||||
background: url("../img/icon-96x96.png") no-repeat left center;
|
||||
background-size: 48px 48px;
|
||||
line-height: 35px !important;
|
||||
padding-left: 55px !important;
|
||||
}
|
||||
|
||||
.nsc_bar_notice_block_services {
|
||||
background: #fff;
|
||||
border: 1px solid #c3c4c7;
|
||||
border-left-width: 4px;
|
||||
box-shadow: 0 1px 1px rgb(0 0 0 / 4%);
|
||||
margin: 5px 15px 2px;
|
||||
padding: 1px 12px;
|
||||
border-left: 4px solid #dba617;
|
||||
}
|
||||
|
||||
.nsc_bar_cookietypes_table td,
|
||||
th {
|
||||
padding: 0em;
|
||||
}
|
||||
|
||||
.nsc_bar_cookietypes_table th {
|
||||
padding: 0em;
|
||||
}
|
||||
|
||||
label.nsc_bar_inline_error {
|
||||
text-align: center;
|
||||
color: #cc0000;
|
||||
font-weight: bold;
|
||||
font-size: 0.8em;
|
||||
}
|
||||
|
||||
input.nsc_bar_inline_error {
|
||||
background: #cc0000;
|
||||
color: white;
|
||||
}
|
||||
|
||||
@media screen and (max-width: 782px) {
|
||||
.nsc_bar_cookietypes_table
|
||||
tr:not(.inline-edit-row):not(.no-items)
|
||||
td:not(.column-primary)::before {
|
||||
position: relative;
|
||||
left: 2px;
|
||||
display: block;
|
||||
overflow: hidden;
|
||||
content: attr(data-colname);
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.nsc_bar_cookietypes_table th {
|
||||
display: none;
|
||||
}
|
||||
.nsc_bar_cookietypes_table tr {
|
||||
background: #f9f9f9;
|
||||
}
|
||||
|
||||
.nsc_bar_cookietypes_table td {
|
||||
padding: 0.5em;
|
||||
}
|
||||
.nsc_bar_cookietypes_table {
|
||||
border-spacing: 1em 1em;
|
||||
position: relative;
|
||||
top: -2em;
|
||||
}
|
||||
}
|
||||
|
||||
#nsc_settings_content {
|
||||
float: left;
|
||||
min-width: 600px;
|
||||
width: 72%;
|
||||
}
|
||||
|
||||
#nsc_bar_sidebar .nsc_bar_info_box h3 {
|
||||
padding: 0 0 1em 0;
|
||||
margin: 0;
|
||||
border-bottom: 1px solid #ececec;
|
||||
}
|
||||
|
||||
#nsc_bar_sidebar .nsc_bar_info_box {
|
||||
background-color: #fff;
|
||||
padding: 1em;
|
||||
margin: 0 0 1em 0;
|
||||
}
|
||||
|
||||
#nsc_bar_sidebar {
|
||||
width: 280px;
|
||||
float: right;
|
||||
padding: 1em 0 0 1em;
|
||||
}
|
||||
|
||||
#nsc_bar_sidebar .nsc_bar_inside_text {
|
||||
margin: 1em 0;
|
||||
}
|
||||
|
||||
@media (max-width: 1278px) {
|
||||
#nsc_bar_sidebar {
|
||||
padding: 1em 1em 1em 0;
|
||||
width: 100%;
|
||||
float: left;
|
||||
}
|
||||
|
||||
#nsc_settings_content {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 390px) {
|
||||
#nsc_bar_sidebar {
|
||||
width: 280px;
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 9.3 KiB |
@@ -0,0 +1,331 @@
|
||||
document.addEventListener("DOMContentLoaded", function(event) {
|
||||
var table_config = {
|
||||
label: {
|
||||
type: "text",
|
||||
headline: "Cookie Type Name",
|
||||
maxlength: "100",
|
||||
validateRegex: "",
|
||||
validateErrorMessage: ""
|
||||
},
|
||||
checked: {
|
||||
type: "checkbox",
|
||||
headline: "default checked",
|
||||
validateRegex: "",
|
||||
validateErrorMessage: ""
|
||||
},
|
||||
disabled: {
|
||||
type: "checkbox",
|
||||
headline: "Is disabled",
|
||||
validateRegex: "",
|
||||
validateErrorMessage: ""
|
||||
},
|
||||
cookie_suffix: {
|
||||
type: "text",
|
||||
headline: "Cookie Suffix",
|
||||
maxlength: "10",
|
||||
validateRegex: /^[a-z_]+$/,
|
||||
validateErrorMessage: "Only lowercase letters and underscore allowed"
|
||||
},
|
||||
delete_icon: {
|
||||
type: "html",
|
||||
element: "span",
|
||||
class: ["dashicons", "dashicons-no-alt"],
|
||||
headline: "",
|
||||
value: "",
|
||||
clickHandler: delete_row
|
||||
}
|
||||
};
|
||||
|
||||
//getting values
|
||||
try {
|
||||
var cookietypes_json = JSON.parse(
|
||||
document.getElementById("ff_nsc_bar_cookietypes").value
|
||||
);
|
||||
} catch (err) {
|
||||
cookietypes_json = [];
|
||||
}
|
||||
|
||||
if (!Array.isArray(cookietypes_json) || cookietypes_json.length <= 0) {
|
||||
cookietypes_json = [];
|
||||
}
|
||||
|
||||
//creating table
|
||||
add_table_to_dom(generateTable());
|
||||
|
||||
//methods
|
||||
|
||||
function generateTable() {
|
||||
let table = document.createElement("table");
|
||||
|
||||
table.classList.add("nsc_bar_cookietypes_table");
|
||||
table.id = "nsc_bar_cookietypes_table";
|
||||
|
||||
table = generateTableHead(table);
|
||||
|
||||
let tbody = table.createTBody();
|
||||
|
||||
cookietypes_json.forEach(function(cookietype_fields) {
|
||||
let row = tbody.insertRow();
|
||||
Object.keys(cookietype_fields).forEach(function(field_key) {
|
||||
let cell = row.insertCell();
|
||||
let input_field = create_form(cookietype_fields[field_key], field_key);
|
||||
cell.setAttribute("data-colname", input_field.placeholder);
|
||||
cell.appendChild(input_field);
|
||||
});
|
||||
let cell = row.insertCell();
|
||||
let delete_icon = create_form("", "delete_icon");
|
||||
cell.appendChild(delete_icon);
|
||||
});
|
||||
|
||||
return table;
|
||||
}
|
||||
|
||||
function generateTableHead(table) {
|
||||
let thead = table.createTHead();
|
||||
let row = thead.insertRow();
|
||||
Object.keys(table_config).forEach(function(field_key) {
|
||||
let th = document.createElement("th");
|
||||
let text = document.createTextNode(table_config[field_key].headline);
|
||||
th.appendChild(text);
|
||||
row.appendChild(th);
|
||||
});
|
||||
return table;
|
||||
}
|
||||
|
||||
function create_form(value, field_key) {
|
||||
switch (table_config[field_key].type) {
|
||||
case "text":
|
||||
input_field = create_textfield(create_input_field(value, field_key));
|
||||
break;
|
||||
case "checkbox":
|
||||
input_field = create_checkbox(create_input_field(value, field_key));
|
||||
break;
|
||||
case "html":
|
||||
input_field = create_html(value, field_key);
|
||||
break;
|
||||
}
|
||||
|
||||
return input_field;
|
||||
}
|
||||
|
||||
function onchange_handler(event) {
|
||||
field_key = event.target.getAttribute("data-field_key");
|
||||
if (validate_field(field_key, event.target.value) == false) {
|
||||
var error_message = document.createElement("label");
|
||||
error_message.classList.add("nsc_bar_inline_error");
|
||||
event.target.classList.add("nsc_bar_inline_error");
|
||||
error_message.innerText = table_config[field_key].validateErrorMessage;
|
||||
event.target.parentNode.appendChild(error_message);
|
||||
} else {
|
||||
try {
|
||||
var el = event.target.parentNode.getElementsByTagName("label")[0];
|
||||
el.parentNode.removeChild(el);
|
||||
event.target.classList.remove("nsc_bar_inline_error");
|
||||
} catch (er) {}
|
||||
}
|
||||
build_json_file();
|
||||
}
|
||||
|
||||
function create_input_field(value, field_key) {
|
||||
var input_field = document.createElement("input");
|
||||
input_field.name = "nsc_bar_" + field_key;
|
||||
input_field.value = value;
|
||||
input_field.classList.add("nsc_bar_" + field_key);
|
||||
input_field.setAttribute("data-field_key", field_key);
|
||||
field_config = table_config[input_field.getAttribute("data-field_key")];
|
||||
input_field.placeholder = field_config.headline;
|
||||
input_field.onchange = onchange_handler;
|
||||
return input_field;
|
||||
}
|
||||
|
||||
function create_textfield(input_field) {
|
||||
input_field.setAttribute("type", "text");
|
||||
field_config = table_config[input_field.getAttribute("data-field_key")];
|
||||
input_field.maxLength = field_config.maxlength;
|
||||
return input_field;
|
||||
}
|
||||
|
||||
function create_checkbox(input_field) {
|
||||
input_field.setAttribute("type", "checkbox");
|
||||
switch (input_field.value) {
|
||||
case "checked":
|
||||
input_field.checked = true;
|
||||
break;
|
||||
case "disabled":
|
||||
input_field.checked = true;
|
||||
break;
|
||||
}
|
||||
|
||||
return input_field;
|
||||
}
|
||||
|
||||
function create_html(value, field_key) {
|
||||
html_element = document.createElement(table_config[field_key].element);
|
||||
table_config[field_key].class.forEach(function(oneclass) {
|
||||
html_element.classList.add(oneclass);
|
||||
});
|
||||
html_element.onclick = table_config[field_key].clickHandler;
|
||||
return html_element;
|
||||
}
|
||||
|
||||
function create_add_link() {
|
||||
var link = document.createElement("a");
|
||||
link.classList.add("nsc_bar_cookietypes_add_new_link");
|
||||
link.id = "nsc_bar_cookietypes_add_new_link";
|
||||
link.text = "add new cookie type";
|
||||
link.onclick = add_empty_row;
|
||||
return link;
|
||||
}
|
||||
|
||||
function add_empty_row() {
|
||||
var tbody = document.querySelector("#nsc_bar_cookietypes_table > tbody");
|
||||
var row = tbody.insertRow();
|
||||
Object.keys(table_config).forEach(function(field_key) {
|
||||
let cell = row.insertCell();
|
||||
let input_field = create_form("", field_key);
|
||||
cell.appendChild(input_field);
|
||||
});
|
||||
}
|
||||
|
||||
function delete_row(event) {
|
||||
var td = event.target.parentNode;
|
||||
var tr = td.parentNode; // the row to be removed
|
||||
tr.parentNode.removeChild(tr);
|
||||
build_json_file();
|
||||
}
|
||||
|
||||
function add_table_to_dom(table) {
|
||||
try {
|
||||
var textar = document.querySelector("#ff_nsc_bar_cookietypes");
|
||||
} catch (er) {}
|
||||
if (textar) {
|
||||
textar.parentNode.appendChild(table);
|
||||
textar.parentNode.appendChild(create_add_link());
|
||||
}
|
||||
}
|
||||
|
||||
function build_json_file() {
|
||||
//creating the highest level of json.
|
||||
var new_json = [];
|
||||
|
||||
var cookietype_rows = document.querySelectorAll(
|
||||
"#nsc_bar_cookietypes_table > tbody > tr"
|
||||
);
|
||||
|
||||
for (var i = 0; i < cookietype_rows.length; i++) {
|
||||
var skip_row = false;
|
||||
var row = cookietype_rows[i];
|
||||
var formfields = row.getElementsByTagName("input");
|
||||
|
||||
var cookietype_fields = {};
|
||||
for (var r = 0; r < formfields.length; r++) {
|
||||
var field_key = formfields[r].getAttribute("data-field_key");
|
||||
if (
|
||||
formfields[r].type != "checkbox" &&
|
||||
(!formfields[r].value || formfields[r].value == "")
|
||||
) {
|
||||
skip_row = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (formfields[r].type) {
|
||||
case "checkbox":
|
||||
cookietype_fields[field_key] = get_checkbox_value(
|
||||
formfields[r],
|
||||
field_key
|
||||
);
|
||||
break;
|
||||
default:
|
||||
cookietype_fields[field_key] = formfields[r].value;
|
||||
}
|
||||
}
|
||||
|
||||
if (skip_row) {
|
||||
continue;
|
||||
}
|
||||
new_json.push(cookietype_fields);
|
||||
}
|
||||
add_new_json(new_json);
|
||||
}
|
||||
|
||||
function get_checkbox_value(formfield, field_key) {
|
||||
if (formfield.checked == true) {
|
||||
return field_key;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
function validate_field(field_key, value) {
|
||||
var regex = table_config[field_key].validateRegex;
|
||||
|
||||
if (!regex) {
|
||||
return true;
|
||||
}
|
||||
return regex.test(value);
|
||||
}
|
||||
|
||||
function add_new_json(new_json) {
|
||||
if (!Array.isArray(new_json) || new_json.length <= 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
document.getElementById("ff_nsc_bar_cookietypes").value = JSON.stringify(
|
||||
new_json
|
||||
);
|
||||
//console.log("new json", new_json);
|
||||
}
|
||||
});
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function(event) {
|
||||
var selector = "[name='nsc_bar_type']";
|
||||
nsc_bar_setVisibility_cookie_settings_text();
|
||||
nsc_bar_set_element_visibility();
|
||||
var nsc_bar_selector_nodes = document.querySelectorAll(selector);
|
||||
|
||||
if (nsc_bar_selector_nodes) {
|
||||
for (var i = 0; i < nsc_bar_selector_nodes.length; i++) {
|
||||
nsc_bar_selector_nodes[i].addEventListener("change", function() {
|
||||
nsc_bar_set_element_visibility();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
var nsc_bar_revokable = document.querySelector("[name='nsc_bar_revokable']");
|
||||
if (nsc_bar_revokable) {
|
||||
nsc_bar_revokable.addEventListener("click", function() {
|
||||
nsc_bar_setVisibility_cookie_settings_text();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
function nsc_bar_set_element_visibility() {
|
||||
var selector = "[name='nsc_bar_type']";
|
||||
if (!document.querySelector(selector)) {
|
||||
return false;
|
||||
}
|
||||
var selector_value = document.querySelector(selector).value;
|
||||
if (selector_value && selector_value == "detailed") {
|
||||
document.getElementById("tr_setDiffDefaultCookiesFirstPV").hidden = false;
|
||||
document.getElementById("tr_cookietypes").hidden = false;
|
||||
} else {
|
||||
document.getElementById("tr_setDiffDefaultCookiesFirstPV").hidden = true;
|
||||
document.getElementById("tr_cookietypes").hidden = true;
|
||||
}
|
||||
}
|
||||
|
||||
function nsc_bar_setVisibility_cookie_settings_text() {
|
||||
var nsc_bar_activate_cookie_settings_tab;
|
||||
if (document.querySelector("[name='nsc_bar_revokable']")) {
|
||||
nsc_bar_activate_cookie_settings_tab = document.querySelector(
|
||||
"[name='nsc_bar_revokable']"
|
||||
);
|
||||
}
|
||||
if (
|
||||
nsc_bar_activate_cookie_settings_tab &&
|
||||
nsc_bar_activate_cookie_settings_tab.checked
|
||||
) {
|
||||
document.getElementById("tr_content_policy").hidden = false;
|
||||
} else if (nsc_bar_activate_cookie_settings_tab) {
|
||||
document.getElementById("tr_content_policy").hidden = true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,409 @@
|
||||
document.addEventListener("DOMContentLoaded", function (event) {
|
||||
nsc_bar_setVisibility_after_checkbox(
|
||||
"[id='ff_nsc_bar_onStatusChange']",
|
||||
["tr_dataLayerName"],
|
||||
true
|
||||
);
|
||||
nsc_bar_setVisibility_after_checkbox("[name='nsc_bar_revokable']", ["tr_content_policy"], true);
|
||||
nsc_bar_setVisibility_after_checkbox("[id='ff_nsc_bar_showCloseX']", ["tr_content_close"], true);
|
||||
nsc_bar_setVisibility_compliance_drop_down();
|
||||
});
|
||||
|
||||
function nsc_bar_setVisibility_after_checkbox(selector, idsToSetVisibility, visibileIfChecked) {
|
||||
if (!document.querySelector(selector)) {
|
||||
return;
|
||||
}
|
||||
var checkbox = document.querySelector(selector);
|
||||
|
||||
if (!checkbox) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (var i = 0, len = idsToSetVisibility.length; i < len; i += 1) {
|
||||
var elementToSetVisibility = document.getElementById(idsToSetVisibility[i]);
|
||||
if (!elementToSetVisibility) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (checkbox.checked) {
|
||||
elementToSetVisibility.hidden = !visibileIfChecked;
|
||||
} else {
|
||||
elementToSetVisibility.hidden = visibileIfChecked;
|
||||
}
|
||||
}
|
||||
|
||||
if (checkbox.dataset.clickListener) {
|
||||
return;
|
||||
}
|
||||
|
||||
checkbox.addEventListener("click", function () {
|
||||
nsc_bar_setVisibility_after_checkbox(selector, idsToSetVisibility, visibileIfChecked);
|
||||
});
|
||||
checkbox.dataset.clickListener = true;
|
||||
}
|
||||
|
||||
function nsc_bar_setVisibility_compliance_drop_down() {
|
||||
if (!document.querySelector("[name='nsc_bar_type']")) {
|
||||
return;
|
||||
}
|
||||
var complianceDropDown = document.querySelector("[name='nsc_bar_type']");
|
||||
|
||||
var selector_value = complianceDropDown.value;
|
||||
if (selector_value && (selector_value == "detailed" || selector_value == "detailedRev")) {
|
||||
document.getElementById("tr_setDiffDefaultCookiesFirstPV").hidden = false;
|
||||
document.getElementById("tr_cookietypes").hidden = false;
|
||||
} else {
|
||||
document.getElementById("tr_setDiffDefaultCookiesFirstPV").hidden = true;
|
||||
document.getElementById("tr_cookietypes").hidden = true;
|
||||
}
|
||||
|
||||
if (complianceDropDown.dataset.clickListener) {
|
||||
return;
|
||||
}
|
||||
|
||||
var nsc_bar_selector_nodes = document.querySelectorAll("[name='nsc_bar_type']");
|
||||
for (var i = 0; i < nsc_bar_selector_nodes.length; i++) {
|
||||
nsc_bar_selector_nodes[i].addEventListener("change", function () {
|
||||
nsc_bar_setVisibility_compliance_drop_down();
|
||||
});
|
||||
}
|
||||
complianceDropDown.dataset.clickListener = true;
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function (event) {
|
||||
var table_config = {
|
||||
label: {
|
||||
type: "text",
|
||||
headline: "Cookie Type Name",
|
||||
maxlength: "100",
|
||||
validateRegex: "",
|
||||
validateErrorMessage: "",
|
||||
translatable: true,
|
||||
},
|
||||
checked: {
|
||||
type: "checkbox",
|
||||
headline: "default checked",
|
||||
validateRegex: "",
|
||||
validateErrorMessage: "",
|
||||
translatable: false,
|
||||
},
|
||||
disabled: {
|
||||
type: "checkbox",
|
||||
headline: "Is disabled",
|
||||
validateRegex: "",
|
||||
validateErrorMessage: "",
|
||||
translatable: false,
|
||||
},
|
||||
cookie_suffix: {
|
||||
type: "text",
|
||||
headline: "Cookie Suffix",
|
||||
maxlength: "10",
|
||||
validateRegex: /^[a-z_]+$/,
|
||||
validateErrorMessage: "Only lowercase letters and underscore allowed",
|
||||
translatable: false,
|
||||
},
|
||||
delete_icon: {
|
||||
type: "html",
|
||||
element: "span",
|
||||
class: ["dashicons", "dashicons-no-alt"],
|
||||
headline: "",
|
||||
value: "",
|
||||
translatable: false,
|
||||
clickHandler: delete_row,
|
||||
},
|
||||
};
|
||||
|
||||
//getting values
|
||||
try {
|
||||
var cookietypes_json = JSON.parse(document.getElementById("ff_nsc_bar_cookietypes").value);
|
||||
} catch (err) {
|
||||
cookietypes_json = [];
|
||||
}
|
||||
|
||||
if (!Array.isArray(cookietypes_json) || cookietypes_json.length <= 0) {
|
||||
cookietypes_json = [];
|
||||
}
|
||||
|
||||
//creating table
|
||||
add_table_to_dom(generateTable());
|
||||
|
||||
//methods
|
||||
|
||||
function generateTable() {
|
||||
let table = document.createElement("table");
|
||||
|
||||
table.classList.add("nsc_bar_cookietypes_table");
|
||||
table.id = "nsc_bar_cookietypes_table";
|
||||
|
||||
table = generateTableHead(table);
|
||||
|
||||
let tbody = table.createTBody();
|
||||
|
||||
cookietypes_json.forEach(function (cookietype_fields) {
|
||||
let row = tbody.insertRow();
|
||||
Object.keys(cookietype_fields).forEach(function (field_key) {
|
||||
let cell = row.insertCell();
|
||||
let input_field = create_form(cookietype_fields[field_key], field_key);
|
||||
cell.setAttribute("data-colname", input_field.placeholder);
|
||||
cell.appendChild(input_field);
|
||||
});
|
||||
let cell = row.insertCell();
|
||||
if (getLanguage() === "xx") {
|
||||
let delete_icon = create_form("", "delete_icon");
|
||||
delete_icon.style.cursor = "pointer";
|
||||
cell.appendChild(delete_icon);
|
||||
}
|
||||
});
|
||||
|
||||
return table;
|
||||
}
|
||||
|
||||
function generateTableHead(table) {
|
||||
let thead = table.createTHead();
|
||||
let row = thead.insertRow();
|
||||
Object.keys(table_config).forEach(function (field_key) {
|
||||
let th = document.createElement("th");
|
||||
let text = document.createTextNode(table_config[field_key].headline);
|
||||
th.appendChild(text);
|
||||
row.appendChild(th);
|
||||
});
|
||||
return table;
|
||||
}
|
||||
|
||||
function create_form(value, field_key) {
|
||||
switch (table_config[field_key].type) {
|
||||
case "text":
|
||||
input_field = create_textfield(create_input_field(value, field_key));
|
||||
break;
|
||||
case "checkbox":
|
||||
input_field = create_checkbox(create_input_field(value, field_key));
|
||||
break;
|
||||
case "html":
|
||||
input_field = create_html(value, field_key);
|
||||
break;
|
||||
}
|
||||
|
||||
return input_field;
|
||||
}
|
||||
|
||||
function onchange_handler(event) {
|
||||
field_key = event.target.getAttribute("data-field_key");
|
||||
if (validate_field(field_key, event.target.value) == false) {
|
||||
var error_message = document.createElement("label");
|
||||
error_message.classList.add("nsc_bar_inline_error");
|
||||
event.target.classList.add("nsc_bar_inline_error");
|
||||
error_message.innerText = table_config[field_key].validateErrorMessage;
|
||||
event.target.parentNode.appendChild(error_message);
|
||||
} else {
|
||||
try {
|
||||
var el = event.target.parentNode.getElementsByTagName("label")[0];
|
||||
el.parentNode.removeChild(el);
|
||||
event.target.classList.remove("nsc_bar_inline_error");
|
||||
} catch (er) {}
|
||||
}
|
||||
build_json_file();
|
||||
}
|
||||
|
||||
function create_input_field(value, field_key) {
|
||||
var input_field = document.createElement("input");
|
||||
input_field.name = "nsc_bar_" + field_key;
|
||||
input_field.value = value;
|
||||
input_field.classList.add("nsc_bar_" + field_key);
|
||||
input_field.setAttribute("data-field_key", field_key);
|
||||
var field_config = table_config[input_field.getAttribute("data-field_key")];
|
||||
input_field.placeholder = field_config.headline;
|
||||
if (should_element_be_disabled(input_field)) {
|
||||
input_field.setAttribute("disabled", true);
|
||||
}
|
||||
input_field.onchange = onchange_handler;
|
||||
return input_field;
|
||||
}
|
||||
|
||||
function create_textfield(input_field) {
|
||||
input_field.setAttribute("type", "text");
|
||||
var field_config = table_config[input_field.getAttribute("data-field_key")];
|
||||
input_field.maxLength = field_config.maxlength;
|
||||
if (should_element_be_disabled(input_field)) {
|
||||
input_field.setAttribute("disabled", true);
|
||||
}
|
||||
return input_field;
|
||||
}
|
||||
|
||||
function create_checkbox(input_field) {
|
||||
input_field.setAttribute("type", "checkbox");
|
||||
switch (input_field.value) {
|
||||
case "checked":
|
||||
input_field.checked = true;
|
||||
break;
|
||||
case "disabled":
|
||||
input_field.checked = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (should_element_be_disabled(input_field)) {
|
||||
input_field.setAttribute("disabled", true);
|
||||
}
|
||||
|
||||
return input_field;
|
||||
}
|
||||
|
||||
function create_html(value, field_key) {
|
||||
html_element = document.createElement(table_config[field_key].element);
|
||||
table_config[field_key].class.forEach(function (oneclass) {
|
||||
html_element.classList.add(oneclass);
|
||||
});
|
||||
html_element.onclick = table_config[field_key].clickHandler;
|
||||
return html_element;
|
||||
}
|
||||
|
||||
function create_add_link() {
|
||||
var link = document.createElement("a");
|
||||
link.classList.add("nsc_bar_cookietypes_add_new_link");
|
||||
link.id = "nsc_bar_cookietypes_add_new_link";
|
||||
link.text = "add new cookie type";
|
||||
link.onclick = add_empty_row;
|
||||
link.style.cursor = "pointer";
|
||||
return link;
|
||||
}
|
||||
|
||||
function add_empty_row() {
|
||||
var tbody = document.querySelector("#nsc_bar_cookietypes_table > tbody");
|
||||
var row = tbody.insertRow();
|
||||
var first = true;
|
||||
Object.keys(table_config).forEach(function (field_key) {
|
||||
let cell = row.insertCell();
|
||||
let input_field = create_form("", field_key);
|
||||
if (field_key === "delete_icon") {
|
||||
input_field.style.cursor = "pointer";
|
||||
}
|
||||
cell.appendChild(input_field);
|
||||
if (first) {
|
||||
first = false;
|
||||
cell.childNodes[0].focus();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function delete_row(event) {
|
||||
var td = event.target.parentNode;
|
||||
var tr = td.parentNode; // the row to be removed
|
||||
tr.parentNode.removeChild(tr);
|
||||
build_json_file();
|
||||
}
|
||||
|
||||
function add_table_to_dom(table) {
|
||||
try {
|
||||
var textar = document.querySelector("#ff_nsc_bar_cookietypes");
|
||||
} catch (er) {}
|
||||
if (textar) {
|
||||
textar.parentNode.appendChild(table);
|
||||
if (getLanguage() === "xx") {
|
||||
textar.parentNode.appendChild(create_add_link());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function build_json_file() {
|
||||
//creating the highest level of json.
|
||||
var new_json = [];
|
||||
|
||||
var cookietype_rows = document.querySelectorAll("#nsc_bar_cookietypes_table > tbody > tr");
|
||||
|
||||
for (var i = 0; i < cookietype_rows.length; i++) {
|
||||
var skip_row = false;
|
||||
var row = cookietype_rows[i];
|
||||
var formfields = row.getElementsByTagName("input");
|
||||
|
||||
var cookietype_fields = {};
|
||||
for (var r = 0; r < formfields.length; r++) {
|
||||
var field_key = formfields[r].getAttribute("data-field_key");
|
||||
if (
|
||||
formfields[r].type != "checkbox" &&
|
||||
(!formfields[r].value || formfields[r].value == "")
|
||||
) {
|
||||
skip_row = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (formfields[r].type) {
|
||||
case "checkbox":
|
||||
cookietype_fields[field_key] = get_checkbox_value(formfields[r], field_key);
|
||||
break;
|
||||
default:
|
||||
cookietype_fields[field_key] = formfields[r].value;
|
||||
}
|
||||
}
|
||||
|
||||
if (skip_row) {
|
||||
continue;
|
||||
}
|
||||
new_json.push(cookietype_fields);
|
||||
}
|
||||
add_new_json(new_json);
|
||||
}
|
||||
|
||||
function get_checkbox_value(formfield, field_key) {
|
||||
if (formfield.checked == true) {
|
||||
return field_key;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
function validate_field(field_key, value) {
|
||||
var regex = table_config[field_key].validateRegex;
|
||||
|
||||
if (!regex) {
|
||||
return true;
|
||||
}
|
||||
return regex.test(value);
|
||||
}
|
||||
|
||||
function add_new_json(new_json) {
|
||||
if (!Array.isArray(new_json) || new_json.length <= 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
document.getElementById("ff_nsc_bar_cookietypes").value = JSON.stringify(new_json);
|
||||
//console.log("new json", new_json);
|
||||
}
|
||||
|
||||
function should_element_be_disabled(element) {
|
||||
var field_config = table_config[element.getAttribute("data-field_key")];
|
||||
if (field_config.translatable) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (getLanguage() === "xx") {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function getLanguage() {
|
||||
var url = new URL(window.location.href);
|
||||
var language = url.searchParams.get("nsc_bara_language_selector") || "xx";
|
||||
return language;
|
||||
}
|
||||
});
|
||||
|
||||
// TODO Implement a check if selecto is valid, e.g. #38c421 breaks whole banner.
|
||||
// document.addEventListener("DOMContentLoaded", function (event) {
|
||||
// var inputContainer = document.getElementById("ff_nsc_bar_container");
|
||||
// if (!inputContainer) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
// function isSelectorValid(selector) {
|
||||
// try {
|
||||
// queryCheck(selector);
|
||||
// } catch {
|
||||
// return false;
|
||||
// }
|
||||
// return true;
|
||||
// }
|
||||
|
||||
// function queryCheck(s) {
|
||||
// return document.createDocumentFragment().querySelector(s);
|
||||
// }
|
||||
// });
|
||||
@@ -0,0 +1,61 @@
|
||||
<div class="wrap">
|
||||
<div id="nsc_bar_upper_area">
|
||||
<h1 id="nsc_bar_admin_title"><?php echo $objSettings->settings_page_configs->page_title ?></h1>
|
||||
<p><?php echo $objSettings->settings_page_configs->description ?></p>
|
||||
</div>
|
||||
<h2 class="nav-tab-wrapper">
|
||||
<?php
|
||||
//tabs are created
|
||||
foreach ($objSettings->setting_page_fields->tabs as $tab) {
|
||||
$activeTab = "";
|
||||
if ($tab->active === true) {
|
||||
$activeTab = 'nav-tab-active';
|
||||
}
|
||||
echo '<a href="?page=' . $objSettings->plugin_slug . '&tab=' . $tab->tab_slug . '&' . $objSettings->additional_tab_link_parameter . '" class="nav-tab ' . $activeTab . '" >' . $tab->tabname . '</a>';
|
||||
}
|
||||
$active_tab_index = $objSettings->setting_page_fields->active_tab_index;
|
||||
?>
|
||||
</h2>
|
||||
<span id="nsc_settings_content">
|
||||
<table class="form-table nsc_bar_language">
|
||||
<tbody>
|
||||
<tr id="tr_content_language_setter">
|
||||
<th scope="row">Language</th>
|
||||
<td>
|
||||
<fieldset>
|
||||
<label><?php echo $form_fields->nsc_bar_get_language_dropdown() ?></label>
|
||||
<p class="description"><?php echo $objSettings->addon_lang_description ?></p>
|
||||
</fieldset>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<?php echo $objSettings->setting_page_fields->tabs[$active_tab_index]->tab_description ?>
|
||||
<form action="" method="post">
|
||||
<?php
|
||||
settings_fields($objSettings->plugin_slug . $objSettings->setting_page_fields->tabs[$active_tab_index]->tab_slug);
|
||||
?>
|
||||
<?php submit_button();?>
|
||||
|
||||
<table class="form-table">
|
||||
<?php foreach ($objSettings->setting_page_fields->tabs[$active_tab_index]->tabfields as $field_configs) {?>
|
||||
<tr id="tr_<?php echo $field_configs->field_slug ?>">
|
||||
<th scope="row">
|
||||
<?php echo $field_configs->name ?>
|
||||
</th>
|
||||
<td>
|
||||
<fieldset>
|
||||
<?php echo $form_fields->nsc_bar_return_form_field($field_configs, $objSettings->plugin_prefix); ?>
|
||||
<?php if (!empty($field_configs->custom_component)) {echo $field_configs->custom_component;}?>
|
||||
<p class="description"><?php echo $field_configs->helpertext ?></p>
|
||||
</fieldset>
|
||||
</td>
|
||||
</tr>
|
||||
<?php }?>
|
||||
</table>
|
||||
</form>
|
||||
</span>
|
||||
<?php require 'sidebar.php';?>
|
||||
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
<div id="nsc_bar_sidebar">
|
||||
<?php if (!empty($objSettings->setting_page_fields->tabs[$active_tab_index]->tab_tipps)) {?>
|
||||
<div class="nsc_bar_info_box">
|
||||
<h3>Tipps</h3>
|
||||
<div class="nsc_bar_inside_text">
|
||||
<?php echo $objSettings->setting_page_fields->tabs[$active_tab_index]->tab_tipps ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php }?>
|
||||
<div class="nsc_bar_info_box">
|
||||
<h3>Share some love</h3>
|
||||
<div class="nsc_bar_inside_text">
|
||||
<div>
|
||||
🤟
|
||||
<a
|
||||
target="_blank"
|
||||
href="https://wordpress.org/support/plugin/beautiful-and-responsive-cookie-consent/reviews/#new-post"
|
||||
>Rate this plugin
|
||||
</a>
|
||||
</div>
|
||||
<div>
|
||||
You like this plugin? Really happy to hear. Please tell others and start by leaving nice rating <a
|
||||
target="_blank"
|
||||
href="https://wordpress.org/support/plugin/beautiful-and-responsive-cookie-consent/reviews/#new-post"
|
||||
>here.
|
||||
</a> Thanks a lot.
|
||||
</div>
|
||||
<br />
|
||||
<div>
|
||||
🤨
|
||||
<a
|
||||
target="_blank"
|
||||
href="https://wordpress.org/support/plugin/beautiful-and-responsive-cookie-consent/"
|
||||
>Don't like this plugin?</a
|
||||
>
|
||||
</div>
|
||||
<div>
|
||||
Or you have discovered a bug? Please tell us. It really helps us improving this plugin. Use the
|
||||
link above or
|
||||
<a target="_blank" href="https://beautiful-cookie-banner.com/contact-form/"
|
||||
>this formular.</a
|
||||
>
|
||||
</div>
|
||||
<br />
|
||||
<div>
|
||||
🖖
|
||||
<a target="_blank" href="https://beautiful-cookie-banner.com/">More Features?</a>
|
||||
</div>
|
||||
<div>
|
||||
Or you are able to support the development with money? Have a look at the
|
||||
<a target="_blank" href="https://beautiful-cookie-banner.com/">premium add-on.</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="nsc_bar_info_box">
|
||||
<h3>Getting Help</h3>
|
||||
<div class="nsc_bar_inside_text">
|
||||
<div>
|
||||
<a target="_blank" href="https://beautiful-cookie-banner.com/documentation/"
|
||||
>Official Documentation</a
|
||||
>
|
||||
</div>
|
||||
<div>Here you can find some documentation for this plugin.</div>
|
||||
<br />
|
||||
<div>
|
||||
<a
|
||||
target="_blank"
|
||||
href="https://wordpress.org/support/plugin/beautiful-and-responsive-cookie-consent/"
|
||||
>Wordpress Support Forum</a
|
||||
>
|
||||
</div>
|
||||
<div>
|
||||
If the documentation is not helping please have a look at the Forum, maybe your question is
|
||||
already answered.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="nsc_bar_info_box">
|
||||
<h3>Description & Credits</h3>
|
||||
<div class="nsc_bar_inside_text">
|
||||
This plugin uses the very great open source cookie consent banner solution from osano:
|
||||
<a href="https://github.com/osano/cookieconsent/tree/master" target="_blank">github link</a>
|
||||
BUT only as basis. In this wordpress plugin version there were some adjustements.<br />
|
||||
If you have feature requests or problems let me know.
|
||||
<p>
|
||||
You want to have a link in your data privacy page or anywhere else on your page to show
|
||||
banner again? Use this shortcode:
|
||||
<strong>[cc_show_cookie_banner_nsc_bar]</strong>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,10 @@
|
||||
<div class="nsc_bar_notice_block_services">
|
||||
<p>
|
||||
<strong>Service Blocking</strong> makes it easy to block third-party services that install
|
||||
cookies, but that comfort comes with a price: it may not be able to block all services and it
|
||||
might remove other assets by accident which were not intended to be removed. Please make sure,
|
||||
that your settings are properly tested on a test system before applying them to production.
|
||||
There is no warrenty that it will work in all situations. In some edge cases it might even break
|
||||
your site.
|
||||
</p>
|
||||
</div>
|
||||
@@ -0,0 +1,15 @@
|
||||
<p>
|
||||
More information how compliance types work and how to use the cookies set by this plugin see in
|
||||
<a
|
||||
href="https://beautiful-cookie-banner.com/documentation/cookie-banner-compliance-types-explained/"
|
||||
target="_blank"
|
||||
>our documentation</a
|
||||
><br /><br />
|
||||
<strong>Notice:</strong> If you want that the banner is shown to all users again, even if
|
||||
they already saved their settings, you must
|
||||
<a
|
||||
href="/wp-admin/options-general.php?page=nsc_bar-cookie-consent&tab=cookie_settings&nsc_bara_language_selector=xx"
|
||||
target="_blank"
|
||||
>rename the cookie.</a
|
||||
>
|
||||
</p>
|
||||
@@ -0,0 +1,4 @@
|
||||
<p>
|
||||
You can export most of your bannersetting with this json: copy it and add it to another wordpress
|
||||
installation. Save it. Thats it.
|
||||
</p>
|
||||
@@ -0,0 +1,5 @@
|
||||
<p>
|
||||
You do not like the "cookie policy" tab? Just deactivate it. You can use this shortcode
|
||||
<br /><br /><strong>[cc_show_cookie_banner_nsc_bar]</strong><br /><br />
|
||||
anywhere in your wordpress installation instead to display a link to the banner settings.
|
||||
</p>
|
||||
@@ -0,0 +1,20 @@
|
||||
<p>
|
||||
This plugin uses the very great open source cookie consent banner solution from osano:
|
||||
<a href="https://github.com/osano/cookieconsent/tree/master" target="_blank">github link</a>
|
||||
BUT only as basis. In this wordpress plugin version there were some adjustements.<br />
|
||||
If you have feature requests or problems let me know.
|
||||
</p>
|
||||
<p>
|
||||
You want to have a link in your data privacy page to show banner again? Use this shortcode:
|
||||
[cc_show_cookie_banner_nsc_bar]
|
||||
</p>
|
||||
<p>
|
||||
If you are awesome, like this plugin and want support its further development leave a rating:
|
||||
<a
|
||||
href="https://wordpress.org/support/plugin/beautiful-and-responsive-cookie-consent/reviews/#new-post"
|
||||
target="_blank"
|
||||
>rate this plugin.</a
|
||||
>
|
||||
or even buy the premium add-on:
|
||||
<a href=" https://beautiful-cookie-banner.com" target="_blank">beautiful-cookie-banner.com</a>
|
||||
</p>
|
||||
Reference in New Issue
Block a user