(function(f) {var _np=(window.P._namespace("PremiumAplusModule"));if(_np.guardFatal){_np.guardFatal(f)(_np);}else{f(_np);}}(function(P) {
P.now('premium-module-5-comparison-table-scroller').execute(function(init){
if (init) {
return;
}
P.register('premium-module-5-comparison-table-scroller', function(){
return function() {
P.when('jQuery', 'a-popover', 'A', 'ready').execute(function($, popover, A) {
function initCompTable(module) {
/**
* Premium comparison table: popover trigger module
*/
var comparisonName = $(module).data('comparison-name');
(function() {
var $additionalInfo = $('.aplus-v2 .aplus-popover-trigger');
$additionalInfo.each(function(i, trigger) {
return popover.create(trigger, $(trigger).data());
});
$additionalInfo.hover(
function() {
$(this).focus();
}
);
})();
/**
* Premium comparison table: adjust column width module
*/
(function() {
var VISIBLE_COLUMNS = 4.2; /* How many visible columns on load */
var MIN_WIDTH = 230;
var getWidth = function() {
return $(this).outerWidth();
}
/* cache selectors */
var
$container = $('.aplus-v2 .comparison-table #'+comparisonName),
$header = $('.aplus-v2 .comparison-table #'+comparisonName+' td.attribute'),
$slider = $('.aplus-v2 .comparison-table #'+comparisonName+' .table-slider'),
$columns = $('.aplus-v2 .comparison-table #'+comparisonName+' .aplus-data-column'),
$activeColumn = $('.aplus-v2 .comparison-table #'+comparisonName+' .aplus-data-column.active.active-item');
/* Formula for determining desired column width */
var calculatedColumnWidth = Math.floor(
($container.innerWidth() - $header.innerWidth()) / VISIBLE_COLUMNS
);
var childWidths = $activeColumn.map(getWidth).get();
var maxChildWidth = Math.max(MIN_WIDTH, Math.max.apply(Math, childWidths));
var minColumnWidth = $columns.innerWidth();
/* set the min-width of each column to the calulated width or minWidth */
$columns.css(
'min-width',
Math.max(MIN_WIDTH, (calculatedColumnWidth < minColumnWidth
? calculatedColumnWidth
: minColumnWidth))
);
$activeColumn.css('width', maxChildWidth);
/* show the component */
$container.removeClass('loading');
})();
/**
* Premium comparison table: sticky attribute & column
*/
(function() {
/* cache selectors */
const comparisonTable = document.querySelector('.aplus-v2 .comparison-table #'+comparisonName);
const header = comparisonTable.querySelector('td.attribute');
const fixedColumn = comparisonTable.querySelector('td.active');
const attributeColumnObserver = new ResizeObserver((entries) => {
for (let entry of entries) {
const bounds = entry.target.getBoundingClientRect().width;
const activeCellWidth = window.getComputedStyle(fixedColumn).left;
if (bounds + "px" !== activeCellWidth) {
const activeCells = document.querySelectorAll('.aplus-data-column.active');
activeCells.forEach(cell => cell.style.left = bounds + "px");
}
}
})
attributeColumnObserver.observe(header)
})();
/**
* Premium comparison table: top scroll bar
*/
(function() {
/* cache selectors */
var
$header = $('.aplus-v2 .comparison-table #'+comparisonName+' td.attribute'),
$fixedColumn = $('.aplus-v2 .comparison-table #'+comparisonName+' td.active'),
$scrollWrapperTop = $('.aplus-v2 .comparison-table #'+comparisonName+' .scroll-wrapper-top'),
$scrollWrapperBottom = $('.aplus-v2 .comparison-table #'+comparisonName+' .scroll-wrapper-bottom'),
$scrollWidth = $('.aplus-v2 .comparison-table #'+comparisonName+' .scroll-width'),
$scrollBar = $('.aplus-v2 .comparison-table #'+comparisonName+' .scroll-bar');
/* confirm fixed column exists and can add width to the total width of the scroll bar */
var fixedColumnWidth = $fixedColumn.innerWidth();
if ( fixedColumnWidth === null ) {
fixedColumnWidth = 0;
}
/* set width of scrollBar */
$scrollBar.css('width', $scrollWidth.innerWidth() + fixedColumnWidth + $header.innerWidth());
/* connect scrolls together */
$scrollWrapperTop.scroll(function() {
$scrollWrapperBottom.scrollLeft($scrollWrapperTop.scrollLeft());
});
$scrollWrapperBottom.scroll(function() {
$scrollWrapperTop.scrollLeft($scrollWrapperBottom.scrollLeft());
});
})();
}
$('.aplus-v2 .premium-aplus-module-5 .table-container').each(function(index, module) {
initCompTable(module);
});
});
}
});
});
}));
(function(f) {var _np=(window.P._namespace("PremiumAplusModule"));if(_np.guardFatal){_np.guardFatal(f)(_np);}else{f(_np);}}(function(P) {
P.now('premium-module-12-nav-carousel').execute(function(init) {
if (init) {
return;
}
P.register('premium-module-12-nav-carousel', function(){
return function() {
P.when('A', 'jQuery', 'a-carousel-framework', 'ready').execute(function (A, $, framework) {
function initiateCarousel(module) {
var MODULE_ID = $(module).data('module-id');
/**
* Carousel button element classname
* @const
*/
var GOTO_BTN_CLASS_NAME = "aplus-goto-btn-" + MODULE_ID;
/**
* Carousel button element active classname
* @const
*/
var GOTO_BTN_ACTIVE_CLASS_NAME = "aplus-active";
/**
* AUI name for aui carousel
* @const
*/
var CAROUSEL_NAME = "premium-aplus-12-carousel-" + MODULE_ID;
/**
* Module class name
* @const
*/
var MODULE_CLASS_NAME = ".aplus-v2 .premium-aplus-module-12";
/**
* Carousel text container class name
* @const
*/
var TEXT_CONTAINER_CLASS_NAME = MODULE_CLASS_NAME + " .aplus-carousel-text-container-" + MODULE_ID;
/**
* Carousel text hidden class name
* @const
*/
var TEXT_CONTAINER_HIDDEN = "aplus-hidden";
/**
* Carousel horizontal scroll container class name
* @const
*/
var HORIZONTAL_SCROLL_CONTAINER_CLASS_NAME = MODULE_CLASS_NAME + " .aplus-horizontal-scroll-container-" + MODULE_ID;
function showCarouselText(oldIndex, newIndex) {
var oldClass = TEXT_CONTAINER_CLASS_NAME + "-" + oldIndex;
var newClass= TEXT_CONTAINER_CLASS_NAME + "-" + newIndex;
$(oldClass).addClass(TEXT_CONTAINER_HIDDEN);
$(newClass).removeClass(TEXT_CONTAINER_HIDDEN);
}
function scrollToCarouselButton(scrollLeft) {
if ($(HORIZONTAL_SCROLL_CONTAINER_CLASS_NAME).length) {
$(HORIZONTAL_SCROLL_CONTAINER_CLASS_NAME).animate({scrollLeft}, 200);
}
}
/**
* Creates a CarouselButton class for provided carousel instance
* @param {object} carousel - AUI Carousel instance
* @returns {Class} - CarouselButton Class
*/
function CarouselButtonTemplate(carousel) {
/**
* Button for controlling the active slide
* @constructor
* @param {number} index - slide index
* @param {DOMElement} [elem] - optional DOM element to use as this objects DOM representation
*/
function CarouselButton(index, elem) {
var self = this;
this.index = index;
this.carousel = carousel;
/* create the button element */
this.elem = this.getElem(elem);
this.$elem = $(this.elem); /* store jquery version */
this.elem.addEventListener('click', self.handleClick.bind(self));
this.elem.setAttribute('role', 'tab');
/* add this object to the object manager */
CarouselButton.objects.byId[index] = this;
CarouselButton.objects.all.push(this);
}
/**
* Describe behavior for click events on this.elem
* @memberOf CarouselButton
*/
CarouselButton.prototype.handleClick = function(e) {
e.preventDefault();
this.carousel.gotoPage(this.index);
};
/**
* Enter active state
* @memberOf CarouselButton
*/
CarouselButton.prototype.activate = function() {
this.$elem.addClass(GOTO_BTN_ACTIVE_CLASS_NAME).attr('aria-selected', 'true');
};
/**
* Enter inactive state
* @memberOf CarouselButton
*/
CarouselButton.prototype.deactivate = function() {
this.$elem.removeClass(GOTO_BTN_ACTIVE_CLASS_NAME).attr('aria-selected', 'false');
};
/**
* Returns an existing or creates a new bound element for this object
* @memberOf CarouselButton
* @param {DOMElement} [elem] - optionally provide an existing element in the DOM to use
* @returns {DOMElement} - this objects DOM representation
*/
CarouselButton.prototype.getElem = function(elem) {
if (this.elem) return this.elem;
if (elem) return elem;
var createdElem = document.createElement('span');
createdElem.className = GOTO_BTN_CLASS_NAME;
return createdElem;
};
/** @const Object manager */
CarouselButton.objects = {
byId: {},
all: [],
};
return CarouselButton;
}
framework.onInit(CAROUSEL_NAME, function(carousel) {
/** @const {Class} */
var CarouselButton = CarouselButtonTemplate(carousel);
/* create carousel controls */
var $carouselBtns = $(safeClassSelector(GOTO_BTN_CLASS_NAME));
var btns = $carouselBtns.map(function(i, btnElem) {
return new CarouselButton(i + 1, btnElem);
});
/* activate first one */
CarouselButton.objects.byId[1].activate();
/* Listen to slide changes */
A.on("a:carousel:" + CAROUSEL_NAME + ":change:pageNumber", function (data) {
var newCarouselButton = CarouselButton.objects.byId[data.newValue];
var marginLeft = parseInt(getComputedStyle(newCarouselButton.elem).getPropertyValue('margin-left'));
var positionLeft = newCarouselButton.elem.offsetLeft - marginLeft;
newCarouselButton.activate();
CarouselButton.objects.byId[data.oldValue].deactivate();
scrollToCarouselButton(positionLeft);
showCarouselText(data.oldValue, data.newValue);
});
});
/**
* @returns {string} - css classname prefixed with module selector
*/
function safeClassSelector(className) {
return '.' + MODULE_CLASS_NAME + ' .' + className;
}
}
$('.aplus-v2 .premium-aplus-module-12 .aplus-carousel-container').each(function (index, module) {
initiateCarousel(module);
});
framework.createAll();
framework.initializeAll();
});
}
})
});
}));