-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscripts.js
400 lines (350 loc) · 11.8 KB
/
scripts.js
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
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
/* Template: Tivo - SaaS App HTML Landing Page Template
Author: Inovatik
Created: Sep 2019
Description: Custom JS file
*/
(function($) {
"use strict";
/* Preloader */
$(window).on('load', function() {
var preloaderFadeOutTime = 500;
function hidePreloader() {
var preloader = $('.spinner-wrapper');
setTimeout(function() {
preloader.fadeOut(preloaderFadeOutTime);
}, 500);
}
hidePreloader();
});
/* Navbar Scripts */
// jQuery to collapse the navbar on scroll
$(window).on('scroll load', function() {
if ($(".navbar").offset().top > 60) {
$(".fixed-top").addClass("top-nav-collapse");
} else {
$(".fixed-top").removeClass("top-nav-collapse");
}
});
// jQuery for page scrolling feature - requires jQuery Easing plugin
$(function() {
$(document).on('click', 'a.page-scroll', function(event) {
var $anchor = $(this);
$('html, body').stop().animate({
scrollTop: $($anchor.attr('href')).offset().top
}, 600, 'easeInOutExpo');
event.preventDefault();
});
});
// closes the responsive menu on menu item click
$(".navbar-nav li a").on("click", function(event) {
if (!$(this).parent().hasClass('dropdown'))
$(".navbar-collapse").collapse('hide');
});
/* Image Slider - Swiper */
var imageSlider = new Swiper('.image-slider', {
autoplay: {
delay: 2000,
disableOnInteraction: false
},
loop: true,
spaceBetween: 30,
slidesPerView: 5,
breakpoints: {
// when window is <= 580px
580: {
slidesPerView: 1,
spaceBetween: 10
},
// when window is <= 768px
768: {
slidesPerView: 2,
spaceBetween: 20
},
// when window is <= 992px
992: {
slidesPerView: 3,
spaceBetween: 20
},
// when window is <= 1200px
1200: {
slidesPerView: 4,
spaceBetween: 20
},
}
});
/* Text Slider - Swiper */
var textSlider = new Swiper('.text-slider', {
autoplay: {
delay: 6000,
disableOnInteraction: false
},
loop: true,
navigation: {
nextEl: '.swiper-button-next',
prevEl: '.swiper-button-prev'
}
});
/* Video Lightbox - Magnific Popup */
$('.popup-youtube, .popup-vimeo').magnificPopup({
disableOn: 700,
type: 'iframe',
mainClass: 'mfp-fade',
removalDelay: 160,
preloader: false,
fixedContentPos: false,
iframe: {
patterns: {
youtube: {
index: 'youtube.com/',
id: function(url) {
var m = url.match(/[\\?\\&]v=([^\\?\\&]+)/);
if ( !m || !m[1] ) return null;
return m[1];
},
src: 'https://www.youtube.com/embed/%id%?autoplay=1'
},
vimeo: {
index: 'vimeo.com/',
id: function(url) {
var m = url.match(/(https?:\/\/)?(www.)?(player.)?vimeo.com\/([a-z]*\/)*([0-9]{6,11})[?]?.*/);
if ( !m || !m[5] ) return null;
return m[5];
},
src: 'https://player.vimeo.com/video/%id%?autoplay=1'
}
}
}
});
/* Details Lightbox - Magnific Popup */
$('.popup-with-move-anim').magnificPopup({
type: 'inline',
fixedContentPos: false, /* keep it false to avoid html tag shift with margin-right: 17px */
fixedBgPos: true,
overflowY: 'auto',
closeBtnInside: true,
preloader: false,
midClick: true,
removalDelay: 300,
mainClass: 'my-mfp-slide-bottom'
});
/* Move Form Fields Label When User Types */
// for input and textarea fields
$("input, textarea").keyup(function(){
if ($(this).val() != '') {
$(this).addClass('notEmpty');
} else {
$(this).removeClass('notEmpty');
}
});
/* Sign Up Form */
$("#signUpForm").validator().on("submit", function(event) {
if (event.isDefaultPrevented()) {
// handle the invalid form...
sformError();
ssubmitMSG(false, "Please fill all fields!");
} else {
// everything looks good!
event.preventDefault();
ssubmitForm();
}
});
function ssubmitForm() {
// initiate variables with form content
var email = $("#semail").val();
var name = $("#sname").val();
var password = $("#spassword").val();
var terms = $("#sterms").val();
$.ajax({
type: "POST",
url: "php/signupform-process.php",
data: "email=" + email + "&name=" + name + "&password=" + password + "&terms=" + terms,
success: function(text) {
if (text == "success") {
sformSuccess();
} else {
sformError();
ssubmitMSG(false, text);
}
}
});
}
function sformSuccess() {
$("#signUpForm")[0].reset();
ssubmitMSG(true, "Sign Up Submitted!");
$("input").removeClass('notEmpty'); // resets the field label after submission
}
function sformError() {
$("#signUpForm").removeClass().addClass('shake animated').one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function() {
$(this).removeClass();
});
}
function ssubmitMSG(valid, msg) {
if (valid) {
var msgClasses = "h3 text-center tada animated";
} else {
var msgClasses = "h3 text-center";
}
$("#smsgSubmit").removeClass().addClass(msgClasses).text(msg);
}
/* Log In Form */
$("#logInForm").validator().on("submit", function(event) {
if (event.isDefaultPrevented()) {
// handle the invalid form...
lformError();
lsubmitMSG(false, "Please fill all fields!");
} else {
// everything looks good!
event.preventDefault();
lsubmitForm();
}
});
function lsubmitForm() {
// initiate variables with form content
var email = $("#lemail").val();
var password = $("#lpassword").val();
$.ajax({
type: "POST",
url: "php/loginform-process.php",
data: "email=" + email + "&password=" + password,
success: function(text) {
if (text == "success") {
lformSuccess();
} else {
lformError();
lsubmitMSG(false, text);
}
}
});
}
function lformSuccess() {
$("#logInForm")[0].reset();
lsubmitMSG(true, "Log In Submitted!");
$("input").removeClass('notEmpty'); // resets the field label after submission
}
function lformError() {
$("#logInForm").removeClass().addClass('shake animated').one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function() {
$(this).removeClass();
});
}
function lsubmitMSG(valid, msg) {
if (valid) {
var msgClasses = "h3 text-center tada animated";
} else {
var msgClasses = "h3 text-center";
}
$("#lmsgSubmit").removeClass().addClass(msgClasses).text(msg);
}
/* Newsletter Form */
$("#newsletterForm").validator().on("submit", function(event) {
if (event.isDefaultPrevented()) {
// handle the invalid form...
nformError();
nsubmitMSG(false, "Please fill all fields!");
} else {
// everything looks good!
event.preventDefault();
nsubmitForm();
}
});
function nsubmitForm() {
// initiate variables with form content
var email = $("#nemail").val();
var terms = $("#nterms").val();
$.ajax({
type: "POST",
url: "php/newsletterform-process.php",
data: "email=" + email + "&terms=" + terms,
success: function(text) {
if (text == "success") {
nformSuccess();
} else {
nformError();
nsubmitMSG(false, text);
}
}
});
}
function nformSuccess() {
$("#newsletterForm")[0].reset();
nsubmitMSG(true, "Subscribed!");
$("input").removeClass('notEmpty'); // resets the field label after submission
}
function nformError() {
$("#newsletterForm").removeClass().addClass('shake animated').one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function() {
$(this).removeClass();
});
}
function nsubmitMSG(valid, msg) {
if (valid) {
var msgClasses = "h3 text-center tada animated";
} else {
var msgClasses = "h3 text-center";
}
$("#nmsgSubmit").removeClass().addClass(msgClasses).text(msg);
}
/* Privacy Form */
$("#privacyForm").validator().on("submit", function(event) {
if (event.isDefaultPrevented()) {
// handle the invalid form...
pformError();
psubmitMSG(false, "Please fill all fields!");
} else {
// everything looks good!
event.preventDefault();
psubmitForm();
}
});
function psubmitForm() {
// initiate variables with form content
var name = $("#pname").val();
var email = $("#pemail").val();
var select = $("#pselect").val();
var terms = $("#pterms").val();
$.ajax({
type: "POST",
url: "php/privacyform-process.php",
data: "name=" + name + "&email=" + email + "&select=" + select + "&terms=" + terms,
success: function(text) {
if (text == "success") {
pformSuccess();
} else {
pformError();
psubmitMSG(false, text);
}
}
});
}
function pformSuccess() {
$("#privacyForm")[0].reset();
psubmitMSG(true, "Request Submitted!");
$("input").removeClass('notEmpty'); // resets the field label after submission
}
function pformError() {
$("#privacyForm").removeClass().addClass('shake animated').one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function() {
$(this).removeClass();
});
}
function psubmitMSG(valid, msg) {
if (valid) {
var msgClasses = "h3 text-center tada animated";
} else {
var msgClasses = "h3 text-center";
}
$("#pmsgSubmit").removeClass().addClass(msgClasses).text(msg);
}
/* Back To Top Button */
// create the back to top button
$('body').prepend('<a href="body" class="back-to-top page-scroll">Back to Top</a>');
var amountScrolled = 700;
$(window).scroll(function() {
if ($(window).scrollTop() > amountScrolled) {
$('a.back-to-top').fadeIn('500');
} else {
$('a.back-to-top').fadeOut('500');
}
});
/* Removes Long Focus On Buttons */
$(".button, a, button").mouseup(function() {
$(this).blur();
});
})(jQuery);