diff options
Diffstat (limited to 'theme/cccevents/static/hemingway/global.js')
-rw-r--r-- | theme/cccevents/static/hemingway/global.js | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/theme/cccevents/static/hemingway/global.js b/theme/cccevents/static/hemingway/global.js new file mode 100644 index 0000000..af3681d --- /dev/null +++ b/theme/cccevents/static/hemingway/global.js | |||
@@ -0,0 +1,86 @@ | |||
1 | jQuery(document).ready(function($) { | ||
2 | |||
3 | // Toggle mobile-menu | ||
4 | $(".nav-toggle").on("click", function(){ | ||
5 | $(this).toggleClass("active"); | ||
6 | $(".mobile-menu").slideToggle(); | ||
7 | if ($(".search-toggle").hasClass("active")) { | ||
8 | $(".search-toggle").removeClass("active"); | ||
9 | $(".blog-search").slideToggle(); | ||
10 | } | ||
11 | }); | ||
12 | |||
13 | // Toggle search form | ||
14 | $(".search-toggle").on("click", function(){ | ||
15 | $(this).toggleClass("active"); | ||
16 | $(".blog-search").slideToggle(); | ||
17 | if ($(".nav-toggle").hasClass("active")) { | ||
18 | $(".nav-toggle").removeClass("active"); | ||
19 | $(".mobile-menu").slideToggle(); | ||
20 | } | ||
21 | }); | ||
22 | |||
23 | |||
24 | // Show mobile-menu > 700 | ||
25 | $(window).resize(function() { | ||
26 | if ($(window).width() > 800) { | ||
27 | $(".toggle").removeClass("active"); | ||
28 | $(".mobile-menu").hide(); | ||
29 | $(".blog-search").hide(); | ||
30 | } | ||
31 | }); | ||
32 | |||
33 | |||
34 | // Cool header image scroll | ||
35 | $(window).scroll(function(e){ | ||
36 | if ($(window).width() > 800) { | ||
37 | $('.header').css({ | ||
38 | 'bottom' : -($(this).scrollTop()/3)+"px", | ||
39 | }); | ||
40 | var thisdist = $(this).scrollTop(); | ||
41 | var headerheight = $(".header").outerHeight(); | ||
42 | $('.blog-info').css({ | ||
43 | 'opacity' : (1 - thisdist/headerheight) | ||
44 | }); | ||
45 | } else { | ||
46 | $('.header').css({'bottom' : 'auto'}); | ||
47 | $('.blog-info').css({'opacity' : "1" }); | ||
48 | } | ||
49 | }); | ||
50 | |||
51 | |||
52 | // resize videos after container | ||
53 | var vidSelector = ".post iframe, .post object, .post video, .widget-content iframe, .widget-content object, .widget-content iframe"; | ||
54 | var resizeVideo = function(sSel) { | ||
55 | $( sSel ).each(function() { | ||
56 | var $video = $(this), | ||
57 | $container = $video.parent(), | ||
58 | iTargetWidth = $container.width(); | ||
59 | |||
60 | if ( !$video.attr("data-origwidth") ) { | ||
61 | $video.attr("data-origwidth", $video.attr("width")); | ||
62 | $video.attr("data-origheight", $video.attr("height")); | ||
63 | } | ||
64 | |||
65 | var ratio = iTargetWidth / $video.attr("data-origwidth"); | ||
66 | |||
67 | $video.css("width", iTargetWidth + "px"); | ||
68 | $video.css("height", ( $video.attr("data-origheight") * ratio ) + "px"); | ||
69 | }); | ||
70 | }; | ||
71 | |||
72 | resizeVideo(vidSelector); | ||
73 | |||
74 | $(window).resize(function() { | ||
75 | resizeVideo(vidSelector); | ||
76 | }); | ||
77 | |||
78 | // Smooth scroll to header | ||
79 | $('.tothetop').click(function(){ | ||
80 | $('html,body').animate({scrollTop: 0}, 500); | ||
81 | $(this).unbind("mouseenter mouseleave"); | ||
82 | return false; | ||
83 | }); | ||
84 | |||
85 | |||
86 | }); \ No newline at end of file | ||