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

Delta Between Two Patch Sets: static/js/scripts.js

Issue 29335113: Issue 2675 - Implemented responsive header for web.eyeo.com (Closed)
Left Patch Set: Removed extra whitespace Created Jan. 29, 2016, 5:39 p.m.
Right Patch Set: Fixed code style and consistancy issues Created June 23, 2016, 5:23 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « static/js/respond.min.js ('k') | templates/default.tmpl » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 jQuery(function() 1 (function(){
2 { 2 function addListener(target, event, callback)
3 var $toTop = jQuery("#to-top"); 3 {
4 if (target.addEventListener)
5 return target.addEventListener(event, callback, false);
6 else
7 return target.attachEvent("on" + event, callback);
8 }
4 9
5 $toTop.click(function () 10 function onLoad(callback)
6 { 11 {
7 jQuery("body,html").animate({ 12 if (document.addEventListener)
8 scrollTop: 0 13 return addListener(document, "DOMContentLoaded", callback);
9 }, 800); 14 else
10 return false; 15 return addListener(window, "load", callback);
16 }
17
18 onLoad(function()
19 {
20 // expand & contract fixed header
21 var header = document.getElementById("header");
22 var headerPadding = 13;
23 addListener(window, "scroll", function()
24 {
25 var scrollY = window.scrollY || document.documentElement.scrollTop;
26 if (scrollY < headerPadding)
27 header.className = "top";
28 else
29 header.className = "";
30 });
31 // open & close header menu (on small screens)
32 var menu = document.getElementById("menu");
33 var menuButton = document.getElementById("header-hamburger");
34 addListener(menuButton, "click", function()
35 {
36 if (menu.className === "open")
37 {
38 menu.className = "";
39 menu.setAttribute("aria-expanded", false);
40 }
41 else
42 {
43 menu.className = "open";
44 menu.setAttribute("aria-expanded", true);
45 }
46 });
11 }); 47 });
12 48 }());
13 var $window = jQuery(window);
14 var $header = jQuery("#header");
15 var headerPadding = 13;
16
17 $window.scroll(function()
18 {
19 if ($window.scrollTop() > headerPadding)
20 {
21 if ($header.hasClass("top"))
22 {
23 $header.removeClass("top");
24 $toTop.show();
25 }
26 }
27 else
28 {
29 if (!$header.hasClass("top"))
30 {
31 $header.addClass("top");
32 $toTop.hide();
33 }
34 }
35 });
36
37 jQuery('#header-hamberger').click(function()
38 {
39 var $menu = jQuery("#menu");
40
41 if ($menu.hasClass("open")) {
42 $menu.removeClass("open");
43 $menu.attr("aria-expanded", false);
44 }
45 else
46 {
47 $menu.addClass("open");
48 $menu.attr("aria-expanded", true);
49 }
50 })
51
52 });
LEFTRIGHT

Powered by Google App Engine
This is Rietveld