Pass params in form pricing

This commit is contained in:
Henry Bravo 2017-05-23 12:06:48 -05:00
parent 506fbca204
commit c383156c42
4 changed files with 119 additions and 16 deletions

View file

@ -528,6 +528,10 @@ h6 {
position: relative;
text-align: right;
}
.price-calc-section .text .description{
font-size: 20px;
text-align: right;
}
.price-calc-section .text .section-heading::before{
content: "";
position: absolute;
@ -565,9 +569,13 @@ h6 {
padding: 12px;
border-bottom: 1px solid rgba(128, 128, 128, 0.3);
position: relative;
display: flex;
justify-content: center;
align-items: center;
}
.price-calc-section .card .description span{
font-size: 20px;
margin-left: 4px;
}
.price-calc-section .card .description i{
color: #29427A;
@ -588,6 +596,25 @@ h6 {
}
.price-calc-section .card .btn{
margin-top: 20px;
font-size: 20px;
width: 200px;
}
.price-calc-section .card .select-configuration select{
outline: none;
background: #fff;
border-color: #d0d0d0;
height: 40px;
width: 200px;
text-align: center;
font-size: 18px;
}
.price-calc-section .card .check-ip{
font-size: 18px;
}
.price-calc-section .card .check-ip input[type=checkbox]{
font-size: 17px;
margin: 0 8px;
}
@media(max-width:990px) {

View file

@ -5,7 +5,23 @@
/* ---------------------------------------------
Scripts initialization
--------------------------------------------- */
var cardPricing ={
'cpu': {
'id': 'coreValue',
'value': 1,
'limit': 48
},
'ram': {
'id': 'ramValue',
'value': 1,
'limit': 200
},
'storage': {
'id': 'storageValue',
'value': 1,
'limit': 500
}
}
$(window).load(function(){
@ -16,6 +32,7 @@
_navScroll();
_initScroll();
_initNavUrl();
_initPricing();
});
@ -41,7 +58,6 @@
function _navScroll(){
if($(window).scrollTop() > 10 ){
console.log($(window).scrollTop());
$(".navbar").removeClass("navbar-transparent");
$(".navbar-default .btn-link").css("color", "#777");
}else{
@ -65,6 +81,39 @@
}
}
function _initPricing(){
_fetchPricing();
$('.fa-minus-circle.left').click(function(event){
var data = $(this).data('minus');
if(cardPricing[data].value > 1){
cardPricing[data].value --;
}
_fetchPricing();
});
$('.fa-plus-circle.right').click(function(event){
var data = $(this).data('plus');
if(cardPricing[data].value < cardPricing[data].limit){
cardPricing[data].value ++;
}
_fetchPricing();
});
}
function _fetchPricing(){
Object.keys(cardPricing).map(function(element){
$('#'+cardPricing[element].id).text(cardPricing[element].value);
$('input[name='+element+']').val(cardPricing[element].value);
});
_calcPricing();
}
function _calcPricing(){
var total = (cardPricing['cpu'].value * 5) + (2* cardPricing['ram'].value) + (0.6* cardPricing['storage'].value)
$("#total").text(total);
$('input[name=total]').val(total);
}
function form_success(){
$('#sucessModal').modal('show');
}

View file

@ -243,7 +243,7 @@
<p>{% trans "15 GiB storage(SSD)" %}</p>
</div>
</div>
<a href="#" class="btn btn-primary">{% trans "Buy Now!" %}</a>
<a href="{% url 'datacenterlight:pricing' %}" class="btn btn-primary">{% trans "Buy Now!" %}</a>
</div>
</div>
</div>

View file

@ -52,8 +52,8 @@
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a id="logoBlack" class="navbar-brand topnav url" href="/datacenterlight" ><img src="{% static 'datacenterlight/img/logo_black.svg' %}"></a>
<a id="logoWhite" class="navbar-brand topnav url" href="/datacenterlight" ><img src="{% static 'datacenterlight/img/logo_white.svg' %}"></a>
<a id="logoBlack" class="navbar-brand topnav url" href="{% url 'datacenterlight:index' %}" ><img src="{% static 'datacenterlight/img/logo_black.svg' %}"></a>
<a id="logoWhite" class="navbar-brand topnav url" href="{% url 'datacenterlight:index' %}" ><img src="{% static 'datacenterlight/img/logo_white.svg' %}"></a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
@ -106,38 +106,65 @@
<div class="price-calc-section">
<div class="card">
<div class="caption">
<form action="POST">
<div class="title">
<h3>{% trans "VM hosting" %} </h3>
</div>
<div class="price">
<span id="total">15CHF</span>
<span id="total">15</span>
<span>CHF</span>
</div>
<div class="descriptions">
<div class="description">
<p>{% trans "Based in Switzerland" %}</p>
</div>
<div class="description">
<i class="left fa fa-minus-circle" aria-hidden="true"></i>
<span id="coreValue">1</span> <span>core</span>
<i class="right fa fa-plus-circle" aria-hidden="true"></i>
<i class="fa fa-minus-circle left" data-minus="cpu" aria-hidden="true"></i>
<span id="coreValue">1</span><span> core</span>
<i class="fa fa-plus-circle right" data-plus="cpu" aria-hidden="true"></i>
</div>
<div class="description">
<i class="left fa fa-minus-circle" aria-hidden="true"></i>
<span id="ramValue">2</span><span> GiB RAM,</span>
<i class="right fa fa-plus-circle" aria-hidden="true"></i>
<i class="fa fa-minus-circle left" data-minus="ram" aria-hidden="true"></i>
<span id="ramValue">2</span><span> GiB RAM</span>
<i class="fa fa-plus-circle right" data-plus="ram" aria-hidden="true"></i>
</div>
<div class="description">
<i class="left fa fa-minus-circle" aria-hidden="true"></i>
<i class="fa fa-minus-circle left" data-minus="storage" aria-hidden="true"></i>
<span id="storageValue">15</span><span>{% trans "GiB storage(SSD)" %}</span>
<i class="right fa fa-plus-circle" aria-hidden="true"></i>
<i class="fa fa-plus-circle right" data-plus="storage" aria-hidden="true"></i>
</div>
<div class="description select-configuration">
<select name="config" id="">
<option value="" disabled selected>Configuration</option>
<option value="CentOS 7">CentOS 7</option>
<option value="Debian 8">Debian 8</option>
<option value="Ubuntu 14.04">Ubuntu 14.04</option>
<option value="Ubuntu 16.04">Ubuntu 16.04</option>
</select>
</div>
<input type="hidden" name="cpu">
<input type="hidden" name="ram">
<input type="hidden" name="storage">
<input type="hidden" name="total">
<div class="description check-ip">
<input type="checkbox" name="ipv6"> Ipv6 Only<br>
</div>
</div>
<a href="#" class="btn btn-primary">{% trans "Buy Now!" %}</a>
<input type="submit" class="btn btn-primary" value="{% trans 'Buy Now!' %}"></input>
</form>
</div>
</div>
<div class="text">
<h2 class="section-heading">{% trans "We are cutting down the costs significantly!" %}</h2>
<h2 class="section-heading">{% trans "Simple and affordable: Try our virtual machine with featherlight price." %}</h2>
<div class="description">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ab laudantium quis quam nostrum ipsum est nisi asperiores provident recusandae aliquid, reiciendis vitae quisquam error, porro fuga obcaecati maiores dolores repudiandae?</p>
</div>
</div>
</div>