-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathformio-script.staging.js
152 lines (148 loc) · 4.86 KB
/
formio-script.staging.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
else if(typeof define === 'function' && define.amd)
define([], factory);
else if(typeof exports === 'object')
exports["FormioScript"] = factory();
else
root["FormioScript"] = factory();
})(self, () => {
return /******/ (() => { // webpackBootstrap
/******/ "use strict";
/******/ // The require scope
/******/ var __webpack_require__ = {};
/******/
/************************************************************************/
/******/ /* webpack/runtime/define property getters */
/******/ (() => {
/******/ // define getter functions for harmony exports
/******/ __webpack_require__.d = (exports, definition) => {
/******/ for(var key in definition) {
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
/******/ }
/******/ }
/******/ };
/******/ })();
/******/
/******/ /* webpack/runtime/hasOwnProperty shorthand */
/******/ (() => {
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
/******/ })();
/******/
/******/ /* webpack/runtime/make namespace object */
/******/ (() => {
/******/ // define __esModule on exports
/******/ __webpack_require__.r = (exports) => {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/ })();
/******/
/************************************************************************/
var __webpack_exports__ = {};
// ESM COMPAT FLAG
__webpack_require__.r(__webpack_exports__);
// EXPORTS
__webpack_require__.d(__webpack_exports__, {
init: () => (/* binding */ init)
});
;// ./src/helpers/FormioScript/FormioScript.js
const defaultVersion = window.formioQldCdnVersion || "v2/v2.x.x-latest";
const createScripts = (scripts, i, mainResolve) => {
if (i > scripts.length - 1) {
FormioLoader.initFormio();
mainResolve();
return;
}
const {
type,
async,
src,
href,
rel
} = scripts[i];
if (!document.querySelector("".concat(type, "[src='").concat(src, "']")) && !document.querySelector("".concat(type, "[href='").concat(href, "']"))) {
const promise = new Promise(resolve => {
const elem = document.createElement(type);
if (async !== undefined) elem.setAttribute("async", async);
if (src !== undefined) elem.setAttribute("src", src);
if (href !== undefined) elem.setAttribute("href", href);
if (rel !== undefined) elem.setAttribute("rel", rel);
document.body.appendChild(elem);
elem.onload = () => {
console.info("FormioScript loaded:", src || href);
resolve();
};
});
promise.then(() => {
createScripts(scripts, i + 1, mainResolve);
});
} else {
createScripts(scripts, i + 1, mainResolve);
}
};
const getDefaultCdn = function () {
let subdomain = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "static";
let version = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultVersion;
return "https://".concat(subdomain, ".qgov.net.au/formio-qld/").concat(version);
};
const getDefaultScripts = baseUrl => {
return [{
type: "script",
src: "".concat(baseUrl, "/formio.full.js"),
async: false
}, {
type: "script",
src: "".concat(baseUrl, "/premium.min.js"),
async: false
}, {
type: "script",
src: "".concat(baseUrl, "/formio-qld.js"),
async: false
},
// note: formio-loader should always load last
{
type: "script",
src: "".concat(baseUrl, "/formio-loader.js"),
async: false
}, {
type: "link",
href: "".concat(baseUrl, "/formio.full.min.css"),
rel: "stylesheet"
}, {
type: "link",
href: "".concat(baseUrl, "/premium.css"),
rel: "stylesheet"
}, {
type: "link",
href: "".concat(baseUrl, "/formio-qld.min.css"),
rel: "stylesheet"
}];
};
const initScript = function (scripts) {
let cdn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
return new Promise(resolve => {
if (window.formioScriptLoaded) {
if (typeof FormioLoader !== "undefined") setTimeout(() => {
FormioLoader.initFormio(cdn);
resolve();
});
} else {
window.formioScriptLoaded = true;
createScripts(scripts, 0, resolve);
}
});
};
;// ./src/helpers/FormioScript/index.js
;// ./src/helpers/FormioScript/index.staging.js
const baseUrl = getDefaultCdn("beta-static");
const scripts = getDefaultScripts(baseUrl);
const init = () => initScript(scripts, baseUrl);
/******/ return __webpack_exports__;
/******/ })()
;
});