1 line
2.5 KiB
JavaScript
1 line
2.5 KiB
JavaScript
|
window.VT=window.VT||{},VT.TodoFrameDays=function(a){function b(){for(var b=280,c=a.querySelector(".container"),d=0,e=c.children.length;d<e;++d)b=Math.max(c.children[d].offsetHeight,b);a.style.height=b+50+"px"}function c(){for(var a,b=[],c=0;c<28;++c){a=new Date(e.at),a.setDate(a.getDate()-14+c);var f=VT.formatDateId(a);b.push({id:f,items:d(f),position:-14+c})}return b}function d(a){var b=e.items.filter(function(b){return b.listId===a});return b.sort(function(c,a){return c.index-a.index}),b}var e={items:[],at:VT.formatDateId(new Date)};a.innerHTML="<nav class=\"leftcontrols\">\n <p><button class=\"app-button -circle -xl backward\"><i class=\"app-icon\" data-id=\"chevron-left-24\"></i></button></p>\n <p><button class=\"app-button fastbackward\"><i class=\"app-icon -double\" data-id=\"chevron-left-16\"></i></i></button></p>\n <p><button class=\"app-button home\"><i class=\"app-icon\" data-id=\"home-16\"></i></button></p>\n</nav>\n<div class=\"container\"></div>\n<nav class=\"rightcontrols\">\n <p><button class=\"app-button -circle -xl forward\"><i class=\"app-icon\" data-id=\"chevron-right-24\"></i></button></p>\n <p><button class=\"app-button fastforward\"><i class=\"app-icon -double\" data-id=\"chevron-right-16\"></i></button></p>\n</nav>",setTimeout(function(){a.classList.add("-animated")},200),a.querySelectorAll(".app-icon").forEach(VT.AppIcon),a.querySelector(".backward").addEventListener("click",function(){a.dispatchEvent(new CustomEvent("seek",{detail:-1,bubbles:!0}))}),a.querySelector(".forward").addEventListener("click",function(){a.dispatchEvent(new CustomEvent("seek",{detail:1,bubbles:!0}))}),a.querySelector(".fastbackward").addEventListener("click",function(){a.dispatchEvent(new CustomEvent("seek",{detail:-5,bubbles:!0}))}),a.querySelector(".fastforward").addEventListener("click",function(){a.dispatchEvent(new CustomEvent("seek",{detail:5,bubbles:!0}))}),a.querySelector(".home").addEventListener("click",function(){a.dispatchEvent(new CustomEvent("seekHome",{bubbles:!0}))}),a.todoFrameDays={update:function(d){Object.assign(e,d);var f=c(),g=a.querySelector(".container"),h=new Set(g.children),i=new Map;h.forEach(function(a){i.set(a.dataset.key,a)});var j=f.map(function(a){var b=i.get(a.id);return b?h.delete(b):(b=document.createElement("div"),b.className="card todo-day",b.dataset.key=a.id,VT.TodoDay(b)),b.todoDay.update(a),b.style.transform="translateX("+100*a.position+"%)",b});h.forEach(function(a){g.removeChild(a)}),j.forEach(function(a,b){a!==g.children[b]&&g.insertBefore(a,g.children[b])}),b()}}};
|