<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<!------ Include the above in your HEAD tag ---------->
<div class="container">
<div class="price-box">
<div class="row">
<div class="col-sm-6">
<form class="form-horizontal form-pricing" role="form">
<div class="price-slider">
<h4 class="great">Data Volume</h4>
<span>Approximate data in GB per day</span>
<div class="col-sm-12">
<div id="slider_amirol"></div>
</div>
</div>
<div class="price-slider">
<!--<h4 class="great">Duration</h4>
<span>Please choose one</span>
<button type="button" class="btn btn-primary btn-lg month" data-toggle="button" aria-pressed="false" autocomplete="off" id='24month'>.pdf </button>
<button type="button" class="btn btn-primary btn-lg month" data-toggle="button" aria-pressed="false" autocomplete="off" id='18month'>.jpeg </button>
<button type="button" class="btn btn-primary btn-lg month" data-toggle="button" aria-pressed="false" autocomplete="off" id='office'>.office </button>
<button type="button" class="btn btn-primary btn-lg month" data-toggle="button" aria-pressed="false" autocomplete="off" id='18month'>.pdf </button>
<button type="button" class="btn btn-primary btn-lg month" data-toggle="button" aria-pressed="false" autocomplete="off" id='24month'>.pdf </button>
<div class="btn-group btn-group-justified">
<div class="btn-group btn-group-lg">
<button type="button" class="btn btn-primary btn-lg btn-block month active-month selected-month" data-toggle="button" id='24month'>24 Months</button>
</div>
<div class="btn-group btn-group-lg">
<button type="button" class="btn btn-primary btn-lg btn-block month" id='18month'>18 Months</button>
</div>
<div class="btn-group btn-group-lg">
<button type="button" class="btn btn-primary btn-lg btn-block month" id='12month'>12 Months</button>
</div>
</div> -->
</div>
<div class="price-slider">
<h4 class="great">Filetypes</h4>
<span>Please choose one</span>
<input name="sliderVal" type="hidden" id="sliderVal" value='0' readonly="true"/>
<input name="month" type="hidden" id="month" value='24month' readonly="readonly" />
<input name="filetype" type="hidden" id="filetype" value='quarterly' readonly="readonly" />
<button type="button" class="btn btn-primary btn-lg filetype" data-toggle="button" aria-pressed="false" autocomplete="off" id='.jpeg'>.jpeg </button>
<button type="button" class="btn btn-primary btn-lg filetype" data-toggle="button" aria-pressed="false" autocomplete="off" id='.office'>.office </button>
<button type="button" class="btn btn-primary btn-lg filetype" data-toggle="button" aria-pressed="false" autocomplete="off" id='.xml no schema'>.xml no schema </button>
<button type="button" class="btn btn-primary btn-lg filetype" data-toggle="button" aria-pressed="false" autocomplete="off" id='.xml with schema'>.xml with schema </button>
<!-- <div class="btn-group btn-group-justified">
<div class="btn-group btn-group-lg">
<button type="button" class="btn btn-primary btn-lg btn-block filetype active-filetype selected-filetype" id='quarterly'>Quarterly</button>
</div>
<div class="btn-group btn-group-lg">
<button type="button" class="btn btn-primary btn-lg btn-block filetype" id='monthly'>Monthly</button>
</div>
<div class="btn-group btn-group-lg">
<button type="button" class="btn btn-primary btn-lg btn-block filetype" id='weekly'>Weekly</button>
</div>
</div> -->
</div>
</div>
<div class="col-sm-6">
<div class="price-form">
<div class="form-group">
<div class="row">
<div class="col-sm-6">
<label for="amount_amirol" class="control-label">Annually ($): </label>
<span class="help-text">Amount that you need to pay</span>
</div>
<div class="col-sm-6">
<input type="hidden" id="amount_amirol" class="form-control">
<!-- <p class="price lead" id="total"></p> -->
<input class="price lead" name="totalprice" type="text" id="total" disabled="disabled" style="" />
</div>
</div>
</div>
<!--<div class="form-group">
<div class="row">
<div class="col-sm-6">
<label for="amount_amirol" class="control-label">Monthly ($): </label>
<span class="help-text">Amount that you need to pay</span>
</div>
<div class="col-sm-6">
<input type="hidden" id="amount_amirol" class="form-control">
<p class="price lead" id="total12"></p>
<input class="price lead" name="totalprice12" type="text" id="total12" disabled="disabled" style="" />
</div>
</div>
</div>-->
<div class="form-group">
<div class="row">
<div class="col-sm-6">
<label for="amount_amirol" class="control-label">Time To Completion: </label>
<span class="help-text">Approximate time in days</span>
</div>
<div class="col-sm-6">
<input type="hidden" id="amount_amirol" class="form-control">
<!-- <p class="price lead" id="total52"></p> -->
<input class="price lead" name="totalprice52" type="text" id="total52" disabled="disabled" style="" />
</div>
</div>
</div>
<div style="margin-top:30px"></div>
<hr class="style">
<div class="form-group">
<div class="col-sm-12">
<button type="submit" class="btn btn-primary btn-lg btn-block">Proceed <span class="glyphicon glyphicon-chevron-right"></span></button>
</div>
</div>
<div class="form-group">
<div class="col-sm-12">
<img src="https://github.com/AmirolAhmad/Bootstrap-Calculator/blob/master/images/payment.png?raw=true" class="img-responsive payment" />
</div>
</div>
</div>
</form>
</div>
<p class="text-center" style="padding-top:10px;font-size:12px;color:#2c3e50;font-style:italic;">Created by <a href="https://twitter.com/AmirolAhmad" target="_blank">AmirolAhmad</a></p>
</div>
</div>
</div>
<script
src="https://code.jquery.com/jquery-1.11.1.min.js"
integrity="sha256-VAvG3sHdS5LqTT+5A/aeq/bZGa/Uj04xKxY8KM/w9EE="
crossorigin="anonymous"></script>
<script src="https://code.jquery.com/ui/1.10.4/jquery-ui.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
body {
padding-top: 60px;
}
.price-box {
margin: 0 auto;
background: #E9E9E9;
border-radius: 10px;
padding: 40px 15px;
/*width: 500px;*/
}
.ui-widget-content {
border: 1px solid #bdc3c7;
background: #e1e1e1;
color: #222222;
margin-top: 4px;
}
.ui-slider .ui-slider-handle {
position: absolute;
z-index: 2;
width: 7.2em;
height: 2.7em;
cursor: default;
margin: 0 -40px auto !important;
text-align: center;
line-height: 30px;
color: #FFFFFF;
font-size: 12px;
}
.ui-slider .ui-slider-handle .glyphicon {
color: #FFFFFF;
margin: 0 1px;
font-size: 11px;
opacity: 0.7;
}
.ui-corner-all {
border-radius: 20px;
}
.ui-slider-horizontal .ui-slider-handle {
top: -.9em;
}
.ui-state-default,
.ui-widget-content .ui-state-default {
border: 1px solid #f9f9f9;
background: #3498db;
}
.ui-slider-horizontal .ui-slider-handle {
margin-left: -0.5em;
}
.ui-slider .ui-slider-handle {
cursor: pointer;
}
.ui-slider a,
.ui-slider a:focus {
cursor: pointer;
outline: none;
}
.price, .lead p {
font-weight: 600;
font-size: 32px;
display: inline-block;
line-height: 60px;
border:0;
width: 245px;
}
h4.great {
background: #00ac98;
margin: 0 0 25px -60px;
padding: 7px 15px;
color: #ffffff;
font-size: 18px;
font-weight: 600;
border-radius: 5px;
display: inline-block;
-moz-box-shadow: 2px 4px 5px 0 #ccc;
-webkit-box-shadow: 2px 4px 5px 0 #ccc;
box-shadow: 2px 4px 5px 0 #ccc;
}
.total {
border-bottom: 1px solid #7f8c8d;
/*display: inline;
padding: 10px 5px;*/
position: relative;
padding-bottom: 20px;
}
.total:before {
content: "";
display: inline;
position: absolute;
left: 0;
bottom: 5px;
width: 100%;
height: 3px;
background: #7f8c8d;
opacity: 0.5;
}
.price-slider {
margin-bottom: 70px;
}
.price-slider span {
font-weight: 200;
display: inline-block;
color: #7f8c8d;
font-size: 13px;
}
.form-pricing {
background: #ffffff;
padding: 20px;
border-radius: 4px;
}
.price-form {
background: #ffffff;
margin-bottom: 10px;
padding: 20px;
border: 1px solid #eeeeee;
min-height: 520px;
border-radius: 4px;
/*-moz-box-shadow: 0 5px 5px 0 #ccc;
-webkit-box-shadow: 0 5px 5px 0 #ccc;
box-shadow: 0 5px 5px 0 #ccc;*/
}
.form-group {
margin-bottom: 0;
}
.form-group span.price {
font-weight: 200;
display: inline-block;
color: #7f8c8d;
font-size: 14px;
}
.help-text {
display: block;
margin-top: -10px;
margin-bottom: 10px;
color: #737373;
/*position: absolute;*/
/*margin-left: 20px;*/
font-weight: 200;
/*text-align: right;*/
width: 188px;
}
.price-form label {
font-weight: 200;
font-size: 21px;
}
img.payment {
display: block;
margin-left: auto;
margin-right: auto
}
.ui-slider-range-min {
background: #2980b9;
}
.active-month,
.active-term {
background: #3276b1;
}
/* HR */
hr.style {
margin-top: 0;
border: 0;
border-bottom: 1px dashed #ccc;
background: #999;
}
// JavaScript Document
var p = {
0: "1 GB",
1: "10 GB",
2: "20 GB",
3: "30 GB",
4: "40 GB",
5: "50 GB",
6: "60 GB",
7: "70 GB",
8: "80 GB",
9: "90 GB",
10: "100 GB",
11: "150 GB",
12: "200 GB",
13: "300 GB",
14: "400 GB",
15: "500 GB",
16: "600 GB",
17: "700 GB",
18: "800 GB",
19: "900 GB",
20: "1 TB",
21: "2 TB",
22: "3 TB",
23: "4 TB",
24: "5 TB",
25: "6 TB",
26: "7 TB",
27: "8 TB",
28: ">8 TB",
};
/**
* Constructor function for the FileType class
* @param calc function(gigs): calculation function that takes in the amout of gigs and returns a price
* @param time int: the number of days the feed takes to complete
*/
function FileType(time,calc){
var obj = new Object();
obj.calc = calc;
obj.time = time;
return obj;
}
/**
* FileType storage, All values should be instances of the FileType class
*/
var obj = {
'.jpeg' : FileType(2,function(gigs){
if(gigs<6){
return 0;
}else{
return gigs * 1000
}
}),
'.office' : FileType(1,function(gigs){return 0;}),
'.xml no schema' : FileType(1,function(gigs){return 0;}),
'.xml with schema' : FileType(1,function(gigs){return 0;}),
};
$(document).ready(function() {
$("#total").val("10000");
$("#slider_amirol").slider({
range: "min",
animate: true,
min: 0,
max: 28,
step: 1,
//Slider change handler
slide:
function(event, ui)
{
//console.log(ui.value);
var sliderIndex = ui.value;
updateSliderValue(sliderIndex); //changed
calcualtePrice();
}
});
/* $('.month').on('click',function(event) {
var id = $(this).attr('id');
$('.month').removeClass('selected-month');
$(this).addClass('selected-month');
$(".month").removeClass("active-month");
$(this).addClass("active-month");
$('#month').val(id);
calcualtePrice()
});
*/
$('.filetype').on('click',function(event) {
var id = $(this).attr('id');
$('.filetype').removeClass('selected-filetype');
$(this).addClass('selected-filetype');
$(".filetype").removeClass("active-filetype");
$(this).addClass("active-filetype");
$('#filetype').val(id);
calcualtePrice()
});
updateSliderValue();
calcualtePrice();
});
/**
* Converts the slider value
*/
function convertGbString(val){
if(val === undefined)
return "0 GB";
temp = val.split(" ");
var multiplier = 1;
if(temp[1]=="TB"){
multiplier=1000;
}
return temp[0]*multiplier;
}
/**
* Updates the slider text, and the sliderVal input value
* @param newIndex int: the new index of the slider
*/
function updateSliderValue(newIndex) {
if(undefined === newIndex) newIndex = 0;
var amount = p[newIndex];
$('#sliderVal').val(newIndex);
$('#slider_amirol a').html('<label><span class="glyphicon glyphicon-chevron-left"></span> '+amount+' <span class="glyphicon glyphicon-chevron-right"></span></label>');
}
/**
* Calculate the price and update price and and time to completion
*/
function calcualtePrice(){
var val = $('#sliderVal').val();
if(val ===undefined)
val=0;
/*if(obj[month] == office)
val = 5; */
/*var month = $('#month').val(); */
var fT = obj[$('#filetype').val()];
if(undefined === fT){
return;
}
//get calculation function based on file type
val = p[val];
val = convertGbString(val);
//calculate with calculation function
var totalPrice = fT.calc(val);
var totalTime = 1*fT.time;
$("#total").val(totalPrice.toFixed(2)+0);
$("#total52").val(Math.round((totalTime)+0).toFixed(2));
}