PageSourceSearch

https://www.ucg.org/modules/custom/ucg_order_handler/js/cart/cart-icon.js?tlqvpg

js ucg.org collected 2026-09-24 09:20:22 UTC 1,115 bytes, 35 lines download raw bytes

1/**
2 * @file
3 * Handles showing and hiding cart icon and item count.
4 */
5
6"use strict";
7
8Drupal.behaviors.cartIcon = {
9  attach: function (context) {
10    for (const cartIcon of once("cartIcon", "a.cart-icon", context)) {
11      // Show/hide cart icon and set item count; also need to attach event
12      // listener (for cart change event) to update cart icon when the cart is
13      // updated.
14      const updateCartIcon = function(){
15        const freeItems = Ucg.Cart.Handler.freeCart.getNumberOfItems();
16        const donationitems = Ucg.Cart.Handler.variablePriceCart.getNumberOfItems();
17        if(freeItems > 0 || donationitems > 0){
18          cartIcon.classList.remove("d-none");
19        } else {
20          cartIcon.classList.add("d-none");
21        }
22
23        const itemCountNode = cartIcon.querySelector(".cart-icon-count");
24        if(itemCountNode) {
25          const totalItems = freeItems + donationitems;
26          itemCountNode.textContent = totalItems;
27        }
28      }
29      updateCartIcon();
30      window.addEventListener("cartUpdated", function(){
31        updateCartIcon();
32      });
33    }
34  },
35};

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.