").dxMenu( {
cssClass : "systemMenu",
items : systemMenuItems,
onItemClick : function( e ) {
let item = e.itemData;
if( ! item.id ) {
return;
}
if( item.id == "reportCenter" ) {
let reportCenterURL = `${portalDocRootURL}/apps/RPT/index.cfm`;
window.location.href = reportCenterURL;
return;
}
let popoverTarget = e.element;
if( item.id == "userProfile" ) {
popoverTarget = e.itemElement;
}
let popover = null;
let popoverConfig = {
hideOnOutsideClick : true,
target : popoverTarget,
width : 400,
enableBodyScroll : false,
contentTemplate : function() {
return contentElement;
},
onHidden : function( e ) {
e.component.element().remove();
e.component.dispose();
if( e.component === systemMenuPopover ) {
systemMenuPopover = null;
}
}
};
let contentElement = null;
let popoverContentWidget = null;
switch ( item.id ) {
case "search" :
item.showSearch();
break;
case "userProfile" :
popoverContentWidget = new UserProfileEditor();
// contentElement = userProfileEditor.element();
break;
case "runReports" :
popoverContentWidget = new RunReportsWidget();
// contentElement = runReportsWidget.element();
break;
case "viewReports" :
popoverContentWidget = new ViewReportsWidget();
$("#report-center-view-options-switch" ).removeClass( "finished");
// contentElement = viewReportsWidget.element();
break;
case "getHelp" :
window.location.href = $("link#PortalDocRootURL").attr( "href" ) + "/apps/ContactUs/index.cfm?view=getHelp";
break;
case "logout" :
if( confirm( "Are you sure you want to logout?" ) ) {
let logoffURL = $("link#PortalDocRootURL").attr( "href" ) + "/public/actions/logoff.cfm";
Fse.Portal.doLogoff( logoffURL );
}
break;
}
if( ! popoverContentWidget ) {
return;
}
contentElement = popoverContentWidget.element();
if( ! contentElement ) {
return;
}
if( systemMenuPopover ) {
systemMenuPopover.hide();
systemMenuPopover = null;
}
systemMenuPopover = $("
").dxPopover( popoverConfig ).appendTo( "body" ).dxPopover( "instance" );
popoverContentWidget.setContainer( systemMenuPopover );
systemMenuPopover.show();
}
}).dxMenu( "instance" );
let loadPromise = null;
let sessionUserId = sessionStorage.getItem( "userId" );
let sessionClientName = sessionStorage.getItem( "clientName" );
let navigationJSON = sessionStorage.getItem( "navigationJSON" );
if( userData.userId != sessionUserId || userData.clientName != sessionClientName ) {
navigationJSON = null;
sessionStorage.removeItem( "navigationJSON" );
sessionStorage.removeItem( "userId" );
sessionStorage.removeItem( "clientName" );
sessionStorage.removeItem( "stpNavigation" );
}
if( ! navigationJSON ) {
loadPromise = ( new DevExpress.data.DataSource( navigationURL ) ).load();
loadPromise.done( function( navigationItems ) {
//console.log( 1 );
let navigationJSON = JSON.stringify( navigationItems );
sessionStorage.setItem( "navigationJSON", navigationJSON );
sessionStorage.setItem( "userId", userData.userId );
sessionStorage.setItem( "clientName", userData.clientName );
})
} else {
loadPromise = $.Deferred();
loadPromise.resolve( JSON.parse( navigationJSON ) )
}
loadPromise.done( function( navigationItems ) {
let maxItems = Fse.Portal.appConfiguration.STP.navigationMaxItems;
let menuItems = [];
let moreItems = [];
let setParentItem = function( i ) {
if( i.items ) {
for( let x = 0; x < i.items.length; x++ ) {
i.items[x].parentItem = i;
setParentItem( i.items[x] );
}
}
}
navigationItems.forEach( function( i ) {
i.parentItem = null;
setParentItem( i )
} );
for( let x = 0; x < navigationItems.length; x++ ) {
// home page
if( navigationItems[x].uri === "/welcome.cfm" ) {
continue;
}
// report center
if( navigationItems[x].uri === "/apps/RPT/index.cfm" ) {
// decision was to include in the menu as well as the system menu
// continue;
}
if( menuItems.length < maxItems ) {
menuItems.push( navigationItems[x] );
} else {
moreItems.push( navigationItems[x] );
}
}
if( moreItems.length ) {
let more = {
text : "More",
items : moreItems
}
more.items.forEach( function( mi ) {
mi.parentItem = more;
})
menuItems.push( more );
}
menu.option( {
"items" : menuItems,
"selectedItem" : moreItems[0]
});
let findNavigation = function( menuItems ) {
let foundItem = null;
for( let nx = 0; nx < menuItems.length && ! foundItem; nx++ ) {
let item = menuItems[nx];
if( item.items ) {
foundItem = findNavigation( item.items );
}
if( ! foundItem ) {
let menuSelectionRegExp = null;
if( /^re:/.test( item.menuSelectionCode ) ) {
try {
menuSelectionRegExp = new RegExp( item.menuSelectionCode.replace( /^re:/, '' ), "i" );
} catch( t ) {}
} else if ( item.uri ) {
//console.log( item.uri );
try {
// let regExpSrc = item.uri.replace( /\//g, '\\/' );
// regExpSrc = regExpSrc.replace( /\?/, '\\?' );
let regExpSrc = item.uri.replace( /[.*+?^${}()|[\]\\]/g, '\\$&' );
menuSelectionRegExp = new RegExp( regExpSrc, "i" );
} catch( t ) {
}
}
if( menuSelectionRegExp ) {
try {
if( menuSelectionRegExp.test( window.location.href ) ) {
// this is the current matching menu item
foundItem = item;
}
} catch( t ) {}
}
}
}
return foundItem;
}
let currentItem = findNavigation( navigationItems );
if( currentItem ) {
let menuTrail = [];
buildMenuTrail = function( menuItem ) {
menuTrail.unshift( menuItem.text );
if( menuItem.parentItem ) {
buildMenuTrail( menuItem.parentItem );
}
}
buildMenuTrail( currentItem );
sessionStorage.setItem( "stpNavigation", JSON.stringify( menuTrail ));
updateMenuTrail();
let selectedItem = currentItem;
while( selectedItem.parentItem ) {
selectedItem = selectedItem.parentItem;
}
menu.option( { "selectedItem" : selectedItem, "selectionMode" : "single" } );
} else {
console.log( "Navigation NOT FOUND" );
}
})
let headerToolbarItems = [
{
location : "before",
template : function() {
return $("
![]()
").attr( {
"src" : `${portalDocRootURL}/resources/stp-clean/graphics/Sales-Enablement-Logo.svg`
} ).
css( {
"display" : "block",
// "height" : "90px",
"height" : "87px",
"margin-left" : "-65px",
"margin-top" : "-12px"
});
}
}
];
let floatingNotice = $("
").css( {
"position" :"absolute",
"left" : "32px",
"top" : "47px"
});
let showFloatingNotice = false;
let showNavigation = $("meta[name='stp-mode']").attr( "content" ) == "standard";
let environment = $("meta[name='stp-environment']").attr( "content" );
if( environment === "DEVELOPMENT" ) {
showFloatingNotice = true;
floatingNotice.append( $("
").text( 'DEVELOPMENT' ).css( { "font-size" : "14px", "color" : "red", "padding-right" : "10px" } ));
}
if( Fse.Portal.appConfiguration.STP.loginEmailAddress !== Fse.Portal.appConfiguration.STP.userEmailAddress ) {
showFloatingNotice = true;
floatingNotice.append( $("").text( `${Fse.Portal.appConfiguration.STP.loginEmailAddress}/${Fse.Portal.appConfiguration.STP.userEmailAddress}` ).css( { "color" : "red" } ));
}
if( showFloatingNotice ) {
$("body").append( floatingNotice );
}
headerToolbarItems.push(
{
location : "after",
template : function() {
let clientLogoPath = userData.clientLogoPath;
clientLogoPath = clientLogoPath.replace( /^http\:/i, 'https:' );
clientLogoPath = clientLogoPath.replace( /images\.fsenablers\.com/i, 'appslibrary.com/images' );
let pathParts = clientLogoPath.split( "." );
let filePartIdx= pathParts.length - 2;
let lastPart = pathParts[pathParts.length-2];
pathParts[filePartIdx] = `${pathParts[filePartIdx]}_100`;
clientLogoPath = pathParts.join( "." );
let logoCSS = {
"display" : "block",
"max-height" : "50px"
};
let clientLogo = $("
").attr( {
"src" : clientLogoPath,
} )
.css( logoCSS );
let logoContainerCSS = {
"padding-right" : "25px",
"display" : "flex",
"align-items" : "center",
"justify-content" : "center",
"border-right-width" : "1px",
"border-right-style" : "solid",
"height" : "68px"
}
return $("").append ( clientLogo ).css( logoContainerCSS ).addClass( "dx-theme-border-color" )
}
})
if( showNavigation ) headerToolbarItems.push(
{
location : "after",
template : function() {
let sMyRelationshipsDataURL = $("link#PortalDocRootURL").attr("href") + "/data.cfm?object=crm.myRelationships";
let myRelationshipsDataSource = new DevExpress.data.DataSource( sMyRelationshipsDataURL );
/* select box implementation */
let accountContainer = $("
").css( "padding-left", "25px ")
.append(
$("
").dxSelectBox( {
placeholder : "-- Select Account --",
dataSource : myRelationshipsDataSource,
width : 250,
// height : 21,
displayExpr : "text",
valueExpr : "value",
onSelectionChanged : function( e ) {
if( e.selectedItem && e.selectedItem.value != "?" ) {
let handled = Fse.CRM.viewProfile( e.selectedItem.value );
if( handled ) {
setTimeout( function() {
e.component.option( "value", null );
}, 10 );
} else {
window.location.href = e.selectedItem.value;
}
}
}
} )
)
return accountContainer;
}
},
{
location : "after",
template : function() {
return systemMenu.element();
}
}
);
let headerToolbar = $("
").dxToolbar( {
height : 68,
items : headerToolbarItems
});
let menuToolbar = $("
").dxToolbar( {
xheight : 40,
items : [
{
location : "before",
template : function() {
return $("
").addClass( "dx-icon-home").css( { "cursor" : "pointer", "font-size" : "20px", "display" : "inline-block", "margin-top" : "2px" } )
.on( "click", function() {
window.location.href = homeURL;
} )
}
},
{
location : "before",
template : function() {
return menu.element();
}
}
]
})
let breadcrumbToolbar = $("").dxToolbar( {
items : [
{ location : "before",
template : function() {
updateMenuTrail();
return trail;
}
}
]
})
let breadcrumbSectionCSS = {
"height" : "32px",
"padding-top" : "6px",
"background-color" : "#F6F7F8",
"border-bottom-width" : "1px",
"border-bottom-style" : "solid",
"padding-left" : "42px"
}
breadcrumbSectionCSS["border-bottom"] = "none";
breadcrumbSectionCSS["padding-top"] = "unset";
breadcrumbSectionCSS["height"] = "10px";
let toolbarCSS = {
"padding-left" : "10px"
};
if( showNavigation ) {
toolbarCSS["padding-right"] = "20px";
}
$("#titleContainer")
.append( headerToolbar.css( toolbarCSS ) );
if( showNavigation ) $("#titleContainer")
.append( $("
").css( {
"border-top-width": "1px",
"border-top-style" : "solid",
"border-bottom-width": "1px",
"border-bottom-style" : "solid",
"height" : "auto",
"padding-top" : "5px",
"padding-bottom" : "7px",
"xpadding-bottom" : "auto",
"padding-left" : "28px"
} ).addClass( "dx-theme-border-color" ).append( menuToolbar ))
.append( $("
").css( breadcrumbSectionCSS ).addClass( "dx-theme-border-color" )
// .append( breadcrumbToolbar.css( { "background" : "transparent" } ) )
)
$("#primaryContainer").css( { "visibility" : "visible" });
}) }) });