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