| 1 |
var tierIndex = parseInt(document.getElementById('wizard-project-monetization-cfg').dataset.tierCount, 10); |
| 2 |
|
| 3 |
function updatePricingUI() { |
| 4 |
var model = document.getElementById('pricing-model').value; |
| 5 |
|
| 6 |
var sections = [ |
| 7 |
{ id: 'buy-once-fields', active: model === 'buy_once' }, |
| 8 |
{ id: 'pwyw-fields', active: model === 'pwyw' }, |
| 9 |
{ id: 'subscription-fields', active: model === 'subscription' } |
| 10 |
]; |
| 11 |
|
| 12 |
sections.forEach(function(s) { |
| 13 |
var el = document.getElementById(s.id); |
| 14 |
el.classList.toggle('hidden', !s.active); |
| 15 |
|
| 16 |
var inputs = el.querySelectorAll('input, select'); |
| 17 |
inputs.forEach(function(inp) { inp.disabled = !s.active; }); |
| 18 |
}); |
| 19 |
} |
| 20 |
|
| 21 |
function addTierForm() { |
| 22 |
var container = document.getElementById('tier-forms'); |
| 23 |
var html = '<div class="tier-form-row">' + |
| 24 |
'<div class="form-group"><label>Tier Name</label>' + |
| 25 |
'<input type="text" name="tier_name_' + tierIndex + '" placeholder="e.g. Supporter" required></div>' + |
| 26 |
'<div class="form-group"><label>Price ($/month)</label>' + |
| 27 |
'<input type="number" name="tier_price_' + tierIndex + '" min="1" step="0.01" placeholder="5.00" required></div>' + |
| 28 |
'<div class="form-group"><label>Description</label>' + |
| 29 |
'<input type="text" name="tier_desc_' + tierIndex + '" placeholder="What members get..."></div>' + |
| 30 |
'</div>'; |
| 31 |
container.insertAdjacentHTML('beforeend', html); |
| 32 |
tierIndex++; |
| 33 |
} |
| 34 |
|
| 35 |
updatePricingUI(); |
| 36 |
|