mirror of
https://github.com/hacks-guide/Guide_3DS.git
synced 2025-08-31 20:21:49 +02:00
first rebase
ALSO: Remove fading on dropdown menu click. This is also a bug on the actual upstream, when the cursor leaves the screen the menu disappears but the fading doesn't. This causes things like the menu saying it's open when it's not and closed when open. I'm not dealing with an upstream bug.
This commit is contained in:
committed by
lifehackerhansol
parent
247e815186
commit
5641d7e51a
61
_includes/search/algolia-search-scripts.html
Normal file
61
_includes/search/algolia-search-scripts.html
Normal file
@@ -0,0 +1,61 @@
|
||||
<!-- Including InstantSearch.js library and styling -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/instantsearch.js@2.3.3/dist/instantsearch.min.js"></script>
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/instantsearch.js@2.3.3/dist/instantsearch.min.css">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/instantsearch.js@2.3.3/dist/instantsearch-theme-algolia.min.css">
|
||||
|
||||
<script>
|
||||
// Instanciating InstantSearch.js with Algolia credentials
|
||||
const search = instantsearch({
|
||||
appId: '{{ site.algolia.application_id }}',
|
||||
apiKey: '{{ site.algolia.search_only_api_key }}',
|
||||
indexName: '{{ site.algolia.index_name }}',
|
||||
searchParameters: {
|
||||
restrictSearchableAttributes: [
|
||||
'title',
|
||||
'content'
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
const hitTemplate = function(hit) {
|
||||
const url = hit.url;
|
||||
const title = hit._highlightResult.title.value;
|
||||
const content = hit._highlightResult.html.value;
|
||||
|
||||
return `
|
||||
<div class="list__item">
|
||||
<article class="archive__item" itemscope itemtype="https://schema.org/CreativeWork">
|
||||
<h2 class="archive__item-title" itemprop="headline"><a href="{{ site.baseurl }}${url}">${title}</a></h2>
|
||||
<div class="archive__item-excerpt" itemprop="description">${content}</div>
|
||||
</article>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
// Adding searchbar and results widgets
|
||||
search.addWidget(
|
||||
instantsearch.widgets.searchBox({
|
||||
container: '.search-searchbar',
|
||||
{% unless site.algolia.powered_by == false %}poweredBy: true,{% endunless %}
|
||||
placeholder: '{{ site.data.ui-text[site.locale].search_placeholder_text | default: "Enter your search term..." }}'
|
||||
})
|
||||
);
|
||||
search.addWidget(
|
||||
instantsearch.widgets.hits({
|
||||
container: '.search-hits',
|
||||
templates: {
|
||||
item: hitTemplate,
|
||||
empty: '{{ site.data.ui-text[site.locale].search_algolia_no_results | default: "No results" }}',
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
// Starting the search only when toggle is clicked
|
||||
$(document).ready(function () {
|
||||
$(".search__toggle").on("click", function() {
|
||||
if(!search.started) {
|
||||
search.start();
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
30
_includes/search/google-search-scripts.html
Normal file
30
_includes/search/google-search-scripts.html
Normal file
@@ -0,0 +1,30 @@
|
||||
<script>
|
||||
(function () {
|
||||
var cx = '{{ site.google.search_engine_id }}';
|
||||
var gcse = document.createElement('script');
|
||||
gcse.type = 'text/javascript';
|
||||
gcse.async = true;
|
||||
gcse.src = 'https://cse.google.com/cse.js?cx=' + cx;
|
||||
var s = document.getElementsByTagName('script')[0];
|
||||
s.parentNode.insertBefore(gcse, s);
|
||||
})();
|
||||
|
||||
function googleCustomSearchExecute() {
|
||||
var input = document.getElementById('cse-search-input-box-id');
|
||||
var element = google.search.cse.element.getElement('searchresults-only0');
|
||||
if (input.value == '') {
|
||||
element.clearAllResults();
|
||||
} else {
|
||||
element.execute(input.value);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
{% if site.google.instant_search %}
|
||||
$(document).ready(function () {
|
||||
$('input#cse-search-input-box-id').on('keyup', function () {
|
||||
googleCustomSearchExecute();
|
||||
});
|
||||
});
|
||||
{% endif %}
|
||||
</script>
|
10
_includes/search/lunr-search-scripts.html
Normal file
10
_includes/search/lunr-search-scripts.html
Normal file
@@ -0,0 +1,10 @@
|
||||
{% assign lang = site.locale | slice: 0,2 | default: "en" %}
|
||||
{% case lang %}
|
||||
{% when "gr" %}
|
||||
{% assign lang = "gr" %}
|
||||
{% else %}
|
||||
{% assign lang = "en" %}
|
||||
{% endcase %}
|
||||
<script src="{{ '/assets/js/lunr/lunr.min.js' | relative_url }}"></script>
|
||||
<script src="{{ '/assets/js/lunr/lunr-store.js' | relative_url }}"></script>
|
||||
<script src="{{ '/assets/js/lunr/lunr-' | append: lang | append: '.js' | relative_url }}"></script>
|
26
_includes/search/search_form.html
Normal file
26
_includes/search/search_form.html
Normal file
@@ -0,0 +1,26 @@
|
||||
<div class="search-content__inner-wrap">
|
||||
{%- assign search_provider = site.search_provider | default: "lunr" -%}
|
||||
{%- case search_provider -%}
|
||||
{%- when "lunr" -%}
|
||||
<form class="search-content__form" onkeydown="return event.key != 'Enter';">
|
||||
<label class="sr-only" for="search">
|
||||
{{ site.data.ui-text[site.locale].search_label_text | default: 'Enter your search term...' }}
|
||||
</label>
|
||||
<input type="search" id="search" class="search-input" tabindex="-1" placeholder="{{ site.data.ui-text[site.locale].search_placeholder_text | default: 'Enter your search term...' }}" />
|
||||
</form>
|
||||
<div id="results" class="results"></div>
|
||||
{%- when "google" -%}
|
||||
<form onsubmit="return googleCustomSearchExecute();" id="cse-search-box-form-id">
|
||||
<label class="sr-only" for="cse-search-input-box-id">
|
||||
{{ site.data.ui-text[site.locale].search_label_text | default: 'Enter your search term...' }}
|
||||
</label>
|
||||
<input type="search" id="cse-search-input-box-id" class="search-input" tabindex="-1" placeholder="{{ site.data.ui-text[site.locale].search_placeholder_text | default: 'Enter your search term...' }}" />
|
||||
</form>
|
||||
<div id="results" class="results">
|
||||
<gcse:searchresults-only></gcse:searchresults-only>
|
||||
</div>
|
||||
{%- when "algolia" -%}
|
||||
<div class="search-searchbar"></div>
|
||||
<div class="search-hits"></div>
|
||||
{%- endcase -%}
|
||||
</div>
|
Reference in New Issue
Block a user