Skip to content

Commit

Permalink
chore(*): add replacement script
Browse files Browse the repository at this point in the history
  • Loading branch information
dobromirts committed Apr 4, 2024
1 parent 6330cf2 commit 04a8f98
Show file tree
Hide file tree
Showing 2 changed files with 130 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/styles/appbuilder/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@
font-size: rem(14px) !important;
}

#LblacceptGDPRFormSubmission_2 > p {
display: block;
text-align: left;
padding: 0px;
white-space: normal;
}
.footer {
background: #282561 !important;
padding: 0;
Expand Down
125 changes: 124 additions & 1 deletion template/partials/head.tmpl.partial
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,130 @@ full license information.}}
<link rel='stylesheet' id='main-styles-css' href='https://staging.appbuilder.dev/wp-content/themes/slingshot/css/styles.css' media='all' />
<link href="https://fonts.googleapis.com/css?family=Figtree:300,400,700&amp;display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Nunito+Sans:wght@400;600;700&display=swap" rel="stylesheet">


<script>
var includeContent = (function() {
'use strict';

var domain = window.location.origin.includes('staging') || window.location.origin.includes('localhost') ? 'https://staging.appbuilder.dev' : 'https://www.appbuilder.dev';
var sourcesURL = `${domain}/header-footer-export`;

function _getContent(){
var request = new XMLHttpRequest();
request.open('GET', sourcesURL, true);
request.onload = function() {
if (request.status >= 200 && request.status < 400) {
var resp = request.responseText;
var parser = new DOMParser();
var htmlDoc = parser.parseFromString(resp, 'text/html');

_includeHeader(htmlDoc).then(
function(){
//Mega menu init
jQuery('.max-mega-menu').maxmegamenu();
}
).then(
function(){
//Search form toggle
document.querySelector('.mega-search .search-icon').onclick = function(){_siteSearchToggle()};
document.querySelector('.mega-search input[type=text]').onblur = function(){_siteSearchToggle()};
}
);
_includeFooter(htmlDoc).then(
//Contact sales form (in modal) init
function(){
var settings = {
macro: "LeadTracker",
lang: "en",
leadFormID: "lead-form_2",
reaptchaKey: "6Lc-MFAaAAAAAIWi7UOrSUfUZnVmDUSsXjzS4BgY",
redirectUrl: "",
thankYouMessage: "1",
formContainerId: "modal-contact-sales-pricing",
productCode: "B7",
leadProductCode: "",
packageName: "",
productResourceType: "",
osSupport: "",
installerType: "",
eventTypeParam: "contact sales",
eventDetailParam: "form submitted",
prohibitFreeMail: true,
showRequestDemo: false,
googleEventType: "Form Submit",
googleEventLabel: "Slingshot - Contact Sales Pricing",
googleEventTypeDownload: "",
googleEventLabelDownload: "",
zoomWebinarId: ""
};
leadTracker.execute(settings);
}
).then(
//Modal plugin init
customModal.init()
)
} else {}
};
request.onerror = function() {};
request.send();
}

async function _includeHeader(html){

//Header
//Removing "Demo request" modal (if exists)
if (typeof(html.getElementById('requestDemo')) != 'undefined' && html.getElementById('requestDemo') != null) {
html.getElementById('requestDemo').remove();
}

//Set header
document.querySelector('header').parentNode.replaceChild(html.querySelector('header'), document.querySelector('header'));
}

async function _includeFooter(html){
//Contact sales modal
document.body.append(html.getElementById('contactSales'));

//Footer
document.querySelector('footer').parentNode.replaceChild(html.querySelector('footer'), document.querySelector('footer'));
}

function _siteSearchToggle(e){

var form = document.querySelector('.mega-search'),
formInput = document.querySelector('.mega-search input[type=text]'),
searchIcon = document.querySelector('.mega-search .search-icon');

if ( form.classList.contains('mega-search-open') ) {
form.classList.remove('mega-search-open');
form.classList.add('mega-search-closed');
formInput.setAttribute('placeholder', '');
formInput.value = '';
formInput.setAttribute('tabindex', 0);

} else {
form.classList.remove('mega-search-closed');
form.classList.add('mega-search-open');
formInput.setAttribute('placeholder', 'Search...');
formInput.focus();
formInput.setAttribute('tabindex', -1);
}
}

function includeSources(){
_getContent();
}

return {
processInclude:includeSources
};
})();

window.addEventListener('load', function(){
includeContent.processInclude();
});

</script>
{{/_isAppBuilder}}

<link rel="stylesheet" href="{{_rel}}bundles/{{_globalStyle}}">
Expand Down

0 comments on commit 04a8f98

Please sign in to comment.