From c13f02006bcd44ea823d953ca30e2a1ba60c1f1a Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Sat, 8 Aug 2020 18:59:17 -0700 Subject: [PATCH] Let button_with_confirm inherit original CSS when not specified. --- frontends/ycdl_flask/static/js/common.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/frontends/ycdl_flask/static/js/common.js b/frontends/ycdl_flask/static/js/common.js index 00ce0ab..521e72b 100644 --- a/frontends/ycdl_flask/static/js/common.js +++ b/frontends/ycdl_flask/static/js/common.js @@ -195,7 +195,9 @@ function init_button_with_confirm() data-confirm: Text inside the confirm button. Default is to inherit the 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-class @@ -244,7 +246,15 @@ function init_button_with_confirm() var button_confirm = document.createElement("button"); 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; holder_stage2.appendChild(button_confirm); holder_stage2.appendChild(document.createTextNode(" "));