When you play with the google CSE by removing various things via CSS happens that the placeholder could be "undefined".
The timewait or onload are not working correctly and just a workaround.
After your usual script part to include GCSE
gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//cse.google.com/cse.js?cx=' + cx;
put this part
I found the script part on github.
https://github.com/mongodb/docs-tools/blob/master/themes/mms-onprem/page.html
Thank you to mongodb!
The timewait or onload are not working correctly and just a workaround.
After your usual script part to include GCSE
gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//cse.google.com/cse.js?cx=' + cx;
put this part
gcse.onload = gcse.onreadystatechange = function() {
$(function() {
// hack to set a placeholder in google's custom search input
var pollInput = window.setInterval(function() {
var $input = $('.gsc-input input.gsc-input'),
$div = $('.search-db');
if ($input.length) {
$input.on('focus', function(e) { $div.addClass('wide').removeClass('narrow'); });
$input.on('blur', function(e) {
if (!$input.val().length) { $div.addClass('narrow').removeClass('wide'); }
});
$input.attr('placeholder', "");
window.clearInterval(pollInput);
}
}, 10);
});
};
I found the script part on github.
https://github.com/mongodb/docs-tools/blob/master/themes/mms-onprem/page.html
Thank you to mongodb!
Comments
Post a Comment