Created
October 4, 2019 20:56
-
-
Save denlunev/cf6cb6ccdd0406a0dc62911aba49b308 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src='https://widgets.depositfix.com/v1/app.min.js'></script> | |
<script type='text/javascript' id='df-script'> DepositFixForm.init({ | |
formId: 'dffhuwfj-453b-44b4-83e8-fc199741359j', | |
portalId: '1705488', | |
settings: { | |
multipleContacts: { | |
fields: ['email', 'firstname', 'lastname', 'mobilephone'] | |
} | |
}, | |
callbacks: { | |
onFormReady: function(){ | |
var maxCoaches = 10; | |
var isStaticPrice = false; | |
DepositFixForm.widget.view.getHSFrame().getElementById("df-subscription").innerText = ''; | |
DepositFixForm.widget.view.getHSFrame().getElementById("df_subscriptions").addEventListener('change', function(){ | |
var value = this.options[this.selectedIndex].value; | |
if('plan_Fqdej6Qtt7TXUs' == value || 'plan_FqdgdiTKM82X3i' == value){ | |
if('plan_Fqdej6Qtt7TXUs' == value){ | |
maxCoaches = 5; | |
}else if('plan_FqdgdiTKM82X3i' == value){ | |
maxCoaches = 10; | |
} | |
checkQuantityMax(); | |
setQuantityListener(); | |
DepositFixForm.widget.view.getHSFrame().getElementById("df-subscription").innerText = 'Up to ' + maxCoaches + ' seats'; | |
isStaticPrice = true; | |
}else{ | |
isStaticPrice = false; | |
setNormalQuantity(); | |
DepositFixForm.widget.view.getHSFrame().getElementById("df-subscription").innerText = ''; | |
} | |
}); | |
DepositFixForm.widget.view.getHSFrame().getElementById("df_subscription_quantity").addEventListener('change', function(){ | |
if(isStaticPrice){ | |
checkQuantityMax(); | |
setQuantityListener(); | |
}else{ | |
setNormalQuantity(); | |
} | |
}); | |
setNormalQuantity = function(){ | |
DepositFixForm.widget.getSubscriptionForm().quantityForm.quantity = DepositFixForm.widget.view.getHSFrame().getElementById("df_subscription_quantity").value; | |
DepositFixForm.widget.getSubscriptionForm().setQuantity(); | |
} | |
checkQuantityMax = function(){ | |
var quantityElement = DepositFixForm.widget.view.getHSFrame().getElementById("df_subscription_quantity"); | |
if(quantityElement.value > maxCoaches){ | |
quantityElement.value = maxCoaches; | |
quantityElement.dispatchEvent(new Event('input')); | |
} | |
} | |
setQuantityListener = function(){ | |
DepositFixForm.widget.getSubscriptionForm().quantityForm.quantity = 1; | |
DepositFixForm.widget.getSubscriptionForm().setQuantity(); | |
} | |
} | |
} | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment