Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Declaring constants
- // Meant to represent number of items per page
- var MAXITEMSPERPAGE = 5;
- function openTab(evt, tabName) {
- // Declare all variables
- var i, tabcontent, tablinks;
- // Get all elements with class="tabcontent" and hide them
- tabcontent = document.getElementsByClassName("tabcontent");
- for (i = 0; i < tabcontent.length; i++) {
- tabcontent[i].style.display = "none";
- }
- // Get all elements with class="tablinks" and remove the class "active"
- tablinks = document.getElementsByClassName("tablinks");
- for (i = 0; i < tablinks.length; i++) {
- tablinks[i].className = tablinks[i].className.replace(" active", "");
- }
- // Show the current tab, and add an "active" class to the button that opened the tab
- document.getElementById(tabName).style.display = "block";
- evt.currentTarget.className += " active";
- }
- // Toggles hamburger-menu
- function toggleMenu(){
- $('.hamburger').toggleClass('is-active');
- $('#main-nav').toggleClass('toggled');
- }
- // Scroll to top
- $(window).scroll(function() {
- if ($(this).scrollTop() >= 50) {
- $('.scrollMobile').fadeIn(200);
- } else {
- $('.scrollMobile').fadeOut(200);
- }
- });
- $(".scrollMobile").click(function() {
- $('html, body').animate({
- scrollTop: $("#navbar-wrapper").offset().top
- }, ($(document).height() - 800));
- });
- // Display current amount of items in shopping cart
- function getAmount() {
- var amount = 0;
- $.each(document.cookie.split(/; */), function() {
- var splitCookie = this.split('=');
- if (splitCookie[0].length == 36) {
- amount++;
- }
- });
- if (amount > 0) {
- $('#shopping-items').html(amount);
- }
- else {
- $('#shopping-items').html('');
- }
- }
- $(document).ready(function(){
- getAmount();
- });
- // Add item to cart
- function addItem(){
- var expires;
- var date = new Date();
- date.setDate(date.getDate() + 7);
- expires = "; expires=" + date.toGMTString();
- // set cookie
- document.cookie = $('#courseID').html() + "=" + $('#courseID').html() + expires + "; path=/site/";
- showPopup();
- getAmount();
- }
- // Shopping cart popup
- function showPopup() {
- $('.pop-up').toggleClass('hidden').fadeIn('slow');
- $('.pop-up').css('opacity', '1');
- }
- // Delete item from cart
- function deleteItem(id) {
- document.cookie = id + "=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/site/;";
- location.reload();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement