Created
November 27, 2014 21:54
-
-
Save gabrielgilini/c7f2945dc57d470cf720 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function () { | |
if ($("body#careers").length == 0) { | |
return; | |
} | |
var getHash = function ($anchor) { | |
var hash = $anchor.prop('hash'); | |
if (typeof hash != 'string') { | |
hash = '#' + $anchor.prop('href').split('#').pop(); | |
} | |
return hash; | |
}; | |
// Change hash for page-reload | |
$('a.position-nav').on('click', function (e) { | |
var $target = $(e.target).closest('a'); | |
var hash = getHash($target); | |
if(hash && hash != '#') { | |
window.location.hash = hash; | |
} | |
}); | |
// Javascript to enable link to tab | |
var url = window.location.toString(); | |
if (url.indexOf('#') > -1) { | |
var element = $('a[href=#'+url.split('#')[1]+']'); | |
element.tab('show'); | |
$('html, body').scrollTop($("#careers-container").offset().top); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment