g2-8.x-1.x-dev/js/dist/g2.js
js/dist/g2.js
(()=>{var l=class{constructor(e,t,o){this.text=e,this.url=t,this.title=o}isFullySet(){return!!this.url&&!!this.title&&!!this.text}toString(){return JSON.stringify(this,(e,t)=>t||void 0)}};var i=class c{constructor(e,t,o){this.index=e,this.definition=t,this.elem=o}renderAnchor(e){let t=this.elem.ownerDocument,o=this.elem;o.removeAttribute("href"),o.id=`g2-dfn-${this.index}`;let n=t.createElement("SUP"),s=t.createElement("A");s.href=`#${c.fnPrefix}${e}`,s.text=String(this.index),n.appendChild(s),o.append(n)}};i.fnPrefix="g2-fn-";var d=class extends i{constructor(e,t,o,n=[]){let s=e.createElement("a");s.text=o.text,s.title=o.title,s.href=o.url,super(t,o,s),this.sourceAnchors=n,this.sourceAnchors=n}renderNote(e){let t=e.ownerDocument,o=t.createElement("LI");o.id=`${i.fnPrefix}${this.index}`;let n=t.createElement("SPAN");n.classList.add("g2-backlinks");let s=t.createTextNode("\u2191 "),r=t.createTextNode(" ");n.appendChild(s);let f=t.createElement("SUP"),g=t.createTextNode(", ");for(let h=0;h<this.sourceAnchors.length;h++){let x=this.sourceAnchors[h],m=t.createElement("A");m.href=`#g2-dfn-${x.index}`,m.text=String(x.index),f.appendChild(m),h<this.sourceAnchors.length-1&&f.append(g)}n.appendChild(f),n.append(r),o.appendChild(n);let u=t.createElement("SPAN");u.classList.add("g2-reference-text");let p=t.createElement("A");p.href=this.definition.url,p.text=this.definition.title,u.appendChild(p),o.appendChild(u),e.appendChild(o)}};var a=class{constructor(e){this.blockClass="g2-footnotes",this.linkSelector=".g2-dfn-link:not(.g2-footnotes .g2-dfn-link)",this.doc=e||document}anchorsFromSource(){let e=[],t=1;return this.doc.querySelectorAll(this.linkSelector).forEach(n=>{let s=new l(n.textContent,n.href,n.title);if(!s.isFullySet())return;let r=new i(t++,s,n);e.push(r)}),e}footnotesFromAnchors(e){let t={},o=1;for(let n of e){let s=n.definition.text,r=t[s];r||(r=new d(this.doc,o,n.definition),o++),r.sourceAnchors.push(n),t[s]=r}return Object.values(t)}buildFootnotes(e){let t=this.doc.createElement("OL");Object.entries(e).forEach(([,o])=>{o.renderNote(t)}),t.childElementCount!==0&&(this.$block=this.doc.querySelector(`.${this.blockClass}`),this.$block instanceof HTMLDivElement||console.error("No footnotes block in DOM, G2 Footnotes aborted"),this.$block.appendChild(t))}convertAnchors(e){for(let t of e)for(let o of t.sourceAnchors)o.renderAnchor(t.index)}transform(){let e=this.anchorsFromSource(),t=this.footnotesFromAnchors(e);this.buildFootnotes(t),this.convertAnchors(t)}};(()=>{let c=new a;Drupal.behaviors.g2={attach(e){(e instanceof Document||e.tagName==="DIV"&&/^block-g2footnotes-\d+$/.test(e.id))&&once("g2","body").forEach(()=>{c.transform()})}}})();})();
