add calculator placeholder to cms_integration
This commit is contained in:
parent
67a6c8f2c2
commit
3bf064a017
13 changed files with 195 additions and 74 deletions
|
|
@ -1,7 +1,7 @@
|
|||
/* Create VM calculator */
|
||||
|
||||
.price-calc-section {
|
||||
padding: 80px 40px !important;
|
||||
padding: 20px 0 !important;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
|
|
@ -40,7 +40,7 @@
|
|||
}
|
||||
|
||||
.price-calc-section .card {
|
||||
width: 50%;
|
||||
/* width: 50%; */
|
||||
margin: 0 auto;
|
||||
background: #fff;
|
||||
box-shadow: 1px 3px 6px 2px rgba(0, 0, 0, 0.2);
|
||||
|
|
@ -52,7 +52,7 @@
|
|||
|
||||
@media (min-width: 768px) {
|
||||
.price-calc-section .card {
|
||||
margin-left: 0;
|
||||
/* margin-left: 0; */
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -153,4 +153,84 @@ $( document ).ready(function() {
|
|||
$('.navbar-fixed-top.topnav').css('padding-right', topnavPadding-scrollbarWidth);
|
||||
}
|
||||
});
|
||||
|
||||
/* ---------------------------------------------
|
||||
Scripts initialization
|
||||
--------------------------------------------- */
|
||||
var cardPricing = {
|
||||
'cpu': {
|
||||
'id': 'coreValue',
|
||||
'value': 1,
|
||||
'min': 1,
|
||||
'max': 48,
|
||||
'interval': 1
|
||||
},
|
||||
'ram': {
|
||||
'id': 'ramValue',
|
||||
'value': 2,
|
||||
'min': 1,
|
||||
'max': 200,
|
||||
'interval': 1
|
||||
},
|
||||
'storage': {
|
||||
'id': 'storageValue',
|
||||
'value': 10,
|
||||
'min': 10,
|
||||
'max': 2000,
|
||||
'interval': 10
|
||||
}
|
||||
};
|
||||
|
||||
function _initPricing() {
|
||||
_fetchPricing();
|
||||
|
||||
$('.fa-minus-circle.left').click(function(event) {
|
||||
var data = $(this).data('minus');
|
||||
|
||||
if (cardPricing[data].value > cardPricing[data].min) {
|
||||
cardPricing[data].value = Number(cardPricing[data].value) - cardPricing[data].interval;
|
||||
}
|
||||
_fetchPricing();
|
||||
});
|
||||
$('.fa-plus-circle.right').click(function(event) {
|
||||
var data = $(this).data('plus');
|
||||
if (cardPricing[data].value < cardPricing[data].max) {
|
||||
cardPricing[data].value = Number(cardPricing[data].value) + cardPricing[data].interval;
|
||||
}
|
||||
_fetchPricing();
|
||||
});
|
||||
|
||||
$('.input-price').change(function() {
|
||||
var data = $(this).attr("name");
|
||||
cardPricing[data].value = $('input[name=' + data + ']').val();
|
||||
_fetchPricing();
|
||||
});
|
||||
}
|
||||
|
||||
function _fetchPricing() {
|
||||
Object.keys(cardPricing).map(function(element) {
|
||||
$('input[name=' + element + ']').val(cardPricing[element].value);
|
||||
});
|
||||
_calcPricing();
|
||||
}
|
||||
|
||||
function _calcPricing() {
|
||||
if(typeof window.coresUnitPrice === 'undefined'){
|
||||
window.coresUnitPrice = 5;
|
||||
}
|
||||
if(typeof window.ramUnitPrice === 'undefined'){
|
||||
window.coresUnitPrice = 2;
|
||||
}
|
||||
if(typeof window.ssdUnitPrice === 'undefined'){
|
||||
window.ssdUnitPrice = 0.6;
|
||||
}
|
||||
console.log(coresUnitPrice, ramUnitPrice, ssdUnitPrice, cardPricing)
|
||||
var total = (cardPricing['cpu'].value * window.coresUnitPrice) +
|
||||
(cardPricing['ram'].value * window.ramUnitPrice) +
|
||||
(cardPricing['storage'].value * window.ssdUnitPrice);
|
||||
total = parseFloat(total.toFixed(2));
|
||||
$("#total").text(total);
|
||||
}
|
||||
|
||||
_initPricing();
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue