1// Curriculum Search 2function algoliaSearchCurriculumCompact(algoliaIndexName = "wp_curriculum") { 3 4 if (document.getElementById("algolia-searchbox--curriculum--compact") !== null) { 5 6 // Translation Object 7 var translationObject = translations_object_algolia_search_curriculum_compact; 8 9 const searchCurriculum = instantsearch({ 10 indexName: algoliaIndexName, 11 debug: true, 12 searchClient, 13 routing: true, 14 searchFunction(helper) { 15 const container = document.querySelector("#algolia-hits--curriculum--compact"); 16 container.style.display = helper.state.query === "" ? "none" : ""; 17 // Ensure we only trigger a search when there's a query 18 if (helper.state.query) { 19 helper.search(); 20 } 21 }, 22 }); 23 24 searchCurriculum.addWidgets([ 25 26 // Configure 27 instantsearch.widgets.configure({ 28 hitsPerPage: 12, 29 attributesToSnippet: ['content:20'], 30 }), 31 32 // Search Form 33 instantsearch.widgets.searchBox({ 34 container: "#algolia-searchbox--curriculum--compact", 35 placeholder: translationObject.placeholder_search, 36 showSubmit: false, 37 showPrevious: true, 38 sortBy: ['name:asc'], 39 }), 40 41 // Results 42 // Config & template 43 instantsearch.widgets.infiniteHits({ 44 container: "#algolia-hits--curriculum--compact", 45 escapeHTML: false, 46 templates: { 47 empty: translationObject.label_empty, 48 showMoreText: translationObject.label_more, 49 item: ` 50 <div class="learning-goal__postcard--mini learning-goal__postcard--mini--curriculum {{featured}}"> 51 52 {{#serial}} 53 <span class="serial"> 54 {{#helpers.highlight}} 55 { "attribute": "serial", "highlightedTagName": "mark" } 56 {{/helpers.highlight}} 57 </span> 58 {{/serial}} 59 60 {{#serial}} 61 <span class="title"> 62 <a href="{{ url }}" title="{{ title }}" class="is-highlighted"> 63 {{#helpers.highlight}} 64 { "attribute": "title", "highlightedTagName": "mark"} 65 {{/helpers.highlight}} 66 </a> 67 </span> 68 {{/serial}} 69 70 {{#subheader}} 71 <div class="subtitle is-highlighted"> 72 {{#helpers.highlight}} 73 { "attribute": "subheader", "highlightedTagName": "mark" } 74 {{/helpers.highlight}} 75 </div> 76 {{/subheader}} 77 78 </div> 79 `, 80 }, 81 }), 82 ]); 83 84 searchCurriculum.start(); 85 86 // Clear search query & results 87 function clearCurriculumSearch() { 88 searchCurriculum.helper.setQuery("").search; 89 // searchCurriculum.search; 90 // searchCurriculum.refresh(); 91 } 92 93 } 94} 95document.addEventListener('DOMContentLoaded', function () { 96 algoliaSearchCurriculumCompact('wp_curriculum'); 97}, false);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.