allow embed customization #46
@ -1,3 +1,4 @@
|
||||
|
||||
class GuestbookForm extends HTMLElement {
|
||||
static get observedAttributes() {
|
||||
return ['guestbook'];
|
||||
@ -6,6 +7,8 @@ class GuestbookForm extends HTMLElement {
|
||||
constructor() {
|
||||
super();
|
||||
this.attachShadow({ mode: 'open' });
|
||||
let template = document.getElementById("custom-guestbook-form");
|
||||
this.templateContent = template.content;
|
||||
this._guestbook = this.getAttribute('guestbook') || '';
|
||||
this._postUrl = `${this._guestbook}/comments/create/remote`
|
||||
this.render();
|
||||
@ -63,6 +66,7 @@ class GuestbookForm extends HTMLElement {
|
||||
</div>
|
||||
</form>
|
||||
`;
|
||||
this.shadowRoot.appendChild(document.importNode(this.templateContent, true))
|
||||
}
|
||||
}
|
||||
|
||||
@ -74,9 +78,12 @@ class CommentList extends HTMLElement {
|
||||
constructor() {
|
||||
super();
|
||||
this.attachShadow({ mode: 'open' });
|
||||
let template = document.getElementById("custom-guestbook-comments");
|
||||
this.templateContent = template.content;
|
||||
this.comments = [];
|
||||
this.loading = false;
|
||||
this.error = null;
|
||||
|
||||
}
|
||||
|
||||
connectedCallback() {
|
||||
@ -169,9 +176,11 @@ class CommentList extends HTMLElement {
|
||||
}
|
||||
</div>
|
||||
`;
|
||||
this.shadowRoot.appendChild(document.importNode(this.templateContent, true))
|
||||
}
|
||||
}
|
||||
|
||||
customElements.define('guestbook-form', GuestbookForm);
|
||||
customElements.define('guestbook-comments', CommentList);
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user