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,31 +72,6 @@
<script src="${resourceUrl}/node_modules/patternfly/dist/js/patternfly.min.js"></script>
<script src="${authUrl}/js/keycloak.js"></script>
<script>
var keycloak = Keycloak('${authUrl}/realms/${realm.name}/account/keycloak.json');
keycloak.init({onLoad: 'check-sso'}).success(function(authenticated) {
var loadjs = function (url,loadListener) {
const script = document.createElement("script");
script.src = resourceUrl + url;
if (loadListener) script.addEventListener("load", loadListener);
document.head.appendChild(script);
};
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() {
loadjs("/systemjs.config.js");
System.import('${resourceUrl}/main.js').catch(function (err) {
console.error(err);
});
if (!keycloak.authenticated) document.getElementById("signInButton").style.visibility='visible';
});
});
}).error(function() {
alert('failed to initialize keycloak');
});
</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.
-->
@ -113,8 +88,32 @@
</#list>
</#if>
</head>
<body>
<script>
var keycloak = Keycloak('${authUrl}/realms/${realm.name}/account/keycloak.json');
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() {
loadjs("/systemjs.config.js");
System.import('${resourceUrl}/main.js').catch(function (err) {
console.error(err);
});
if (!keycloak.authenticated) document.getElementById("signInButton").style.visibility='visible';
});
});
}).error(function() {
alert('failed to initialize keycloak');
});
</script>
<!-- Top Navigation -->
@ -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

@ -11,6 +11,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;
baseHref = baseHref.pathname;