Last active
February 29, 2016 22:38
-
-
Save Tiny-Giant/89e74617fd7013bbb957 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($) | |
{ | |
'use strict'; | |
if (typeof jQuery == 'undefined') | |
{ | |
alert('no jquery'); | |
} | |
$(document).ready(function() | |
{ | |
(function() | |
{ | |
if (!/portfolio-item/.test(window.location.href)) return; | |
var i; | |
var bigwrap = document.querySelector('.page-header .portfolio-entry-img').parentNode; | |
var bigimages = {}; | |
var products = document.querySelectorAll('.product-thumbnail-wrap img'); | |
var title = document.querySelector('.product-title'); | |
var code = document.querySelector('.product-code'); | |
var trays_tmp = document.querySelectorAll('.tray-reference [data-tray]'); | |
var trays = {}; | |
var wraps_tmp = document.querySelectorAll('.tray-wrap'); | |
var wraps = {}; | |
var active = {}; | |
active.bigimage = bigwrap.firstElementChild; | |
if (active.bigimage) bigimages[active.bigimage.src] = active.bigimage; | |
for (i in Object.keys(trays_tmp)) | |
{ | |
if (trays_tmp.hasOwnProperty(i)) | |
{ | |
trays[trays_tmp[i].getAttribute('data-tray')] = trays_tmp[i]; | |
if (/tray-active/.test(trays_tmp[i].className)) active.tray = trays_tmp[i].getAttribute('data-tray'); | |
} | |
} | |
for (i in Object.keys(wraps_tmp)) | |
{ | |
if (wraps_tmp.hasOwnProperty(i)) | |
{ | |
var table = wraps_tmp[i].getAttribute('data-table'); | |
wraps[table] = wraps_tmp[i]; | |
if (wraps_tmp[i].style.display === '') active.wrap = wraps_tmp[i]; | |
} | |
} | |
for (i in Object.keys(products)) | |
{ | |
if (products.hasOwnProperty(i)) | |
{ | |
if (/product-thumb-active/.test(products[i].className)) active.product = products[i]; | |
if (products[i].getAttribute('data-big') && !bigwrap.querySelector('[src="' + products[i].getAttribute('data-big') + '"]') && active.bigimage) | |
{ | |
var bigimg = active.bigimage.cloneNode(); | |
bigimg.src = products[i].getAttribute('data-big'); | |
bigimg.style.display = 'none'; | |
bigwrap.appendChild(bigimg); | |
bigimages[products[i].getAttribute('data-big')] = bigimg; | |
} | |
products[i].addEventListener('click', function() | |
{ | |
if (active.product) active.product.className = active.product.className.replace(/\s*product-thumb-active/, ''); | |
this.className += ' product-thumb-active'; | |
active.product = this; | |
if (active.tray) trays[active.tray].className = trays[active.tray].className.replace(/\s*tray-active/, ''); | |
active.tray = this.getAttribute('data-tray'); | |
if (active.tray) | |
{ | |
if (!trays[active.tray]) active.tray = undefined; | |
else trays[active.tray].className += ' tray-active'; | |
} | |
console.log(active.tray, trays[active.tray]); | |
if ((active.tray && active.wrap !== active.tray[0]) || !active.tray) | |
{ | |
if (active.wrap) active.wrap.style.display = 'none'; | |
if (!active.tray) active.wrap = wraps.None; | |
else active.wrap = wraps[active.tray[0]]; | |
if (!active.wrap) active.wrap = wraps.None; | |
active.wrap.style.display = ''; | |
} | |
title.textContent = this.getAttribute('title'); | |
code.textContent = this.getAttribute('code'); | |
if (active.bigimage) active.bigimage.style.display = 'none'; | |
active.bigimage = bigimages[this.getAttribute('data-big')]; | |
$(active.bigimage).fadeIn('fast'); | |
}); | |
} | |
} | |
})(); | |
var navnodes = {}; | |
navnodes.toggle = $(".nav-toggle"); | |
navnodes.overlay = $(".overlay-boxify"); | |
navnodes.wrap = $("#site-navigation-wrap"); | |
navnodes.logo = $(".fixed-logo"); | |
navnodes.social = $("#site-social-wrap"); | |
$('.nav-toggle, .overlay').on('click', function(event) | |
{ | |
navnodes.toggle.toggleClass("active"); | |
navnodes.overlay.toggleClass("open"); | |
navnodes.wrap.toggleClass("menuActive"); | |
navnodes.logo.toggleClass("logoActive"); | |
navnodes.social.toggleClass("socialActive"); | |
}); | |
$('.single-question').click(function() | |
{ | |
$('.tray-reference').toggle(); | |
}); | |
/***************** Header BG Scroll ******************/ | |
var pastWaypoint = false; | |
$(window).scroll(function() | |
{ | |
if ($(window).scrollTop() > 580 && !pastWaypoint) | |
{ | |
$('.fixed-logo').show(); | |
$(".fixed-header").addClass("hasBg header-sml"); | |
$("#site-navigation-wrap").show(); | |
console.log('d'); | |
pastWaypoint = true; | |
} | |
else if ($(window).scrollTop() <= 580 && pastWaypoint) | |
{ | |
$('.fixed-logo').hide(); | |
console.log('f'); | |
$(".fixed-header").removeClass("hasBg header-sml"); | |
pastWaypoint = false; | |
} | |
}); | |
$("img").bind("contextmenu", function(e) | |
{ | |
return false; | |
}); | |
$("div.desc").hide(); | |
$("input[name$='requestbrochure']").change(function() | |
{ | |
$("div.desc").hide(); | |
$("#" + this.value).show(); | |
}).filter(function() | |
{ | |
return this.checked; | |
}).change(); | |
$(".resource-tabs-menu a").click(function(event) | |
{ | |
event.preventDefault(); | |
$(this).parent().addClass("resource-current"); | |
$(this).parent().siblings().removeClass("resource-current"); | |
var tab = $(this).attr("href"); | |
$(".resource-tab-content").not(tab).css("display", "none"); | |
$(tab).fadeIn(); | |
}); | |
$('.portfolio-dropdown-content').show(); | |
$('#portfolio-dropdown-menu').click(function() | |
{ | |
$('.portfolio-dropdown-content').slideToggle("fast"); | |
$('#portfolio-dropdown-icon').toggleClass("portfolio-dropdown-selected"); | |
}); | |
$('.request-brochure-button').click(function() | |
{ | |
$('.request-brochure-content').slideToggle("fast"); | |
$('.request-brochure-button').toggleClass("request-brochure-button-active"); | |
}); | |
$('.overlay a[href="#request-brochure-container"]').click(function() | |
{ | |
if ($('.request-brochure-button').hasClass("request-brochure-button-active")) | |
{ | |
return; | |
} | |
$('.request-brochure-content').slideToggle("fast"); | |
$('.request-brochure-button').toggleClass("request-brochure-button-active"); | |
}); | |
$(".youtube-media").on("click", function(e) | |
{ | |
var t = $(window).width(); | |
if (t <= 768) | |
{ | |
return | |
} | |
$.fancybox( | |
{ | |
padding: 4, | |
type: "iframe", | |
href: this.href.replace(new RegExp("watch\\?v=", "i"), "v/") | |
}); | |
return false; | |
}); | |
$(document).on('click', 'a[href*="#"]:not([href="#"])', function() | |
{ | |
if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) | |
{ | |
var target = $(this.hash); | |
target = target.length ? target : $('[name=' + this.hash.slice(1) + ']'); | |
if (target.length) | |
{ | |
$('html, body').animate( | |
{ | |
scrollTop: target.offset().top - jQuery('.fixed-header')[0].clientHeight | |
}, 1000); | |
return false; | |
} | |
} | |
}); | |
}); // End doc ready | |
$(window).load(function() | |
{ | |
// Homepage FlexSlider | |
$('#homepage-slider').flexslider( | |
{ | |
animation: 'slide', | |
slideshow: true, | |
smoothHeight: true, | |
controlNav: false, | |
directionNav: true, | |
prevText: '<span class="fa fa-angle-left"></span>', | |
nextText: '<span class="fa fa-angle-right"></span>', | |
controlsContainer: ".flexslider-container" | |
}); | |
// Post FlexSlider | |
$('div.post-slider').flexslider( | |
{ | |
animation: 'slide', | |
slideshow: true, | |
smoothHeight: true, | |
controlNav: false, | |
directionNav: true, | |
prevText: '<span class="fa fa-angle-left"></span>', | |
nextText: '<span class="fa fa-angle-right"></span>', | |
controlsContainer: ".flexslider-container" | |
}); | |
}); // End on window load | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment