forked from mmistakes/minimal-mistakes
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement feature mmistakes#1652 google custom search support. (mmist…
…akes#1667) Implement feature mmistakes#1652 google custom search support. For now we only support the look and feel "results only" and the engine must be set to use that layout. Add a google section to the search providers and search_form and search layout. Close mmistakes#1652
- Loading branch information
Showing
5 changed files
with
52 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters