1/*----------------------------------------------------*/ 2/* Quantity Buttons with Total Value Counter 3/* 4/* Author: Vasterad 5/* Version: 1.0 6/*----------------------------------------------------*/ 7 8jQuery(document).ready(function($) { 9 10 function qtySum(){ 11 var arr = document.getElementsByName('qtyInput'); 12 var tot=0; 13 for(var i=0;i<arr.length;i++){ 14 if(parseInt(arr[i].value)) 15 tot += parseInt(arr[i].value); 16 } 17 18 var cardQty = $(".qtyTotal"); 19 cardQty.html(tot); 20 } 21 qtySum(); 22 23 $(".qtyButtons input").after('<div class="qtyInc"></div>'); 24 $(".qtyButtons input").before('<div class="qtyDec"></div>'); 25 26 $(".qtyDec, .qtyInc").on("click", function() { 27 28 var $button = $(this); 29 var oldValue = $button.parent().find("input").val(); 30 var max = $button.parent().find("input").data('max'); 31 var min = $button.parent().find("input").data('min'); 32 33 if ($button.hasClass('qtyInc')) { 34 if(max){ 35 if (oldValue < max) { 36 var newVal = parseFloat(oldValue) + 1; 37 } else { 38 newVal = oldValue; 39 } 40 } else { 41 var newVal = parseFloat(oldValue) + 1; 42 } 43 44 } else { 45 // don't allow decrementing below zero 46 if(min){ 47 48 if (oldValue > min) { 49 50 var newVal = parseFloat(oldValue) - 1; 51 } else { 52 newVal = oldValue; 53 } 54 } else { 55 if (oldValue > 1) { 56 var newVal = parseFloat(oldValue) - 1; 57 } else { 58 newVal = 1; 59 } 60 } 61 62 } 63 64 65 $button.parent().find("input").val(newVal).trigger('change');; 66 qtySum(); 67 $(".qtyTotal").addClass("rotate-x"); 68 69 }); 70 71 // Total Value Counter Animation 72 function removeAnimation() { $(".qtyTotal").removeClass("rotate-x"); } 73 74 const counter = $(".qtyTotal"); 75 counter.on("animationend", removeAnimation); 76 // Adjusting Panel Dropdown Width 77 $(window).on('load resize', function() { 78 var panelTrigger = $('.booking-widget .panel-dropdown a'); 79 $('.booking-widget .panel-dropdown .panel-dropdown-content').css({ 80 'width' : panelTrigger.outerWidth() 81 }); 82 }); 83 84});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.