-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
102 lines (81 loc) · 2.38 KB
/
script.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
var noFocus = true;
if (masonryActive === undefined ) {var masonryActive = true;}
if (noMasonry === undefined ) { var noMasonry = false; }
$(document).ready(function() {
// bouton menu for small device
$('.menu-btn').click (
function() {
$(this).toggleClass("current");
$('#main-nav').toggleClass("openmenu")
}
)
// Search button makes field appears
$('.search-btn').click (
function() {
$('#searchform').toggleClass("visible");
$('#searchform input').focus();
$('#searchform input').focusout( function(){ $('#searchform').removeClass("visible")});
}
)
//no masonry in single content (loop.php)
if ( noMasonry != true ) {
//first loading masonry
$('.articles-grid').masonry({
columnWidth: 240,
itemSelector: 'article',
isFitWidth: true,
gutter: 25,
transitionDuration: 0,
});
//boutons changement layout
$('.static-btn, .grid-btn').click(
function() {
$('.static-btn, .grid-btn').toggleClass( "current" );
$('#articles').toggleClass( "articles-grid" ).toggleClass( "articles-flow" );
if ( masonryActive ) {
$('#articles').masonry('destroy');
$('body').scrollTo('.lastFocus', 500, {offset:-100} );
}
else {
$('.articles-grid').masonry({
columnWidth: 240,
itemSelector: 'article',
isFitWidth: true,
gutter: 25,
transitionDuration: 0,
});
}
masonryActive = !masonryActive;
});
//focus sur un article
$('article').focusin(function() {
setTimeout(function() {noFocus = false;}, 10);
if ( masonryActive ) {
$('#articles').masonry('destroy');
$('#articles').removeClass( "articles-grid" ).addClass( "articles-flow" );
}
$('body').scrollTo( this, 500, {offset:-100} );
});
//perte du focus d'un article
$('article').focusout(function() {
$(this).addClass("lastFocus");
setTimeout(function() {noFocus = true;}, 5);
if ( masonryActive ) {
setTimeout(function() {
if ( noFocus ){
$('#articles').addClass( "articles-grid" ).removeClass( "articles-flow" );
$('.articles-grid').masonry({
columnWidth: 240,
itemSelector: 'article',
isFitWidth: true,
gutter: 25,
transitionDuration: 0,
});
$('body').scrollTo('.lastFocus', 0, {offset:-100} );
}
}, 15);
}
setTimeout(function() {$('article').removeClass("lastFocus");}, 200);
});
}
});