This repository has been archived by the owner on Jul 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
haxcms-editor-builder.html
66 lines (61 loc) · 2.27 KB
/
haxcms-editor-builder.html
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
<link rel="import" href="../polymer/polymer.html">
<!--
`haxcms-editor-builder`
Figure out what our context is and setup based on that
@demo demo/index.html
@microcopy - the mental model for this element
- something called us asking to provide an authoring solution
- we need to decide based on environment if this supports php, beaker or none
-->
<dom-module id="haxcms-editor-builder">
<script>
Polymer.cmsSiteEditor = Polymer({
is: 'haxcms-editor-builder',
/**
* created life cycle
*/
ready: function() {
this.getContext();
},
/**
* Try to get context of what backend is powering this
*/
getContext: function () {
let context = '';
Polymer.cmsSiteEditor.tag = 'haxcms-jwt';
// figure out if we need to load the PHP or beaker
if (typeof DatArchive !== typeof undefined) {
context = this.importHref(this.resolveUrl('haxcms-beaker.html'), (e) => {
Polymer.cmsSiteEditor.tag = 'haxcms-beaker';
});
}
else {
context = this.importHref(this.resolveUrl('haxcms-jwt.php'), (e) => {
Polymer.cmsSiteEditor.tag = 'haxcms-jwt';
});
}
return context;
}
});
// store reference to the instance as a global
Polymer.cmsSiteEditor.instance = null;
// self append if anyone calls us into action
Polymer.cmsSiteEditor.requestAvailability = function (element = this, location = document.body) {
if (!Polymer.cmsSiteEditor.instance) {
Polymer.cmsSiteEditor.instance = document.createElement(Polymer.cmsSiteEditor.tag);
Polymer.cmsSiteEditor.instance.appElement = element;
Polymer.cmsSiteEditor.instance.appendTarget = location;
// self append the reference to.. well.. us.
document.body.appendChild(Polymer.cmsSiteEditor.instance);
}
else {
// already exists, just alter some references
Polymer.cmsSiteEditor.instance.appElement = element;
Polymer.cmsSiteEditor.instance.appendTarget = location;
if (typeof Polymer.cmsSiteEditor.instance.haxCmsSiteEditorElement !== typeof undefined) {
Polymer.cmsSiteEditor.instance.appendTarget.appendChild(Polymer.cmsSiteEditor.instance.haxCmsSiteEditorElement);
}
}
};
</script>
</dom-module>