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: Minor code style and variable scope cleanup Created Feb. 29, 2016, 5:03 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
OLDNEW
1 jQuery(function() 1 jQuery(function()
saroyanm 2016/04/08 16:56:10 Note: I think if we could use Javascript instead o
juliandoucette 2016/04/25 19:08:56 - I agree that we should get rid of jquery - But I
saroyanm 2016/05/06 14:49:28 I think if we will decide to get rid of animation
juliandoucette 2016/05/11 18:11:06 Ok, I will implement this without jQuery.
2 { 2 {
3 var toTop = jQuery("#to-top"); 3 var $toTop = jQuery("#to-top");
saroyanm 2016/04/08 16:56:09 Why to use dollar sign in front of the variable na
saroyanm 2016/04/08 16:56:10 The element is missing, it was removed.
juliandoucette 2016/04/25 19:08:56 This is a standard practice used to identify a val
juliandoucette 2016/04/25 19:08:56 Good point :D . I didn't notice that. I think we
saroyanm 2016/05/06 14:49:27 Acknowledged.
saroyanm 2016/05/06 14:49:28 I agree I'm not sure if it provides much value, bu
juliandoucette 2016/05/11 18:11:06 Will do.
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()
saroyanm 2016/05/06 14:49:28 Detail: it's "hamburger" also please use double qu
juliandoucette 2016/05/11 18:11:06 Nice catch :)
40 {
41 if ($menu.hasClass("open")) {
saroyanm 2016/04/08 16:56:09 Detail: please move opening curly brace on it's ow
juliandoucette 2016/04/25 19:08:56 Nice catch.
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

Powered by Google App Engine
This is Rietveld