custom-javascript.js
8.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
// Add your custom JS here.
jQuery( document ).ready(function($) {
AOS.init({
// Global settings:
disable: false, // accepts following values: 'phone', 'tablet', 'mobile', boolean, expression or function
startEvent: 'DOMContentLoaded', // name of the event dispatched on the document, that AOS should initialize on
initClassName: 'aos-init', // class applied after initialization
animatedClassName: 'aos-animate', // class applied on animation
useClassNames: false, // if true, will add content of `data-aos` as classes on scroll
disableMutationObserver: false, // disables automatic mutations' detections (advanced)
debounceDelay: 50, // the delay on debounce used while resizing window (advanced)
throttleDelay: 99, // the delay on throttle used while scrolling the page (advanced)
// Settings that can be overridden on per-element basis, by `data-aos-*` attributes:
offset: 120, // offset (in px) from the original trigger point
delay: 0, // values from 0 to 3000, with step 50ms
duration: 400, // values from 0 to 3000, with step 50ms
easing: 'ease', // default easing for AOS animations
once: false, // whether animation should happen only once - while scrolling down
mirror: false, // whether elements should animate out while scrolling past them
anchorPlacement: 'top-bottom', // defines which position of the element regarding to window should trigger the animation
});
$('.wp-block-button__link').attr('tabindex', 0);
$('.cf7mls_btn').attr('tabindex', 0);
$('#Layer_1').appendTo('.n2-ss-slider-wrapper-inside');
$('#Layer_1').show();
$(document).on("click","#register-here",function() {
$('.wp-block-group.register').toggle();
$('.numbers-second .wp-block-column:first-child a.wp-block-button__link').toggleClass('rotated');
$([document.documentElement, document.body]).animate({
scrollTop: $(".wp-block-group.register").offset().top
}, 500);
});
var maxLength = 200;
$('#description-of-services').keyup(function() {
console.log('keyup');
var length = $(this).val().length;
console.log(length);
var length = maxLength - length;
console.log(length);
$('#chars').text(length);
});
$( "#wpsl-search-input" ).on( "keydown", function(event) {
if(event.which == 13){
$('#wpsl-s').show();
}
});
$( "#register-here" ).on( "keydown", function(event) {
if(event.which == 13){
$('.wp-block-group.register').toggle();
$('.numbers-second .wp-block-column:first-child a.wp-block-button__link').toggleClass('rotated');
$([document.documentElement, document.body]).animate({
scrollTop: $(".wp-block-group.register").offset().top
}, 500);
}
});
$('.wpcf7-form-control-wrap').each(function( index ) {
$(this).parent().addClass($(this).attr('class').split(' ')[1]);
});
document.addEventListener( 'wpcf7mailsent', function( event ) {
if ( '36' == event.detail.contactFormId ) {
console.log('wpcf7submit');
$('.fieldset-cf7mls-wrapper').remove();
$('.cf7mls_progress_bar').remove();
$('.thank-you').show();
}
}, false );
var boxes = document.querySelectorAll("g");
var box = getShuffledArr(boxes);
function getShuffledArr (arr){
return [...arr].map( (_, i, arrCopy) => {
var rand = i + ( Math.floor( Math.random() * (arrCopy.length - i) ) );
[arrCopy[rand], arrCopy[i]] = [arrCopy[i], arrCopy[rand]]
return arrCopy[i]
})
}
box.forEach((element,i) => {
setTimeout(
function(){
animateMe(element)
}
, i * 900);
});
function animateMe(box){
let tl = gsap.timeline();
tl.to(box, 1.5, {opacity:0.6})
.to(box, 1.5,{opacity:0.07})
}
function randomNumber(min, max) {
return Math.random() * (max - min) + min;
}
updateContainer()
function updateContainer() {
var maxHeight = 0;
$(".numbers-block").height('auto');
$(".numbers-block").each(function(index){
if ($(window).width() > 1200) {
delay = index * 200 + 300;
$(this).attr('data-aos-delay', delay);
}
if ($(this).height() > maxHeight) { maxHeight = $(this).height();}
});
$(".numbers-block").height(maxHeight);
}
$( window ).resize(function() {
updateContainer();
})
function animateValue(id, start, end, duration) {
var start= 0 ;
// here we retrieve the text of the 'target' element by its 'id',
// and convert the returned value into a number, using
// parseInt(); the first argument is the string to convert and
// the second is the numeric base of the number into which you
// want to convert the given numeric string:
var end = parseInt(document.getElementById(id).textContent, 10);
var duration = 500;
var range = end - start;
var current = start;
var increment = end > start? 1 : -1;
var stepTime = Math.abs(Math.floor(duration / range));
var obj = document.getElementById(id);
var timer = setInterval(function() {
current += increment;
obj.innerHTML = current;
if (current == end) {
clearInterval(timer);
}
}, stepTime);
}
$(window).on('load resize scroll', function() {
// elementInViewport($('#number16'), 'number16');
// elementInViewport($('#number17'), 'number17');
elementInViewport($('#find-number'), 'find-number');
});
function elementInViewport(element, id) {
if (inViewport(element) && !$(element).hasClass('done')) {
animateValue(id ,0,0,5000);
$(element).addClass('done')
}
}
function inViewport(element) {
if (typeof jQuery === "function" && element instanceof jQuery) {
element = element[0];
}
var elementBounds = element.getBoundingClientRect();
return (
elementBounds.top >= 0 &&
elementBounds.left >= 0 &&
elementBounds.bottom <= $(window).height() &&
elementBounds.right <= $(window).width()
);
}
$(document).on("click",".start_a_contact",function() {
$('#exampleModalLong').find('form').append('<input type="hidden" name="planner_id" value="'+$(this).data('store-id')+'"/>')
$('#exampleModalLong').modal('show');
});
$(document).on("click",".find-a-planner-close",function() {
$('#exampleModalLong').modal('hide');
});
document.addEventListener( 'wpcf7submit', function( event ) {
if ( '142' == event.detail.contactFormId ) {
if($(event.target).hasClass('invalid')) {
$('#exampleModalLong').find('form').show();
return;
}
event.preventDefault();
var service_choices = "";
$('.service-choose-container input[type="checkbox"]:checked').each(function() {
if(service_choices == "") {
service_choices = $(this).val();
} else {
service_choices += ", " + $(this).val();
}
});
var html= '<h5 class="modal-title" style="text-align:center;" id="exampleModalLongTitle">THANK YOU!</h5><p><center>An eos dolore accusamus vituperatoribus. Ei pertinax appellantur mei, verear atomorum cu pro.</center></p>'
jQuery.ajax({
url: '/wp-admin/admin-ajax.php',
method: "POST",
data: {
action: 'send_planner_notice',
name: $("[name='your-name']").val(),
email: $("[name='your-email']").val(),
phone: $("[name='your-phone']").val(),
panner_id: $("[name='planner_id']").val(),
choices:service_choices
},
beforeSend: function(xhr) {
},
success: function(response) {
$('#exampleModalLong').find('form').html(html);
$('#exampleModalLong').find('form').append(response.data.html);
$('#exampleModalLong').find('form').show();
}
});
}
}, false );
});