/
custom.js
203 lines (137 loc) · 3.92 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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
/********************************************************
*
* Animation du header au scroll
*
********************************************************/
var cbpAnimatedHeader = (function() {
var docElem = document.documentElement,
header = document.querySelector( '.headerstandard' ),
didScroll = false,
changeHeaderOn = 300;
function init() {
window.addEventListener( 'scroll', function( event ) {
if( !didScroll ) {
didScroll = true;
setTimeout( scrollPage, 250 );
}
}, false );
}
function scrollPage() {
var sy = scrollY();
if ( sy >= changeHeaderOn ) {
classie.add( header, 'headerstandard-shrink' );
}
else {
classie.remove( header, 'headerstandard-shrink' );
}
didScroll = false;
}
function scrollY() {
return window.pageYOffset || docElem.scrollTop;
}
init();
})();
$(function() {
/********************************************************
*
* gestion de la mobilité
*
********************************************************/
function toggleMobileMenu(){
$('.menumobile').slideToggle();
}
$('#releaseMenu').click(function(){
toggleMobileMenu();
});
$('.menumobile a').click(function(){
toggleMobileMenu();
});
$('.menumobile span').click(function(){
toggleMobileMenu();
});
/********************************************************
*
* Changements au scroll
*
********************************************************/
$('nav.menu a').click(function(){
$('html, body').animate({
scrollTop: $( $(this).attr('href') ).offset().top
}, 500);
});
var currentSection = "section1";
function change($section){
$('nav.menu a').removeClass('current');
currentSection = $section.attr('id');
$('body').removeClass();
$('body').addClass( $section.attr('id') + '-visible' );
$('.target-'+currentSection).addClass('current');
}
$("#main section").waypoint( function( direction ) {
if( direction === 'down' ) {
change( $( this ) );
}
}, { offset: '20%' } ).waypoint( function( direction ) {
if( direction === 'up' ) {
change( $( this ) );
}
}, { offset: '-20%' } );
$( window ).on( 'debouncedresize', function() {
$('html, body').animate({
scrollTop: $("#"+currentSection).offset().top
}, 500);
} );
/********************************************************
*
* Magnific Popup
*
********************************************************/
$('.portfolio ul li a').magnificPopup({type:'image'});
/********************************************************
*
* Portfolio
*
********************************************************/
var $elements = $('#elements');
// initialize isotope
$elements.isotope({
// options...
});
$elements.isotope({ filter: '.tous' });
// filter items when filter link is clicked
$('.portfolio nav a').click(function(){
var selector = $(this).attr('data-filter');
$elements.isotope({ filter: selector });
$('.portfolio nav a').removeClass('current');
$(this).addClass('current');
return false;
});
/********************************************************
*
* Contact form
*
********************************************************/
// Create input element for testing
var inputs = document.createElement('input');
// Create the supports object
var supports = {};
supports.autofocus = 'autofocus' in inputs;
supports.required = 'required' in inputs;
supports.placeholder = 'placeholder' in inputs;
// Fallback for autofocus attribute
if(!supports.autofocus) {
}
// Fallback for required attribute
if(!supports.required) {
}
// Fallback for placeholder attribute
if(!supports.placeholder) {
}
// Change text inside send button on submit
var send = document.getElementById('contact-submit');
if(send) {
send.onclick = function () {
this.innerHTML = '...Sending';
}
}
});