-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds Canvas and ensures loading order
Stylesheets are loaded in the following order: * Vendor * Commons * Current Application * Those defined in uiExports.styleSheetPaths Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co>
- Loading branch information
Tyler Smalley
committed
Sep 17, 2018
1 parent
f231a14
commit d511971
Showing
6 changed files
with
54 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,58 @@ | ||
window.onload = function () { | ||
var files = [ | ||
'{{bundlePath}}/vendors.style.css', | ||
'{{bundlePath}}/commons.style.css', | ||
'{{bundlePath}}/{{appId}}.style.css', | ||
|
||
'{{bundlePath}}/vendors.bundle.js', | ||
'{{bundlePath}}/commons.bundle.js', | ||
'{{bundlePath}}/{{appId}}.bundle.js' | ||
]; | ||
|
||
var failure = function () { | ||
// make subsequent calls to failure() noop | ||
failure = function () {}; | ||
|
||
var err = document.createElement('h1'); | ||
err.style['color'] = 'white'; | ||
err.style['font-family'] = 'monospace'; | ||
err.style['text-align'] = 'center'; | ||
err.style['background'] = '#F44336'; | ||
err.style['padding'] = '25px'; | ||
err.innerText = '{{i18n 'common.ui.welcomeError' '{"defaultMessage": "Kibana did not load properly. Check the server output for more information."}'}}'; | ||
|
||
document.body.innerHTML = err.outerHTML; | ||
} | ||
|
||
function loadStyleSheet(path) { | ||
var dom = document.createElement('link'); | ||
|
||
dom.addEventListener('error', failure); | ||
dom.setAttribute('rel', 'stylesheet'); | ||
dom.setAttribute('href', path); | ||
document.head.appendChild(dom); | ||
} | ||
|
||
function createJavascriptElement(path) { | ||
var dom = document.createElement('script'); | ||
|
||
dom.setAttribute('async', ''); | ||
dom.addEventListener('error', failure); | ||
dom.setAttribute('src', file); | ||
dom.addEventListener('load', next); | ||
document.head.appendChild(dom); | ||
} | ||
|
||
{{#each styleSheetPaths}} | ||
files.unshift('{{this}}'); | ||
loadStyleSheet('{{this}}'); | ||
{{/each}} | ||
|
||
(function next() { | ||
var file = files.shift(); | ||
if (!file) return; | ||
|
||
var failure = function () { | ||
// make subsequent calls to failure() noop | ||
failure = function () {}; | ||
var dom = document.createElement('script'); | ||
|
||
var err = document.createElement('h1'); | ||
err.style['color'] = 'white'; | ||
err.style['font-family'] = 'monospace'; | ||
err.style['text-align'] = 'center'; | ||
err.style['background'] = '#F44336'; | ||
err.style['padding'] = '25px'; | ||
err.innerText = '{{i18n 'common.ui.welcomeError' '{"defaultMessage": "Kibana did not load properly. Check the server output for more information."}'}}'; | ||
|
||
document.body.innerHTML = err.outerHTML; | ||
} | ||
|
||
var type = /\.js(\?.+)?$/.test(file) ? 'script' : 'link'; | ||
var dom = document.createElement(type); | ||
dom.setAttribute('async', ''); | ||
dom.addEventListener('error', failure); | ||
|
||
if (type === 'script') { | ||
dom.setAttribute('src', file); | ||
dom.addEventListener('load', next); | ||
document.head.appendChild(dom); | ||
} else { | ||
dom.setAttribute('rel', 'stylesheet'); | ||
dom.setAttribute('href', file); | ||
document.head.appendChild(dom); | ||
next(); | ||
} | ||
dom.setAttribute('src', file); | ||
dom.addEventListener('load', next); | ||
document.head.appendChild(dom); | ||
}()); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters