; /* Start:"a:4:{s:4:"full";s:99:"/local/templates/moleculab/components/bitrix/catalog.section/main_sec2/script.min.js?17140287275657";s:6:"source";s:80:"/local/templates/moleculab/components/bitrix/catalog.section/main_sec2/script.js";s:3:"min";s:84:"/local/templates/moleculab/components/bitrix/catalog.section/main_sec2/script.min.js";s:3:"map";s:84:"/local/templates/moleculab/components/bitrix/catalog.section/main_sec2/script.map.js";}"*/ (function(){"use strict";if(!!window.JCCatalogSectionComponent)return;window.JCCatalogSectionComponent=function(t){this.formPosting=false;this.siteId=t.siteId||"";this.ajaxId=t.ajaxId||"";this.template=t.template||"";this.componentPath=t.componentPath||"";this.parameters=t.parameters||"";if(t.navParams){this.navParams={NavNum:t.navParams.NavNum||1,NavPageNomer:parseInt(t.navParams.NavPageNomer)||1,NavPageCount:parseInt(t.navParams.NavPageCount)||1}}this.bigData=t.bigData||{enabled:false};this.container=document.querySelector('[data-entity="'+t.container+'"]');this.lazyLoadContainer=document.querySelector('[data-entity="lazy-'+t.container+'"]');this.showMoreButton=null;this.showMoreButtonMessage=null;if(this.bigData.enabled&&BX.util.object_keys(this.bigData.rows).length>0){BX.cookie_prefix=this.bigData.js.cookiePrefix||"";BX.cookie_domain=this.bigData.js.cookieDomain||"";BX.current_server_time=this.bigData.js.serverTime;BX.ready(BX.delegate(this.bigDataLoad,this))}if(t.initiallyShowHeader){BX.ready(BX.delegate(this.showHeader,this))}if(t.deferredLoad){BX.ready(BX.delegate(this.deferredLoad,this))}if(t.lazyLoad){this.showMoreButton=document.querySelector('[data-use="show-more-'+this.navParams.NavNum+'"]');this.showMoreButtonMessage=this.showMoreButton.innerHTML;BX.bind(this.showMoreButton,"click",BX.proxy(this.showMore,this))}if(t.loadOnScroll){BX.bind(window,"scroll",BX.proxy(this.loadOnScroll,this))}};window.JCCatalogSectionComponent.prototype={checkButton:function(){if(this.showMoreButton){if(this.navParams.NavPageNomer==this.navParams.NavPageCount){BX.remove(this.showMoreButton)}else{this.lazyLoadContainer.appendChild(this.showMoreButton)}}},enableButton:function(){if(this.showMoreButton){BX.removeClass(this.showMoreButton,"disabled");this.showMoreButton.innerHTML=this.showMoreButtonMessage}},disableButton:function(){if(this.showMoreButton){BX.addClass(this.showMoreButton,"disabled");this.showMoreButton.innerHTML=BX.message("BTN_MESSAGE_LAZY_LOAD_WAITER")}},loadOnScroll:function(){var t=BX.GetWindowScrollPos().scrollTop,e=BX.pos(this.container).bottom;if(t+window.innerHeight>e){this.showMore()}},showMore:function(){if(this.navParams.NavPageNomer 1 && this.obPictSlider) { this.initializeSlider(); } this.checkQuantityControls(); break; case 3: // sku if (this.offers.length > 0 && this.obTree) { treeItems = BX.findChildren(this.obTree, {tagName: 'li'}, true); if (treeItems && treeItems.length) { for (i = 0; i < treeItems.length; i++) { BX.bind(treeItems[i], 'click', BX.delegate(this.selectOfferProp, this)); } } this.setCurrent(); } else if (parseInt(this.product.morePhotoCount) > 1 && this.obPictSlider) { this.initializeSlider(); } break; } if (this.obBuyBtn) { if (this.basketAction === 'ADD') { BX.bind(this.obBuyBtn, 'click', BX.proxy(this.add2Basket, this)); } else { BX.bind(this.obBuyBtn, 'click', BX.proxy(this.buyBasket, this)); } } if (this.useCompare) { this.obCompare = BX(this.visual.COMPARE_LINK_ID); if (this.obCompare) { BX.bind(this.obCompare, 'click', BX.proxy(this.compare, this)); } BX.addCustomEvent('onCatalogDeleteCompare', BX.proxy(this.checkDeletedCompare, this)); } } }, setAnalyticsDataLayer: function(action) { if (!this.useEnhancedEcommerce || !this.dataLayerName) return; var item = {}, info = {}, variants = [], i, k, j, propId, skuId, propValues; switch (this.productType) { case 0: //no catalog case 1: //product case 2: //set case 7: // service item = { 'id': this.product.id, 'name': this.product.name, 'price': this.currentPrices[this.currentPriceSelected] && this.currentPrices[this.currentPriceSelected].PRICE, 'brand': BX.type.isArray(this.brandProperty) ? this.brandProperty.join('/') : this.brandProperty }; break; case 3: //sku for (i in this.offers[this.offerNum].TREE) { if (this.offers[this.offerNum].TREE.hasOwnProperty(i)) { propId = i.substring(5); skuId = this.offers[this.offerNum].TREE[i]; for (k in this.treeProps) { if (this.treeProps.hasOwnProperty(k) && this.treeProps[k].ID == propId) { for (j in this.treeProps[k].VALUES) { propValues = this.treeProps[k].VALUES[j]; if (propValues.ID == skuId) { variants.push(propValues.NAME); break; } } } } } } item = { 'id': this.offers[this.offerNum].ID, 'name': this.offers[this.offerNum].NAME, 'price': this.currentPrices[this.currentPriceSelected] && this.currentPrices[this.currentPriceSelected].PRICE, 'brand': BX.type.isArray(this.brandProperty) ? this.brandProperty.join('/') : this.brandProperty, 'variant': variants.join('/') }; break; } switch (action) { case 'addToCart': info = { 'ecommerce': { 'currencyCode': this.currentPrices[this.currentPriceSelected] && this.currentPrices[this.currentPriceSelected].CURRENCY || '', 'add': { 'products': [{ 'name': item.name || '', 'id': item.id || '', 'price': item.price || 0, 'brand': item.brand || '', 'category': item.category || '', 'variant': item.variant || '', 'quantity': this.showQuantity && this.obQuantity ? this.obQuantity.value : 1 }] } } }; break; } window[this.dataLayerName] = window[this.dataLayerName] || []; window[this.dataLayerName].push(info); }, hoverOn: function(event) { clearTimeout(this.hoverTimer); this.obProduct.style.height = getComputedStyle(this.obProduct).height; BX.addClass(this.obProduct, 'hover'); BX.PreventDefault(event); }, hoverOff: function(event) { if (this.hoverStateChangeForbidden) return; BX.removeClass(this.obProduct, 'hover'); this.hoverTimer = setTimeout( BX.delegate(function(){ this.obProduct.style.height = 'auto'; }, this), 300 ); BX.PreventDefault(event); }, onFocus: function() { this.hoverStateChangeForbidden = true; BX.bind(document, 'mousemove', BX.proxy(this.captureMousePosition, this)); }, onBlur: function() { this.hoverStateChangeForbidden = false; BX.unbind(document, 'mousemove', BX.proxy(this.captureMousePosition, this)); var cursorElement = document.elementFromPoint(this.mouseX, this.mouseY); if (!cursorElement || !this.obProduct.contains(cursorElement)) { this.hoverOff(); } }, captureMousePosition: function(event) { this.mouseX = event.clientX; this.mouseY = event.clientY; }, getCookie: function(name) { var matches = document.cookie.match(new RegExp( "(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)" )); return matches ? decodeURIComponent(matches[1]) : null; }, rememberProductRecommendation: function() { // save to RCM_PRODUCT_LOG var cookieName = BX.cookie_prefix + '_RCM_PRODUCT_LOG', cookie = this.getCookie(cookieName), itemFound = false; var cItems = [], cItem; if (cookie) { cItems = cookie.split('.'); } var i = cItems.length; while (i--) { cItem = cItems[i].split('-'); if (cItem[0] == this.product.id) { // it's already in recommendations, update the date cItem = cItems[i].split('-'); // update rcmId and date cItem[1] = this.product.rcmId; cItem[2] = BX.current_server_time; cItems[i] = cItem.join('-'); itemFound = true; } else { if ((BX.current_server_time - cItem[2]) > 3600 * 24 * 30) { cItems.splice(i, 1); } } } if (!itemFound) { // add recommendation cItems.push([this.product.id, this.product.rcmId, BX.current_server_time].join('-')); } // serialize var plNewCookie = cItems.join('.'), cookieDate = new Date(new Date().getTime() + 1000 * 3600 * 24 * 365 * 10).toUTCString(); document.cookie = cookieName + "=" + plNewCookie + "; path=/; expires=" + cookieDate + "; domain=" + BX.cookie_domain; }, startQuantityInterval: function() { var target = BX.proxy_context; var func = target.id === this.visual.QUANTITY_DOWN_ID ? BX.proxy(this.quantityDown, this) : BX.proxy(this.quantityUp, this); this.quantityDelay = setTimeout( BX.delegate(function() { this.quantityTimer = setInterval(func, 150); }, this), 300 ); }, clearQuantityInterval: function() { clearTimeout(this.quantityDelay); clearInterval(this.quantityTimer); }, quantityUp: function() { var curValue = 0, boolSet = true; if (this.errorCode === 0 && this.showQuantity && this.canBuy) { curValue = (this.isDblQuantity ? parseFloat(this.obQuantity.value) : parseInt(this.obQuantity.value, 10)); if (!isNaN(curValue)) { curValue += this.stepQuantity; if (this.checkQuantity) { if (curValue > this.maxQuantity) { boolSet = false; } } if (boolSet) { if (this.isDblQuantity) { curValue = Math.round(curValue * this.precisionFactor) / this.precisionFactor; } this.obQuantity.value = curValue; this.setPrice(); } } } }, quantityDown: function() { var curValue = 0, boolSet = true; if (this.errorCode === 0 && this.showQuantity && this.canBuy) { curValue = (this.isDblQuantity ? parseFloat(this.obQuantity.value) : parseInt(this.obQuantity.value, 10)); if (!isNaN(curValue)) { curValue -= this.stepQuantity; this.checkPriceRange(curValue); if (curValue < this.minQuantity) { boolSet = false; } if (boolSet) { if (this.isDblQuantity) { curValue = Math.round(curValue * this.precisionFactor) / this.precisionFactor; } this.obQuantity.value = curValue; this.setPrice(); } } } }, quantityChange: function() { var curValue = 0, intCount; if (this.errorCode === 0 && this.showQuantity) { if (this.canBuy) { curValue = this.isDblQuantity ? parseFloat(this.obQuantity.value) : Math.round(this.obQuantity.value); if (!isNaN(curValue)) { if (this.checkQuantity) { if (curValue > this.maxQuantity) { curValue = this.maxQuantity; } } this.checkPriceRange(curValue); intCount = Math.floor( Math.round(curValue * this.precisionFactor / this.stepQuantity) / this.precisionFactor ) || 1; curValue = (intCount <= 1 ? this.stepQuantity : intCount * this.stepQuantity); curValue = Math.round(curValue * this.precisionFactor) / this.precisionFactor; if (curValue < this.minQuantity) { curValue = this.minQuantity; } this.obQuantity.value = curValue; } else { this.obQuantity.value = this.minQuantity; } } else { this.obQuantity.value = this.minQuantity; } this.setPrice(); } }, quantitySet: function(index) { var resetQuantity, strLimit; var newOffer = this.offers[index], oldOffer = this.offers[this.offerNum]; if (this.errorCode === 0) { this.canBuy = newOffer.CAN_BUY; this.currentPriceMode = newOffer.ITEM_PRICE_MODE; this.currentPrices = newOffer.ITEM_PRICES; this.currentPriceSelected = newOffer.ITEM_PRICE_SELECTED; this.currentQuantityRanges = newOffer.ITEM_QUANTITY_RANGES; this.currentQuantityRangeSelected = newOffer.ITEM_QUANTITY_RANGE_SELECTED; if (this.canBuy) { if (this.blockNodes.quantity) { BX.style(this.blockNodes.quantity, 'display', ''); } if (this.obBasketActions) { BX.style(this.obBasketActions, 'display', ''); } if (this.obNotAvail) { BX.style(this.obNotAvail, 'display', 'none'); } if (this.obSubscribe) { BX.style(this.obSubscribe, 'display', 'none'); } } else { if (this.blockNodes.quantity) { BX.style(this.blockNodes.quantity, 'display', 'none'); } if (this.obBasketActions) { BX.style(this.obBasketActions, 'display', 'none'); } if (this.obNotAvail) { BX.style(this.obNotAvail, 'display', ''); } if (this.obSubscribe) { if (newOffer.CATALOG_SUBSCRIBE === 'Y') { BX.style(this.obSubscribe, 'display', ''); this.obSubscribe.setAttribute('data-item', newOffer.ID); BX(this.visual.SUBSCRIBE_ID + '_hidden').click(); } else { BX.style(this.obSubscribe, 'display', 'none'); } } } this.isDblQuantity = newOffer.QUANTITY_FLOAT; this.checkQuantity = newOffer.CHECK_QUANTITY; if (this.isDblQuantity) { this.stepQuantity = Math.round(parseFloat(newOffer.STEP_QUANTITY) * this.precisionFactor) / this.precisionFactor; this.maxQuantity = parseFloat(newOffer.MAX_QUANTITY); this.minQuantity = this.currentPriceMode === 'Q' ? parseFloat(this.currentPrices[this.currentPriceSelected].MIN_QUANTITY) : this.stepQuantity; } else { this.stepQuantity = parseInt(newOffer.STEP_QUANTITY, 10); this.maxQuantity = parseInt(newOffer.MAX_QUANTITY, 10); this.minQuantity = this.currentPriceMode === 'Q' ? parseInt(this.currentPrices[this.currentPriceSelected].MIN_QUANTITY) : this.stepQuantity; } if (this.showQuantity) { var isDifferentMinQuantity = oldOffer.ITEM_PRICES.length && oldOffer.ITEM_PRICES[oldOffer.ITEM_PRICE_SELECTED] && oldOffer.ITEM_PRICES[oldOffer.ITEM_PRICE_SELECTED].MIN_QUANTITY != this.minQuantity; if (this.isDblQuantity) { resetQuantity = Math.round(parseFloat(oldOffer.STEP_QUANTITY) * this.precisionFactor) / this.precisionFactor !== this.stepQuantity || isDifferentMinQuantity || oldOffer.MEASURE !== newOffer.MEASURE || ( this.checkQuantity && parseFloat(oldOffer.MAX_QUANTITY) > this.maxQuantity && parseFloat(this.obQuantity.value) > this.maxQuantity ); } else { resetQuantity = parseInt(oldOffer.STEP_QUANTITY, 10) !== this.stepQuantity || isDifferentMinQuantity || oldOffer.MEASURE !== newOffer.MEASURE || ( this.checkQuantity && parseInt(oldOffer.MAX_QUANTITY, 10) > this.maxQuantity && parseInt(this.obQuantity.value, 10) > this.maxQuantity ); } this.obQuantity.disabled = !this.canBuy; if (resetQuantity) { this.obQuantity.value = this.minQuantity; } if (this.obMeasure) { if (newOffer.MEASURE) { BX.adjust(this.obMeasure, {html: newOffer.MEASURE}); } else { BX.adjust(this.obMeasure, {html: ''}); } } } if (this.obQuantityLimit.all) { if (!this.checkQuantity || this.maxQuantity == 0) { BX.adjust(this.obQuantityLimit.value, {html: ''}); BX.adjust(this.obQuantityLimit.all, {style: {display: 'none'}}); } else { if (this.showMaxQuantity === 'M') { strLimit = (this.maxQuantity / this.stepQuantity >= this.relativeQuantityFactor) ? BX.message('RELATIVE_QUANTITY_MANY') : BX.message('RELATIVE_QUANTITY_FEW'); } else { strLimit = this.maxQuantity; if (newOffer.MEASURE) { strLimit += (' ' + newOffer.MEASURE); } } BX.adjust(this.obQuantityLimit.value, {html: strLimit}); BX.adjust(this.obQuantityLimit.all, {style: {display: ''}}); } } } }, initializeSlider: function() { var wrap = this.obPictSlider.getAttribute('data-slider-wrap'); if (wrap) { this.slider.options.wrap = wrap === 'true'; } else { this.slider.options.wrap = this.defaultSliderOptions.wrap; } if (this.isTouchDevice) { this.slider.options.interval = false; } else { this.slider.options.interval = parseInt(this.obPictSlider.getAttribute('data-slider-interval')) || this.defaultSliderOptions.interval; // slider interval must be more than 700ms because of css transitions if (this.slider.options.interval < 700) { this.slider.options.interval = 700; } if (this.obPictSliderIndicator) { var controls = this.obPictSliderIndicator.querySelectorAll('[data-go-to]'); for (var i in controls) { if (controls.hasOwnProperty(i)) { BX.bind(controls[i], 'click', BX.proxy(this.sliderClickHandler, this)); } } } if (this.obPictSliderProgressBar) { if (this.slider.progress) { this.resetProgress(); this.cycleSlider(); } else { this.slider.progress = new BX.easing({ transition: BX.easing.transitions.linear, step: BX.delegate(function(state){ this.obPictSliderProgressBar.style.width = state.width / 10 + '%'; }, this) }); } } } }, checkTouch: function(event) { if (!event || !event.changedTouches) return false; return event.changedTouches[0].identifier === this.touch.identifier; }, touchStartEvent: function(event) { if (event.touches.length != 1) return; this.touch = event.changedTouches[0]; }, touchEndEvent: function(event) { if (!this.checkTouch(event)) return; var deltaX = this.touch.pageX - event.changedTouches[0].pageX, deltaY = this.touch.pageY - event.changedTouches[0].pageY; if (Math.abs(deltaX) >= Math.abs(deltaY) + 10) { if (deltaX > 0) { this.slideNext(); } if (deltaX < 0) { this.slidePrev(); } } }, sliderClickHandler: function(event) { var target = BX.getEventTarget(event), slideIndex = target.getAttribute('data-go-to'); if (slideIndex) { this.slideTo(slideIndex) } BX.PreventDefault(event); }, slideNext: function() { if (this.slider.sliding) return; return this.slide('next'); }, slidePrev: function() { if (this.slider.sliding) return; return this.slide('prev'); }, slideTo: function(pos) { this.slider.active = BX.findChild(this.obPictSlider, {className: 'item active'}, true, false); this.slider.progress && (this.slider.interval = true); var activeIndex = this.getItemIndex(this.slider.active); if (pos > (this.slider.items.length - 1) || pos < 0) return; if (this.slider.sliding) return false; if (activeIndex == pos) { this.stopSlider(); this.cycleSlider(); return; } return this.slide(pos > activeIndex ? 'next' : 'prev', this.eq(this.slider.items, pos)); }, slide: function(type, next) { var active = BX.findChild(this.obPictSlider, {className: 'item active'}, true, false), isCycling = this.slider.interval, direction = type === 'next' ? 'left' : 'right'; next = next || this.getItemForDirection(type, active); if (BX.hasClass(next, 'active')) { return (this.slider.sliding = false); } this.slider.sliding = true; isCycling && this.stopSlider(); if (this.obPictSliderIndicator) { BX.removeClass(this.obPictSliderIndicator.querySelector('.active'), 'active'); var nextIndicator = this.obPictSliderIndicator.querySelectorAll('[data-go-to]')[this.getItemIndex(next)]; nextIndicator && BX.addClass(nextIndicator, 'active'); } if (BX.hasClass(this.obPictSlider, 'slide') && !BX.browser.IsIE()) { var self = this; BX.addClass(next, type); next.offsetWidth; // force reflow BX.addClass(active, direction); BX.addClass(next, direction); setTimeout(function() { BX.addClass(next, 'active'); BX.removeClass(active, 'active'); BX.removeClass(active, direction); BX.removeClass(next, type); BX.removeClass(next, direction); self.slider.sliding = false; }, 700); } else { BX.addClass(next, 'active'); this.slider.sliding = false; } this.obPictSliderProgressBar && this.resetProgress(); isCycling && this.cycleSlider(); }, stopSlider: function(event) { event || (this.slider.paused = true); this.slider.interval && clearInterval(this.slider.interval); if (this.slider.progress) { this.slider.progress.stop(); var width = parseInt(this.obPictSliderProgressBar.style.width); this.slider.progress.options.duration = this.slider.options.interval * width / 200; this.slider.progress.options.start = {width: width * 10}; this.slider.progress.options.finish = {width: 0}; this.slider.progress.options.complete = null; this.slider.progress.animate(); } }, cycleSlider: function(event) { event || (this.slider.paused = false); this.slider.interval && clearInterval(this.slider.interval); if (this.slider.options.interval && !this.slider.paused) { if (this.slider.progress) { this.slider.progress.stop(); var width = parseInt(this.obPictSliderProgressBar.style.width); this.slider.progress.options.duration = this.slider.options.interval * (100 - width) / 100; this.slider.progress.options.start = {width: width * 10}; this.slider.progress.options.finish = {width: 1000}; this.slider.progress.options.complete = BX.delegate(function(){ this.slider.interval = true; this.slideNext(); }, this); this.slider.progress.animate(); } else { this.slider.interval = setInterval(BX.proxy(this.slideNext, this), this.slider.options.interval); } } }, resetProgress: function() { this.slider.progress && this.slider.progress.stop(); this.obPictSliderProgressBar.style.width = 0; }, getItemForDirection: function(direction, active) { var activeIndex = this.getItemIndex(active), willWrap = direction === 'prev' && activeIndex === 0 || direction === 'next' && activeIndex == (this.slider.items.length - 1); if (willWrap && !this.slider.options.wrap) return active; var delta = direction === 'prev' ? -1 : 1, itemIndex = (activeIndex + delta) % this.slider.items.length; return this.eq(this.slider.items, itemIndex); }, getItemIndex: function(item) { this.slider.items = BX.findChildren(item.parentNode, {className: 'item'}, true); return this.slider.items.indexOf(item || this.slider.active); }, eq: function(obj, i) { var len = obj.length, j = +i + (i < 0 ? len : 0); return j >= 0 && j < len ? obj[j] : {}; }, selectOfferProp: function() { var i = 0, value = '', strTreeValue = '', arTreeItem = [], rowItems = null, target = BX.proxy_context; if (target && target.hasAttribute('data-treevalue')) { if (BX.hasClass(target, 'selected')) return; strTreeValue = target.getAttribute('data-treevalue'); arTreeItem = strTreeValue.split('_'); if (this.searchOfferPropIndex(arTreeItem[0], arTreeItem[1])) { rowItems = BX.findChildren(target.parentNode, {tagName: 'li'}, false); if (rowItems && 0 < rowItems.length) { for (i = 0; i < rowItems.length; i++) { value = rowItems[i].getAttribute('data-onevalue'); if (value === arTreeItem[1]) { BX.addClass(rowItems[i], 'selected'); } else { BX.removeClass(rowItems[i], 'selected'); } } } if ( this.isFacebookConversionCustomizeProductEventEnabled && BX.Type.isArrayFilled(this.offers) && BX.Type.isObject(this.offers[this.offerNum]) ) { BX.ajax.runAction( 'sale.facebookconversion.customizeProduct', { data: { offerId: this.offers[this.offerNum]['ID'] } } ); } } } }, searchOfferPropIndex: function(strPropID, strPropValue) { var strName = '', arShowValues = false, i, j, arCanBuyValues = [], allValues = [], index = -1, arFilter = {}, tmpFilter = []; for (i = 0; i < this.treeProps.length; i++) { if (this.treeProps[i].ID === strPropID) { index = i; break; } } if (-1 < index) { for (i = 0; i < index; i++) { strName = 'PROP_'+this.treeProps[i].ID; arFilter[strName] = this.selectedValues[strName]; } strName = 'PROP_'+this.treeProps[index].ID; arShowValues = this.getRowValues(arFilter, strName); if (!arShowValues) { return false; } if (!BX.util.in_array(strPropValue, arShowValues)) { return false; } arFilter[strName] = strPropValue; for (i = index+1; i < this.treeProps.length; i++) { strName = 'PROP_'+this.treeProps[i].ID; arShowValues = this.getRowValues(arFilter, strName); if (!arShowValues) { return false; } allValues = []; if (this.showAbsent) { arCanBuyValues = []; tmpFilter = []; tmpFilter = BX.clone(arFilter, true); for (j = 0; j < arShowValues.length; j++) { tmpFilter[strName] = arShowValues[j]; allValues[allValues.length] = arShowValues[j]; if (this.getCanBuy(tmpFilter)) arCanBuyValues[arCanBuyValues.length] = arShowValues[j]; } } else { arCanBuyValues = arShowValues; } if (this.selectedValues[strName] && BX.util.in_array(this.selectedValues[strName], arCanBuyValues)) { arFilter[strName] = this.selectedValues[strName]; } else { if (this.showAbsent) arFilter[strName] = (arCanBuyValues.length > 0 ? arCanBuyValues[0] : allValues[0]); else arFilter[strName] = arCanBuyValues[0]; } this.updateRow(i, arFilter[strName], arShowValues, arCanBuyValues); } this.selectedValues = arFilter; this.changeInfo(); } return true; }, updateRow: function(intNumber, activeID, showID, canBuyID) { var i = 0, value = '', isCurrent = false, rowItems = null; var lineContainer = this.obTree.querySelectorAll('[data-entity="sku-line-block"]'), listContainer; if (intNumber > -1 && intNumber < lineContainer.length) { listContainer = lineContainer[intNumber].querySelector('ul'); rowItems = BX.findChildren(listContainer, {tagName: 'li'}, false); if (rowItems && 0 < rowItems.length) { for (i = 0; i < rowItems.length; i++) { value = rowItems[i].getAttribute('data-onevalue'); isCurrent = value === activeID; if (isCurrent) { BX.addClass(rowItems[i], 'selected'); } else { BX.removeClass(rowItems[i], 'selected'); } if (BX.util.in_array(value, canBuyID)) { BX.removeClass(rowItems[i], 'notallowed'); } else { BX.addClass(rowItems[i], 'notallowed'); } rowItems[i].style.display = BX.util.in_array(value, showID) ? '' : 'none'; if (isCurrent) { lineContainer[intNumber].style.display = (value == 0 && canBuyID.length == 1) ? 'none' : ''; } } } } }, getRowValues: function(arFilter, index) { var i = 0, j, arValues = [], boolSearch = false, boolOneSearch = true; if (0 === arFilter.length) { for (i = 0; i < this.offers.length; i++) { if (!BX.util.in_array(this.offers[i].TREE[index], arValues)) { arValues[arValues.length] = this.offers[i].TREE[index]; } } boolSearch = true; } else { for (i = 0; i < this.offers.length; i++) { boolOneSearch = true; for (j in arFilter) { if (arFilter[j] !== this.offers[i].TREE[j]) { boolOneSearch = false; break; } } if (boolOneSearch) { if (!BX.util.in_array(this.offers[i].TREE[index], arValues)) { arValues[arValues.length] = this.offers[i].TREE[index]; } boolSearch = true; } } } return (boolSearch ? arValues : false); }, getCanBuy: function(arFilter) { var i, j, boolSearch = false, boolOneSearch = true; for (i = 0; i < this.offers.length; i++) { boolOneSearch = true; for (j in arFilter) { if (arFilter[j] !== this.offers[i].TREE[j]) { boolOneSearch = false; break; } } if (boolOneSearch) { if (this.offers[i].CAN_BUY) { boolSearch = true; break; } } } return boolSearch; }, setCurrent: function() { var i, j = 0, arCanBuyValues = [], strName = '', arShowValues = false, arFilter = {}, tmpFilter = [], current = this.offers[this.offerNum].TREE; for (i = 0; i < this.treeProps.length; i++) { strName = 'PROP_'+this.treeProps[i].ID; arShowValues = this.getRowValues(arFilter, strName); if (!arShowValues) { break; } if (BX.util.in_array(current[strName], arShowValues)) { arFilter[strName] = current[strName]; } else { arFilter[strName] = arShowValues[0]; this.offerNum = 0; } if (this.showAbsent) { arCanBuyValues = []; tmpFilter = []; tmpFilter = BX.clone(arFilter, true); for (j = 0; j < arShowValues.length; j++) { tmpFilter[strName] = arShowValues[j]; if (this.getCanBuy(tmpFilter)) { arCanBuyValues[arCanBuyValues.length] = arShowValues[j]; } } } else { arCanBuyValues = arShowValues; } this.updateRow(i, arFilter[strName], arShowValues, arCanBuyValues); } this.selectedValues = arFilter; this.changeInfo(); }, changeInfo: function() { var i, j, index = -1, boolOneSearch = true, quantityChanged; for (i = 0; i < this.offers.length; i++) { boolOneSearch = true; for (j in this.selectedValues) { if (this.selectedValues[j] !== this.offers[i].TREE[j]) { boolOneSearch = false; break; } } if (boolOneSearch) { index = i; break; } } if (index > -1) { if (parseInt(this.offers[index].MORE_PHOTO_COUNT) > 1 && this.obPictSlider) { // hide pict and second_pict containers if (this.obPict) { this.obPict.style.display = 'none'; } if (this.obSecondPict) { this.obSecondPict.style.display = 'none'; } // clear slider container BX.cleanNode(this.obPictSlider); // fill slider container with slides for (i in this.offers[index].MORE_PHOTO) { if (this.offers[index].MORE_PHOTO.hasOwnProperty(i)) { this.obPictSlider.appendChild( BX.create('SPAN', { props: {className: 'product-item-image-slide item' + (i == 0 ? ' active' : '')}, style: {backgroundImage: 'url(\'' + this.offers[index].MORE_PHOTO[i].SRC + '\')'} }) ); } } // fill slider indicator if exists if (this.obPictSliderIndicator) { BX.cleanNode(this.obPictSliderIndicator); for (i in this.offers[index].MORE_PHOTO) { if (this.offers[index].MORE_PHOTO.hasOwnProperty(i)) { this.obPictSliderIndicator.appendChild( BX.create('DIV', { attrs: {'data-go-to': i}, props: {className: 'product-item-image-slider-control' + (i == 0 ? ' active' : '')} }) ); this.obPictSliderIndicator.appendChild(document.createTextNode(' ')); } } this.obPictSliderIndicator.style.display = ''; } if (this.obPictSliderProgressBar) { this.obPictSliderProgressBar.style.display = ''; } // show slider container this.obPictSlider.style.display = ''; this.initializeSlider(); } else { // hide slider container if (this.obPictSlider) { this.obPictSlider.style.display = 'none'; } if (this.obPictSliderIndicator) { this.obPictSliderIndicator.style.display = 'none'; } if (this.obPictSliderProgressBar) { this.obPictSliderProgressBar.style.display = 'none'; } // show pict and pict_second containers if (this.obPict) { if (this.offers[index].PREVIEW_PICTURE) { BX.adjust(this.obPict, {style: {backgroundImage: 'url(\'' + this.offers[index].PREVIEW_PICTURE.SRC + '\')'}}); } else { BX.adjust(this.obPict, {style: {backgroundImage: 'url(\'' + this.defaultPict.pict.SRC + '\')'}}); } this.obPict.style.display = ''; } if (this.secondPict && this.obSecondPict) { if (this.offers[index].PREVIEW_PICTURE_SECOND) { BX.adjust(this.obSecondPict, {style: {backgroundImage: 'url(\'' + this.offers[index].PREVIEW_PICTURE_SECOND.SRC + '\')'}}); } else if (this.offers[index].PREVIEW_PICTURE.SRC) { BX.adjust(this.obSecondPict, {style: {backgroundImage: 'url(\'' + this.offers[index].PREVIEW_PICTURE.SRC + '\')'}}); } else if (this.defaultPict.secondPict) { BX.adjust(this.obSecondPict, {style: {backgroundImage: 'url(\'' + this.defaultPict.secondPict.SRC + '\')'}}); } else { BX.adjust(this.obSecondPict, {style: {backgroundImage: 'url(\'' + this.defaultPict.pict.SRC + '\')'}}); } this.obSecondPict.style.display = ''; } } if (this.showSkuProps && this.obSkuProps) { if (this.offers[index].DISPLAY_PROPERTIES.length) { BX.adjust(this.obSkuProps, {style: {display: ''}, html: this.offers[index].DISPLAY_PROPERTIES}); } else { BX.adjust(this.obSkuProps, {style: {display: 'none'}, html: ''}); } } this.quantitySet(index); this.setPrice(); this.setCompared(this.offers[index].COMPARED); this.offerNum = index; } }, checkPriceRange: function(quantity) { if (typeof quantity === 'undefined'|| this.currentPriceMode != 'Q') return; var range, found = false; for (var i in this.currentQuantityRanges) { if (this.currentQuantityRanges.hasOwnProperty(i)) { range = this.currentQuantityRanges[i]; if ( parseInt(quantity) >= parseInt(range.SORT_FROM) && ( range.SORT_TO == 'INF' || parseInt(quantity) <= parseInt(range.SORT_TO) ) ) { found = true; this.currentQuantityRangeSelected = range.HASH; break; } } } if (!found && (range = this.getMinPriceRange())) { this.currentQuantityRangeSelected = range.HASH; } for (var k in this.currentPrices) { if (this.currentPrices.hasOwnProperty(k)) { if (this.currentPrices[k].QUANTITY_HASH == this.currentQuantityRangeSelected) { this.currentPriceSelected = k; break; } } } }, getMinPriceRange: function() { var range; for (var i in this.currentQuantityRanges) { if (this.currentQuantityRanges.hasOwnProperty(i)) { if ( !range || parseInt(this.currentQuantityRanges[i].SORT_FROM) < parseInt(range.SORT_FROM) ) { range = this.currentQuantityRanges[i]; } } } return range; }, checkQuantityControls: function() { if (!this.obQuantity) return; var reachedTopLimit = this.checkQuantity && parseFloat(this.obQuantity.value) + this.stepQuantity > this.maxQuantity, reachedBottomLimit = parseFloat(this.obQuantity.value) - this.stepQuantity < this.minQuantity; if (reachedTopLimit) { BX.addClass(this.obQuantityUp, 'product-item-amount-field-btn-disabled'); } else if (BX.hasClass(this.obQuantityUp, 'product-item-amount-field-btn-disabled')) { BX.removeClass(this.obQuantityUp, 'product-item-amount-field-btn-disabled'); } if (reachedBottomLimit) { BX.addClass(this.obQuantityDown, 'product-item-amount-field-btn-disabled'); } else if (BX.hasClass(this.obQuantityDown, 'product-item-amount-field-btn-disabled')) { BX.removeClass(this.obQuantityDown, 'product-item-amount-field-btn-disabled'); } if (reachedTopLimit && reachedBottomLimit) { this.obQuantity.setAttribute('disabled', 'disabled'); } else { this.obQuantity.removeAttribute('disabled'); } }, setPrice: function() { var obData, price; if (this.obQuantity) { this.checkPriceRange(this.obQuantity.value); } this.checkQuantityControls(); price = this.currentPrices[this.currentPriceSelected]; if (this.obPrice) { if (price) { BX.adjust(this.obPrice, {html: BX.Currency.currencyFormat(price.RATIO_PRICE, price.CURRENCY, true)}); } else { BX.adjust(this.obPrice, {html: ''}); } if (this.showOldPrice && this.obPriceOld) { if (price && price.RATIO_PRICE !== price.RATIO_BASE_PRICE) { BX.adjust(this.obPriceOld, { style: {display: ''}, html: BX.Currency.currencyFormat(price.RATIO_BASE_PRICE, price.CURRENCY, true) }); } else { BX.adjust(this.obPriceOld, { style: {display: 'none'}, html: '' }); } } if (this.obPriceTotal) { if (price && this.obQuantity && this.obQuantity.value != this.stepQuantity) { BX.adjust(this.obPriceTotal, { html: BX.message('PRICE_TOTAL_PREFIX') + ' ' + BX.Currency.currencyFormat(price.PRICE * this.obQuantity.value, price.CURRENCY, true) + '', style: {display: ''} }); } else { BX.adjust(this.obPriceTotal, { html: '', style: {display: 'none'} }); } } if (this.showPercent) { if (price && parseInt(price.PERCENT) > 0) { obData = {style: {display: ''}, html: -price.PERCENT + '%'}; } else { obData = {style: {display: 'none'}, html: ''}; } if (this.obDscPerc) { BX.adjust(this.obDscPerc, obData); } if (this.obSecondDscPerc) { BX.adjust(this.obSecondDscPerc, obData); } } } }, compare: function(event) { var checkbox = this.obCompare.querySelector('[data-entity="compare-checkbox"]'), target = BX.getEventTarget(event), checked = true; if (checkbox) { checked = target === checkbox ? checkbox.checked : !checkbox.checked; } var url = checked ? this.compareData.compareUrl : this.compareData.compareDeleteUrl, compareLink; if (url) { if (target !== checkbox) { BX.PreventDefault(event); this.setCompared(checked); } switch (this.productType) { case 0: // no catalog case 1: // product case 2: // set case 7: // service compareLink = url.replace('#ID#', this.product.id.toString()); break; case 3: // sku compareLink = url.replace('#ID#', this.offers[this.offerNum].ID); break; } BX.ajax({ method: 'POST', dataType: checked ? 'json' : 'html', url: compareLink + (compareLink.indexOf('?') !== -1 ? '&' : '?') + 'ajax_action=Y', onsuccess: checked ? BX.proxy(this.compareResult, this) : BX.proxy(this.compareDeleteResult, this) }); } }, compareResult: function(result) { var popupContent, popupButtons; if (this.obPopupWin) { this.obPopupWin.close(); } if (!BX.type.isPlainObject(result)) return; this.initPopupWindow(); if (this.offers.length > 0) { this.offers[this.offerNum].COMPARED = result.STATUS === 'OK'; } if (result.STATUS === 'OK') { BX.onCustomEvent('OnCompareChange'); popupContent = '

' + BX.message('COMPARE_MESSAGE_OK') + '

'; if (this.showClosePopup) { popupButtons = [ new BasketButton({ text: BX.message('BTN_MESSAGE_COMPARE_REDIRECT'), events: { click: BX.delegate(this.compareRedirect, this) }, style: {marginRight: '10px'} }), new BasketButton({ text: BX.message('BTN_MESSAGE_CLOSE_POPUP'), events: { click: BX.delegate(this.obPopupWin.close, this.obPopupWin) } }) ]; } else { popupButtons = [ new BasketButton({ text: BX.message('BTN_MESSAGE_COMPARE_REDIRECT'), events: { click: BX.delegate(this.compareRedirect, this) } }) ]; } } else { popupContent = '

' + (result.MESSAGE ? result.MESSAGE : BX.message('COMPARE_UNKNOWN_ERROR')) + '

'; popupButtons = [ new BasketButton({ text: BX.message('BTN_MESSAGE_CLOSE'), events: { click: BX.delegate(this.obPopupWin.close, this.obPopupWin) } }) ]; } this.obPopupWin.setTitleBar(BX.message('COMPARE_TITLE')); this.obPopupWin.setContent(popupContent); this.obPopupWin.setButtons(popupButtons); this.obPopupWin.show(); }, compareDeleteResult: function() { BX.onCustomEvent('OnCompareChange'); if (this.offers && this.offers.length) { this.offers[this.offerNum].COMPARED = false; } }, setCompared: function(state) { if (!this.obCompare) return; var checkbox = this.obCompare.querySelector('[data-entity="compare-checkbox"]'); if (checkbox) { checkbox.checked = state; } }, setCompareInfo: function(comparedIds) { if (!BX.type.isArray(comparedIds)) return; for (var i in this.offers) { if (this.offers.hasOwnProperty(i)) { this.offers[i].COMPARED = BX.util.in_array(this.offers[i].ID, comparedIds); } } }, compareRedirect: function() { if (this.compareData.comparePath) { location.href = this.compareData.comparePath; } else { this.obPopupWin.close(); } }, checkDeletedCompare: function(id) { switch (this.productType) { case 0: // no catalog case 1: // product case 2: // set case 7: // service if (this.product.id == id) { this.setCompared(false); } break; case 3: // sku var i = this.offers.length; while (i--) { if (this.offers[i].ID == id) { this.offers[i].COMPARED = false; if (this.offerNum == i) { this.setCompared(false); } break; } } } }, initBasketUrl: function() { this.basketUrl = (this.basketMode === 'ADD' ? this.basketData.add_url : this.basketData.buy_url); switch (this.productType) { case 1: // product case 2: // set case 7: // service this.basketUrl = this.basketUrl.replace('#ID#', this.product.id.toString()); break; case 3: // sku this.basketUrl = this.basketUrl.replace('#ID#', this.offers[this.offerNum].ID); break; } this.basketParams = { 'ajax_basket': 'Y' }; if (this.showQuantity) { this.basketParams[this.basketData.quantity] = this.obQuantity.value; } if (this.basketData.sku_props) { this.basketParams[this.basketData.sku_props_var] = this.basketData.sku_props; } }, fillBasketProps: function() { if (!this.visual.BASKET_PROP_DIV) { return; } var i = 0, propCollection = null, foundValues = false, obBasketProps = null; if (this.basketData.useProps && !this.basketData.emptyProps) { if (this.obPopupWin && this.obPopupWin.contentContainer) { obBasketProps = this.obPopupWin.contentContainer; } } else { obBasketProps = BX(this.visual.BASKET_PROP_DIV); } if (obBasketProps) { propCollection = obBasketProps.getElementsByTagName('select'); if (propCollection && propCollection.length) { for (i = 0; i < propCollection.length; i++) { if (!propCollection[i].disabled) { switch (propCollection[i].type.toLowerCase()) { case 'select-one': this.basketParams[propCollection[i].name] = propCollection[i].value; foundValues = true; break; default: break; } } } } propCollection = obBasketProps.getElementsByTagName('input'); if (propCollection && propCollection.length) { for (i = 0; i < propCollection.length; i++) { if (!propCollection[i].disabled) { switch (propCollection[i].type.toLowerCase()) { case 'hidden': this.basketParams[propCollection[i].name] = propCollection[i].value; foundValues = true; break; case 'radio': if (propCollection[i].checked) { this.basketParams[propCollection[i].name] = propCollection[i].value; foundValues = true; } break; default: break; } } } } } if (!foundValues) { this.basketParams[this.basketData.props] = []; this.basketParams[this.basketData.props][0] = 0; } }, add2Basket: function() { this.basketMode = 'ADD'; this.basket(); }, buyBasket: function() { this.basketMode = 'BUY'; this.basket(); }, sendToBasket: function() { if (!this.canBuy) { return; } // check recommendation if (this.product && this.product.id && this.bigData) { this.rememberProductRecommendation(); } this.initBasketUrl(); this.fillBasketProps(); BX.ajax({ method: 'POST', dataType: 'json', url: this.basketUrl, data: this.basketParams, onsuccess: BX.proxy(this.basketResult, this) }); }, basket: function() { var contentBasketProps = ''; if (!this.canBuy) { return; } switch (this.productType) { case 1: // product case 2: // set case 7: // service if (this.basketData.useProps && !this.basketData.emptyProps) { this.initPopupWindow(); this.obPopupWin.setTitleBar(BX.message('TITLE_BASKET_PROPS')); if (BX(this.visual.BASKET_PROP_DIV)) { contentBasketProps = BX(this.visual.BASKET_PROP_DIV).innerHTML; } this.obPopupWin.setContent(contentBasketProps); this.obPopupWin.setButtons([ new BasketButton({ text: BX.message('BTN_MESSAGE_SEND_PROPS'), events: { click: BX.delegate(this.sendToBasket, this) } }) ]); this.obPopupWin.show(); } else { this.sendToBasket(); } break; case 3: // sku this.sendToBasket(); break; } }, basketResult: function(arResult) { var strContent = '', strPict = '', successful, buttons = []; if (this.obPopupWin) this.obPopupWin.close(); if (!BX.type.isPlainObject(arResult)) return; successful = arResult.STATUS === 'OK'; if (successful) { this.setAnalyticsDataLayer('addToCart'); } if (successful && this.basketAction === 'BUY') { this.basketRedirect(); } else { this.initPopupWindow(); if (successful) { BX.onCustomEvent('OnBasketChange'); if (BX.findParent(this.obProduct, {className: 'bx_sale_gift_main_products'}, 10)) { BX.onCustomEvent('onAddToBasketMainProduct', [this]); } switch (this.productType) { case 1: // product case 2: // set case 7: // service strPict = this.product.pict.SRC; break; case 3: // sku strPict = (this.offers[this.offerNum].PREVIEW_PICTURE ? this.offers[this.offerNum].PREVIEW_PICTURE.SRC : this.defaultPict.pict.SRC ); break; } strContent = '

' + this.product.name + '

'; if (this.showClosePopup) { buttons = [ new BasketButton({ text: BX.message("BTN_MESSAGE_BASKET_REDIRECT"), events: { click: BX.delegate(this.basketRedirect, this) }, style: {marginRight: '10px'} }), new BasketButton({ text: BX.message("BTN_MESSAGE_CLOSE_POPUP"), events: { click: BX.delegate(this.obPopupWin.close, this.obPopupWin) } }) ]; } else { buttons = [ new BasketButton({ text: BX.message("BTN_MESSAGE_BASKET_REDIRECT"), events: { click: BX.delegate(this.basketRedirect, this) } }) ]; } } else { strContent = '

' + (arResult.MESSAGE ? arResult.MESSAGE : BX.message('BASKET_UNKNOWN_ERROR')) + '

'; buttons = [ new BasketButton({ text: BX.message('BTN_MESSAGE_CLOSE'), events: { click: BX.delegate(this.obPopupWin.close, this.obPopupWin) } }) ]; } this.obPopupWin.setTitleBar(successful ? BX.message('TITLE_SUCCESSFUL') : BX.message('TITLE_ERROR')); this.obPopupWin.setContent(strContent); this.obPopupWin.setButtons(buttons); this.obPopupWin.show(); } }, basketRedirect: function() { location.href = (this.basketData.basketUrl ? this.basketData.basketUrl : BX.message('BASKET_URL')); }, initPopupWindow: function() { if (this.obPopupWin) return; this.obPopupWin = BX.PopupWindowManager.create('CatalogSectionBasket_' + this.visual.ID, null, { autoHide: true, offsetLeft: 0, offsetTop: 0, overlay : true, closeByEsc: true, titleBar: true, closeIcon: true, contentColor: 'white', className: this.templateTheme ? 'bx-' + this.templateTheme : '' }); } }; })(window); /* End */ ;; /* /local/templates/moleculab/components/bitrix/catalog.section/main_sec2/script.min.js?17140287275657*/ ; /* /local/templates/moleculab/components/bitrix/catalog.item/main_item2/script.js?171402876963933*/ //# sourceMappingURL=page_ac1ec7fe1fe345cbfe9946939ae672b9.map.js