jQuery(document).ready(function () { "use strict"; jQuery('.category-container').click(function () { var slug = jQuery(this).attr('data-slug'); jQuery('.references-wrapper .slider-navigation').html(''); jQuery('.single-category').hide('400'); jQuery('.single-category').html(''); var catID = jQuery(this).attr('data-id'); jQuery.ajax({ type: "POST", url: "http://www.resoundinc.com/wp-content/themes/impuls/category-ajax.php", async: true, cache: false, data: "cat_id=" + catID, dataType: "html", success: function (data) { jQuery('.single-category').attr('data-slug', slug); jQuery('.single-category').append(data); jQuery('.single-category').show('400'); jQuery('html, body').animate({ scrollTop: jQuery(".single-category").offset().top - 60 }, 500); } }); }); jQuery(".blog-post a").fancybox({ padding: 0, fitToView: false, width: 'auto', height: 'auto', autoSize: false, closeClick: false, openEffect: 'none', closeEffect: 'none', beforeClose: function () { window.location.hash = '#blog'; }, afterLoad: function (current) { var post = jQuery('.blog-post').eq(current.index).attr('data-slug'); window.location.hash = '#blog/' + post; } }); jQuery(".member").fancybox({ padding: 0, fitToView: false, width: 'auto', height: 'auto', autoSize: false, closeClick: false, openEffect: 'none', closeEffect: 'none', beforeClose: function () { window.location.hash = '#team'; }, afterLoad: function (current) { var post = jQuery('.member').eq(current.index).attr('data-slug'); window.location.hash = '#team/' + post; } }); function parseHash() { var hash = window.location.hash; var params = hash.split('/'); if (params[0] !== '') { jQuery('html, body').animate({ scrollTop: jQuery(params[0]).offset().top }, 1000); } if (params[1] !== '') { if (params[0] === '#references') { jQuery('.category-container').each(function () { if (jQuery(this).attr('data-slug') === params[1]) { jQuery(this).trigger('click'); } }); } if (params[0] === '#blog') { jQuery('.blog-post-link').each(function () { if (jQuery(this).attr('data-slug') === params[1]) { jQuery(this).trigger('click'); } }); } if (params[0] === '#team') { jQuery('.member').each(function () { if (jQuery(this).attr('data-slug') === params[1]) { jQuery(this).trigger('click'); } }); } } } parseHash(); });