-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathfunctions.js
83 lines (75 loc) · 2.68 KB
/
functions.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
/**
* Functionality specific to Portfolio.
**/
(function($) {
$(document).ready(function(){
// get the post images
var blocks = [];
jQuery('.article-helper.notloaded').each(function(i, block) {
blocks.push(block);
});
var add_class = function(block, class_name, delay) {
setTimeout(function() {
jQuery(block).addClass(class_name);
}, delay);
};
for(var i = 0; i < blocks.length; i++) {
add_class(blocks[i], 'article-helper animated', i * 200);
}
jQuery('.article-helper.notloaded').each(function(i, wrapper) {
wrapper = jQuery(wrapper);
var img = wrapper.find('header > img')[0];
if(img) {
// wait for the images
var timer = setInterval(function() {
// when the image is laoded
if(img.complete) {
// stop periodical calls
clearInterval(timer);
// generate the image wrapper
var src = jQuery(img).attr('src');
var url = jQuery(img).parent().attr('data-url');
jQuery(img).remove();
var img_container = jQuery('<div class="post-image el-transition-long" data-url="'+url+'" style="background-image: url(\''+src+'\')"></div>');
img_container.appendTo(wrapper);
if(url) {
img_container.css('cursor', 'pointer');
img_container.click(function() {
window.location = img_container.attr('data-url');
});
}
wrapper.removeClass('notloaded');
// add class with delay
setTimeout(function() {
img_container.addClass('loaded');
}, 250);
}
}, 500);
// add necessary mouse events
wrapper.mouseenter(function() {
if(!wrapper.hasClass('no-anim')) {
wrapper.addClass('article-hover');
}
});
wrapper.mouseleave(function() {
if(!wrapper.hasClass('no-anim')) {
wrapper.removeClass('article-hover');
}
});
} else {
// where there is no image - display the text directly
wrapper.addClass('article-hover');
}
});
// fit videos
jQuery(".video-wrapper").fitVids();
var main_menu = jQuery(".main-navigation");
main_menu.click(function() {
if(main_menu.hasClass("opened")) {
main_menu.removeClass("opened");
} else {
main_menu.addClass("opened");
}
});
});
})(jQuery);