This repository has been archived by the owner on Jun 29, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* demo page ie fixes * no message * no message * no message * no message * ie11 check * review fix for port * review comment
- Loading branch information
Showing
1 changed file
with
47 additions
and
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,59 @@ | ||
(function() { | ||
const root = window.location.pathname.split("demos").shift(); | ||
const CSS = ["demos/demos.css", "build/calcite-app.css", "vendor/@esri/calcite-components/calcite.css"]; | ||
|
||
const SCRIPTS = [ | ||
{ | ||
src: "build/calcite-app.esm.js", | ||
type: "module" | ||
}, | ||
{ | ||
src: "build/calcite-app.js", | ||
noModule: true | ||
}, | ||
{ | ||
src: "vendor/@esri/calcite-components/calcite.esm.js", | ||
type: "module" | ||
}, | ||
{ | ||
src: "vendor/@esri/calcite-components/calcite.js", | ||
noModule: true | ||
} | ||
]; | ||
|
||
// Assume server is running in a development environment if there is a port present in the URL and reload demo pages. | ||
if (location.port) { | ||
SCRIPTS.push({ | ||
src: "demos/demoPageReloader.js" | ||
}); | ||
} | ||
|
||
const IS_IE11 = /Trident.*rv[ :]*11\./.test(navigator.userAgent); | ||
|
||
if (!IS_IE11) { | ||
SCRIPTS.push({ | ||
src: "demos/toggles.js" | ||
}); | ||
} | ||
|
||
const ROOT = window.location.pathname.split("demos").shift(); | ||
|
||
function loadCss(url) { | ||
let link = document.createElement("link"); | ||
link.rel = "stylesheet"; | ||
link.href = root + url; | ||
link.href = ROOT + url; | ||
document.head.appendChild(link); | ||
} | ||
|
||
function loadScript(url, options) { | ||
let script = document.createElement("script"); | ||
if (options) { | ||
Object.keys(options).forEach(function(key) { | ||
script[key] = options[key]; | ||
}); | ||
} | ||
script.src = root + url; | ||
function loadScript(options) { | ||
let scriptElement = document.createElement("script"); | ||
|
||
Object.keys(options).forEach(function(key) { | ||
scriptElement[key] = key === "src" ? ROOT + options[key] : options[key]; | ||
}); | ||
|
||
document.head.appendChild(script); | ||
document.head.appendChild(scriptElement); | ||
} | ||
|
||
loadCss("demos/demos.css"); | ||
loadCss("build/calcite-app.css"); | ||
loadCss("vendor/@esri/calcite-components/calcite.css"); | ||
loadScript("demos/demoPageReloader.js"); | ||
loadScript("demos/toggles.js"); | ||
loadScript("build/calcite-app.esm.js", { type: "module" }); | ||
loadScript("build/calcite-app.js", { noModule: true }); | ||
loadScript("vendor/@esri/calcite-components/calcite.esm.js", { type: "module" }); | ||
loadScript("vendor/@esri/calcite-components/calcite.js", { noModule: true }); | ||
CSS.forEach(loadCss); | ||
SCRIPTS.forEach(loadScript); | ||
})(); |