'; var typesOrder = ['Rings','Earrings','Bracelets & Bangles','Lockets','Necklaces','Pendants','Brooches','Chains','Seals','Charms','Curiosities','Men\'s Jewellery']; function compareTypes(a,b) { aPos = typesOrder.indexOf(a.name); bPos = typesOrder.indexOf(b.name); if(a.isRefined && !b.isRefined) return -1 else if(!a.isRefined && b.isRefined) return 1 else if(aPos > bPos) return 1; else return -1; } // period search.addWidget( instantsearch.widgets.refinementList({ container: '#period', attributeName: 'taxonomies.period', templates: { header: 'By Period', item: ' {{name}}{{count}} ' } }) ); // material search.addWidget( instantsearch.widgets.refinementList({ container: '#materials', attributeName: 'taxonomies.material', templates: { header: 'By Material', item: ' {{name}}{{count}} ' }, limit: 10, showMore: true, sortBy: compareMaterials }) ); var materialsOrder = ['Metals','Gold','Platinum','Silver','Iron & Cut Steel','Precious Stones','Diamond','Sapphire','Emerald','Ruby','Semi-Precious Stones']; function compareMaterials(a,b) { //console.log(new Date().getTime()); aPos = materialsOrder.indexOf(a.name); bPos = materialsOrder.indexOf(b.name); if(a.isRefined && !b.isRefined){ return -1 } else if(!a.isRefined && b.isRefined){ return 1; } else if(aPos == -1 && bPos == -1){ if(a.count >= b.count) return -1; else return 1; } else if(aPos == -1){ return 1; } else if(bPos == -1){ return -1; } else if(aPos > bPos){ return 1; } else{ return -1; } } // ring style search.addWidget( instantsearch.widgets.refinementList({ container: '#ring-styles', attributeName: 'taxonomies.ring-styles', templates: { header: 'By Ring Style', item: ' {{name}}{{count}} ' }, limit: 20, showMore: true }) ); // ring central stone search.addWidget( instantsearch.widgets.refinementList({ container: '#ring-central-stone', attributeName: 'taxonomies.ring-central-stone', templates: { header: 'By Central Stone', item: ' {{name}}{{count}} ' }, limit: 4, showMore: true }) ); //ajc_p_status search.addWidget( instantsearch.widgets.refinementList({ container: '#item_stat', attributeName: 'ajc_p_status', sortBy: ['name:asc'], templates: { item: ' {{name}}{{count}} ' } }) ); //olly picks search.addWidget( instantsearch.widgets.refinementList({ container: '#ollypicks', attributeName: 'taxonomies.ollys-picks', templates: { item: ' {{name}}{{count}} ' } }) ); var rsInterval = null; var onRenderHandlerOnce = function() { //keep price rangeslider in sync with selected currency $('.ais-range-slider--target').on('pointerdown', function() { //console.log('pointer down'); rsInterval = setInterval("$('body').trigger('wc_currency_converter_calculate')",10); }); $('.ais-range-slider--target').on('pointerup', function(){ //console.log('pointer up'); $('body').trigger('wc_currency_converter_calculate'); clearInterval(rsInterval); }); }; var firstRender = true; var onRenderHandler = function() { clearInterval(rsInterval); $('body').trigger('wc_currency_converter_calculate'); if(!firstRender && $('body').scrollTop() > 220) $('body').scrollTop(220); firstRender = false; //console.log(search.helper.lastResults.nbPages); if(search.helper.lastResults.nbPages <= 1) { $('div.pagination').hide(); } else { $('div.pagination').show(); } jQuery('.algolia-results-promo').remove(); //Shop //jQuery( '