Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: static/js/scripts.js

Issue 29335113: Issue 2675 - Implemented responsive header for web.eyeo.com (Closed)
Patch Set: Fixed html formatting, script links, and assistive text. Created May 11, 2016, 6:41 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « static/js/respond.min.js ('k') | templates/default.tmpl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 jQuery(function() 1 jQuery(function()
2 { 2 {
3 var toTop = jQuery("#to-top"); 3 var $toTop = jQuery("#to-top");
4 toTop.click(function () 4
5 $toTop.click(function ()
5 { 6 {
6 jQuery("body,html").animate({ 7 jQuery("body,html").animate({
7 scrollTop: 0 8 scrollTop: 0
8 }, 800); 9 }, 800);
9 return false; 10 return false;
10 }); 11 });
11 });
12 12
13 jQuery(window).scroll(function() 13 var $window = jQuery(window);
14 { 14 var $header = jQuery("#header");
15 var scrollTop = jQuery(window).scrollTop(); 15 var headerPadding = 13;
16 16
17 // Fix header 17 $window.scroll(function()
18 var header = jQuery("#header");
19 var height = header.height();
20 var fixed = (scrollTop > height);
21 if (fixed != header.hasClass("fixed"))
22 { 18 {
23 if (fixed) 19 if ($window.scrollTop() > headerPadding)
24 { 20 {
25 header.css("top", -height); 21 if ($header.hasClass("top"))
26 header.animate({top: 0},function()
27 { 22 {
28 header.css("top", ""); 23 $header.removeClass("top");
29 }); 24 $toTop.show();
30 header.addClass("fixed"); 25 }
26 }
27 else
28 {
29 if (!$header.hasClass("top"))
30 {
31 $header.addClass("top");
32 $toTop.hide();
33 }
34 }
35 });
36
37 var $menu = jQuery("#menu");
38
39 jQuery('#header-hamberger').click(function()
40 {
41 if ($menu.hasClass("open")) {
42 $menu.removeClass("open");
43 $menu.attr("aria-expanded", false);
31 } 44 }
32 else 45 else
33 header.removeClass("fixed"); 46 {
34 } 47 $menu.addClass("open");
48 $menu.attr("aria-expanded", true);
49 }
50 })
35 51
36 // Display "to top" button
37 var toTop = jQuery("#to-top");
38 toTop.css("opacity", scrollTop > 100 ? 1 : 0)
39 }); 52 });
OLDNEW
« no previous file with comments | « static/js/respond.min.js ('k') | templates/default.tmpl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld