' ).insertAfter( ".shop.christmas-gifts .shop-container .ais-hits--item:nth-child(30)" ); }; //run this every time instantsearch.js renders results search.on('render', onRenderHandler); //run this the first time instantsearch.js renders results search.once('render', onRenderHandlerOnce); search.start(); $('#algolia-search-box input').attr('type', 'search').select(); $.fn.exists = function(callback1, callback2) { if (this.length) { callback1.call(this); } else { callback2.call(this); } return this; }; $("body").on('DOMSubtreeModified', '.ais-current-refined-values--list', function() { $('.ais-current-refined-values--item').exists(function() { if ($('.shop.sidebar-filter.in').length) { $('.algolia-apply').addClass('show'); } else { $('.algolia-apply').removeClass('show'); } }, function() { $('.algolia-apply').removeClass('show'); }); }); $('.algolia-apply').on('click', function(e) { e.preventDefault(); $('.shop.sidebar-filter.canvas-slid .ion-android-close').click(); }); $('body').on('show.bs.offcanvas', '.sidebar-filter', function(e) { $('.ais-current-refined-values--item').exists(function() { $('.algolia-apply').addClass('show'); }, function() { $('.algolia-apply').removeClass('show'); }); }); $('.shop.sidebar-filter').on('hide.bs.offcanvas', function(e) { $('.algolia-apply').removeClass('show'); }) }); function clearTypeRefinement() { search.helper.clearRefinements('taxonomies_hierarchical.type.lvl0').search(); }