var mamezi_box_config = "eyJhcHBsaWNhdGlvbl9uYW1lIjoiYm94eSIsInNob3BfaWQiOiIyOTM1NWY4ZmY5NDNmMjkwZjA2NjBjNDEzNDY3MmZiNTU2NDIzMGQ1IiwicHJpY2UiOiJiIn0="; mamezi_box_config = atob(mamezi_box_config) mamezi_box_config = JSON.parse(mamezi_box_config); function BoxProducts(){ this.regularOptions = ["id", "position"]; this.proOptions = ["show", "search", "category", "limit", "slider", "autoScrolling", "getFromMainCategory", "category_id", "onlyAvailable"]; this.priceTypes = ["b","bn", "n", "brak"]; this.proName = "boxy_pro"; this.apiLimit = 50; this.options = {}; this.app_config = {}; this.productList = []; this.downloaded = 0; this.template = ""; this._done_function_callback = function(){}; var self = this; this.init = function(options, app_config, doneFunction, dataDefer){ self.app_config = app_config; self.options = parseOptions(options); if(!self.options) return false; self._done_function_callback = doneFunction; self.dataDefer = dataDefer; getProductList(self.options); }; function buildProductList(data){ self.downloaded += data.list.length; for(var i=0; i= 0){ newOptions[Object.keys(options)[i]] = options[Object.keys(options)[i]]; } else { if(self.proOptions.indexOf(Object.keys(options)[i]) >= 0) { console.warn("Boxy produktowe: Parametr '" + Object.keys(options)[i] + "' dostępny w wersji PRO aplikacji https://www.shoper.pl/aplikacje/boxy-produktowe-pro/"); } else { console.warn("Boxy produktowe: Nieznany parametr '" + Object.keys(options)[i] + "'"); } } } if(Object.keys(newOptions).length === 0){ console.warn("Boxy produktowe: Nie podano wymaganych parametrów w Shortcode lub wystąpił błąd w składni, boxy nie inicjalizują się"); return false; } else return newOptions; } function generateHTML(){ var products = self.productList; var pr = self.app_config.price; var orderedProducts = []; //only available param if(returnParam(self.options.onlyAvailable) == "true") { var tempProd = []; for (var j = 0; j < products.length; j++) { if(products[j].can_buy) tempProd.push(products[j]); } self.productList = tempProd; products = self.productList; } //limit if(returnParam(self.options.limit)) { self.productList = self.productList.slice(0, returnParam(self.options.limit)) } // do wyświetlania produktów w odpowiedznij kolejności if (returnParam(self.options.id)) { var pushed = []; var productsId = returnParam(self.options.id).split(","); for (var i = 0; i < productsId.length; i++) { for (var j = 0; j < self.productList.length; j++) { if (productsId[i] == self.productList[j].id && pushed.indexOf(self.productList[j].id) === -1) { orderedProducts.push(self.productList[j]); pushed.push(self.productList[j].id) break; } } } } else{ orderedProducts = self.productList; } var header = ""; products = orderedProducts; if( products.length === 0){ header = ""; var footer = ""; } if(products.length === 1){ var product = products[0]; let resultOne = ""; if(returnParam(self.options.position) === "right"){ resultOne += "
1) { var result = "
" ; header = sliderResult; var footer = "
" } var html = ""; for (i = 0; i < products.length; i++) { var product = products[i]; html += Mustache.render(self.template, product); } self._done_function_callback(header + html + footer, products); } } $(function () { initFrontApiBoxy(); function initFrontApiBoxy() { if (typeof frontAPI !== 'undefined') { initScriptBoxy(); } else { setTimeout(function () { initFrontApiBoxy() }, 50); } } setTimeout(initFrontApiBoxy, 1000); }); function initScriptBoxy() { new Shortcode(document.querySelector('body'), { product: function (callback) { new BoxProducts().init(this.options, mamezi_box_config, callback); } }, function(content, classname, data){ postInitBoxProducts(content, classname); if(typeof Shop.prototype.callBackMamezi != "undefined"){ if(typeof Shop.prototype.callBackMamezi.productBoxesCallback !== "undefined"){ Shop.prototype.callBackMamezi.productBoxesCallback(data, content); } } }) } function postInitBoxProducts(block, classname){ var bl = block.find(".box_mamezi_product"); var sl = bl.find(".slider_mamezi"); Shop.prototype.selectorFunctions.boxslider.load(sl, shoper) setTimeout(function(){ var addtobasket = new Shop.AddToCart() $(sl).addClass("slider"); },1000) } $(window).resize(function () { windowWidth = window.innerWidth; if(windowWidth < 767){ $(".flag_right_boxy_produktowe").removeClass("right"); for(i = 0; i < $(".flag_right_boxy_produktowe").length ; i++){ $(".flag_right_boxy_produktowe")[i].children[0].style.marginLeft = "0px"; $(".flag_right_boxy_produktowe")[i].children[0].style.marginRight = "0px"; } }else{ $(".flag_right_boxy_produktowe").addClass("right"); for(i = 0; i < $(".flag_right_boxy_produktowe").length ; i++){ $(".flag_right_boxy_produktowe")[i].children[0].style.marginLeft = "20px"; $(".flag_right_boxy_produktowe")[i].children[0].style.marginRight = "0px"; } } }); setTimeout(function(){ for( j = 0; j < document.getElementsByClassName('slider-wrap').length; j ++) { document.getElementsByClassName('slider-wrap')[j].style.height= "auto"; } }, 1500); Shop.AddToCart.include({ options: { selectors: { form: 'form.basket.mamezi_basket[action], .basket form[action], form.basket[action]' }, elements: { forms: null }, preventSubmit: false }, initialize: function(options) { var self; this.constructor.setOptions(options); this.options.elements.forms = $(this.options.selectors.form); self = this; this.options.elements.forms.each(function() { if($(this).data("binded") != true) { $(this).data("binded", true); $(this).on('submit', function (ev) { ev.preventDefault(); ev.stopPropagation(); self.parent.fireEvent('cart:add', ev, self.options, $(this)); if (!self.options.preventSubmit) { this.submit(); } }); } }); } }); var addtobasket = new Shop.AddToCart()