@versoly/plugins 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1032 @@
1
+ "use strict";
2
+ (() => {
3
+ // src/config.ts
4
+ var defineConfig = (config) => {
5
+ return config;
6
+ };
7
+
8
+ // src/plugins/headroom.ts
9
+ var headroom = defineConfig({
10
+ name: "Headroom",
11
+ cdnUrls: [
12
+ {
13
+ url: "https://cdnjs.cloudflare.com/ajax/libs/headroom/0.12.0/headroom.min.js",
14
+ inline: false,
15
+ defer: true
16
+ }
17
+ ],
18
+ js: `window.vGetElementsByToggle('headroom').forEach((elem, index) => {
19
+ let options = window.vGetElementOptions(elem);
20
+
21
+ var headroom = new Headroom(elem, {
22
+ classes: {
23
+ pinned: "d-block block",
24
+ unpinned: 'd-none hidden'
25
+ },
26
+ ...options
27
+ });
28
+
29
+ headroom.init();
30
+ });`,
31
+ checks: [{ plugin: "headroom" }],
32
+ components: []
33
+ });
34
+
35
+ // src/plugins/marquee.ts
36
+ var src = "https://d1pnnwteuly8z3.cloudfront.net/libs/versoly-marquee/0.0.2/versoly-marquee.iife.js";
37
+ var marquee = defineConfig({
38
+ name: "Marquee",
39
+ options: {
40
+ name: "Marquee",
41
+ previewInEditor: true,
42
+ isShown: {
43
+ props: {
44
+ "data-toggle": "marquee"
45
+ }
46
+ },
47
+ fields: [
48
+ {
49
+ name: "Loop",
50
+ type: "BooleanPropOption",
51
+ propsName: "data-options.loop",
52
+ defaultValue: true,
53
+ enabledValue: true,
54
+ inHeaderAction: true,
55
+ headerGroup: "Core"
56
+ },
57
+ {
58
+ name: "Duration",
59
+ type: "SliderPropOption",
60
+ propsName: "data-options.duration",
61
+ min: 1,
62
+ max: 20,
63
+ stepSize: 1,
64
+ defaultValue: 5
65
+ },
66
+ {
67
+ name: "Direction",
68
+ type: "IconButtonOption",
69
+ propsName: "data-options.direction",
70
+ options: ["ltr", "rtl", "ttb", "btt"],
71
+ defaultValue: "ltr"
72
+ },
73
+ {
74
+ name: "Pauseable",
75
+ type: "BooleanPropOption",
76
+ propsName: "data-options.pauseable",
77
+ defaultValue: true
78
+ },
79
+ {
80
+ name: "Iterations",
81
+ type: "SliderPropOption",
82
+ propsName: "data-options.iterations",
83
+ min: 1,
84
+ max: 5,
85
+ stepSize: 1,
86
+ defaultValue: 1,
87
+ enabledValue: 1,
88
+ inHeaderAction: true,
89
+ headerGroup: "Core"
90
+ }
91
+ ]
92
+ },
93
+ checks: [{ plugin: "marquee" }],
94
+ src,
95
+ cdnUrls: [
96
+ {
97
+ url: src,
98
+ defer: true
99
+ }
100
+ ],
101
+ js: `window.vMarquees = [];
102
+ window.vGetElementsByToggle('marquee').forEach((elem, index) => {
103
+ const options = window.vGetElementOptions(elem);
104
+ const marquee = new Marquee(elem, options);
105
+ elem.setAttribute('data-marquee-index', index);
106
+ window.vMarquees.push(elem);
107
+ });`,
108
+ displayNames: [
109
+ {
110
+ displayName: "Marquee",
111
+ property: "data-toggle",
112
+ value: "marquee"
113
+ }
114
+ ]
115
+ });
116
+
117
+ // src/plugins/swiper.ts
118
+ var js = `
119
+ window.vSwipers = [];
120
+ window.vGetElementsByToggle('swiper').forEach((elem, index) => {
121
+ let props = window.vGetElementOptions(elem);
122
+
123
+ if (props.pagination && props.pagination.renderBullet === 'number') {
124
+ props.pagination.renderBullet = function(index, className) {
125
+ const span = document.createElement('span');
126
+ span.className = className;
127
+ span.textContent = index + 1;
128
+ return span.outerHTML;
129
+ }
130
+ }
131
+
132
+ elem.setAttribute('data-swiper-index', index);
133
+ window.vSwipers.push(new Swiper(elem, props));
134
+ });`;
135
+ var swiper = defineConfig({
136
+ name: "Swiper",
137
+ cdnUrls: [
138
+ {
139
+ url: `https://cdnjs.cloudflare.com/ajax/libs/Swiper/9.3.2/swiper-bundle.min.js`,
140
+ inline: false,
141
+ defer: true
142
+ },
143
+ {
144
+ url: `https://cdnjs.cloudflare.com/ajax/libs/Swiper/9.3.2/swiper-bundle.min.css`
145
+ }
146
+ ],
147
+ js,
148
+ checks: [{ plugin: "swiper" }]
149
+ });
150
+
151
+ // src/plugins/prism.ts
152
+ var prism = defineConfig({
153
+ name: "Prism",
154
+ cdnUrls: [
155
+ {
156
+ url: "https://cdnjs.cloudflare.com/ajax/libs/prism/1.25.0/plugins/line-numbers/prism-line-numbers.min.css"
157
+ },
158
+ {
159
+ url: "https://cdnjs.cloudflare.com/ajax/libs/prism/1.25.0/prism.min.js"
160
+ },
161
+ {
162
+ url: "https://cdnjs.cloudflare.com/ajax/libs/prism/1.25.0/plugins/autoloader/prism-autoloader.min.js"
163
+ },
164
+ {
165
+ url: "https://cdnjs.cloudflare.com/ajax/libs/prism/1.25.0/plugins/line-numbers/prism-line-numbers.min.js"
166
+ }
167
+ ],
168
+ js: `
169
+ document.querySelectorAll("pre > code[class^='language-']").forEach((elem) => {
170
+ elem.parentNode.innerHTML = elem.parentNode.innerHTML.trim();
171
+ });
172
+
173
+ let themeLink = window.vPrismTheme !== undefined ? window.vPrismTheme : 'default';
174
+
175
+ if (themeLink === 'default') {
176
+ themeLink = 'https://cdnjs.cloudflare.com/ajax/libs/prism/1.25.0/themes/prism.min.css';
177
+ } else if (themeLink && !themeLink.includes('https://')) {
178
+ themeLink = 'https://cdnjs.cloudflare.com/ajax/libs/prism-themes/1.9.0/prism-' + themeLink + '.min.css';
179
+ }
180
+
181
+ if (themeLink && themeLink.includes('https://')) {
182
+ const link = document.createElement('link');
183
+ link.rel = 'stylesheet';
184
+ link.href = themeLink;
185
+ document.head.appendChild(link);
186
+ }
187
+
188
+ window.addEventListener('load', () => {
189
+ window.Prism && window.Prism.highlightAll();
190
+ });`,
191
+ checks: [{ html: "prism" }]
192
+ });
193
+
194
+ // src/plugins/tailtip.ts
195
+ var js2 = `window.vTailtips = [];
196
+
197
+ document.querySelectorAll('[data-toggle="tooltip"]').forEach((elem) => {
198
+ const tailtip = Tailtip(elem, window.vGetElementOptions(elem));
199
+ window.vTailtips.push(tailtip);
200
+ });`;
201
+ var tailtip = defineConfig({
202
+ name: "Tailtip",
203
+ src: "https://d1pnnwteuly8z3.cloudfront.net/libs/tailtip/1.0.3/tailtip.js",
204
+ cdnUrls: [
205
+ {
206
+ url: "https://d1pnnwteuly8z3.cloudfront.net/libs/tailtip/1.0.3/tailtip.js",
207
+ defer: true
208
+ }
209
+ ],
210
+ js: js2,
211
+ checks: [{ plugin: "tailtip" }],
212
+ components: [
213
+ {
214
+ name: "Info Tooltip",
215
+ category: "Plugins",
216
+ html: `<span class="flex w-4 h-4 bg-dark text-white items-center justify-center rounded-full text-xs font-medium" data-toggle="tooltip">i</span>
217
+ <div class="tooltip" role="tooltip">
218
+ <div class="tooltip-inner">
219
+ <span>This is a tooltip that is shown when hovered or clicked.</span>
220
+ </div>
221
+ <div class="tooltip-arrow"></div>
222
+ </div>`
223
+ }
224
+ ],
225
+ options: {
226
+ name: "Tailtip Options",
227
+ // isShown: (element) => element['data-toggle'] === 'tooltip',
228
+ isShown: {
229
+ props: {
230
+ "data-toggle": "tooltip"
231
+ }
232
+ },
233
+ previewInEditor: true,
234
+ fields: [
235
+ {
236
+ name: "tailtip",
237
+ type: "TailtipOption"
238
+ },
239
+ {
240
+ name: "Placement",
241
+ propsName: "data-options.placement",
242
+ type: "DropdownPropOption",
243
+ inline: true,
244
+ noneDisplayValue: "Default",
245
+ options: [false, "top", "bottom", "left", "right"]
246
+ }
247
+ ]
248
+ }
249
+ });
250
+
251
+ // src/plugins/taos.ts
252
+ var js3 = `!function(){const e=(e,t)=>{let s=!1;return()=>{s||(e(),s=!0,setTimeout((()=>s=!1),t))}},t=e=>{e.className!==e.dataset.taosClass&&(e.className=e.dataset.taosClass)},s=e=>e.className=e.className.replaceAll("taos:",""),a=e=>(e.className.includes("taos-init")||(e.dataset.taosClass=e.className+" taos-init",t(e)),e.className+=" !duration-[0ms] !delay-[0ms]",s(e),{element:e,once:"1"===getComputedStyle(e)["animation-iteration-count"],offset:parseInt(e.dataset.taosOffset||0)});let n=[],i=window.innerWidth,o=window.scrollY;const l=e((()=>{n.forEach((e=>e.trigger=e.element.getBoundingClientRect().top-window.innerHeight+e.offset+o))}),250),r=()=>{n=[],document.querySelectorAll('[class*="taos"]').forEach((e=>n.push(a(e)))),l(),requestAnimationFrame(c)},c=()=>{o=window.scrollY,n.forEach((({element:e,trigger:a,once:n})=>{a<o?t(e):!n&&e.className.includes("taos:")&&s(e)})),l()};r(),addEventListener("scroll",e(c,32)),addEventListener("orientationchange",r),addEventListener("resize",((e,t)=>{let s=null;return()=>{clearTimeout(s),s=setTimeout(e,t)}})((()=>{i!==window.innerWidth&&(i=window.innerWidth,r())}),250)),new MutationObserver((e=>{e.forEach((({target:e})=>{e.className&&!e.className.includes("taos-init")&&e.className.includes("taos:")&&n.push(a(e))}))})).observe(document,{attributes:!0,childList:!0,subtree:!0})}();`;
253
+ var taos = defineConfig({
254
+ name: "TAOS",
255
+ css: `
256
+ html.js :where([class*="taos:"]:not(.taos-init)) {
257
+ visibility: hidden;
258
+ }`,
259
+ js: js3,
260
+ checks: [{ plugin: "taos" }, { html: "taos:" }],
261
+ safelist: ["!duration-[0ms]", "!delay-[0ms]"]
262
+ });
263
+
264
+ // src/plugins/tilt.ts
265
+ var js4 = `window.vTilts = [];
266
+ window.vGetElementsByToggle('tilt').forEach((tiltEle, index) => {
267
+ const options = window.vGetElementOptions(elem);
268
+ VanillaTilt.init(tiltEle, options)
269
+ tiltEle.setAttribute('data-tilt-index', index);
270
+ window.vTilts.push(tiltEle);
271
+ });`;
272
+ var tilt = defineConfig({
273
+ name: "Tilt",
274
+ options: {
275
+ name: "Tilt",
276
+ previewInEditor: true,
277
+ isShown: {
278
+ props: {
279
+ "data-toggle": "tilt"
280
+ }
281
+ },
282
+ fields: [
283
+ {
284
+ name: "Speed",
285
+ type: "SliderPropOption",
286
+ propsName: "data-options.speed",
287
+ min: 0,
288
+ max: 3e3,
289
+ stepSize: 100,
290
+ defaultValue: 300
291
+ },
292
+ {
293
+ name: "Max Tilt",
294
+ type: "SliderPropOption",
295
+ propsName: "data-options.max",
296
+ min: 0,
297
+ max: 180,
298
+ stepSize: 1,
299
+ defaultValue: 35
300
+ },
301
+ {
302
+ name: "Reverse",
303
+ type: "BooleanPropOption",
304
+ propsName: "data-options.reverse",
305
+ defaultValue: false,
306
+ enabledValue: true,
307
+ inHeaderAction: true,
308
+ headerGroup: "Core"
309
+ },
310
+ {
311
+ name: "Transition",
312
+ type: "BooleanPropOption",
313
+ propsName: "data-options.transition",
314
+ defaultValue: true,
315
+ enabledValue: false,
316
+ inHeaderAction: true,
317
+ headerGroup: "Core"
318
+ },
319
+ {
320
+ label: "Easing",
321
+ name: "Easing",
322
+ propsName: "data-options.easing",
323
+ type: "TextOption",
324
+ defaultValue: "cubic-bezier(.03,.98,.52,.99)",
325
+ enabledValue: "cubic-bezier(.03,.98,.52,.99)",
326
+ inHeaderAction: true,
327
+ headerGroup: "Core"
328
+ },
329
+ {
330
+ name: "Full Page Listening",
331
+ type: "BooleanPropOption",
332
+ propsName: "data-options.full-page-listening",
333
+ defaultValue: false,
334
+ enabledValue: true,
335
+ inHeaderAction: true,
336
+ headerGroup: "Core"
337
+ },
338
+ {
339
+ name: "Start X",
340
+ type: "SliderPropOption",
341
+ propsName: "data-options.startX",
342
+ min: 0,
343
+ max: 180,
344
+ stepSize: 1,
345
+ defaultValue: 0,
346
+ enabledValue: 15,
347
+ inHeaderAction: true,
348
+ headerGroup: "Core"
349
+ },
350
+ {
351
+ name: "Start Y",
352
+ type: "SliderPropOption",
353
+ propsName: "data-options.startY",
354
+ min: 0,
355
+ max: 180,
356
+ stepSize: 1,
357
+ defaultValue: 0,
358
+ enabledValue: 15,
359
+ inHeaderAction: true,
360
+ headerGroup: "Core"
361
+ },
362
+ {
363
+ name: "Perspective",
364
+ type: "SliderPropOption",
365
+ propsName: "data-options.perspective",
366
+ min: 0,
367
+ max: 3e3,
368
+ stepSize: 1,
369
+ defaultValue: 1e3,
370
+ enabledValue: 1e3,
371
+ inHeaderAction: true,
372
+ headerGroup: "Core"
373
+ },
374
+ {
375
+ name: "Scale",
376
+ type: "SliderPropOption",
377
+ propsName: "data-options.scale",
378
+ min: 0.5,
379
+ max: 3,
380
+ stepSize: 0.1,
381
+ defaultValue: 1,
382
+ enabledValue: 1.5,
383
+ inHeaderAction: true,
384
+ headerGroup: "Core"
385
+ },
386
+ {
387
+ name: "Axis",
388
+ type: "IconButtonOption",
389
+ propsName: "data-options.axis",
390
+ options: ["x", "y"],
391
+ defaultValue: null,
392
+ enabledValue: "x",
393
+ inHeaderAction: true,
394
+ headerGroup: "Core"
395
+ },
396
+ {
397
+ name: "Glare",
398
+ type: "BooleanPropOption",
399
+ propsName: "data-options.glare",
400
+ defaultValue: false,
401
+ enabledValue: true,
402
+ inHeaderAction: true,
403
+ headerGroup: "Glare"
404
+ },
405
+ {
406
+ name: "Max Glare",
407
+ type: "SliderPropOption",
408
+ propsName: "data-options.max-glare",
409
+ min: 0.1,
410
+ max: 1,
411
+ stepSize: 0.1,
412
+ defaultValue: 1,
413
+ enabledValue: 0.5,
414
+ inHeaderAction: true,
415
+ headerGroup: "Glare"
416
+ },
417
+ {
418
+ name: "Reset",
419
+ type: "BooleanPropOption",
420
+ propsName: "data-options.reset",
421
+ defaultValue: true,
422
+ enabledValue: true,
423
+ inHeaderAction: true,
424
+ headerGroup: "Reset"
425
+ },
426
+ {
427
+ name: "Reset To Start",
428
+ type: "BooleanPropOption",
429
+ propsName: "data-options.reset-to-start",
430
+ defaultValue: true,
431
+ enabledValue: true,
432
+ inHeaderAction: true,
433
+ headerGroup: "Reset"
434
+ }
435
+ ]
436
+ },
437
+ cdnUrls: [
438
+ {
439
+ url: "https://cdnjs.cloudflare.com/ajax/libs/vanilla-tilt/1.8.0/vanilla-tilt.js",
440
+ defer: true
441
+ }
442
+ ],
443
+ js: js4,
444
+ checks: [{ plugin: "tilt" }],
445
+ components: [
446
+ {
447
+ name: "Tilt Image",
448
+ category: "Plugins",
449
+ html: `<img class="w-96" src="https://dummyimage.com/1000x600/edf2f7/0f1631&text=Placeholder" data-toggle="tilt" data-options="{'max':15,'reset':true}" />`
450
+ },
451
+ {
452
+ name: "Tilt Div",
453
+ category: "Plugins",
454
+ html: `<div class="w-full h-full" data-toggle="tilt" data-options="{'max':15,'reset':true}"></div>`
455
+ }
456
+ ]
457
+ });
458
+
459
+ // src/plugins/typed.ts
460
+ var typed = defineConfig({
461
+ name: "Typed",
462
+ options: {
463
+ name: "Typed Effect Options",
464
+ previewInEditor: true,
465
+ isShown: {
466
+ props: {
467
+ "data-toggle": "typed"
468
+ }
469
+ },
470
+ fields: [
471
+ {
472
+ type: "TextOption",
473
+ name: "Phrases",
474
+ tooltipProps: { content: "Use commas to add new words/phrases" },
475
+ placeholder: "second phrase., third phrase.",
476
+ propsName: "data-options.strings",
477
+ isArray: true
478
+ },
479
+ {
480
+ name: "Loop",
481
+ type: "BooleanPropOption",
482
+ propsName: "data-options.loop",
483
+ defaultValue: true,
484
+ enabledValue: true,
485
+ inHeaderAction: true,
486
+ headerGroup: "Core"
487
+ },
488
+ {
489
+ name: "Type Speed",
490
+ type: "SliderPropOption",
491
+ propsName: "data-options.typeSpeed",
492
+ min: 10,
493
+ max: 400,
494
+ stepSize: 10,
495
+ defaultValue: 100,
496
+ enabledValue: 100,
497
+ inHeaderAction: true,
498
+ headerGroup: "Core"
499
+ },
500
+ {
501
+ name: "Back Speed",
502
+ type: "SliderPropOption",
503
+ propsName: "data-options.backSpeed",
504
+ min: 10,
505
+ max: 400,
506
+ stepSize: 10,
507
+ defaultValue: 50,
508
+ enabledValue: 50,
509
+ inHeaderAction: true,
510
+ headerGroup: "Core"
511
+ },
512
+ {
513
+ name: "Start Delay",
514
+ type: "SliderPropOption",
515
+ propsName: "data-options.startDelay",
516
+ min: 50,
517
+ max: 3e3,
518
+ stepSize: 50,
519
+ defaultValue: 500,
520
+ enabledValue: 500,
521
+ inHeaderAction: true,
522
+ headerGroup: "Core"
523
+ },
524
+ {
525
+ name: "Back Delay",
526
+ type: "SliderPropOption",
527
+ propsName: "data-options.backDelay",
528
+ min: 50,
529
+ max: 3e3,
530
+ stepSize: 50,
531
+ defaultValue: 1e3,
532
+ enabledValue: 1e3,
533
+ inHeaderAction: true,
534
+ headerGroup: "Core"
535
+ }
536
+ ]
537
+ },
538
+ cdnUrls: [
539
+ {
540
+ url: "https://cdnjs.cloudflare.com/ajax/libs/typed.js/2.0.11/typed.min.js",
541
+ defer: true
542
+ }
543
+ ],
544
+ js: `
545
+ window.vGetElementsByToggle('typed').forEach((elem, index) => {
546
+ let options = window.vGetElementOptions(elem);
547
+
548
+ options.strings = [elem.innerHTML, ...options.strings];
549
+ elem.innerHTML = '';
550
+
551
+ new Typed(elem, {
552
+ typeSpeed: 100,
553
+ backSpeed: 50,
554
+ startDelay: 500,
555
+ backDelay: 1000,
556
+ loop: true,
557
+ ...options
558
+ });
559
+ });`,
560
+ checks: [{ plugin: "typed" }],
561
+ components: [
562
+ // {
563
+ // name: 'Tilt Div',
564
+ // category: 'Plugins',
565
+ // html: `<div class="w-full h-full" data-toggle="tilt" data-options="{'max':15,'reset':true}"></div>`,
566
+ // },
567
+ ],
568
+ displayNames: [
569
+ {
570
+ displayName: "Typed Effect",
571
+ property: "data-toggle",
572
+ value: "typed"
573
+ }
574
+ ]
575
+ });
576
+
577
+ // src/plugins/eventAnalytics.ts
578
+ var eventAnalytics = defineConfig({
579
+ name: "Event Analytics",
580
+ js: `const eventElements = document.querySelectorAll('[data-eventid]');
581
+ for (const eventElement of eventElements) {
582
+ if (eventElement.tagName !== 'FORM') {
583
+ eventElement.addEventListener('click', function(e) {
584
+ const eventName = eventElement.getAttribute('data-eventid');
585
+
586
+ if (window.versoly) {
587
+ window.versoly.event({name: eventName})
588
+ }
589
+ if (window.gtag) {
590
+ window.gtag('event', eventName)
591
+ }
592
+ if (window.amplitude) {
593
+ window.amplitude.getInstance().logEvent(event);
594
+ }
595
+ })
596
+ }
597
+ }`,
598
+ checks: [{ html: "data-eventid" }]
599
+ });
600
+
601
+ // src/plugins/versolyAnalytics.ts
602
+ var js5 = `!function(e){e.versoly.event=function(t){if(!("visibilityState"in document&&"prerender"===document.visibilityState||/bot|google|baidu|bing|msn|duckduckbot|teoma|slurp|yandex/i.test(navigator.userAgent)||e._phantom||e.__nightmare||e.navigator.webdriver||e.Cypress||""===e.location.host)){var n=new XMLHttpRequest;n.open("POST",e.versoly.url,!0),n.setRequestHeader("Content-Type","application/json; charset=UTF-8"),n.send(JSON.stringify({siteId:e.versoly.id,referrer:document.referrer,paramReferrer:"",hostname:e.location.hostname,pathname:e.location.pathname+e.location.search,width:e.innerWidth,height:e.innerHeight,tz:Intl.DateTimeFormat().resolvedOptions().timeZone,...t}))}}}(window),window.versoly.event({name: 'pageview'});`;
603
+ var versolyAnalytics = defineConfig({
604
+ name: "Versoly Analytics",
605
+ js: js5,
606
+ checks: [{ html: "/api/event" }]
607
+ });
608
+
609
+ // src/plugins/modal.ts
610
+ var modal = defineConfig({
611
+ name: "Versoly UI Modal",
612
+ js: `window.vGetElementsByToggle('modal').forEach(elem => {
613
+ let options = window.vGetElementOptions(elem);
614
+
615
+ if (options.globalBlockId && window.vComponents[options.globalBlockId]) {
616
+ elem.dataset.html = window.vComponents[options.globalBlockId];
617
+
618
+ if (window.vComponents[options.globalBlockId].includes('data-formid')) {
619
+ options.beforeShown = 'addFormListener'
620
+ }
621
+ }
622
+
623
+ elem.dataset.options = JSON.stringify(options);
624
+ });`,
625
+ checks: [{ plugin: "modal" }]
626
+ });
627
+
628
+ // src/plugins/form.ts
629
+ var form = defineConfig({
630
+ name: "versoly-form",
631
+ checks: [{ plugin: "formid" }],
632
+ js: `window.vPageLoadedAt = Date.now()
633
+
634
+ setTimeout(() => {
635
+ let inputs = [...document.getElementsByTagName("input")]
636
+ inputs.forEach(i => {
637
+ if (i.name === 'email_second' || i.name === 'name_second') {
638
+ i.setAttribute('aria-hidden', 'true')
639
+ i.setAttribute('tabindex', '-1')
640
+ i.setAttribute('autocomplete', 'false')
641
+ }
642
+ })
643
+ }, 3000)
644
+
645
+ const sendFormData = function (e, form) {
646
+ e.preventDefault();
647
+ const formId = form.dataset.formid;
648
+ let scriptsByForm = window.vForms[formId] || {}
649
+
650
+ if (window.vPageLoadedAt + 3000 > Date.now()) {
651
+ return null
652
+ }
653
+
654
+ let data = {
655
+ created: Date.now(),
656
+ url: location.pathname + location.search
657
+ }
658
+
659
+ const filteredForms = document.querySelectorAll('[data-formId="' + formId + '"]')
660
+ let formIndex = 0
661
+ filteredForms.forEach((f, index) => {
662
+ if (f === form) {
663
+ formIndex = index
664
+ }
665
+ })
666
+
667
+ const errorElement = document.querySelectorAll('[data-form-errorid="' + formId + '"]')[formIndex]
668
+ let inputs = [
669
+ ...form.getElementsByTagName("input"),
670
+ ...form.getElementsByTagName("textarea"),
671
+ ...form.getElementsByTagName("select")
672
+ ]
673
+
674
+ inputs.forEach(input => {
675
+ if (input.type === 'radio') {
676
+ if (input.checked) {
677
+ data[input.name] = input.value
678
+ }
679
+ return
680
+ }
681
+ if (input.tagName === 'SELECT') {
682
+ data[input.name] = input.options[input.selectedIndex].value
683
+ return
684
+ }
685
+ if (input.type === 'checkbox') {
686
+ data[input.name] = input.checked + ""
687
+ return
688
+ }
689
+ data[input.name] = input.value
690
+ })
691
+
692
+ if (!!data['email_second'] || !!data['name_second']) {
693
+ return null
694
+ }
695
+ delete data['email_second'];
696
+ delete data['name_second'];
697
+
698
+ if (scriptsByForm.pre) {
699
+ eval(scriptsByForm.pre)
700
+ }
701
+
702
+ const submitButton = form.querySelector(('button[type="submit"]'))
703
+ const buttonInnerHTML = submitButton.innerHTML
704
+ submitButton.disabled = true
705
+
706
+ let loadingButtonInnerHTML = '<i class="fa fa-spinner fa-spin"></i> Loading'
707
+ if (submitButton.getAttribute('data-loading-html')) {
708
+ loadingButtonInnerHTML = submitButton.getAttribute('data-loading-html')
709
+ }
710
+ submitButton.innerHTML = loadingButtonInnerHTML
711
+
712
+ data = JSON.stringify(data)
713
+ fetch('https://api.versoly.com/v1/form/submit', {
714
+ method: 'POST',
715
+ headers: {
716
+ 'Content-Type': 'application/json'
717
+ },
718
+ body: JSON.stringify({formId: formId, data: data})
719
+ })
720
+ .then(function (response){
721
+ if (!response.ok) {
722
+ throw new Error('Bad response from server');
723
+ }
724
+
725
+ if (window.versoly && form.getAttribute('data-eventid')) {
726
+ window.versoly.event({name: form.getAttribute('data-eventid')})
727
+ }
728
+
729
+ if (scriptsByForm.post) {
730
+ eval(scriptsByForm.post)
731
+ }
732
+
733
+ if (form.dataset["successUrl"]) {
734
+ window.location.replace(form.dataset["successUrl"])
735
+ return
736
+ }
737
+
738
+ const successElement = document.querySelectorAll('[data-form-successid="' + formId + '"]')[formIndex]
739
+
740
+ if (successElement) {
741
+ successElement.classList.remove("d-js");
742
+ errorElement.classList.add("d-js");
743
+ form.classList.add("d-js");
744
+
745
+ successElement.classList.remove("d-none");
746
+ errorElement.classList.add("d-none");
747
+ form.classList.add("d-none");
748
+ }
749
+
750
+ submitButton.disabled = false
751
+ submitButton.innerHTML = buttonInnerHTML
752
+ })
753
+ .catch(function (error){
754
+ console.log(error)
755
+ if (errorElement) {
756
+ errorElement.classList.remove("d-js");
757
+ errorElement.classList.remove("d-none");
758
+ }
759
+ if (scriptsByForm.failed) {
760
+ eval(scriptsByForm.failed)
761
+ }
762
+ submitButton.disabled = false
763
+ submitButton.innerHTML = buttonInnerHTML
764
+ })
765
+ }
766
+
767
+
768
+ window.addFormListener = () => {
769
+ const forms = document.querySelectorAll('[data-formid]');
770
+
771
+ for (const form of forms) {
772
+ if (!form.getAttribute('data-has-form-eventlistener')) {
773
+ form.addEventListener("submit", function (e) {
774
+ sendFormData(e, form)
775
+ });
776
+ form.setAttribute('data-has-form-eventlistener', 'true')
777
+ }
778
+ }
779
+ }
780
+ window.addFormListener && window.addFormListener()
781
+ `
782
+ });
783
+
784
+ // src/plugins/countup.ts
785
+ var countup = defineConfig({
786
+ name: "Countup",
787
+ cdnUrls: [
788
+ {
789
+ url: "https://cdnjs.cloudflare.com/ajax/libs/scrollReveal.js/3.4.0/scrollreveal.min.js"
790
+ },
791
+ {
792
+ url: "https://cdnjs.cloudflare.com/ajax/libs/countup.js/2.0.8/countUp.umd.min.js"
793
+ }
794
+ ],
795
+ js: `window.scrollReveal = ScrollReveal();
796
+
797
+ window.countStart = e => {
798
+ var startVal = e.dataset.from ? +e.dataset.from : 0
799
+ ,endVal = e.dataset.to ? +e.dataset.to : 0
800
+ ,duration = e.dataset.duration ? +e.dataset.duration : 2
801
+ ,options = e.dataset.options ? JSON.parse(e.dataset.options) : {}
802
+ const up = new countUp.CountUp(e, endVal, {...options, startVal, duration});
803
+ up.start()
804
+ }
805
+
806
+ window.vGetElementsByToggle('countup').forEach(e => {
807
+ scrollReveal.reveal(e, {beforeReveal: window.countStart, duration: 0});
808
+ });`,
809
+ checks: [{ plugin: "countup" }],
810
+ options: {
811
+ name: "Countup Options",
812
+ isShown: {
813
+ props: {
814
+ "data-toggle": "countup"
815
+ }
816
+ },
817
+ fields: [
818
+ {
819
+ name: "Count From",
820
+ propsName: "data-from",
821
+ type: "NumberOption"
822
+ },
823
+ {
824
+ name: "Count To",
825
+ propsName: "data-to",
826
+ type: "NumberOption"
827
+ },
828
+ {
829
+ name: "Duration",
830
+ propsName: "data-duration",
831
+ type: "NumberOption",
832
+ placeholder: "2",
833
+ stepSize: 0.1
834
+ },
835
+ {
836
+ name: "Countup when Visible",
837
+ propsName: "data-aos",
838
+ options: [false, true],
839
+ type: "BooleanPropOption",
840
+ defaultValue: false
841
+ }
842
+ ]
843
+ },
844
+ components: [
845
+ {
846
+ name: "Countup",
847
+ category: "Plugins",
848
+ html: `<h2 data-toggle="countup" data-aos data-aos-id="countup:in" data-from="100" data-to="800">100</h2>`
849
+ }
850
+ ]
851
+ });
852
+
853
+ // src/plugins/countdown.ts
854
+ var js6 = `window.vGetElementsByToggle('countdown').forEach(e => {
855
+ const deadline = new Date(e.dataset.countdown).getTime();
856
+
857
+ const daysEl = e.querySelector('[data-countdown-type="days"]'),
858
+ hoursEl = e.querySelector('[data-countdown-type="hours"]'),
859
+ minutesEl = e.querySelector('[data-countdown-type="minutes"]'),
860
+ secondsEl = e.querySelector('[data-countdown-type="seconds"]');
861
+
862
+ const countdownFunc = () => {
863
+ const now = new Date().getTime();
864
+ let t = deadline - now;
865
+
866
+ if (t < 0) {
867
+ clearInterval(x);
868
+ t = 0;
869
+ }
870
+
871
+ let seconds = ''+Math.floor((t / 1000) % 60),
872
+ minutes = ''+Math.floor((t / 1000 / 60) % 60),
873
+ hours = ''+Math.floor((t / (1000 * 60 * 60)) % 24),
874
+ days = ''+Math.floor(t / (1000 * 60 * 60 * 24));
875
+
876
+ if (seconds.length === 1) seconds = '0' + seconds;
877
+ if (minutes.length === 1) minutes = '0' + minutes;
878
+ if (hours.length === 1) hours = '0' + hours;
879
+ if (days.length === 1) days = '0' + days;
880
+
881
+ if (secondsEl) secondsEl.innerHTML = seconds;
882
+ if (minutesEl) minutesEl.innerHTML = minutes;
883
+ if (hoursEl) hoursEl.innerHTML = hours;
884
+ if (daysEl) daysEl.innerHTML = days;
885
+ }
886
+
887
+ var x = setInterval(countdownFunc, 1000);
888
+ countdownFunc();
889
+ })
890
+ `;
891
+ var currentDate = /* @__PURE__ */ new Date();
892
+ var ISODateIn5Days = new Date(currentDate.getTime() + 5 * 24 * 60 * 60 * 1234).toISOString();
893
+ var countdown = defineConfig({
894
+ name: "Countdown Options",
895
+ js: js6,
896
+ checks: [{ plugin: "countdown" }],
897
+ options: {
898
+ name: "Countdown",
899
+ isShown: {
900
+ props: {
901
+ "data-toggle": "countdown",
902
+ "data-countdown": true
903
+ }
904
+ },
905
+ fields: [
906
+ {
907
+ name: "Countdown Timer",
908
+ propsName: "data-countdown",
909
+ type: "DateTimePickerOption"
910
+ }
911
+ ]
912
+ },
913
+ components: [
914
+ {
915
+ name: "Countdown",
916
+ category: "Plugins",
917
+ html: `<h2 class="font-semibold" data-toggle="countdown" data-countdown="${ISODateIn5Days}">
918
+ <span data-countdown-type="days">4</span>
919
+ <span class="opacity-20">:</span>
920
+ <span data-countdown-type="hours">1</span>
921
+ <span class="opacity-20">:</span>
922
+ <span data-countdown-type="minutes">0</span>
923
+ <span class="opacity-20">:</span>
924
+ <span data-countdown-type="seconds">0</span>
925
+ </h2>`
926
+ }
927
+ ]
928
+ });
929
+
930
+ // src/plugins/calendly.ts
931
+ var calendly = defineConfig({
932
+ name: "Calendly",
933
+ cdnUrls: [
934
+ {
935
+ url: "https://assets.calendly.com/assets/external/widget.js",
936
+ delay: true
937
+ },
938
+ {
939
+ url: "https://assets.calendly.com/assets/external/widget.css",
940
+ delay: true
941
+ }
942
+ ],
943
+ js: `
944
+ document.querySelectorAll('[data-calendly-url]').forEach(a => {
945
+ const url = a.getAttribute('data-calendly-url')
946
+
947
+ if (!url) {
948
+ return;
949
+ }
950
+
951
+ a.addEventListener('click', e => {
952
+ e.preventDefault();
953
+ window.Calendly.initPopupWidget({ url, parentElement: a})
954
+ })
955
+ });`,
956
+ checks: [{ plugin: "calendly" }, { html: "calendly" }],
957
+ options: {
958
+ name: "Calendly Options",
959
+ isShown: {
960
+ props: {
961
+ "data-calendly-url": true
962
+ }
963
+ },
964
+ fields: [
965
+ {
966
+ name: "Calendly Url",
967
+ propsName: "data-calendly-url",
968
+ type: "TextOption"
969
+ }
970
+ ]
971
+ }
972
+ });
973
+
974
+ // src/plugins/versolyUI.ts
975
+ var versolyUI = defineConfig({
976
+ name: "Versoly UI",
977
+ cdnUrls: [
978
+ {
979
+ url: "https://d1pnnwteuly8z3.cloudfront.net/libs/floating-ui/1.0.1/floating-ui.min.js",
980
+ defer: true
981
+ },
982
+ {
983
+ url: "https://d1pnnwteuly8z3.cloudfront.net/libs/versoly-ui/2.1.1/versoly-ui.js",
984
+ delay: true
985
+ }
986
+ ]
987
+ });
988
+
989
+ // src/plugins/finisherHeader.ts
990
+ var finisherHeader = defineConfig({
991
+ name: "Finisher Header",
992
+ cdnUrls: [
993
+ {
994
+ url: "https://d1pnnwteuly8z3.cloudfront.net/js/finisher-header.es5.min.js",
995
+ defer: true
996
+ }
997
+ ],
998
+ js: `document.querySelectorAll('.finisher-header').forEach(elem => {
999
+ let options = window.vGetElementOptions(elem);
1000
+ new FinisherHeader(options);
1001
+ });`,
1002
+ checks: [{ html: "finisher-header" }],
1003
+ components: [
1004
+ {
1005
+ name: "Finisher Header",
1006
+ category: "Plugins",
1007
+ html: `<div class="finisher-header" data-toggle="finisher-header" data-options="{'count':15,'size':{'min':2,'max':40,'pulse':0},'speed':{'x':{'min':0,'max':0.8},'y':{'min':0,'max':0.2}},'colors':{'background':'#fff','particles':['#ff926b','#87ddfe','#acaaff','#1bffc2','#f9a5fe']},'blending':'screen','opacity':{'center':1,'edge':1},'skew':-1,'shapes':['c','s','t']}"></div>`
1008
+ }
1009
+ ]
1010
+ });
1011
+
1012
+ // src/plugins/index.ts
1013
+ var plugins = {
1014
+ headroom,
1015
+ marquee,
1016
+ swiper,
1017
+ prism,
1018
+ tailtip,
1019
+ taos,
1020
+ tilt,
1021
+ typed,
1022
+ modal,
1023
+ form,
1024
+ finisherHeader,
1025
+ countup,
1026
+ countdown,
1027
+ eventAnalytics,
1028
+ versolyAnalytics,
1029
+ versolyUI,
1030
+ calendly
1031
+ };
1032
+ })();