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