Skip to content

Instantly share code, notes, and snippets.

@gabrielgilini
Created November 27, 2014 21:54
Show Gist options
  • Save gabrielgilini/c7f2945dc57d470cf720 to your computer and use it in GitHub Desktop.
Save gabrielgilini/c7f2945dc57d470cf720 to your computer and use it in GitHub Desktop.
$(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