Let button_with_confirm inherit original CSS when not specified.

This commit is contained in:
voussoir 2020-08-08 18:59:17 -07:00
parent 1eafdf5e5b
commit c13f02006b

View file

@ -195,7 +195,9 @@ function init_button_with_confirm()
data-confirm: Text inside the confirm button. Default is to inherit the data-confirm: Text inside the confirm button. Default is to inherit the
original button's text. original button's text.
data-confirm-class data-confirm-class: CSS class for the confirm button. Default is to
inheret all classes of the original button, except for
"button_with_confirm" of course.
data-cancel: Text inside the cancel button. Default is "Cancel". data-cancel: Text inside the cancel button. Default is "Cancel".
data-cancel-class data-cancel-class
@ -244,7 +246,15 @@ function init_button_with_confirm()
var button_confirm = document.createElement("button"); var button_confirm = document.createElement("button");
button_confirm.innerText = (button.dataset.confirm || button.innerText).trim(); button_confirm.innerText = (button.dataset.confirm || button.innerText).trim();
button_confirm.className = button.dataset.confirmClass || ""; if (button.dataset.confirmClass === undefined)
{
button_confirm.className = button.className;
button_confirm.classList.remove("button_with_confirm");
}
else
{
button_confirm.className = button.dataset.confirmClass;
}
button_confirm.input_source = input_source; button_confirm.input_source = input_source;
holder_stage2.appendChild(button_confirm); holder_stage2.appendChild(button_confirm);
holder_stage2.appendChild(document.createTextNode(" ")); holder_stage2.appendChild(document.createTextNode(" "));