//-----------------------------------------------------------------
// Licensed Materials - Property of IBM
//
// WebSphere Commerce
//
// (C) Copyright IBM Corp. 2013, 2014 All Rights Reserved.
//
// US Government Users Restricted Rights - Use, duplication or
// disclosure restricted by GSA ADP Schedule Contract with
// IBM Corp.
//-----------------------------------------------------------------
/**
* @preserve HTML5 Shiv 3.7.3-pre | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed
*/
//!function(a,b){function c(a,b){var c=a.createElement("p"),d=a.getElementsByTagName("head")[0]||a.documentElement;return c.innerHTML="x",d.insertBefore(c.lastChild,d.firstChild)}function d(){var a=t.elements;return"string"==typeof a?a.split(" "):a}function e(a,b){var c=t.elements;"string"!=typeof c&&(c=c.join(" ")),"string"!=typeof a&&(a=a.join(" ")),t.elements=c+" "+a,j(b)}function f(a){var b=s[a[q]];return b||(b={},r++,a[q]=r,s[r]=b),b}function g(a,c,d){if(c||(c=b),l)return c.createElement(a);d||(d=f(c));var e;return e=d.cache[a]?d.cache[a].cloneNode():p.test(a)?(d.cache[a]=d.createElem(a)).cloneNode():d.createElem(a),!e.canHaveChildren||o.test(a)||e.tagUrn?e:d.frag.appendChild(e)}function h(a,c){if(a||(a=b),l)return a.createDocumentFragment();c=c||f(a);for(var e=c.frag.cloneNode(),g=0,h=d(),i=h.length;i>g;g++)e.createElement(h[g]);return e}function i(a,b){b.cache||(b.cache={},b.createElem=a.createElement,b.createFrag=a.createDocumentFragment,b.frag=b.createFrag()),a.createElement=function(c){return t.shivMethods?g(c,a,b):b.createElem(c)},a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+d().join().replace(/[\w\-:]+/g,function(a){return b.createElem(a),b.frag.createElement(a),'c("'+a+'")'})+");return n}")(t,b.frag)}function j(a){a||(a=b);var d=f(a);return!t.shivCSS||k||d.hasCSS||(d.hasCSS=!!c(a,"article,aside,dialog,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}mark{background:#FF0;color:#000}template{display:none}")),l||i(a,d),a}var k,l,m="3.7.3-pre",n=a.html5||{},o=/^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i,p=/^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i,q="_html5shiv",r=0,s={};!function(){try{var a=b.createElement("a");a.innerHTML="",k="hidden"in a,l=1==a.childNodes.length||function(){b.createElement("a");var a=b.createDocumentFragment();return"undefined"==typeof a.cloneNode||"undefined"==typeof a.createDocumentFragment||"undefined"==typeof a.createElement}()}catch(c){k=!0,l=!0}}();var t={elements:n.elements||"abbr article aside audio bdi canvas data datalist details dialog figcaption figure footer header hgroup main mark meter nav output picture progress section summary template time video",version:m,shivCSS:n.shivCSS!==!1,supportsUnknownElements:l,shivMethods:n.shivMethods!==!1,type:"default",shivDocument:j,createElement:g,createDocumentFragment:h,addElements:e};a.html5=t,j(b),"object"==typeof module&&module.exports&&(module.exports=t)}("undefined"!=typeof window?window:this,document);
if (!Array.prototype.indexOf) {
Array.prototype.indexOf = function (elt /*, from*/) {
var len = this.length >>> 0;
var from = Number(arguments[1]) || 0;
from = (from < 0)
? Math.ceil(from)
: Math.floor(from);
if (from < 0)
from += len;
for (; from < len; from++) {
if (from in this &&
this[from] === elt)
return from;
}
return -1;
};
}
var colruytJs = {};
var componentProducts = [];
// load extra javascript
var Collishop_Loader = function () { }
Collishop_Loader.prototype = {
require: function (scripts, callback) {
this.loadCount = 0;
this.totalRequired = scripts.length;
this.callback = callback;
for (var i = 0; i < scripts.length; i++) {
this.writeScript(scripts[i]);
}
},
loaded: function (evt) {
this.loadCount++;
if (this.loadCount == this.totalRequired && typeof this.callback == 'function') this.callback.call();
},
writeScript: function (src) {
var self = this;
var s = document.createElement('script');
s.type = "text/javascript";
s.async = true;
s.src = src;
s.addEventListener('load', function (e) { self.loaded(e); }, false);
var head = document.getElementsByTagName('head')[0];
head.appendChild(s);
}
}
// Funtion for adding event to some element
var collishop_addEvent = function (evnt, func) {
if (this.addEventListener) { // W3C DOM
this.addEventListener(evnt, func, false);
} else if (this.attachEvent) { // IE DOM
this.attachEvent("on" + evnt, func);
} else { // No much to do
this[evnt] = func;
}
};
function collishop_fireEvent(event) {
if (document.createEventObject) {
// dispatch for IE
var evt = document.createEventObject();
return this.collishop_fireEvent('on' + event, evt)
} else {
// dispatch for firefox + others
var evt = document.createEvent("HTMLEvents");
evt.initEvent(event, true, true); // event type,bubbling,cancelable
return !this.dispatchEvent(evt);
}
}
/*var l = new Collishop_Loader();
l.require([
"/wcsstore/ColruytB2CSFAS/javascript/libraries/jquery-1.11.0.min.js"],
function() {
// Callback
l.require(["/wcsstore/ColruytB2CSFAS/javascript/libraries/jquery.sliderPro.min.js"], function() {
collishop_fireEvent.call(document.getElementsByTagName('body')[0], 'slider-init');
});
});*/
var updateDepartmentsMenu,
activate,
ajaxRefresh = "",
//We need this function to be global for Header_UI.jspf to call it
setAjaxRefresh = function (refresh) {
ajaxRefresh = refresh;
};
$(document).ready(function () {
var mouseDownRegistered = false,
activeMenuNode = null,
toggleControlNode = null,
active = {},
ajaxRefresh = "",
departmentMenuId = "departmentMenu_",
registerMouseDown = function () {
if (!mouseDownRegistered) {
$(document.documentElement).on("mousedown.wc.header", handleMouseDown);
mouseDownRegistered = true;
}
},
unregisterMouseDown = function () {
if (mouseDownRegistered) {
$(document.documentElement).off("mousedown.wc.header");
mouseDownRegistered = false;
}
},
handleMouseDown = function (evt) {
var node = evt.target;
if (activeMenuNode !== null && node != document.documentElement) {
var close = true;
var parent = activeMenuNode.getAttribute("data-parent");
while (node && node != document.documentElement) {
if (node == activeMenuNode || node == toggleControlNode || $(node).hasClass("dijitPopup") || parent == node.getAttribute("data-parent")) {
close = false;
break;
}
node = node.parentNode;
}
if (node === null) {
var children = $("div", activeMenuNode);
for (var i = 0; i < children.length; i++) {
var position = Utils.position(children[i]);
if (evt.clientX >= position.x && evt.clientX < position.x + position.w &&
evt.clientY >= position.y && evt.clientY < position.y + position.h) {
close = false;
break;
}
}
}
if (close) {
deactivate(activeMenuNode);
}
}
},
deactivate = function (target) {
if (active[target.id]) {
deactivate(active[target.id]);
}
$(target).removeClass("active");
$("a[data-activate='" + target.id + "']").removeClass("selected");
$("a[data-toggle='" + target.id + "']").removeClass("selected");
var parent = target.getAttribute("data-parent");
delete active[parent];
if (target == activeMenuNode) {
activeMenuNode = null;
toggleControlNode = null;
unregisterMouseDown();
}
},
toggle = function (target) {
if ($(target).hasClass("active")) {
deactivate(target);
} else {
activate(target);
}
},
setUpEventActions = function () {
$(document).on("click", "a[data-activate]", function (e) {
var target = this.getAttribute("data-activate");
activate(document.getElementById(target));
Utils.stopEvent(e);
});
$(document).on("click", "a[data-deactivate]", function (e) {
var target = this.getAttribute("data-deactivate");
deactivate(document.getElementById(target));
Utils.stopEvent(e);
});
$(document).on("click", "a[data-toggle]", function (e) {
var target = this.getAttribute("data-toggle");
toggle(document.getElementById(target));
Utils.stopEvent(e);
});
$(document).on("keydown", "a[data-toggle]", function (e) {
var target;
if (e.keyCode === 27) {
target = this.getAttribute("data-toggle");
deactivate(document.getElementById(target));
Utils.stopEvent(e);
} else if (e.keyCode === 40) {
target = this.getAttribute("data-toggle");
var targetElem = document.getElementById(target);
activate(targetElem);
$('[class*="menuLink"]', targetElem)[0].focus();
Utils.stopEvent(e);
}
});
var ie_version = Utils.get_IE_version();
if (ie_version && ie_version < 10) {
$("input[placeholder]").each(function (i, input) {
var placeholder = input.getAttribute("placeholder");
if (placeholder) {
var label = document.createElement("label");
label.className = "placeholder";
label.innerHTML = placeholder;
input.parentNode.insertBefore(label, input);
var updatePlaceholder = function () {
label.style.display = (input.value ? "none" : "block");
};
window.setTimeout(updatePlaceholder, 200);
$(input).on("blur focus keyup", updatePlaceholder);
$(label).click(function (e) {
input.focus();
});
}
});
}
};
activate = function (target) {
var startsWith = (target.id.slice(0, departmentMenuId.length) == departmentMenuId);
if (ajaxRefresh == "true" && startsWith) {
setAjaxRefresh(""); // No more refresh till shopper leaves this page
// Update the Context, so that widget gets refreshed..
wcRenderContext.updateRenderContext("departmentSubMenuContext", {
"targetId": target.id
});
if (typeof cX === 'function') {
// For Coremetrics tagging to generate linkclick tags when clicking on navigation buttons
setTimeout(function () {
cX("");
}, 1000);
}
return;
}
/*if (startsWith) {
require(["dojo/dom-geometry"], function(domGeom){
var container = target.parentNode;
var containerPos = domGeom.position(container);
if (containerPos.x + target.clientWidth > window.innerWidth) {
$(container).addClass('jOpenLeft');
} else {
$(container).removeClass('jOpenLeft');
}
});
}*/
var parent = target.getAttribute("data-parent");
if (parent && active[parent]) {
deactivate(active[parent]);
}
if (parent) {
activate(document.getElementById(parent));
}
$(target).addClass("active");
$("a[data-activate='" + target.id + "']").addClass("selected");
var toggleControl = $("a[data-toggle='" + target.id + "']");
toggleControl.addClass("selected");
if (parent) {
active[parent] = target;
if (activeMenuNode === null) {
activeMenuNode = target;
toggleControlNode = toggleControl.length > 0 ? toggleControl[0] : null;
registerMouseDown();
}
}
};
setUpEventActions();
window.setTimeout(function () {
var cQuickLinks = $('#customQuickLinks');
var cQuickLinksContainer = $("#customQuickLinksItems");
var cQuickLinksHiddenContainer = $("#customQuickLinksHiddenContainer");
$("#customQuickLinksHiddenContainer .item").each(function (i, li) {
li = li.cloneNode(true);
$("[id]", li).each(function (j, node) {
node.id += "_alt";
});
cQuickLinksContainer.append(li);
});
$(".lnkQuickLinks a").click(function (e) {
cQuickLinks.toggleClass("jOpen");
Utils.stopEvent(e);
});
$("div.item.login.loggedIn h1 a").click(function (e) {
$("div.item.login.loggedIn").toggleClass("jOpen");
Utils.stopEvent(e);
});
var searchFilterButton = document.getElementById("searchFilterButton");
if (searchFilterButton) {
$(searchFilterButton).keydown(function (e) {
if (e.keyCode === 9 || (e.keyCode === 9 && e.shiftKey)) {
deactivate(document.getElementById(searchFilterButton.getAttribute("data-toggle")));
}
});
}
var searchForm = document.getElementById("SimpleSearchForm_SearchTerm");
if (searchForm) {
$(searchForm).click(function (e) {
$('.selected:not(a[data-toggle="searchBar"])', document.getElementById("header")).each(function (i, selectedDataToggle) {
deactivate(document.getElementById(selectedDataToggle.getAttribute("data-toggle")));
});
});
}
var searchFilterMenu = document.getElementById("searchFilterMenu");
if (searchFilterMenu) {
$('[class*="menuLink"]', searchFilterMenu).each(function (i, searchFilterMenuItems) {
$(searchFilterMenuItems).keydown(function (e) {
if (e.keyCode === 27) {
deactivate(searchFilterMenu);
Utils.stopEvent(e);
} else if (e.keyCode === 9 || (e.keyCode === 9 && e.shiftKey)) {
deactivate(searchFilterMenu);
} else if (e.keyCode === 38) {
searchFilterMenuItems[i === 0 ? searchFilterMenuItems.length - 1 : i - 1].focus();
Utils.stopEvent(e);
} else if (e.keyCode === 40) {
searchFilterMenuItems[(i + 1) % searchFilterMenuItems.length].focus();
Utils.stopEvent(e);
}
});
});
}
}, 100);
var header = document.getElementById("header"),
direction = Utils.getTextDirection(header),
//var direction = header ? domStyle.getComputedStyle(header).direction : 'ltr';
updateQuickLinksBar = function () {
var cQuickLinks = document.getElementById("customQuickLinks");
var cQuickLinksFooter = document.getElementById("customQuickLinksFooter");
if (cQuickLinks) {
var availableWidth = cQuickLinks.offsetWidth - cQuickLinksFooter.offsetWidth;
var cQuickLinksBarItems = $("#customQuickLinksItems .item");
var cQuickLinksBarHiddenItems = $("#customQuickLinksHiddenContainer .item");
if (window.innerWidth >= 768) {
var lastSet = false;
cQuickLinksBarItems.removeClass('jHide');
cQuickLinksBarHiddenItems.addClass('jHide');
for (var i = 0; i <= cQuickLinksBarItems.length - 1; i++) {
availableWidth -= cQuickLinksBarItems[i].offsetWidth;
$(cQuickLinksBarItems[i]).toggleClass("jHide", (availableWidth < 0));
$(cQuickLinksBarHiddenItems[i]).toggleClass("jHide", (availableWidth > 0));
}
$(cQuickLinks).toggleClass("jNoFlyout", (availableWidth >= 0));
} else {
cQuickLinksBarHiddenItems.removeClass("jHide");
$(cQuickLinks).toggleClass("jNoFlyout", false);
}
}
};
window.setTimeout(updateQuickLinksBar, 200);
$(window).resize(updateQuickLinksBar);
updateDepartmentsMenu = function () {
var departmentsMenu = document.getElementById("departmentsMenu");
var searchBar = document.getElementById("searchBar");
var departmentButtons = $(".departmentButton");
var departmentMenus = $(".departmentMenu");
var departmentsMenuItems = $("#departmentsMenu > li");
var allDepartmentsItem = departmentsMenuItems[departmentsMenuItems.length - 1];
var availableWidth = null;
if (departmentsMenu) {
// as search bar is not in the menu bar anymore, no need to use its width
if (searchBar && 1 == 0) {
availableWidth = (direction == "rtl" ? (departmentsMenu.offsetLeft + departmentsMenu.offsetWidth) - (searchBar.offsetLeft + searchBar.offsetWidth) : searchBar.offsetLeft - departmentsMenu.offsetLeft) - allDepartmentsItem.offsetWidth;
}
else {
availableWidth = departmentsMenu.offsetWidth - allDepartmentsItem.offsetWidth;
}
for (var i = 0; i < departmentsMenuItems.length - 1; i++) {
availableWidth -= departmentsMenuItems[i].offsetWidth;
$(departmentsMenuItems[i]).toggleClass("hidden", (availableWidth < 0));
}
departmentMenus.each(function (i, departmentMenu) {
$(departmentMenu).click(function (e) {
var target = this.getAttribute("data-toggle");
if (target !== null) {
toggle(document.getElementById(target));
Utils.stopEvent(e);
}
});
var departmentMenuItems = $('[class*="menuLink"]', departmentMenu);
departmentMenuItems.each(function (j, departmentMenuItem) {
$(departmentMenuItem).keydown(function (e) {
if (e.keyCode === 27) {
deactivate(document.getElementById(departmentMenu.getAttribute("id")));
Utils.stopEvent(e);
} else if (e.keyCode === 9 || (e.keyCode === 9 && e.shiftKey)) {
deactivate(document.getElementById(departmentMenu.getAttribute("id")));
} else if (e.keyCode === 38) {
departmentMenuItems[j === 0 ? departmentMenuItems.length - 1 : j - 1].focus();
Utils.stopEvent(e);
} else if (e.keyCode === 40) {
departmentMenuItems[(j + 1) % departmentMenuItems.length].focus();
Utils.stopEvent(e);
}
});
});
});
}
};
window.setTimeout(updateDepartmentsMenu, 200);
var ie_version = Utils.get_IE_version();
if (!ie_version || ie_version > 8) {
// Disabled in IE8 due to an IE8 bug causing the page to go partially black
$(window).resize(updateDepartmentsMenu);
}
if (document.getElementById("header")) {
fixHeaderOnScroll = function () {
var headerBlock = document.getElementById("header");
var body = $('body')[0];
//var thresholdHeight = parseInt(domStyle.getComputedStyle(headerBlock).height);
var thresholdHeight = 290;
if (window.pageYOffset > thresholdHeight) {
$(body).addClass('jFixedHeader');
} else {
$(body).removeClass('jFixedHeader');
window.setTimeout(updateDepartmentsMenu, 50);
}
};
window.setTimeout(fixHeaderOnScroll, 200);
$(window).scroll(fixHeaderOnScroll);
}
if (document.getElementById("espot-faq")) {
activeCurrentLink = function () {
var currentLocation = document.location.href;
$("#espot-faq ul a").each(function (i, thisLink) {
if (currentLocation.indexOf(thisLink.href) !== -1) {
$(thisLink).addClass('active');
$(thisLink.parentNode.parentNode.parentNode).addClass('openMenu');
}
});
}
window.setTimeout(activeCurrentLink, 200);
}
$("#searchFilterMenu > ul > li > a").click(function (e) {
document.getElementById("searchFilterButton").innerHTML = this.innerHTML;
document.getElementById("categoryId").value = this.getAttribute("data-value");
deactivate(document.getElementById("searchFilterMenu"));
});
$("#searchBox > .submitButton").click(function (e) {
var searchTerm = document.getElementById("SimpleSearchForm_SearchTerm");
searchTerm.value = $.trim(searchTerm.value);
var unquote = $.trim(searchTerm.value.replace(/'|"/g, ""));
/*if (searchTerm.value && unquote !== "") {
processAndSubmitForm(document.getElementById("searchBox"));
}*/
/*
* Start
* restrict 2 character search
* */
var stringval = searchTerm.value;
if (stringval.charAt(0) == '*') {
$('#searchAlertDropdown').css('display', 'block');
$("#psearchAlertDropdown").html(MessageHelper.messages["ASTERIK_ERR"]);
setTimeout(function () { $("#searchAlertDropdown").css('display', 'none'); }, 3000);
return false;
}
if (stringval.length <= 1 || (stringval.substr(stringval.length - 1) == '*') && stringval.length == 2) {
$('#searchAlertDropdown').css('display', 'block');
$("#psearchAlertDropdown").html(MessageHelper.messages["MIN_TWO_CHAR"]);
setTimeout(function () { $("#searchAlertDropdown").css('display', 'none'); }, 3000);
return false;
}
if (unquote != "" && stringval.length > 1 && stringval.charAt(0) != '*') {
document.getElementById("searchBox").submit();
}
/*
* End
* restrict 2 character search
* */
});
var searchBox = document.getElementById("searchBox");
if (searchBox) {
$(searchBox).submit(function (e) {
updateFormWithWcCommonRequestParameters(e.target);
var searchTerm = document.getElementById("SimpleSearchForm_SearchTerm");
var origTerm = searchTerm.value;
var unquote = $.trim(searchTerm.value.replace(/'|"/g, ""));
searchTerm.value = unquote;
if (stringval.charAt(0) == '*') {
$('#searchAlertDropdown').css('display', 'block');
$("#psearchAlertDropdown").html(MessageHelper.messages["ASTERIK_ERR"]);
setTimeout(function () { $("#searchAlertDropdown").css('display', 'none'); }, 3000);
Utils.stopEvent(e);
return false;
}
if (stringval.length <= 1 || (stringval.substr(stringval.length - 1) == '*') && stringval.length == 2) {
$('#searchAlertDropdown').css('display', 'block');
$("#psearchAlertDropdown").html(MessageHelper.messages["MIN_TWO_CHAR"]);
setTimeout(function () { $("#searchAlertDropdown").css('display', 'none'); }, 3000);
Utils.stopEvent(e);
return false;
}
if (!searchTerm.value) {
Utils.stopEvent(e);
return false;
}
searchTerm.value = $.trim(origTerm);
});
}
colruytJs.productDetailImageThumbs = {
orientation: 'vertical',
itemCount: 0,
itemDimension: 57,
visibleItemCount: 0,
scrollOffset: 0,
container: false,
ul: false,
page: 0,
init: function () {
this.container = $('.productImage > .widget_product_image_viewer .other_views');
if (this.container.length) {
this.ul = $('> ul', this.container[0]);
this.addNavigation();
this.resize();
this.bindClickEvents();
this.setScrollPos(0);
$(window).resize(function () {
//$.hitch(this, function(event){
colruytJs.productDetailImageThumbs.resize();
//});
});
// $('a').hitch('click', obj.handleClick, obj);
/*on(window, "resize", dojo.hitch(this, function (e) {
this.resize();
}));*/
}
},
reinit: function () {
this.container = $('.productImage > .widget_product_image_viewer .other_views');
if (this.container.length) {
this.addNavigation();
this.container = $('.productImage > .widget_product_image_viewer .other_views');
this.ul = $('> ul', this.container[0]);
this.setScrollPos(0);
}
},
addNavigation: function () {
// add carousel nav
//var container = domConstruct.toDom('
');
//domConstruct.place(container, $('.productImage > .widget_product_image_viewer .other_views')[0], 'last');
$('.productImage > .widget_product_image_viewer .other_views').first().append('');
this.navigation = $('.productImage > .widget_product_image_viewer .other_views > .paging');
},
bindClickEvents: function () {
colruytJs.productDetailImageThumbs.getVisibleItemCount();
// The below code is hide arrows for image thumbnails in PDP Full Image widget
if ((this.getScrollOffset() + this.scrollWidth) < this.getMaxScroll()) {
//
} else {
this.navigation.css('display', 'none');
}
$(document).on("click", ".productImage > .widget_product_image_viewer .other_views .paging a", function (e) {
Utils.stopEvent(e);
colruytJs.productDetailImageThumbs.getVisibleItemCount();
var oldOffset = colruytJs.productDetailImageThumbs.getScrollOffset();
if ($(e.target).hasClass("next")) {
// next
//console.log('page: ' + this.page + ' -- orientation: ' + this.orientation + ' -- offset: ' + this.getScrollOffset() + ' scroll width: ' + (this.getScrollOffset() + this.scrollWidth) + ' -- max: ' + this.getMaxScroll());
if ((colruytJs.productDetailImageThumbs.getScrollOffset() + this.scrollWidth) < colruytJs.productDetailImageThumbs.getMaxScroll()) {
colruytJs.productDetailImageThumbs.page += 1;
var newOffset = colruytJs.productDetailImageThumbs.page * (colruytJs.productDetailImageThumbs.itemDimension * colruytJs.productDetailImageThumbs.visibleItemCount);
//$( "#ProductAngleProdImagesAreaProdList" ).animate({ "scrollLeft": "-="+newOffset }, "slow" );
$('#ProductAngleProdImagesAreaProdList').animate({ scrollLeft: "+=" + newOffset }, "slow");
}
} else {
// previous
if (colruytJs.productDetailImageThumbs.page > 0) {
colruytJs.productDetailImageThumbs.page -= 1;
var newOffset = colruytJs.productDetailImageThumbs.page * (colruytJs.productDetailImageThumbs.itemDimension * colruytJs.productDetailImageThumbs.visibleItemCount);
if (newOffset < 0) newOffset = 0;
//$( "#ProductAngleProdImagesAreaProdList" ).animate({ "scrollLeft": "+="+newOffset }, "slow" );
$('#ProductAngleProdImagesAreaProdList').animate({ scrollLeft: "-=" + newOffset }, "slow");
}
}
//if (typeof newOffset != 'undefined')
//$('#ProductAngleProdImagesAreaProdList').animate( { scrollLeft: oldOffset }, newOffset, 'easeOutQuad' );
//$("#ProductAngleProdImagesAreaProdList").animate(oldOffset, newOffset);
});
},
resize: function () {
//console.log('resizing');
// determine the amount of items in the carousel
this.updateNav();
// reset carousel position
this.setScrollPos(0);
this.page = 0;
},
updateNav: function () {
// determine the amount of items in the carousel
/*this.getVisibleItemCount();
if (this.visibleItemCount >= this.itemCount) {
// hide nav
//this.navigation.style('display', 'none');
} else {
//this.navigation.style('display', 'block');
}*/
},
getOrientation: function () {
if (this.container[0].offsetWidth == 47) this.orientation = 'vertical';
else this.orientation = 'horizontal';
return this.orientation;
},
getVisibleItemCount: function () {
this.getOrientation();
var availableSpace, itemCount;
if (this.orientation == 'horizontal') {
availableSpace = this.ul[0].offsetWidth;
} else {
availableSpace = this.ul[0].offsetHeight;
}
this.scrollWidth = availableSpace;
this.visibleItemCount = Math.floor(availableSpace / 57);
return this.visibleItemCount;
},
getScrollOffset: function () {
if (this.orientation == 'horizontal') return this.ul[0].scrollLeft;
else return this.ul[0].scrollTop;
},
getMaxScroll: function () {
if (this.orientation == 'horizontal') return this.ul[0].scrollWidth;
else return this.ul[0].scrollHeight;
},
getChildren: function () {
return $('> li', this.ul[0]);
},
moveCarousel: function (start, end) {
var self = this;
/* this.animation = new baseFx.Animation({
duration: 600,
curve: [start, end],
easing: fxEasing.expoInOut,
onAnimate: function (pos) {
self.setScrollPos(pos);
},
onEnd: function () {
//self.updateNav();
}
}).play();*/
$("#ProductAngleProdImagesAreaProdList").animate({
width: "toggle"
}, {
duration: 600
});
},
setScrollPos: function (pos) {
if (this.orientation == 'horizontal') this.ul[0].scrollLeft = pos;
else this.ul[0].scrollTop = pos;
},
/**
* Checks if the slider is currently animating.
* @return {Boolean}
*/
isAnimationRunning: function () {
return (typeof this.animation !== 'undefined') && this.animation.status() === 'playing';
}
}
colruytJs.productDetailRefresh = function () {
if ($('.productDetail').length) {
$('.widget_Attributes_table .attribute:nth-child(2n+1)').addClass('jOdd');
$('.widget_Attributes_table .attribute:nth-child(2n+2)').addClass('jEven');
if ($('.widget_Attributes_table').length) {
$('.specificationsAnchor').css('display', 'block');
$('.widget_Attributes_table').first().attr('id', 'specifications');
$(".specificationsAnchor .lnkSpecifications a").click(function (e) {
Utils.stopEvent(e);
var specs = $('#specifications')[0];
var pos = Utils.position(specs);
pos.y = pos.y + 40;
//win.scrollIntoView(specs, pos);
});
$('.widget_Attributes_table').each(function (i, attributeTable) {
$(attributeTable).addClass('jClosed');
var childClass = '.main';
if (!!jQuery("._jGroup").length) {
childClass = '._jGroup .main';
}
var containers = $('> ' + childClass + ' .attributeWrapper', attributeTable);
containers.each(function (j, attributeWrapper) {
if ($(attributeWrapper).children("li").length > 15) {
if ($('> ' + childClass + ' > .lnkMore', attributeTable).length == 0) {
//var showMore = domConstruct.place('', attributeWrapper, 'after');
var showMore = $(attributeWrapper).after('');
$('#Attributes_table .lnkMore a').on('click', function (e) {
$(attributeTable).toggleClass('jClosed');
//if (domClass.contains(attributeTable, "jClosed")) {
if ($(attributeTable).hasClass('jClosed')) {
$(this).prop("text", attributeTable.getAttribute('data-more'));
} else {
$(this).prop("text", attributeTable.getAttribute('data-less'));
}
Utils.stopEvent(e);
});
}
$('.attribute:nth-child(n+16)', attributeWrapper).addClass('jExtraAttribute');
}
});
$('.attribute > .moreInfo', attributeTable).each(function (i, attributeMoreInfo) {
var container = $(attributeMoreInfo).closest('.attribute');
container.addClass('jClosed');
if ($(attributeMoreInfo).html() != '') {
container.addClass('hasInfo');
if ($('> .values > .lnkInfo', container[0]).length == 0) {
var values = $('> .values', container[0]);
var showInfo = $(values[0]).first().append('');
//var showInfo = domConstruct.place('', values[0], 'last');
$('.lnkInfo a').on('click', function (e) {
container.toggleClass('jClosed');
Utils.stopEvent(e);
});
}
}
});
});
}
$('.componentProduct').addClass('jClosed');
$('.componentProduct').each(function (i, componentProduct) {
if (componentProducts.indexOf(componentProduct) === -1) {
var componentProductHeader = $("> h3", componentProduct);
$(componentProductHeader).click(function (e) {
$(this.parentNode).toggleClass('jClosed');
});
componentProducts.push(componentProduct);
}
});
colruytJs.productDetailImageThumbs.reinit();
}
};
colruytJs.productDetailRefresh();
// image overlay
/*require(["dijit/Dialog", "dojo/domReady!"], function(Dialog){
pdpImageDialog = new Dialog({
title: "",
content: ""
});
dojo.$(".productDetail").delegate('.widget_product_image_viewer #productMainImage', "onclick", function(e) {
event.stop(e);
pdpImageDialog.show();
});
});*/
String.prototype.replaceAll = String.prototype.replaceAll || function (search, replace) {
if (replace === undefined) {
return this.toString();
}
return this.split(search).join(replace);
}
if ($('.productDetail').length) {
$(document).ready(function () {
//append the html for the overlay
var productDetailZoom = {
index: 0,
otherViewCount: 0,
init: function () {
//var pdpContainer = domConstruct.toDom('');
//domConstruct.place(pdpContainer, $('body')[0], 'last');
$('body').first().append('');
productDetailZoom.container = $('#pdpImageOverlay');
productDetailZoom.bindEvents();
},
updateImage: function (imagePath) {
$('> .wrap img', $('#pdpImageOverlay')[0]).first().attr('src', imagePath);
$('> .wrap > .main', $('#pdpImageOverlay')[0]).css('background-image', 'url("' + imagePath + '")');
},
updateState: function (state) {
if (state) {
$('#pdpImageOverlay').first().css("opacity", "1");
$('#pdpImageOverlay').addClass('jShow');
var fadeArgs = {
node: $('#pdpImageOverlay').first(),
duration: 200,
};
//dojo.fadeIn(fadeArgs).play();
$('#pdpImageOverlay').first().fadeIn(200);
} else {
var fadeArgs = {
node: "pdpImageOverlay",
duration: 200,
onEnd: function () {
$('#pdpImageOverlay').removeClass('jShow');
}
};
//dojo.fadeOut(fadeArgs).play();
//fadeArgs.fadeOut("play");
$('#pdpImageOverlay').fadeOut('200', function () {
$('#pdpImageOverlay').removeClass('jShow');
});
}
},
bindEvents: function () {
$('#pdpImageOverlay .mask, #pdpImageOverlay').on('click', function (e) {
//$.hitch(this, function(e) {
Utils.stopEvent(e);
productDetailZoom.updateState(false);
//})
});
$(".productDetail").on('click', '.widget_product_image_viewer > .content > .image_container', function (e) {
//$.hitch(this, function(e) {
var imagePath = $(".widget_product_image_viewer #productMainImage").first().attr("src");
if (imagePath) {
productDetailZoom.updateImage(imagePath);
// check if other views are available and determine the active item index
productDetailZoom.otherViewCount = $('.productImage > .widget_product_image_viewer #ProductAngleImagesArea ul li').length;
if (productDetailZoom.otherViewCount == 0) {
productDetailZoom.otherViewCount = $('.productImage > .widget_product_image_viewer #ProductAngleProdImagesArea ul li').length;
}
if (productDetailZoom.otherViewCount) {
$('#pdpImageOverlay').addClass('jShowNav');
var activeItem = $('.productImage > .widget_product_image_viewer .other_views ul li.selected');
productDetailZoom.index = $('.productImage > .widget_product_image_viewer .other_views ul li').index(activeItem[0]);
if (productDetailZoom.index < 0) productDetailZoom.index = 0;
} else {
$('#pdpImageOverlay').removeClass('jShowNav');
}
productDetailZoom.updateState(true);
}
//})
});
$('.paging a').on('click', function (e) {
//$.hitch(this, function(e) {
Utils.stopEvent(e);
if ($(e.target).hasClass('next')) {
productDetailZoom.index += 1;
if (productDetailZoom.index >= productDetailZoom.otherViewCount) productDetailZoom.index = 0;
} else {
productDetailZoom.index -= 1;
if (productDetailZoom.index < 0) productDetailZoom.index = productDetailZoom.otherViewCount - 1;
}
var nextItem = $('.productImage > .widget_product_image_viewer .other_views ul li')[productDetailZoom.index];
var nextItemHref = $('> a', nextItem).first().attr('href');
var nextItemHrefArray = nextItemHref.split(',');
var newPath = nextItemHrefArray[1];
newPath = newPath.replaceAll(',', '').replaceAll("'", '').replaceAll(')', '').replaceAll(';', '');
productDetailZoom.updateImage(newPath);
//})
});
$('body').on('keydown', function (e) {
//$.hitch(this, function(e) {
if (e.keyCode && e.keyCode == 27) {
if ($('#pdpImageOverlay')[0].hasClass('jShow')) {
this.updateState(false);
} else return;
}
else return;
//})
});
}
};
productDetailZoom.init();
colruytJs.productDetailImageThumbs.init();
});
}
$('body').on("onclick", ".flyoutContainer > header > div > a", function (e) {
Utils.stopEvent(e);
var container = $(this).closest('.flyoutContainer');
if ($(container[0]).hasClass("jShow")) {
// hide other flyouts first
$('.flyoutContainer').removeClass('jShow');
}
$(container).toggleClass('jShow');
});
$('body').on("onclick", ".flyoutContainer .lnkClose a, .flyoutContainer .lnkCancel a", function (e) {
Utils.stopEvent(e);
var container = $(this).closest('.flyoutContainer');
$(container).removeClass('jShow');
});
// split decision
$(".splitDeliveryDecision .lnkSplit a").click(function (e) {
Utils.stopEvent(e);
$('.flyoutContainer').removeClass('jShow');
var container = $('.splitDeliveryDecision > .splitShoppingCart');
$(container).toggleClass('jShow');
});
$(".splitDeliveryDecision > .splitShoppingCart > header .lnkClose a").click(function (e) {
Utils.stopEvent(e);
$('.flyoutContainer').removeClass('jShow');
var container = $('.splitDeliveryDecision > .splitShoppingCart');
$(container).toggleClass('jShow');
});
$('body').on("onclick", ".infoBubble a", function (e) {
Utils.stopEvent(e);
});
// subordinates
function checkSubordinate(parent, checkbox) {
// disable all items
$('> .subordinates > *', parent).css('display', 'none');
if ($(checkbox).attr('data-target')) {
var targetElement = $('#' + $(checkbox).attr('data-target'));
if (checkbox.checked) {
$(targetElement).css('display', 'block');
}
}
}
$(".spec.radio.withSubordinates, .spec.checkbox.withSubordinates").each(function (i, subordinateRadio) {
$('> .value input', subordinateRadio).forEach(function (i, checkbox) {
if ($(checkbox).checked) checkSubordinate(subordinateRadio, checkbox);
$(checkbox).on('change', function (e) {
checkSubordinate(subordinateRadio, this);
});
});
});
if (typeof shoppingActionsJS != 'undefined') {
shoppingActionsJS.showWCDialogPopup = function (widgetId) {
//var popup = dijit.byId(widgetId); //Change the id of the popup div if it is changed in the html
var popup = $("#" + widgetId).data("wc-WCDialog");
if (widgetId == 'lang_selection_popup') {
var body = $('body').get(0);
$(body).addClass('langSelectionPopUp');
//domClass.add(body,'langSelectionPopUp');
}
if (widgetId == 'facetNavNF') {
var body = $('body').get(0);
$(body).addClass('facetNavNF');
//domClass.add(body,'facetNavNF');
if ($('#facet_nav_collapsible'))
$('#facet_nav_collapsible').attr("aria-expanded", "true");
}
if (widgetId == 'topnav_mobile_popup') {
var body = $('body').get(0);
$(body).addClass('topNavMobilePopup');
//domClass.add(body,'topNavMobilePopup');
$('#headerWrapperMobile').css('display', 'block');
$('#subcategory').css('display', 'none');
}
if (widgetId == 'offlineStockPopup') {
var body = $('body').get(0);
$(body).addClass('offStk');
jQuery('div[aria-describedby="offlineStockPopup"]').on("click", function (e) {
if (e.target !== this) {
return;
}
var body = $('body').get(0);
$(body).removeClass('offStk');
var dialogWidget = $("#offlineStockPopup").data("wc-WCDialog");
dialogWidget.close();
});
}
if (widgetId == 'clickAndCollectPopup') {
var body = $('body').get(0);
$(body).addClass('offStk');
jQuery('div[aria-describedby="clickAndCollectPopup"]').on("click", function (e) {
if (e.target !== this) {
return;
}
var body = $('body').get(0);
$(body).removeClass('offStk');
var dialogWidget = $("#clickAndCollectPopup").data("wc-WCDialog");
dialogWidget.close();
});
}
if (popup != null) {
//popup.closeButtonNode.style.display='none';
if (widgetId == 'missing_fields_popup') popup._onKey = function () { };
popup.open();
}
else {
console.debug(widgetId + " does not exist");
}
};
}
var ie_version = Utils.get_IE_version();
/*if (ie_version < 9 || has("safari") < 10) {*/
if (ie_version < 9) {
var searchHistoryCookie = sessionStorage.getItem('unsupportedBrowserClosed');
if (searchHistoryCookie == null) { // Check if user already closed the popup in this session
var popup = $("#unsupportedBrowserPopup").data("wc-WCDialog");
if (typeof popup === 'undefined') {
//dojo.parser.parse($('unsupportedBrowserPopup').parentNode);
WCWidgetParser.parse($('unsupportedBrowserPopup').parentNode);
WCWidgetParser.parseRefreshArea($('unsupportedBrowserPopup').parentNode);
}
popup.open();
jQuery("#unsupportedBrowserPopup").find(".dijitDialogPaneContent").append("");
jQuery("._closeUnsupportedBrowserPopup").on("click", function () {
popup.close();
sessionStorage.setItem('unsupportedBrowserClosed', true);
});
}
}
jQuery.fn.extend({
_setColumnCountAttr: function (columnCount) {
var items = $(this.ul).children("li");
items.width(100 / columnCount + "%");
this._set("columnCount", columnCount);
},
endScroll: function (delay) { // End Scroll is overridden to enablel lazy load on scroll
window.scrollBy(0, 2);
if (this.endScrollTimeout) {
window.clearTimeout(this.endScrollTimeout);
}
if (delay) {
this.set("endScrollTimeout", window.setTimeout(lang.hitch(this, "endScroll"), delay));
}
else {
$(this.ul).children("li").each(function (e) {
//$.hitch(this, function(i, item) {
$(item).toggleClass("hidden", (i < this.pageIndex * this.columnCount || i >= (this.pageIndex + 1) * this.columnCount));
//domClass.toggle(item, "hidden", (i < this.pageIndex * this.columnCount || i >= (this.pageIndex + 1) * this.columnCount));
//})
});
}
window.scrollBy(0, -2);
},
_onMouseClick: function (evt) {
var node = evt.target;
var close = true;
if (this.id == 'lang_selection_popup' || this.id == 'facetNavNF' || this.id == 'topnav_mobile_popup') {
close = false;
}
if (node.nodeName.toLowerCase() != 'html') {
while (node) {
if (node == this.domNode) {
close = false;
this.autoClose = false;
}
node = node.parentNode;
}
if (close) {
if (this.id == 'offlineStockPopup') {
var body = $('body')[0];
$(body).removeClass('offStk');
}
this.hide();
}
else {
this.cancelCloseOnTimeOut();
}
}
}
});
$('._pPassword').keyup(function (e) {
var e = $(this).val();
var n = 0;
var t = new Array;
t[0] = MessageHelper.messages["WEAK"];
t[1] = MessageHelper.messages["WEAK"];
t[2] = MessageHelper.messages["MEDIUM"];
t[3] = MessageHelper.messages["STRONG"];
if (e.length == 0) {
$("#letter,#length,#symbol,#number").removeClass("valid").addClass("invalid");
document.getElementById("passwordCheck").innerHTML = "Password strength";
document.getElementById("passwordStrength").className = "";
} else {
if (e.length < 6) {
$("#length").removeClass("valid").addClass("invalid");
} else {
$("#length").removeClass("invalid").addClass("valid");
n++;
} if (e.match(/[!,@,#,$,%,^,&,*,?,_,~,-,(,),(.),<,>,('),("),(:),(;),([),(\]),({),(}),(|),(//),(\\)]/)) {
$("#symbol").removeClass("invalid").addClass("valid");
n++;
} else {
$("#symbol").removeClass("valid").addClass("invalid");
} if (e.match(/\d/)) {
$("#number").removeClass("invalid").addClass("valid");
n++;
} else {
$("#number").removeClass("valid").addClass("invalid");
} if (e.match(/[A-Za-z]/)) {
$("#letter").removeClass("invalid").addClass("valid");
}
document.getElementById("passwordCheck").innerHTML = t[n];
document.getElementById("passwordStrength").className = "strength" + n;
}
}).focus(function (e) { $('#passwordInfo').css("display", "block"); }).blur(function (e) { $('#passwordInfo').css("display", "none"); });
var categoryFilters = {
init: function () {
if (window.matchMedia) {
var mediaQuery = window.matchMedia("(max-width: 600px)");
mediaQuery.addListener(this.updateStates);
this.updateStates(mediaQuery);
}
else {
this.updateStates();
$(window).resize(function () {
//$.hitch(this, function(event){
this.updateStates();
//});
});
/*on(window, "resize", dojo.hitch(this, function(event) {
this.updateStates();
}));*/
}
},
updateStates: function (mediaQuery) {
var expanded = mediaQuery ? !mediaQuery.matches : document.documentElement.clientWidth > 583;
$('.optionContainer').each(function (i, item) {
var icon = $('> .title .arrow', item);
var section_list = $('> .facetSelectContainer', item);
if (expanded) {
$(icon[0]).attr('class', 'arrow');
$(section_list[0]).attr('aria-expanded', 'true');
$(section_list[0]).css('display', 'block');
} else {
$(icon[0]).attr('class', 'arrow arrow_collapsed');
$(section_list[0]).attr('aria-expanded', 'false');
$(section_list[0]).css('display', 'none');
}
});
}
}
categoryFilters.init();
});
/*
** Lazy load images in flyout menu
*/
if (window.NodeList && !NodeList.prototype.forEach) {
NodeList.prototype.forEach = Array.prototype.forEach;
}
/*
document.addEventListener("DOMContentLoaded", function() {
var lazyloadImages = document.querySelectorAll(".lazy");
console.log("lazyLoadImages", lazyloadImages);
if (lazyloadImages.length) {
if ("IntersectionObserver" in window) {
var imageObserver = new IntersectionObserver(function(entries, observer) {
entries.forEach(function(entry) {
if (entry.isIntersecting) {
var image = entry.target;
image.src = image.dataset.src;
image.classList.remove("lazy");
imageObserver.unobserve(image);
}
});
});
lazyloadImages.forEach(function(image) {
imageObserver.observe(image);
});
} else {
var lazyloadThrottleTimeout;
function lazyload () {
if(lazyloadThrottleTimeout) {
clearTimeout(lazyloadThrottleTimeout);
}
lazyloadThrottleTimeout = setTimeout(function() {
var scrollTop = window.pageYOffset;
lazyloadImages.forEach(function(img) {
if(img.offsetTop < (window.innerHeight + scrollTop)) {
img.src = img.dataset.src;
img.classList.remove('lazy');
}
});
if(lazyloadImages.length == 0) {
document.removeEventListener("scroll", lazyload);
window.removeEventListener("resize", lazyload);
window.removeEventListener("orientationChange", lazyload);
}
}, 20);
}
document.addEventListener("scroll", lazyload);
window.addEventListener("resize", lazyload);
window.addEventListener("orientationChange", lazyload);
}
}
});
*/
function declareDeptDropdownRefreshArea(divId) {
// ============================================
// div: drop_down_${department.uniqueID} refresh area
// Context and Controller to refresh department drop-down
// common render context
wcRenderContext.declare("departmentSubMenuContext", [divId], { targetId: "" });
// render content changed handler
var renderContextChangedHandler = function () {
$("#" + divId).refreshWidget("refresh", wcRenderContext.getRenderContextProperties("departmentSubMenuContext"));
};
// post refresh handler
var postRefreshHandler = function () {
updateDepartmentsMenu(); // Browser may be re-sized. From server we return entire department list.. updateHeader to fit to the list within available size
activate(document.getElementById(wcRenderContext.getRenderContextProperties("departmentSubMenuContext").targetId)); // We have all the data.. Activate the menu...
cursor_clear();
};
// initialize widget
$("#" + divId).refreshWidget({ renderContextChangedHandler: renderContextChangedHandler, postRefreshHandler: postRefreshHandler });
}
(function ($) {
$.fn.hitch = function (ev, fn, scope) {
return this.bind(ev, function () {
return fn.apply(scope || this, Array.prototype.slice.call(arguments));
});
};
})(jQuery);