diff --git a/docs/assets/article-dom.min.js b/docs/assets/article-dom.min.js index 39e275d..f12eadc 100644 --- a/docs/assets/article-dom.min.js +++ b/docs/assets/article-dom.min.js @@ -1 +1 @@ -import{ArticleTagsApp}from"./tags-app.min.js";class ResolvedElements{constructor(e={matched_tags:[],ajax_data:{}}){this.ajax_data=e.ajax_data,this.matched_tags=e.matched_tags}get css_loader(){const e=document.createElement("link");return e.setAttribute("rel","stylesheet"),e.setAttribute("href","../css/new-framework.min.css"),e}get tags_list_dom(){const e=document.createElement("ul");return e.classList.add("badges"),e.classList.add("-round"),this.matched_tags.map((e=>{const t=document.createElement("li");return t.classList.add("item"),t.classList.add("click-icon"),t.textContent=e,t})).forEach((t=>e.appendChild(t))),e}get help_dom(){const e=document.createElement("p");return e.textContent="Tags: ",e}generate_date_component(e="",t="",n=""){const a=(new Intl.DateTimeFormat).resolvedOptions().timeZone,s=document.createElement("i-date");return s.dataset.title=e,s.dataset.date=n,s.dataset.classes=t,s.dataset.timezone=a,s}get date_doms(){return{created:this.generate_date_component("Created: ","date -created",this.ajax_data.created_at),updated:this.generate_date_component("Updated: ","date -updated",this.ajax_data.updated_at)}}get date_components(){const e=document.createElement("div");return e.classList.add("i-date-component"),e.appendChild(this.date_doms.created),e.appendChild(this.gap_dom),e.appendChild(this.date_doms.updated),e}get gap_dom(){const e=document.createElement("span");return e.textContent="; ",e}get lisence_dom(){function e(e="BY",t="4.0"){const n=document.createElement("a");return n.target="_blank",n.href=`https://creativecommons.org/licenses/${e.toLocaleLowerCase()}/${t}/deed.en`,n.textContent=`${e.toUpperCase()} ${t}`,n}const t=document.createElement("div"),n=function(){const t=document.createElement("small");return t.style="display: block; margin-top: 8px;",t.insertAdjacentText("beforeend","Works are licenced under "),t.insertAdjacentElement("beforeend",e("BY-ND","4.0")),t.insertAdjacentText("beforeend"," unless other licences like "),t.insertAdjacentElement("beforeend",e("BY-SA","4.0")),t.insertAdjacentText("beforeend"," applies over CC-BY-ND."),t}(),a=function(){const t=e("BY-ND","4.0");return t.textContent="",t.appendChild(function(){const e=document.createElement("img");return e.src="../api/cc-by-nd-icon.svg",e.alt="CC-BY-ND 4.0",e}()),t}();return t.setAttribute("class","lisence"),t.appendChild(a),t.appendChild(n),t}get wrapper(){const e=document.createElement("footer");return e.setAttribute("class","tags container"),e.appendChild(this.date_components),e.appendChild(this.help_dom),e.appendChild(this.tags_list_dom),e.appendChild(this.lisence_dom),e}}class RejectedElements{constructor(e){console.error(e),this.error_message=e}get css_loader(){const e=document.createElement("link");return e.setAttribute("rel","stylesheet"),e.setAttribute("href","../css/new-framework.min.css"),e}get error_reminder(){const e=document.createElement("span");return e.textContent="Oh-oh. Something's up. :-(",e.dataset.errorMessage=this.error_message,e}get wrapper(){const e=document.createElement("footer");return e.setAttribute("class","tags container"),e.appendChild(this.error_reminder),e}}class ArticleTagsAppELement extends HTMLElement{tags_object=null;constructor(){super()}connectedCallback(){this.tags_object=new ArticleTagsApp,this.tagsapp_action()}tagsapp_action(){this.tags_object.set_id(),this.tags_object.request_api().then((e=>{this.render_given_element(ResolvedElements,this.tags_object)})).catch((e=>{this.render_given_element(RejectedElements,e)}))}render_given_element(e,t){const n=this.attachShadow({mode:"open"}),a=new e(t);n.appendChild(a.css_loader),n.appendChild(a.wrapper)}}export{ArticleTagsAppELement}; \ No newline at end of file +import{ArticleTagsApp}from"./tags-app.min.js";class ResolvedElements{constructor(e={matched_tags:[],ajax_data:{}}){this.ajax_data=e.ajax_data,this.matched_tags=e.matched_tags}get css_loader(){const e=document.createElement("link");return e.setAttribute("rel","stylesheet"),e.setAttribute("href","../css/new-framework.min.css"),e}get tags_list_dom(){const e=document.createElement("ul");return e.classList.add("badges"),e.classList.add("-round"),this.matched_tags.map((e=>{const t=document.createElement("li");return t.classList.add("item"),t.classList.add("click-icon"),t.textContent=e,t})).forEach((t=>e.appendChild(t))),e}get help_dom(){const e=document.createElement("p");return e.textContent="Tags: ",e}generate_date_component(e="",t="",n=""){const a=(new Intl.DateTimeFormat).resolvedOptions().timeZone,s=document.createElement("i-date");return s.dataset.title=e,s.dataset.date=n,s.dataset.classes=t,s.dataset.timezone=a,s}get date_doms(){return{created:this.generate_date_component("Created: ","date -created",this.ajax_data.created_at),updated:this.generate_date_component("Updated: ","date -updated",this.ajax_data.updated_at)}}get date_components(){const e=document.createElement("div");return e.classList.add("i-date-component"),e.appendChild(this.date_doms.created),e.appendChild(this.gap_dom),e.appendChild(this.date_doms.updated),e}get gap_dom(){const e=document.createElement("span");return e.textContent="; ",e}get lisence_dom(){function e(e="BY",t="4.0"){const n=document.createElement("a");return n.target="_blank",n.href=`https://creativecommons.org/licenses/${e.toLocaleLowerCase()}/${t}/deed.en`,n.textContent=`${e.toUpperCase()} ${t}`,n}const t=document.createElement("div"),n=function(){const t=document.createElement("small");return t.style="display: block; margin-top: 8px;",t.insertAdjacentText("beforeend","Works are licenced under "),t.insertAdjacentElement("beforeend",e("BY-ND","4.0")),t.insertAdjacentText("beforeend"," unless other licences like "),t.insertAdjacentElement("beforeend",e("BY-SA","4.0")),t.insertAdjacentText("beforeend"," applies over CC-BY-ND."),t}(),a=function(){const t=e("BY-ND","4.0");return t.textContent="",t.appendChild(function(){const e=document.createElement("img");return e.src="../api/cc-by-nd-icon.svg",e.alt="CC-BY-ND 4.0",e}()),t}();return t.setAttribute("class","lisence"),t.appendChild(a),t.appendChild(n),t}get hr_gap_dom(){return document.createElement("hr")}get wrapper(){const e=document.createElement("footer");return e.setAttribute("class","tags container"),e.appendChild(this.hr_gap_dom),e.appendChild(this.date_components),e.appendChild(this.help_dom),e.appendChild(this.tags_list_dom),e.appendChild(this.lisence_dom),e}}class RejectedElements{constructor(e){console.error(e),this.error_message=e}get css_loader(){const e=document.createElement("link");return e.setAttribute("rel","stylesheet"),e.setAttribute("href","../css/new-framework.min.css"),e}get error_reminder(){const e=document.createElement("span");return e.textContent="Oh-oh. Something's up. :-(",e.dataset.errorMessage=this.error_message,e}get wrapper(){const e=document.createElement("footer");return e.setAttribute("class","tags container"),e.appendChild(this.error_reminder),e}}class ArticleTagsAppELement extends HTMLElement{tags_object=null;constructor(){super()}connectedCallback(){this.tags_object=new ArticleTagsApp,this.tagsapp_action()}tagsapp_action(){this.tags_object.set_id(),this.tags_object.request_api().then((e=>{this.render_given_element(ResolvedElements,this.tags_object)})).catch((e=>{this.render_given_element(RejectedElements,e)}))}render_given_element(e,t){const n=this.attachShadow({mode:"open"}),a=new e(t);n.appendChild(a.css_loader),n.appendChild(a.wrapper)}}export{ArticleTagsAppELement}; \ No newline at end of file diff --git a/src/js/article-dom.js b/src/js/article-dom.js index 70fe0f1..a1d27b9 100644 --- a/src/js/article-dom.js +++ b/src/js/article-dom.js @@ -124,12 +124,17 @@ class ResolvedElements { div.appendChild( small ); return div; } + get hr_gap_dom() { + const gap = document.createElement("hr"); + return gap; + } /** * THE wrapper */ get wrapper() { const wrapper = document.createElement( "footer" ); wrapper.setAttribute( "class", "tags container" ); + wrapper.appendChild( this.hr_gap_dom ); wrapper.appendChild( this.date_components ); wrapper.appendChild( this.help_dom ); wrapper.appendChild( this.tags_list_dom );