/* Page Loader */
$(window).load(function() {
$(".loader").fadeOut("slow");
});
/* Reload Page on Orientation Change */
var supportsOrientationChange = "onorientationchange" in window,
orientationEvent = supportsOrientationChange ? "orientationchange" : "resize";
window.addEventListener(orientationEvent, function(){
window.location.reload()
}, false);
/* Wrap Navigation in Container */
$('#categories-nav').wrap('
');
/* Add Mobile Menu Button to Lower Bar */
$('#menu-button').prependTo('#lower_bar');
/* Display Mobile Menu */
$(document).ready(function(){
$("#menu-button").click(function(){
$("#categories-nav").slideToggle();
$(this).toggleClass("open");
});
});
/* Display Sub-Category Links Mobile Menu */
$(document).ready(function(){
if($(window).width() <= 1200){ //only works on screensizes where mobile menu is present (in this case 1200px)
$('#categories-nav > li.parent > a').bind('click', function(e){
e.preventDefault(); //disable parent link
});
$("#categories-nav li").click(function(e) {
e.stopPropagation();
$(">.dropdown.level-0", this).slideToggle();
$(this).toggleClass("open");
});
}
});
// Add Expand To Mobile Menu
$('.mobile-menu li:has(ul.sub-menu)').append('+
');
/* Add Icon for Level 1 Sub-Navigation Toggle */
$('').insertAfter('.level-0 > li.parent > span, .level-0 > li.parent > a');
/* Display Sub-Navigation on Toggle */
$(document).ready(function(){
$(".sub-menu-toggle-container").click(function() {
$(this).siblings(".level-1").slideToggle();
$(this).parent().toggleClass("active");
});
});
/* Add Logos to Footer on Smaller Devices */
$(function(){
if ($(window).width() > 1200) {
$('#accreditation').prependTo('#main');
}
});
/* Enable Toggle for Menu Navigation */
$(document).ready(function(){
if($(window).width() <= 992){ //only works on screensizes smaller than 992px
$(".FooterTitle").click(function(){
$(this).siblings(".footer-nav-list").slideToggle();
});
}
});
/* Wrap Top Bar Elements in Container */
$('#top_bar_1, #top_bar_2').wrapAll('');
/* Display News Link in Top Bar */
$('|Newsletter').insertAfter('#inline_account_links > ul > li:last-child');
/* Display 100% Irish & Delivery Links in Top Bar */
$('|Delivery').insertAfter('#inline_basket_links > ul > li:last-child');
/* Change Basket Text */
$(document).ready(function() {
$("#inline_basket_links > ul > li > a").text(function () {
return $(this).text().replace("View Basket", "Basket");
});
});
/* Add Placeholder to Search Form */
$('#search_form > fieldset > input#l_nav_search.text').each(
function(i,el) {
if (!el.value || el.value == '') {
el.placeholder = 'Search products...';
}
});
/* Add Placeholder to Newsletter Form */
$('#mce-EMAIL').each(
function(i,el) {
if (!el.value || el.value == '') {
el.placeholder = 'Enter your email...';
}
});
/* Insert Breadcrumb Before H1 */
$('#content > p.breadcrumb').each(function() {
$(this).insertBefore('#content > h1:first-of-type');
});
/* Wrap Page H1 & Breadcrumb in Container */
$('#content > h1:first-of-type, #content > p.breadcrumb').wrapAll('');
/* Scroll to Page Anchor */
$(function(){
$('a[href*="#"]:not([href="#"])').click(function() {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
if (target.length) {
$('html, body').animate({
scrollTop: target.offset().top
}, 1000);
return false;
}
});
});
/* Scroll to Top Function */
$(document).ready(function(){
$(window).scroll(function(){
if ($(this).scrollTop() > 500) {
$('.scrollup').fadeIn();
} else {
$('.scrollup').fadeOut();
}
});
$('.scrollup').click(function(){
$("html, body").animate({ scrollTop: 0 }, 600);
return false;
});
});
/* Add Current Date */
var months = ['January','February','March','April','May','June','July',
'August','September','October','November','December'];
var tomorrow = new Date();
tomorrow.setTime(tomorrow.getTime() + (1000*3600*24));
document.getElementById("spandate").innerHTML = tomorrow.getFullYear();
/* Multi-line Ellipsis for Text Container */
$(document).ready(function(){
$('.max-height-text').each(function (){
var $ellipsisText = $(this);
while ($ellipsisText.outerHeight(true) > 100) {
$ellipsisText.text(function(index, text) {
return text.replace(/\W*\s(\S)*$/, '...');
});
}
});
});
/* Add Container Class to Contact Form & Product Page Containers */
$( "#form_26, #product_top, .product-listings, #related_products_list, #form_basket, #order_history, #product_description" ).addClass( "container" );
/* Wrap Form Error in Container */
$( "#form_error" ).wrap( "" );
/* Add Col Class to Category Listings */
$( ".category-listings" ).addClass( "container" );
/* Relocate Category Listings to After H2 */
$('.category-listings').appendTo('#page-title-section');
/* Add Column Class to Product Listings */
$( ".productbox" ).addClass( "col-xs-6 col-sm-4 col-md-3" );
/* Wrap Product Image in Container */
$('.product_image').wrap('');
/* Relocate Was Price to Start of Div & Change Text for Product Listing */
$(".price_was").each(function() {
$(this).closest(".productbox").prepend(this);
$(this).text('Sale');
});
/* Add Product Listing Title & Price in Same Div */
$(".productbox > h2, .productbox > h3").each(function(index) {
$(this).next(".product_price").andSelf().wrapAll("")
});
/* Add Product Rating Stars to Product Listing */
$('
').insertBefore('.productbox .product_price');
/* Product Page Requirements */
$( "#product_top" ).addClass( "container" );
/* Add Product Rating to Product Information Section */
$( ".rating" ).prependTo( "#product_info" );
/* Add Product Details Title */
$('Product Details
').insertBefore('.rating');
/* Add VAT Message Below Price */
$( 'Price Excludes VAT at 23%
' ).insertAfter( '#product_price');
/* Add Col Class To Product Info & Images then Wrap in Row */
$('#product_images, #product_info').addClass("col-md-6").wrapAll('');
/* Wrap Product Images in Col */
$('#prod_sub_images > a > img').wrap('');
/* Move Product Video Button To last Product Thumbnail Image */
$('.product-video-container').appendTo('#prod_sub_images > a:last-child .sub-product-image-wrap');
/* Add Sale Ribbon To Pages with Discount */
$( 'Sale
' ).insertBefore( '#product_price_was' ).prependTo('#product_images');
/* Move Sharing to After Product Ref */
$( ".sharing" ).insertAfter( "#product_ref" );
/* Click to Display Ratings */
$(document).ready(function(){
$(".rating-info-icon").click(function(){
$(".rating-info").slideToggle();
});
});
/* Change Rating Text */
$(document).ready(function() {
$(".rating .you-rated").text(function () {
return $(this).text().replace("Login to rate this product", "Login to Rate");
});
$(".rating .you-rated").text(function () {
return $(this).text().replace("You rated this at 5 out of 5 stars", "You Rated 5 Stars");
});
$(".rating .you-rated").text(function () {
return $(this).text().replace("You rated this at 4 out of 5 stars", "You Rated 4 Stars");
});
$(".rating .you-rated").text(function () {
return $(this).text().replace("You rated this at 3 out of 5 stars", "You Rated 3 Stars");
});
$(".rating .you-rated").text(function () {
return $(this).text().replace("You rated this at 2 out of 5 stars", "You Rated 2 Stars");
});
$(".rating .you-rated").text(function () {
return $(this).text().replace("You rated this at 1 out of 5 stars", "You Rated 1 Stars");
});
$(".rating .you-rated").text(function () {
return $(this).text().replace("You rated this at 0 out of 5 stars", "You Rated 0 Stars");
});
});
/* Change Nil Price to POA on Product Page */
$(document).ready(function() {
$("#product_price").text(function () {
return $(this).text().replace("€0.00", "€POA");
});
});
/* Change Nil Price to POA on Product Listing */
$(document).ready(function() {
$(".product_price").text(function () {
return $(this).text().replace("€0.00", "€POA");
});
});
/* Add Out of Stock Message to Products */
$(document).ready(function() {
$("#product_out_of_stock").text(function () {
return $(this).text().replace("Sorry, this product is out of stock.", "For pricing or additional details on this product please do not hesitate to contact our friendly & experienced team.");
});
});
/* Add Contact Button to Out of Stock Product */
$(' Get in Touch
').insertAfter('#product_out_of_stock');
/* Add Title to Product Description */
$( '' ).insertBefore('#product_description');
/* Remove Related Products List from Product Description */
$( '#related_products_list' ).insertAfter('#product_description');
/* Add Title to Related Products */
$( '' ).insertBefore('#related_products_list');
/* Wrap Related Products List Items In Div */
$( "#related_products_list > li" ).wrap( '' );
/* Relocate Related Title to After Image */
$('.related-product-col .title').each(function() {
$(this).appendTo(this.parentNode);
});
/* Wrap Related Product Image in Container */
$('.related-product-col img').wrap('');
/* Change Button text from 'Return to Homepage' to 'Homepage' */
$(document).ready(function() {
$("#content > p > a").text(function () {
return $(this).text().replace("Return to homepage", "Homepage");
});
});
/* Wrap News Articles in Container */
$('.news_image, .news_panel').wrapAll('');
/* Wrap News Image */
$( ".news_image img" ).wrap( "" );
/* Remove Space from Pagination */
jQuery.fn.cleanWhitespace = function() {
textNodes = this.contents().filter(
function() { return (this.nodeType == 3 && !/\S/.test(this.nodeValue)); })
.remove();
return this;
};
$('.pagination').cleanWhitespace();
$('.rating-image').cleanWhitespace();
/*Enable Popup Video*/
$('.play-1').yu2fvl();
/*Colorbox Responsive Sizing*/
jQuery.colorbox.settings.maxWidth = '90%';
jQuery.colorbox.settings.maxHeight = '90%';
// ColorBox resize function
var resizeTimer;
function resizeColorBox()
{
if (resizeTimer) clearTimeout(resizeTimer);
resizeTimer = setTimeout(function() {
if (jQuery('#cboxOverlay').is(':visible')) {
jQuery.colorbox.load(true);
}
}, 300);
}
// Resize ColorBox when resizing window or changing mobile device orientation
/* jQuery(window).resize(resizeColorBox); */
window.addEventListener("orientationchange", resizeColorBox, false);