custom-javascript.js
4.87 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
import jQuery from 'jquery';
import jQueryBridget from 'jquery-bridget';
import Isotope from "isotope-layout";
import DataTable from 'datatables.net-bs5';
import validate from 'jquery-validation';
jQueryBridget( 'isotope', Isotope, $ );
// Add your custom JS here.
import "./_carousels";
import "./jssocials.min";
import "./_course_list";
import "./_resources_list";
var a = document.querySelector('.blur-image');
document.addEventListener("DOMContentLoaded", function() {
if (!a) return !1;
var b = a.getAttribute("data-src"),
c = document.querySelector('.full-image'),
img = new Image;
img.src = b;
img.onload = function() {
c.classList.add('image-loaded'),
c.style.backgroundImage = 'url(' + b + ')';
};
});
document.addEventListener("DOMContentLoaded", function() {
window.addEventListener('scroll', function() {
if (window.scrollY > 57) {
document.getElementById('main-nav').classList.add('fixed-top');
} else {
document.getElementById('main-nav').classList.remove('fixed-top');
document.getElementById('search').classList.remove('open');
document.getElementById('search-button').classList.remove('open');
}
});
});
//Get the button
let mybutton = document.getElementById("btn-back-to-top");
// When the user scrolls down 20px from the top of the document, show the button
window.onscroll = function() {
scrollFunction();
};
function scrollFunction() {
if (
document.body.scrollTop > 20 ||
document.documentElement.scrollTop > 20
) {
mybutton.style.display = "block";
} else {
mybutton.style.display = "none";
}
}
// When the user clicks on the button, scroll to the top of the document
mybutton.addEventListener("click", backToTop);
function backToTop() {
document.body.scrollTop = 0;
document.documentElement.scrollTop = 0;
}
jQuery(document).ready(function($) {
var $search = $('.search').clone();
$search.addClass('mobile');
$('.search').attr('id','search');
$('.search-button').attr('id','search-button');
$('#navbarNavDropdown').prepend($search);
$(document).on("click", ".search-button a, .close", function(e) {
e.preventDefault();
$('.search-button').toggleClass('open');
$('.search').toggleClass('open');
});
$('.register').attr('id','register');
$("#register").validate({
// Specify validation rules
rules: {
billing_first_name: {
required: true,
},
billing_last_name:{
required: true,
},
email: {
required: true,
email: true
},
password: {
required: true,
minlength: 10
},
password2: {
required: true,
minlength: 10,
equalTo: "#reg_password"
}
},
});
jQuery(document).on('click','#checkout_apply_coupon_staff', function() {
// Get the coupon code
console.log('staff')
var code = jQuery( '#checkout_coupon_code_staff').val();
var button = jQuery( this );
var data = {
action: 'ajax_apply_coupon',
coupon_code: code
};
button.html( 'wait.');
// Send it over to WordPress.
jQuery.post( wc_checkout_params.ajax_url, data, function( returned_data ) {
if( returned_data.result == 'error' ) {
jQuery( 'p.result' ).html( returned_data.message );
} else {
setTimeout(function(){
//reload with ajax
jQuery(document.body).trigger('update_checkout');
button.html( 'Apply');
}, 3000);
console.log( returned_data+code );
}
})
});
jQuery(document).on('click','#checkout_apply_coupon', function() {
// Get the coupon code
var code = jQuery( '#checkout_coupon_code').val();
var button = jQuery( this );
var data = {
action: 'ajax_apply_coupon',
coupon_code: code
};
button.html( 'wait.');
// Send it over to WordPress.
jQuery.post( wc_checkout_params.ajax_url, data, function( returned_data ) {
if( returned_data.result == 'error' ) {
jQuery( 'p.result' ).html( returned_data.message );
} else {
setTimeout(function(){
//reload with ajax
jQuery(document.body).trigger('update_checkout');
button.html( 'Apply');
}, 3000);
console.log( returned_data+code );
}
})
});
});