Skip to content
Snippets Groups Projects
Commit 3a715311 authored by Eric Rasmussen's avatar Eric Rasmussen
Browse files

Split end-scripts.tpl.php into 4.1/5.0 versions because it contains CSS

parent c79982a6
No related branches found
No related tags found
No related merge requests found
......@@ -143,7 +143,7 @@ $maincontent .= renderTemplate($templatePath . 'search-results.tpl.php', array(
$initialQuery = json_encode(isset($_GET['q']) ? $_GET['q'] : '');
$context = json_encode($context);
$maincontent .= renderTemplate('templates/end-scripts.tpl.php', array(
$maincontent .= renderTemplate($templatePath . 'end-scripts.tpl.php', array(
'localScriptUrl' => $localScriptUrl,
'googleLoaderUrl' => 'https://cse.google.com/cse.js?cx=' . $search_engine_id,
'initialQuery' => $initialQuery,
......
<script>
require(['jquery', '<?php echo $localScriptUrl ?>'], function($, UNLSearch) {
var gSearchDefer = $.Deferred();
window.searchInit = function() {
window.searchInit = $.noop;
gSearchDefer.resolve(google);
};
window.__gcse = {
parsetags: 'explicit',
callback: window.searchInit
};
$('<script>', {
src: '<?php echo $googleLoaderUrl ?>',
async: 'async',
defer: 'defer',
type: 'text/javascript'
}).appendTo($('body'));
var $localCss = $('<link>', {
'href': './css/search-google.css?v=20170404'
});
gSearchDefer.done(function(google) {
// ensure this CSS is loaded AFTER google
require(['css!' + $localCss[0].href], function() {
UNLSearch.initialize(<?php echo $initialQuery ?>, <?php echo $localContext ?>)
});
});
});
</script>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment