Skip to content
This repository has been archived by the owner on Dec 9, 2024. It is now read-only.

Commit

Permalink
Merge pull request #52 from zarathustra323/defer-nativex
Browse files Browse the repository at this point in the history
  • Loading branch information
zarathustra323 authored Mar 23, 2021
2 parents 2a1763f + 286ec68 commit db8bca3
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 11 deletions.
31 changes: 21 additions & 10 deletions packages/marko-web-native-x/components/init.marko
Original file line number Diff line number Diff line change
@@ -1,18 +1,29 @@
import { warn } from "@parameter1/base-cms-utils";

$ const { uri, enabled } = input;
$ const { uri, enabled, on } = input;
$ const src = "https://cdn.parameter1.com/native-x/1.0.0-rc.4.3.js";

<if(uri)>
<if(enabled)>
<script>
(function (i, s, o, g, r, a, m) {
i['FortnightObject'] = r; i[r] = i[r] || function () {
(i[r].q = i[r].q || []).push(arguments)
}, a = s.createElement(o),
m = s.getElementsByTagName(o)[0]; a.async = 1; a.src = g; a.crossOrigin = 'anonymous'; m.parentNode.insertBefore(a, m)
})(window, document, 'script', 'https://cdn.parameter1.com/native-x/1.0.0-rc.4.3.js', 'fortnight');
fortnight('init', { domain: '${uri}' });
</script>
<if(on)>
<marko-web-deferred-script-loader-register
name="fortnight"
src=src
on=on
init="var i = window, r = 'fortnight'; i['FortnightObject'] = r; i[r] = i[r] || function() { (i[r].q = i[r].q || []).push(arguments); };"
/>
</if>
<else>
<script>
(function (i, s, o, g, r, a, m) {
i['FortnightObject'] = r; i[r] = i[r] || function () {
(i[r].q = i[r].q || []).push(arguments)
}, a = s.createElement(o),
m = s.getElementsByTagName(o)[0]; a.async = 1; a.src = g; a.crossOrigin = 'anonymous'; m.parentNode.insertBefore(a, m)
})(window, document, 'script', '${src}', 'fortnight');
</script>
</else>
<script>fortnight('init', { domain: '${uri}' });</script>
</if>
</if>
<else>
Expand Down
3 changes: 2 additions & 1 deletion packages/marko-web-native-x/components/marko.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"<marko-web-native-x-init>": {
"template": "./init.marko",
"@uri": "string",
"@enabled": "boolean"
"@enabled": "boolean",
"@on": "string"
},
"<marko-web-native-x-retrieve>": {
"template": "./retrieve.marko",
Expand Down
1 change: 1 addition & 0 deletions packages/marko-web-native-x/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"test": "yarn compile && yarn lint"
},
"dependencies": {
"@parameter1/base-cms-marko-web-deferred-script-loader": "^2.9.0",
"@parameter1/base-cms-object-path": "^2.5.0",
"@parameter1/base-cms-utils": "^2.4.2",
"node-fetch": "^2.6.1"
Expand Down

0 comments on commit db8bca3

Please sign in to comment.