From 2d3e3b516446f3c8a15f97c1078c77d68da5ffa6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0est=C3=A1k=20V=C3=ADt?= Date: Wed, 10 Feb 2016 10:57:23 +0100 Subject: [PATCH] Fixed glitches with headings by replacing a CSS hack by a JS solution. --- app/assets/css/main.css | 7 ------- app/assets/js/main.js | 9 ++++++++- app/views/main.scala.html | 1 + build.sbt | 2 ++ 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/app/assets/css/main.css b/app/assets/css/main.css index 68c9f35..4c050f2 100644 --- a/app/assets/css/main.css +++ b/app/assets/css/main.css @@ -26,13 +26,6 @@ .badge a{ color: yellow; } -h2:before, h3:before, h4:before, h5:before, h6:before { - display: block; - content: " "; - margin-top: -50px; - height: 50px; - visibility: hidden; -} #project-selector{ float: left; padding: 5px; diff --git a/app/assets/js/main.js b/app/assets/js/main.js index 01f16e0..4a9e01f 100644 --- a/app/assets/js/main.js +++ b/app/assets/js/main.js @@ -56,4 +56,11 @@ function toggleClassified(el){ btn.addClass("btn-danger"); } }); -} \ No newline at end of file +} + +function updatePosition(){ + // document.getElementById(…) is used over $('#'+…) in order to reduce attack surface: It does not look like a good idea to pass untrusted input to “omnipotent” `$` function. + $.scrollTo(document.getElementById(location.hash.substr(1)), {offset: -$('#navbar').height()}); +} +$(window).bind('hashchange', function(e) { updatePosition(); }); +$(window).bind('load', function(e) { updatePosition(); }); \ No newline at end of file diff --git a/app/views/main.scala.html b/app/views/main.scala.html index fea26ce..26aecf7 100644 --- a/app/views/main.scala.html +++ b/app/views/main.scala.html @@ -10,6 +10,7 @@ + diff --git a/build.sbt b/build.sbt index accf104..04eb8be 100644 --- a/build.sbt +++ b/build.sbt @@ -67,6 +67,8 @@ libraryDependencies ++= Seq( "com.mohiva" %% "play-silhouette-testkit" % "3.0.4" % "test" ) +libraryDependencies += "org.webjars.bower" % "jquery.scrollTo" % "2.1.2" + libraryDependencies += "net.codingwell" %% "scala-guice" % "4.0.0" libraryDependencies += "net.ceedubs" %% "ficus" % "1.1.2"