Index: static/js/scripts.js |
diff --git a/static/js/scripts.js b/static/js/scripts.js |
index c08b3b5b4843635dd7ba555f902a85e56f74e7b3..114c51e7233434db18d81af1ed74d59becceca0a 100644 |
--- a/static/js/scripts.js |
+++ b/static/js/scripts.js |
@@ -1,39 +1,52 @@ |
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.
|
{ |
- var toTop = jQuery("#to-top"); |
- toTop.click(function () |
+ 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.
|
+ |
+ $toTop.click(function () |
{ |
jQuery("body,html").animate({ |
scrollTop: 0 |
}, 800); |
return false; |
}); |
-}); |
-jQuery(window).scroll(function() |
-{ |
- var scrollTop = jQuery(window).scrollTop(); |
+ var $window = jQuery(window); |
+ var $header = jQuery("#header"); |
+ var headerPadding = 13; |
- // Fix header |
- var header = jQuery("#header"); |
- var height = header.height(); |
- var fixed = (scrollTop > height); |
- if (fixed != header.hasClass("fixed")) |
+ $window.scroll(function() |
{ |
- if (fixed) |
+ if ($window.scrollTop() > headerPadding) |
{ |
- header.css("top", -height); |
- header.animate({top: 0},function() |
+ if ($header.hasClass("top")) |
{ |
- header.css("top", ""); |
- }); |
- header.addClass("fixed"); |
+ $header.removeClass("top"); |
+ $toTop.show(); |
+ } |
+ } |
+ else |
+ { |
+ if (!$header.hasClass("top")) |
+ { |
+ $header.addClass("top"); |
+ $toTop.hide(); |
+ } |
+ } |
+ }); |
+ |
+ var $menu = jQuery("#menu"); |
+ |
+ 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 :)
|
+ { |
+ 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.
|
+ $menu.removeClass("open"); |
+ $menu.attr("aria-expanded", false); |
} |
else |
- header.removeClass("fixed"); |
- } |
+ { |
+ $menu.addClass("open"); |
+ $menu.attr("aria-expanded", true); |
+ } |
+ }) |
- // Display "to top" button |
- var toTop = jQuery("#to-top"); |
- toTop.css("opacity", scrollTop > 100 ? 1 : 0) |
}); |