initial commit
This commit is contained in:
35
dev/tekton/examples/example-bank/public/javascript/spinner.js
Executable file
35
dev/tekton/examples/example-bank/public/javascript/spinner.js
Executable file
@@ -0,0 +1,35 @@
|
||||
class LoadingSpinner extends HTMLElement {
|
||||
|
||||
static get observedAttributes() { return ['status']; }
|
||||
|
||||
constructor() {
|
||||
// Always call super first in constructor
|
||||
super();
|
||||
|
||||
let template = document.getElementById('loadingspinner');
|
||||
let templateContent = template.content;
|
||||
|
||||
console.log('INITIALIZING SPINNER')
|
||||
|
||||
const shadow = this.attachShadow({
|
||||
mode: 'open'
|
||||
})
|
||||
.appendChild(templateContent.cloneNode(true));
|
||||
}
|
||||
|
||||
attributeChangedCallback(name, oldValue, newValue) {
|
||||
// if status attribute is set, change to custom status
|
||||
console.log("ATTRIBUTE CHANGED")
|
||||
if (name == "status") {
|
||||
this.shadowRoot.getElementById("status").innerHTML = newValue
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
customElements.define('loading-spinner-element', LoadingSpinner);
|
||||
} catch (err) {
|
||||
const h3 = document.createElement('h3')
|
||||
h3.innerHTML = err
|
||||
document.body.appendChild(h3)
|
||||
}
|
||||
Reference in New Issue
Block a user