vagrant/website/www/source/javascripts/vagrantup.js

59 lines
1.6 KiB
JavaScript
Raw Normal View History

2013-09-03 20:48:55 +00:00
// add dropshadow to nav on scroll
$(document).ready(function(){
2015-11-15 01:12:59 +00:00
$(document).scroll(function() {
var top = $(document).scrollTop();
if (top > 0) $('#header').addClass("drop-shadow");
if (top === 0) $('header').removeClass("drop-shadow");
});
2013-09-03 20:48:55 +00:00
});
// open/close documentation side nav on small screens
$(document).ready(function(){
2015-11-15 01:12:59 +00:00
$(".toggle").click(function() {
$(".sidebar-nav ul").slideToggle('slow');
});
2013-09-03 20:48:55 +00:00
});
// Redirect to the proper checkout screen for quantity
$(document).ready(function() {
2015-11-15 01:12:59 +00:00
var selectedProduct = "";
function setSelectedProduct() {
selectedProduct = $("input[name=product]:checked").val();
}
$(".buy-form input[name=product]").change(function() {
setSelectedProduct();
var text = selectedProduct.charAt(0).toUpperCase() + selectedProduct.slice(1);
$("#buy-fusion").text("Buy " + text + " Licenses Now");
});
$("#buy-fusion").click(function() {
var seats = parseInt($("#seats").val(), 10);
if (isNaN(seats)) {
alert("The number of seats you want to purchase must be a number.");
return;
} else if (seats <= 0) {
alert("The number of seats you want must be greater than zero.");
return;
2013-09-03 20:48:55 +00:00
}
2015-11-15 01:12:59 +00:00
var productId = "";
if (selectedProduct == "fusion") {
productId = "279661674";
} else if (selectedProduct == "workstation") {
productId = "302167489";
} else {
alert("Unknown product selected. Please refresh and try again.");
return;
2013-09-03 20:48:55 +00:00
}
2015-11-15 01:12:59 +00:00
window.location = "http://shopify.hashicorp.com/cart/" + productId + ":" + seats;
});
if ($("#buy-fusion").length > 0) {
setSelectedProduct();
}
2013-09-03 20:48:55 +00:00
});