-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathcustom.js
181 lines (157 loc) · 4.19 KB
/
custom.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
console.log('hello, welcome to the simplest start-up starter');
/*
*
*
*
* HERO SECTION
*
*
*
*/
$(".main-cta").sticky({
responsiveWidth: true,
getWidthFrom:'.w150p'
});
$('.main-cta').on('sticky-start', function() {
$('.secondary-cta').css('display', 'none');
$('.main-cta').css('margin-top', '0.9rem'); // XXX : hacky, indeed
$('.main-cta').text('Join');
$('body').toggleClass('is-sticky');
$('.secondary-cta').css('display','none');
});
$('.main-cta').on('sticky-end', function() {
$('.secondary-cta').toggle();
$('.secondary-cta').css('display', '');
$('.main-cta').css('margin-top', '');
$('.main-cta').text('Join mailing list');
$('body').toggleClass('is-sticky');
$('body').removeClass("is-expanded");
$('.menu-section-container-nav').css({display:'none', opacity:0});
$('#nav-toggle').css('display','block');
});
/*
*
*
*
* MENU SECTION
*
*
*
*/
function toggleNavigation() {
if ($('body').hasClass("is-expanded")) {
$('body').removeClass("is-expanded");
$('.menu-section-container-nav').css({display:'none', opacity:0});
} else {
$('body').addClass("is-expanded");
$('.menu-section-container-nav').css({display:'flex'});
setTimeout(function () {
$('.menu-section-container-nav').css({opacity:1});
}, 500);
}
if ($('#nav-toggle').hasClass("active")) {
$('#nav-toggle').removeClass("active");
} else {
$('#nav-toggle').addClass("active");
}
}
$(document).ready(function(){
$("#nav-toggle").on("click", function() {
toggleNavigation();
});
$(".nav-item").on("click", function(e) {
toggleNavigation();
$.scrollTo(
'.' + $(e.currentTarget).attr('data-target'), {duration:500});
});
$(".footer-nav-item").on("click", function(e) {
$.scrollTo(
'.' + $(e.currentTarget).attr('data-target'), {duration:500});
});
$( window ).resize(function() {
if ( ! $('body').hasClass("is-sticky") ) {
$('.main-cta').width('auto');
}
});
});
/*
*
*
*
* CONTACT SECTION
*
*
*
*/
var $loadEmailButton = $('.load-email-button')[0];
var $contactForm = $('#contact-form');
var DEFAULT_TEXT_CONTENT = 'Join the party';
$contactForm.submit(
function (e) {
e.preventDefault();
$loadEmailButton.textContent = 'Please wait...';
var emailValue = $('.load-email-enter').val();
var honeyPotValue = $('.load-email-enter-fake').val();
if (honeyPotValue === '') {
$.ajax({
url: 'https://formspree.io/' + FORMSPREE_EMAIL,
method: 'POST',
data: { email: emailValue },
dataType: 'json',
success: function () {
$loadEmailButton.classList.add('load-email-button-is-active');
$('.first-page-email-enter').attr('disabled', 'disabled');
$('button.load-email-button').attr('disabled', 'disabled');
$loadEmailButton.textContent = DEFAULT_TEXT_CONTENT;
},
error: function () {
$loadEmailButton.classList.add('load-email-button-is-error');
setTimeout(function () {
$('.first-page-email-enter').val('');
$loadEmailButton.classList.remove('load-email-button-is-error');
$loadEmailButton.textContent = DEFAULT_TEXT_CONTENT;
}, 5000);
}
});
}
}
);
/*
*
*
*
* FONT LOADING
*
*
*
*/
WebFont.load({
google: {
families: ['Open Sans:400,700,800', 'Lora:400,700']
}
});
var fontA = new FontFaceObserver('Open Sans', {weight: 400});
var fontB = new FontFaceObserver('Open Sans', {weight: 700});
var fontC = new FontFaceObserver('Open Sans', {weight: 800});
var fontD = new FontFaceObserver('Lora', {weight: 400});
var fontE = new FontFaceObserver('Lora', {weight: 700});
$(document).ready(function(){
Promise.all([fontA.load(), fontB.load(), fontC.load(), fontD.load(), fontE.load()]).then(function () {
console.log('Family A & B & C & d & E have loaded');
$('html').addClass("fonts-loaded");
});
});
/*
*
*
*
* PRICING SECTION
*
*
*
*/
$(document).ready(function(){
$('.plan-a').attr('href', 'https://www.payfacile.com/simpleststartupstart/s/plan-a')
$('.plan-b').attr('href', 'https://www.payfacile.com/simpleststartupstart/s/plan-b')
$('.plan-c').attr('href', 'https://www.payfacile.com/simpleststartupstart/s/plan-c')
});