diff --git a/BTCPayServer/Views/Stores/PayButton.cshtml b/BTCPayServer/Views/Stores/PayButton.cshtml index 3442f393b..910c404db 100644 --- a/BTCPayServer/Views/Stores/PayButton.cshtml +++ b/BTCPayServer/Views/Stores/PayButton.cshtml @@ -232,7 +232,157 @@ } - + + diff --git a/BTCPayServer/wwwroot/paybutton/paybutton.js b/BTCPayServer/wwwroot/paybutton/paybutton.js index 28b3943f2..dc445186a 100644 --- a/BTCPayServer/wwwroot/paybutton/paybutton.js +++ b/BTCPayServer/wwwroot/paybutton/paybutton.js @@ -37,34 +37,34 @@ var dictionary = { }; VeeValidate.Validator.localize(dictionary); +function getStyles (styles) { + return document.getElementById(styles).innerHTML.trim().replace(/\s{2}/g, '') + '\n' +} + function inputChanges(event, buttonSize) { if (buttonSize !== null && buttonSize !== undefined) { srvModel.buttonSize = buttonSize; } + var isFixedAmount = srvModel.buttonType == 0 + var isCustomAmount = srvModel.buttonType == 1 + var isSlider = srvModel.buttonType == 2 + var width = "209px"; var widthInput = "3em"; if (srvModel.buttonSize === 0) { width = "146px"; widthInput = "2em"; - } else if (srvModel.buttonSize === 1 ) { + } else if (srvModel.buttonSize === 1) { width = "168px"; } else if (srvModel.buttonSize === 2) { width = "209px"; } + var html = - '\n' + + // Styles + getStyles('template-paybutton-styles') + (isSlider ? getStyles('template-slider-styles') : '') + + // Form '
'; + html += ' \n'; + html += ''; $("#mainCode").text(html).html(); $("#preview").html(html); @@ -141,11 +136,5 @@ function addSelectCurrency(currency) { } function addSlider(price, min, max, step, width) { - var input = document.getElementById('template-input-slider').innerHTML.trim(); - input = input.replace("PRICE", price); - input = input.replace("MIN", min); - input = input.replace("MAX", max); - input = input.replace("STEP", step); - input = input.replace("WIDTH", width); - return ' ' + input + '\n'; + return ' \n'; }