(function(F){ "use strict"; const D = F.dom, P = F.pikchr = {}; P.addSrcView = function f(svg){ if(!f.hasOwnProperty('parentClick')){ f.parentClick = function(ev){ if(ev.altKey || ev.metaKey || ev.ctrlKey || this.classList.contains('toggle')){ this.classList.toggle('source'); ev.stopPropagation(); ev.preventDefault(); } }; f.clickPikchrShow = function(ev){ const pId = this.dataset['pikchrid']; if(!pId) return; const ePikchr = this.parentNode.parentNode.querySelector('#'+pId); if(!ePikchr) return; ev.stopPropagation(); window.sessionStorage.setItem('pikchr-xfer', ePikchr.innerText); }; }; if(!svg) svg = 'svg.pikchr'; if('string' === typeof svg){ document.querySelectorAll(svg).forEach((e)=>f.call(this, e)); return this; }else if(svg.forEach){ svg.forEach((e)=>f.call(this, e)); return this; } if(svg.dataset.pikchrProcessed){ return this; } svg.dataset.pikchrProcessed = 1; const parent = svg.parentNode.parentNode; const srcView = parent ? svg.parentNode.nextElementSibling : undefined; if(srcView && srcView.classList.contains('pikchr-src')){ parent.addEventListener('click', f.parentClick, false); const eSpan = window.sessionStorage ? srcView.querySelector('span') : undefined; if(eSpan){ const openLink = eSpan.querySelector('a'); if(openLink){ openLink.addEventListener('click', f.clickPikchrShow, false); eSpan.classList.remove('hidden'); } } } return this; }; })(window.fossil);