Skip to content

Commit

Permalink
Added resize handler, and header/footer clear in loadtemplate
Browse files Browse the repository at this point in the history
  • Loading branch information
ravstamper committed Nov 22, 2019
1 parent 0cf3fff commit acd22d8
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion taino.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,20 @@ class taino{
window.addEventListener('popstate', (event) => {
this.update();
});

window.addEventListener("DOMNodeInserted", (event) => {
this.defaultlisteners();/* detect A tags in newly inserted nodes*/
});

var resizeTimer;
window.addEventListener("resize", (event) => {
var t =this;
if(typeof(resizeTimer)!='undefined'){ clearTimeout(resizeTimer); }
resizeTimer = setTimeout(function() {
t.loadtemplate();
t.update();
},250);
});
}


Expand Down Expand Up @@ -99,6 +113,8 @@ class taino{
}

loadtemplate(){
if(taino.el("body > header").length>0){ taino.el("body > header")[0].remove(); }
if(taino.el("body > footer").length>0){ taino.el("body > footer")[0].remove(); }
const callback = () =>{
var loader = this.templatefile.replace("/","") + 'Loader';
this.templateobject = this.createLoader(loader) /*filename+'Loader' has to be the main class.*/
Expand Down Expand Up @@ -196,10 +212,11 @@ class taino{
loadstyling(loader){ /*loads in styling from a component*/
if(!this.cur.styling){return ;}
else{
if(!taino.el('style.'+loader)){
if(!taino.el('style.tainocss_'+loader)){
let body = document.body;
let style = document.createElement('style');
style.type = 'text/css';
style.classList.add('tainocss_'+loader);
style.innerHTML=this.cur.styling;
body.appendChild(style);
}
Expand Down

0 comments on commit acd22d8

Please sign in to comment.