KEYCLOAK-7248: Fixes for IE 11 (#5182)

This commit is contained in:
Stan Silvert 2018-05-02 16:15:31 -04:00 committed by GitHub
parent 90e5c7f3eb
commit 20f24bffc4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 37 additions and 31 deletions

View file

@ -3,6 +3,11 @@
<head>
<title>${msg("accountManagementTitle")}</title>
<meta charset="UTF-8">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta name="robots" content="noindex, nofollow">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script>
var authUrl = '${authUrl}';
var baseUrl = '${baseUrl}';
@ -33,11 +38,6 @@
<base href="${baseUrl}/">
<meta charset="UTF-8">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta name="robots" content="noindex, nofollow">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" href="${resourceUrl}/app/assets/img/favicon.ico" type="image/x-icon"/>
<!-- PatternFly -->
@ -72,15 +72,34 @@
<script src="${resourceUrl}/node_modules/patternfly/dist/js/patternfly.min.js"></script>
<script src="${authUrl}/js/keycloak.js"></script>
<!-- TODO: We should save these css and js into variables and then load in
main.ts for better performance. These might be loaded twice.
-->
<#if properties.styles?has_content>
<#list properties.styles?split(' ') as style>
<link href="${resourceUrl}/${style}" rel="stylesheet"/>
</#list>
<a href="../../../../../../../../keycloak-quickstarts/app-profile-jee-html5/src/main/webapp/index.html"></a>
</#if>
<#if properties.scripts?has_content>
<#list properties.scripts?split(' ') as script>
<script type="text/javascript" src="${resourceUrl}/${script}"></script>
</#list>
</#if>
</head>
<body>
<script>
var keycloak = Keycloak('${authUrl}/realms/${realm.name}/account/keycloak.json');
keycloak.init({onLoad: 'check-sso'}).success(function(authenticated) {
var loadjs = function (url,loadListener) {
var loadjs = function (url,loadListener) {
const script = document.createElement("script");
script.src = resourceUrl + url;
if (loadListener) script.addEventListener("load", loadListener);
document.head.appendChild(script);
};
keycloak.init({onLoad: 'check-sso'}).success(function(authenticated) {
loadjs("/node_modules/core-js/client/shim.min.js", function(){
loadjs("/node_modules/zone.js/dist/zone.min.js");
loadjs("/node_modules/systemjs/dist/system.src.js", function() {
@ -97,26 +116,6 @@
</script>
<!-- TODO: We should save these css and js into variables and then load in
main.ts for better performance. These might be loaded twice.
-->
<#if properties.styles?has_content>
<#list properties.styles?split(' ') as style>
<link href="${resourceUrl}/${style}" rel="stylesheet"/>
</#list>
<a href="../../../../../../../../keycloak-quickstarts/app-profile-jee-html5/src/main/webapp/index.html"></a>
</#if>
<#if properties.scripts?has_content>
<#list properties.scripts?split(' ') as script>
<script type="text/javascript" src="${resourceUrl}/${script}"></script>
</#list>
</#if>
</head>
<body>
<!-- Top Navigation -->
<nav class="navbar navbar-pf-alt">
@ -151,7 +150,7 @@
<!--Top Nav -->
<!-- Home Page --->
<!-- Home Page -->
<div class="cards-pf" id="welcomeScreen">
<div class="text-center">
@ -232,8 +231,8 @@
<script>
var winHash = window.location.hash;
if (winHash.startsWith('#/') && !winHash.startsWith('#/&state')) {
document.getElementById("welcomeScreen").style.visibility='hidden';
if ((winHash.indexOf('#/') == 0) && (!winHash.indexOf('#/&state') == 0)) {
document.getElementById("welcomeScreen").style.display='none';
}
</script>

View file

@ -54,7 +54,9 @@ export class AppComponent implements MenuClickListener {
if (navEnd.url !== '/') {
this.showSideNav = true;
var welcomeScreen = document.getElementById('welcomeScreen')
if (welcomeScreen) welcomeScreen.remove();
// must use removeChild() -- remove() not available on IE 11
if (welcomeScreen) welcomeScreen.parentNode.removeChild(welcomeScreen);
}
}
});

View file

@ -10,6 +10,11 @@ module.exports.translate = function(load){
basePathParts.pop();
var basePath = basePathParts.join('/');
// basePath leaves out leading slash on IE 11
if (!basePath.startsWith('/')) {
basePath = '/' + basePath;
}
var baseHref = document.createElement('a');
baseHref.href = this.baseURL;