var amshopby_working = false; var amshopby_blocks = {}; function amshopby_ajax_fallback_mode() { var myNav = navigator.userAgent.toLowerCase(); var isIE = (myNav.indexOf('msie') != -1) ? parseInt(myNav.split('msie')[1]) : false; return isIE == 7 || isIE == 8; } function amshopby_ajax_init(){ if (amshopby_ajax_fallback_mode()) { return; } $$('div.block-layered-nav a', amshopby_toolbar_selector + ' a'). each(function(e){ var p = e.up(); if (p.hasClassName('amshopby-cat') || p.hasClassName('amshopby-clearer')){ return; } e.onclick = function(){ if (this.hasClassName('checked')) { this.removeClassName('checked'); } else { this.addClassName('checked'); } var s = this.href; if (s.indexOf('#') > 0){ s = s.substring(0, s.indexOf('#')) } amshopby_ajax_push_state(s); amshopby_ajax_request(s); return false; }; }); $$('div.block-layered-nav select.amshopby-ajax-select', amshopby_toolbar_selector + ' select'). each(function(e){ e.onchange = 'return false'; Event.observe(e, 'change', function(e){ amshopby_ajax_push_state(this.value); amshopby_ajax_request(this.value); Event.stop(e); }); }); } function amshopby_get_created_container() { var elements = document.getElementsByClassName('amshopby-page-container'); return (elements.length > 0) ? elements[0] : null; } function amshopby_get_container() { var createdElement = amshopby_get_created_container(); if (!createdElement) { var container_element = null; var elements = $$('div.category-products'); if (elements.length == 0) { container_element = amshopby_get_empty_container(); } else { container_element = elements[0]; } if (!container_element) { console.debug('Please add the
' + data.page + '
'; targetElement = amshopby_get_first_descendant(tmp); } block.parentNode.replaceChild(targetElement, block); if (typeof AmConfigurableData != 'undefined') { try{ targetElement.innerHTML.evalScripts(); } catch(ex){ console.debug(ex); } } } var blocks = data.blocks; for (var id in blocks){ var html = blocks[id]; if (html){ tmp.innerHTML = html; } block = $$('div.'+id)[0]; if (html){ if (!block){ block = amshopby_blocks[id]; // the block WAS in the structure a few requests ago amshopby_blocks[id] = null; } if (block){ var targetElement = amshopby_get_first_descendant(tmp); block.parentNode.replaceChild(targetElement, block); } } else { // no filters returned, need to remove if (block){ var empty = document.createTextNode(''); amshopby_blocks[id] = empty; // remember the block in the DOM structure block.parentNode.replaceChild(empty, block); } } } if (typeof amshopby_jquery_init !== 'undefined') { amshopby_jquery_init(); } amshopby_start(); amshopby_ajax_init(); amshopby_move_top_filter(); try { var categoryProducts = $$('.category-products, .catblocks').first(); var colLeftFirst = amshopby_get_container().parentNode.select('.col-left-first').first(); if(colLeftFirst && categoryProducts){ var parent = categoryProducts.parentNode; parent.insertBefore(colLeftFirst, categoryProducts); } amshopby_external(); } catch (e) { console.debug(e); } } document.observe("dom:loaded", function(event) { amshopby_ajax_init(); if (typeof window.history.replaceState === "function") { window.history.replaceState({url: document.URL}, document.title); setTimeout(function() { /* Timeout is a workaround for iPhone Reproduce scenario is following: 1. Open category 2. Use pagination 3. Click on product 4. Press "Back" Result: Ajax loads the same content right after regular page load */ window.onpopstate = function(e){ if(e.state){ amshopby_ajax_request(e.state.url); } }; }, 0) } }); var amshopby_toolbar_selector = 'div.toolbar'; var amshopby_scroll_to_products = false; function amshopby_external(){ //add here all external scripts for page reloading // like igImgPreviewInit(); if (typeof amscroll_object != 'undefined') { amscroll_object.init(amscroll_params); amscroll_object.bindClick(); } if (typeof amshopby_demo != 'undefined') { amshopby_demo(); } if (typeof AmAjaxObj != 'undefined') { AmAjaxShoppCartLoad('button.btn-cart'); } //amfinder var amfinderScript = document.getElementById('amfinder_script'); if (amfinderScript) { eval(amfinderScript.innerHTML); } if (typeof ProductMediaManager != 'undefined') { amshopby_external_rwd(); } if (typeof amlabel_init == 'function') { amlabel_init(); } /** * Third-party themes */ if (typeof jQuery != 'undefined' && typeof calculateMenuItemsInRow == 'function') { amshopby_external_megatron(); } //Ultimo fortis themes if (typeof setGridItemsEqualHeight != 'undefined') { setTimeout('setGridItemsEqualHeight(jQuery)', 100); setTimeout('setGridItemsEqualHeight(jQuery)', 300); setTimeout('setGridItemsEqualHeight(jQuery)', 800); setTimeout('setGridItemsEqualHeight(jQuery)', 2000); } // venedor/default if (typeof products_grid_resize == 'function') { products_grid_resize(); } if (typeof jQuery != 'undefined' && typeof jQuery.resize == 'function') { jQuery.resize(); } // Magento 1.9.1 Configurable swatches if (typeof ConfigurableSwatchesList != 'undefined') { ConfigurableSwatchesList.init(); } } function amshopby_external_rwd() { enquire.register('(max-width: ' + bp.medium + 'px)', { setup: function () {}, match: function () { $j('.block-subtitle--filter').toggleSingle({destruct: true}); $j('.block-subtitle--filter').toggleSingle(); }, unmatch: function () { $j('.block-subtitle--filter').toggleSingle({destruct: true}); } }); /*align Product Grid Actions */ if ($j('.products-grid').length) { var alignProductGridActions = function () { // Loop through each product grid on the page $j('.products-grid').each(function(){ var gridRows = []; // This will store an array per row var tempRow = []; productGridElements = $j(this).children('li'); productGridElements.each(function (index) { // The JS ought to be agnostic of the specific CSS breakpoints, so we are dynamically checking to find // each row by grouping all cells (eg, li elements) up until we find an element that is cleared. // We are ignoring the first cell since it will always be cleared. if ($j(this).css('clear') != 'none' && index != 0) { gridRows.push(tempRow); // Add the previous set of rows to the main array tempRow = []; // Reset the array since we're on a new row } tempRow.push(this); // The last row will not contain any cells that clear that row, so we check to see if this is the last cell // in the grid, and if so, we add its row to the array if (productGridElements.length == index + 1) { gridRows.push(tempRow); } }); $j.each(gridRows, function () { var tallestProductInfo = 0; $j.each(this, function () { // Since this function is called every time the page is resized, we need to remove the min-height // and bottom-padding so each cell can return to its natural size before being measured. $j(this).find('.product-info').css({ 'min-height': '', 'padding-bottom': '' }); // We are checking the height of .product-info (rather than the entire li), because the images // will not be loaded when this JS is run. var productInfoHeight = $j(this).find('.product-info').height(); // Space above .actions element var actionSpacing = 10; // The height of the absolutely positioned .actions element var actionHeight = $j(this).find('.product-info .actions').height(); // Add height of two elements. This is necessary since .actions is absolutely positioned and won't // be included in the height of .product-info var totalHeight = productInfoHeight + actionSpacing + actionHeight; if (totalHeight > tallestProductInfo) { tallestProductInfo = totalHeight; } // Set the bottom-padding to accommodate the height of the .actions element. Note: if .actions // elements are of varying heights, they will not be aligned. $j(this).find('.product-info').css('padding-bottom', actionHeight + 'px'); }); // Set the height of all .product-info elements in a row to the tallest height $j.each(this, function () { $j(this).find('.product-info').css('min-height', tallestProductInfo); }); }); }); } alignProductGridActions(); } jQuery('.toggle-content').each(function () { var wrapper = jQuery(this); var hasTabs = wrapper.hasClass('tabs'); var startOpen = wrapper.hasClass('open'); var dl = wrapper.children('dl:first'); var dts = dl.children('dt'); var panes = dl.children('dd'); var groups = new Array(dts, panes); //Create a ul for tabs if necessary. if (hasTabs) { var ul = jQuery('