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

Unified Diff: static/js/scripts.js

Issue 29335113: Issue 2675 - Implemented responsive header for web.eyeo.com (Closed)
Patch Set: Removed phablet media query Created May 11, 2016, 6:31 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « static/js/respond.min.js ('k') | templates/default.tmpl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: static/js/scripts.js
===================================================================
--- a/static/js/scripts.js
+++ b/static/js/scripts.js
@@ -1,39 +1,52 @@
jQuery(function()
{
- var toTop = jQuery("#to-top");
- toTop.click(function ()
+ var $toTop = jQuery("#to-top");
+
+ $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()
+ {
+ if ($menu.hasClass("open")) {
+ $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)
});
« 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