Skip to content

Commit

Permalink
Added nodata element
Browse files Browse the repository at this point in the history
  • Loading branch information
Anselm Joseph authored and Anselm Joseph committed Jul 24, 2019
1 parent c5524b0 commit 1c4ba18
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions dist/tea-plates.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ class TeaPlates {

pTP_uid = 0;

constructor(wrapperId, template, loadingTemplate) {
constructor(wrapperId, template, loadingTemplate, noDataTemplate) {
this.jsonData = {};
this.wrapperId = wrapperId;
this.template = template;
this.loadingTemplate = loadingTemplate;
this.noDataTemplate = noDataTemplate;
this.newElements = [];
this.insertedElements = [];
this.loadingElements = [];
this.noDataElement = null;
this.eventListeners = [];
}

Expand Down Expand Up @@ -236,6 +238,25 @@ class TeaPlates {
return div.firstChild;
}

showNoDataElement(completion) {
this.noDataElement = this.pTP_CreateElementFromString(this.noDataTemplate, `no-data`);
this.noDataElement.classList.add("animate-in");
document.getElementById(this.wrapperId).appendChild(this.noDataElement);
setTimeout(() => {
this.noDataElement.classList.remove("animate-in");
completion();
}, this.animationTime, this);
}

removeNoDataElement(completion) {
if (this.noDataElement == null) return;
this.noDataElement.classList.add("animate-out");
setTimeout(() => {
document.getElementById(this.wrapperId).removeChild(this.noDataElement);
completion();
}, this.animationTime, this);
}

showLoading(count = 1, completion = () => {}) {
for (let i = 0; i < count; i++) {
this.loadingElements.push(this.pTP_CreateElementFromString(this.loadingTemplate, `load-${i}`));
Expand All @@ -248,7 +269,7 @@ class TeaPlates {
document.getElementById(this.wrapperId).appendChild(element);
setTimeout(() => {
element.classList.remove("animate-in");
resolve()
resolve();
}, this.animationTime, element, this);
}, this.delta * index, element);
});
Expand Down

0 comments on commit 1c4ba18

Please sign in to comment.