Skip to content

Commit

Permalink
"Search not found" translation to current viewing language. (#103)
Browse files Browse the repository at this point in the history
Merge pull request #103 from Voog/88_Search_noResults_translation
  • Loading branch information
SSirjes authored Apr 13, 2018
2 parents 002e0b4 + 58f48b3 commit c4630d1
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 14 deletions.
14 changes: 3 additions & 11 deletions components/javascripts.tpl
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
{% comment %}SITE WIDE JAVASCRIPTS{% endcomment %}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>
<script src="{{ javascripts_path }}/application.min.js?4"></script>
{% sitejs_include %}

{% comment %}Site search related javascript components.{% endcomment %}
{% if site.search.enabled %}
<script src="{{ site.static_asset_host }}/libs/edicy-search/latest/edicy-search.js"></script>
<script>
var search = new VoogSearch($('.js-search-form').get(0), {
per_page: 10,
lang: '{{ page.language_code }}',
resultsContainer: $('.js-voog-search-modal-inner').get(0),
sideclick: true,
mobileModeWidth: 480,
updateOnKeypress: false
});
</script>
<script>site.bindSiteSearch($('.js-search-form').get(0), '{{ page.language_code }}', '{{ 'search_noresults' | lc | escape }}');</script>
{% endif %}

{% comment %}GOOGLE ANALYTICS INITIATION{% endcomment %}
Expand Down
27 changes: 26 additions & 1 deletion javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -856,6 +856,30 @@ MMCQ = (function() {
};
};

// ===========================================================================
// Binds site search functionality.
// ===========================================================================
var bindSiteSearch = function(searchForm, languageCode, noResultsString) {
if (searchForm) {
var search = new VoogSearch(searchForm, {
// This defines the number of results per query.
per_page: 10,
// Language code for restricting the search to page language.
lang: languageCode,
// If given, an DOM element results are rendered inside that element
resultsContainer: $('.js-voog-search-modal-inner').get(0),
// Defines if modal should close on sideclick.
sideclick: true,
// Mobile checkpoint.
mobileModeWidth: 480,
// Updates results on every keypress.
updateOnKeypress: true,
// String for feedback if no results are found.
noResults: noResultsString
});
}
};

// Enables the usage of the initiations outside this file.
// For example add "<script>site.initBlogPage();</script>" at the end of the "Blog & News" page to initiate blog listing view functions.
window.site = $.extend(window.site || {}, {
Expand All @@ -866,7 +890,8 @@ MMCQ = (function() {
frontPageContentCoverBgPreview: frontPageContentCoverBgPreview,
frontPageContentCoverBgCommit: frontPageContentCoverBgCommit,
handleFrontPageContentCoverColorScheme: handleFrontPageContentCoverColorScheme,
bindCustomTexteditorStyles: bindCustomTexteditorStyles
bindCustomTexteditorStyles: bindCustomTexteditorStyles,
bindSiteSearch: bindSiteSearch
});

// Initiates site wide functions.
Expand Down
Loading

0 comments on commit c4630d1

Please sign in to comment.