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 32 if ($button.hasClass('qtyInc')) { 33 if(max){ 34 if (oldValue < max) { 35 var newVal = parseFloat(oldValue) + 1; 36 } else { 37 newVal = oldValue; 38 } 39 } else { 40 var newVal = parseFloat(oldValue) + 1; 41 } 42 43 } else { 44 // don't allow decrementing below zero 45 if (oldValue > 1) { 46 var newVal = parseFloat(oldValue) - 1; 47 } else { 48 newVal = 1; 49 } 50 } 51 52 53 $button.parent().find("input").val(newVal).trigger('change');; 54 qtySum(); 55 $(".qtyTotal").addClass("rotate-x"); 56 57 }); 58 59 // Total Value Counter Animation 60 function removeAnimation() { $(".qtyTotal").removeClass("rotate-x"); } 61 62 const counter = $(".qtyTotal"); 63 counter.on("animationend", removeAnimation); 64 // Adjusting Panel Dropdown Width 65 $(window).on('load resize', function() { 66 var panelTrigger = $('.booking-widget .panel-dropdown a'); 67 $('.booking-widget .panel-dropdown .panel-dropdown-content').css({ 68 'width' : panelTrigger.outerWidth() 69 }); 70 }); 71 72});
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.