Difference between revisions of "Template:Washington"

Line 278: Line 278:
 
      
 
      
 
<script type="text/javascript">
 
<script type="text/javascript">
$('a[href*=#]:not([href=#])').click(function() {
+
var jump=function(e)
    if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')  
+
{
        || location.hostname == this.hostname) {
+
      //prevent the "normal" behaviour which would be a "hard" jump
 +
      e.preventDefault();
 +
      //Get the target
 +
      var target = $(this).attr("href");
 +
      //perform animated scrolling
 +
      $('html,body').animate(
 +
      {
 +
              //get top-position of target-element and set it as scroll target
 +
              scrollTop: $(target).offset().top
 +
      //scrolldelay: 2 seconds
 +
      },2000,function()
 +
      {
 +
              //attach the hash (#jumptarget) to the pageurl
 +
              location.hash = target;
 +
      });
  
        var target = $(this.hash);
+
}
        target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
+
 
          if (target.length) {
+
$(document).ready(function()
            $('html,body').animate({
+
{
                scrollTop: target.offset().top
+
      $('a[href*=#]').bind("click", jump);
            }, 1000);
+
      return false;
            return false;
+
        }
+
    }
+
 
});
 
});
 +
 +
 
</script>
 
</script>
 
</head>
 
</head>

Revision as of 19:17, 11 September 2015