var customHeader = {};
(function() {
this.context;
this.favIconURL = 'https://www.pepperi.com/wp-content/uploads/2019/05/MyBrandFavicon.png';
this.pageTitle = 'Welcome to BeautyBrands!';
this.userName;
this.setHtml = function() {
console.log("start setHtml");
var str = `
`;
return str; //"
Custom Header
";
}
this.initPlugin = function() {
var options = {
JsURLs: [
],
cssURLs: [
],
favIcon: this.favIconURL,
pageTitle: this.pageTitle,
};
return options;
}
this.onPluginLoad = function(context) {
this.context = context;
const { userName } = context;
this.userName = userName;
this.userNameFunction();
}
// window.onload = function() {
// document.getElementById("userNameText").innerHTML = customHeader.context.userName
// }
this.userNameFunction = function() {
setInterval(function() { document.getElementById("userNameText").innerHTML = customHeader.context.userName }, 1000);
}
this.logout = function() {
var event = new CustomEvent('logout');
if (document.createEvent) {
window.dispatchEvent(event);
} else {
window.fireEvent("on" + event.eventType, event);
}
}
this.changePassword = function() {
window.location.href = 'https://idp.pepperi.com/Account/ChangePassword';
};
this.pepperiHelp = function() {
window.location.href = "https://support.pepperi.com/hc/en-us"
}
this.closeHamburgerMenu = function() {
$('#myDropdown').toggleClass('show').focus()
}
customHeader.navigation = function(path) {
this.closeAllMenusListener();
var eventData = {
detail: {
path: path,
},
};
var event = new CustomEvent("navigateTo", eventData);
if (document.createEvent) {
window.dispatchEvent(event);
} else {
window.fireEvent("on" + event.eventType, event);
}
};
this.closeAllMenusListener = function() {
$('#myDropdown').attr('tabindex', '-1');
$('#myDropdown').on('focusout', function() {
$('#myDropdown').removeClass('show');
});
};
}).apply(customHeader);