-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(inline-script): Fix problem with inline script tag in safari
- Loading branch information
Showing
1 changed file
with
22 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,34 @@ | ||
<?php /** @var Magento\Framework\View\TemplateEngine\Php $this */ | ||
$helper = $this->helper('Idealpostcodes\Ukaddresssearch\Helper\Data'); | ||
|
||
$helper = $this->helper('Idealpostcodes\Ukaddresssearch\Helper\Data'); ?> | ||
|
||
<script type="text/javascript" name="Ideal_Postcodes"> | ||
document.addEventListener('DOMContentLoaded', function() { | ||
var apiKey = "<?php echo $helper->getConfig('api_key'); ?>"; | ||
var autocomplete = <?php echo $helper->getAdminConfig('addressAutocomplete'); ?>; | ||
var populateOrganisation = <?php echo $helper->getConfig('populateOrganisation'); ?>; | ||
var populateCounty = <?php echo $helper->getConfig('requireCounty'); ?>; | ||
var enabled = <?php echo $helper->getConfig('enabled'); ?>; | ||
var customFields = <?php echo trim(preg_replace('/\r|\n/', '',$helper->getConfig('customFields'))); ?>; | ||
|
||
$script = ' | ||
document.addEventListener(\'DOMContentLoaded\', function() { | ||
var apiKey = "' . $helper->getConfig('api_key') . '"; | ||
var postcodeLookup = ' . $helper->getConfig('postcodeLookup') . '; | ||
var autocomplete = ' . $helper->getConfig('addressAutocomplete') . '; | ||
var populateOrganisation = ' . $helper->getConfig('populateOrganisation') . '; | ||
var hoistCountry = ' . $helper->getConfig('hoistCountryField') . '; | ||
var populateCounty = ' . $helper->getConfig('requireCounty') . '; | ||
var autocompleteOverride = ' . $helper->getConfig('autocompleteOverride') . '; | ||
var postcodeLookupOverride = ' . $helper->getConfig('postcodeLookupOverride') . '; | ||
var enabled = ' . $helper->getConfig('enabled') . '; | ||
var customFields = ' . trim(preg_replace("/\r|\n/", "", $helper->getConfig('customFields'))) . '; | ||
// Exit early if disabled | ||
if (enabled === false) return; | ||
window.idpcConfig = { | ||
apiKey: apiKey, | ||
postcodeLookup: false, | ||
postcodeLookup: postcodeLookup, | ||
autocomplete: autocomplete, | ||
populateCounty: populateCounty, | ||
populateOrganisation: populateOrganisation, | ||
hoistCountry: false, | ||
hoistCountry: hoistCountry, | ||
autocompleteOverride: autocompleteOverride, | ||
postcodeLookupOverride: postcodeLookupOverride, | ||
customFields: customFields | ||
}; | ||
|
||
if (window.idpcStart) window.idpcStart(); | ||
window.idpcStart(); | ||
}); | ||
</script> | ||
'; | ||
|
||
$secureRenderer->renderTag('script', [], $script, false); | ||
?> |