PageSourceSearch

https://zippykind.com/assets/front/v3/assets/js/zk-demo.js?ver=2.1.5

js zippykind.com collected 2026-10-01 23:52:32 UTC 5,829 bytes, 171 lines download raw bytes

1/*! Zippykind LLC - Proprietary and confidential. Copyright (c) Zippykind LLC. All rights reserved.
2 *  zk-signature: sha256=e8272b8d4ac14091a3ec4486a21cb70ea6eb5f1131d8f1c818850380c8443148 file=zk-demo.js by=Zippykind LLC
3 */
4/* fe-862 */
5;(function(){var s="Zippykind LLC|zk-signature|sha256=e8272b8d4ac14091a3ec4486a21cb70ea6eb5f1131d8f1c818850380c8443148|file=zk-demo.js";return s;})();
6(function () {
7  "use strict";
8
9  var modal = document.getElementById("zk-demo");
10  if (!modal) return;
11
12  // fe-863
13  var ENDPOINT = "/ajaxfront/bookDemo";
14  var STUBBED = false;
15  var MIN_VOLUME = 5000;       // fe-864
16
17  var card = modal.querySelector(".zk-modal-card");
18  var form = modal.querySelector(".zk-demo-form");
19  var errBox = modal.querySelector("[data-zk-error]");
20  var lastFocus = null;
21
22  function views() {
23    return modal.querySelectorAll(".zk-modal-view");
24  }
25  function show(view) {
26    views().forEach(function (v) { v.hidden = v.getAttribute("data-zk-view") !== view; });
27  }
28
29  function open(e) {
30    if (e) e.preventDefault();
31    lastFocus = document.activeElement;
32    show("form");
33    modal.classList.add("is-open");
34    modal.setAttribute("aria-hidden", "false");
35    document.body.style.overflow = "hidden";
36    var first = form.querySelector("input, select, textarea");
37    if (first) setTimeout(function () { first.focus(); }, 40);
38    document.addEventListener("keydown", onKey);
39  }
40  function close() {
41    modal.classList.remove("is-open");
42    modal.setAttribute("aria-hidden", "true");
43    document.body.style.overflow = "";
44    document.removeEventListener("keydown", onKey);
45    if (lastFocus && lastFocus.focus) lastFocus.focus();
46  }
47
48  function onKey(e) {
49    if (e.key === "Escape") { close(); return; }
50    if (e.key !== "Tab") return;
51    // fe-865
52    var f = card.querySelectorAll(
53      'a[href], button:not([disabled]), input:not([disabled]), select, textarea, [tabindex]:not([tabindex="-1"])');
54    var vis = Array.prototype.filter.call(f, function (el) { return el.offsetParent !== null; });
55    if (!vis.length) return;
56    var first = vis[0], last = vis[vis.length - 1];
57    if (e.shiftKey && document.activeElement === first) { e.preventDefault(); last.focus(); }
58    else if (!e.shiftKey && document.activeElement === last) { e.preventDefault(); first.focus(); }
59  }
60
61  function fail(msg) {
62    if (!errBox) return;
63    errBox.textContent = msg;
64    errBox.hidden = false;
65  }
66
67  form.addEventListener("submit", function (e) {
68    e.preventDefault();
69    if (errBox) errBox.hidden = true;
70
71    // fe-866
72    if (!form.checkValidity()) {
73      form.reportValidity();
74      return;
75    }
76
77    // fe-867
78    var vsel = form.volume;
79    if (!vsel.value) { fail("Please choose your monthly delivery volume."); return; }
80    var vmin = parseInt(vsel.value, 10);
81    var vlabel = vsel.options[vsel.selectedIndex].text;
82
83    // fe-868
84    if (vmin < MIN_VOLUME) {
85      // fe-869
86      if (window.zkTrack && window.zkTrack.ix) {
87        window.zkTrack.ix("form", { s: "demo-modal", id: "zk-demo-form",
88                                    conv: "demo", disqualified: true, vol: vlabel });
89      }
90      show("under");
91      return;
92    }
93
94    var payload = {
95      name: form.name.value.trim(),
96      email: form.email.value.trim(),
97      company: form.company.value.trim(),
98      phone: form.phone.value.trim(),
99      volume: vlabel,
100      // fe-870
101      delivery_locations: form.delivery_locations.value,
102      preferred_date: form.preferred_date.value,
103      preferred_time: form.preferred_time.value,
104      message: form.message.value.trim()
105    };
106
107    // fe-871
108    ["zk_vid", "zkref", "zkcid", "zk_channel"].forEach(function (k) {
109      var el = form.querySelector('[name="' + k + '"]');
110      if (el && el.value) payload[k] = el.value;
111    });
112
113    // fe-872
114    if (window.zkRoiSnapshot) { payload.roi = window.zkRoiSnapshot; }
115
116    // fe-873
117    if (window.zkTrack && window.zkTrack.conversion) {
118      window.zkTrack.conversion("demo", {
119        s: "demo-modal",
120        volume: vlabel,
121        company: payload.company,
122        roi: !!window.zkRoiSnapshot
123      });
124    }
125
126    var btn = form.querySelector(".zk-modal-submit");
127    btn.disabled = true;
128    btn.textContent = "Sending…";
129
130    submit(payload)
131      .then(function () { show("done"); })
132      .catch(function () { fail("Something went wrong. Please email [email protected]."); })
133      .then(function () { btn.disabled = false; btn.textContent = "Request my demo"; });
134  });
135
136  function submit(payload) {
137    if (STUBBED) {
138      // fe-874
139      console.warn("[zk-demo] STUBBED: no email sent. Payload that WOULD go to " +
140                   "[email protected] via " + ENDPOINT + ":", payload);
141      return new Promise(function (res) { setTimeout(res, 500); });
142    }
143    // fe-875
144    var body = new URLSearchParams();
145    Object.keys(payload).forEach(function (k) {
146      var v = payload[k];
147      if (v === null || v === undefined) return;
148      body.append(k, typeof v === "object" ? JSON.stringify(v) : v);
149    });
150    var hp = form.querySelector('[name="zk_hp_website"]');
151    if (hp) body.append("zk_hp_website", hp.value);
152    return fetch(ENDPOINT, {
153      method: "POST",
154      headers: { "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8" },
155      body: body.toString()
156    }).then(function (r) {
157      if (!r.ok) throw new Error(r.status);
158      return r.json();
159    }).then(function (j) {
160      if (!j || j.code !== 1) throw new Error((j && j.msg) || "failed");
161    });
162  }
163
164  // fe-876
165  document.addEventListener("click", function (e) {
166    var t = e.target.closest("[data-zk-open-demo]");
167    if (t) { open(e); return; }
168    if (e.target.closest("[data-zk-close]")) { close(); return; }
169    if (e.target.closest("[data-zk-back]")) { show("form"); return; }
170  });
171})();

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.