PageSourceSearch

https://foreignpolicy.com/wp-content/themes/foreign-policy-2017/as…/vendor/littlefoot/littlefoot.js?ver=1.0.0

js foreignpolicy.com collected 2026-10-01 06:58:47 UTC 8,156 bytes, 2 lines download raw bytes

1/* from https://unpkg.com/[email protected]/dist/littlefoot.js */
2!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).littlefoot={})}(this,(function(t){"use strict";function e(t,e){t.classList.add(e)}function n(t,e){t.classList.remove(e)}function o(t,e){return t.classList.contains(e)}const i="littlefoot__tooltip";function r(t,e){var n,o;return(null!==(o=null===(n=t.ownerDocument)||void 0===n?void 0:n.defaultView)&&void 0!==o?o:window).getComputedStyle(t).getPropertyValue(e)||""}function s(t,e){const n=Number.parseFloat(r(t,e));return Number.isNaN(n)?0:n}function l(t){const e=s(t,"margin-left"),n=t.offsetWidth-e;return(t.getBoundingClientRect().left+n/2)/window.innerWidth}function c(t,o,i){const[r,c]=function(t,e){const n=s(e,"margin-top"),o=2*n+e.offsetHeight,i=t.getBoundingClientRect().top+t.offsetHeight/2,r=window.innerHeight-i;return r>=o||r>=i?["below",r-n-15]:["above",i-n-15]}(o,t);if(i!==r){n(t,"is-"+i),e(t,"is-"+r);const s=100*l(o)+"%",c="above"===r?"100%":"0";t.style.transformOrigin=s+" "+c}return[r,c]}const a="is-active",u="is-changing",d="is-scrollable";function f({id:t,button:f,content:m,host:p,popover:v,wrapper:h}){let b=0,g="above";const y=()=>document.body.contains(v);return{id:t,activate:t=>{f.setAttribute("aria-expanded","true"),e(f,u),e(f,a),f.insertAdjacentElement("afterend",v),v.style.maxWidth=document.body.clientWidth+"px",b=function(t){const e=r(t,"max-height");if(""===e||"none"===e)return Number.POSITIVE_INFINITY;const n=Number.parseFloat(e);return Number.isNaN(n)?Number.POSITIVE_INFINITY:Math.round(n)}(m),null==t||t(v,f)},dismiss:t=>{f.setAttribute("aria-expanded","false"),e(f,u),n(f,a),n(v,a),null==t||t(v,f)},isActive:()=>o(f,a),isReady:()=>!o(f,u),ready:()=>{e(v,a),n(f,u)},remove:()=>{v.remove(),n(f,u)},reposition:()=>{if(y()){const[t,o]=c(v,f,g);g=t,m.style.maxHeight=Math.min(b,o)+"px",v.offsetHeight<m.scrollHeight?(e(v,d),m.setAttribute("tabindex","0")):(n(v,d),m.removeAttribute("tabindex"))}},resize:()=>{y()&&(v.style.left=function(t,e){const n=t.offsetWidth;return-l(e)*n+s(e,"margin-left")+e.offsetWidth/2}(m,f)+"px",h.style.maxWidth=m.offsetWidth+"px",function(t,e){const n=t.querySelector("."+i);n&&(n.style.left=100*l(e)+"%")}(v,f))},destroy:()=>p.remove()}}function m(t,e=0){let n,o=0;return function(...i){const r=Date.now(),s=Math.max(0,o+e-r);if(0===s)return o=r,void t.apply(this,i);void 0!==n&&window.clearTimeout(n),n=window.setTimeout((()=>{o=Date.now(),n=void 0,t.apply(this,i)}),s)}}const p="is-fully-scrolled",v=t=>o=>{const i=o.currentTarget,r=-o.deltaY;r>0&&n(t,p),i&&r<=0&&r<i.clientHeight+i.scrollTop-i.scrollHeight&&e(t,p)};function h(t,e){t.addEventListener("wheel",m(v(e),16)),t.addEventListener("mouseenter",(()=>function(t){t.hasAttribute("tabindex")&&document.activeElement!==t&&t.focus({preventScroll:!0})}(t)))}const b="littlefoot__content",g="littlefoot__wrapper",y="littlefoot--print",w=(...t)=>t.forEach((t=>{e(t,y)}));function E(t,e){return Array.from(t.querySelectorAll(e))}function x(t,e){return t.querySelector("."+e)||t.firstElementChild||t}function T(t){const e=document.createElement("div");e.innerHTML=t;const n=e.firstElementChild;return n.remove(),n}function A(t){return void 0!==t}function D(t){const e=t.parentElement,n=E(e,":scope > :not(."+y+")"),o=n.filter((t=>"HR"===t.tagName));n.length===o.length&&(w(...o.concat(e)),D(e))}function S(t,e){const n=t.parentElement;t.remove(),n&&n!==e&&!n.innerHTML.replace(/(\[\]|&nbsp;|\s)/g,"")&&S(n,e)}function O([t,e,n],o){const i=T(n.outerHTML);E(i,'[href$="#'+t+'"]').forEach((t=>{S(t,i)}));const r=i.innerHTML.trim();return[e,n,{id:String(o+1),number:o+1,reference:"lf-"+t,content:r.startsWith("<")?r:"<p>"+r+"</p>"}]}function H(t){return e=>t.replace(/<%=?\s*(\w+?)\s*%>
2/g,((t,n)=>{var o;return String(null!==(o=e[n])&&void 0!==o?o:"")}))}function N(t){return function(t,e,n){return E(t,n+' a[href*="#"]').filter((t=>(t.href+t.rel).match(e)))}(document,t.anchorPattern,t.scope).map(function(t,e,n,o){const i=[];return r=>{var s;const l=r.href.split("#")[1];if(!l)return;const c=null===(s=E(t,"#"+window.CSS.escape(l)).find((t=>e||!i.includes(t))))||void 0===s?void 0:s.closest(o);if(!c)return;i.push(c);const a=r.closest(n)||r;return[a.id||r.id,a,c]}}(document,t.allowDuplicates,t.anchorParentSelector,t.footnoteSelector)).filter(A).map(O).map(t.numberResetSelector?function(t){let e=0,n=null;return([o,i,r])=>{const s=o.closest(t);return e=n===s?e+1:1,n=s,[o,i,Object.assign(Object.assign({},r),{number:e})]}}(t.numberResetSelector):t=>t).map((([t,e,n])=>(w(t,e),D(e),[t,n]))).map(function(t,e){const n=H(t),o=H(e);return([t,e])=>{const i=e.id,r=T('<span class="littlefoot">'+n(e)+"</span>"),s=r.firstElementChild;s.setAttribute("aria-expanded","false"),s.dataset.footnoteButton="",s.dataset.footnoteId=i;const l=T(o(e));l.dataset.footnotePopover="",l.dataset.footnoteId=i;const c=x(l,g),a=x(l,b);return h(a,l),t.insertAdjacentElement("beforebegin",r),{id:i,button:s,host:r,popover:l,content:a,wrapper:c}}}(t.buttonTemplate,t.contentTemplate)).map(f)}function _(){E(document,"."+y).forEach((t=>{n(t,y)}))}const I="[data-footnote-id]",M=(t,e)=>t.target.closest(e),C=t=>null==t?void 0:t.dataset.footnoteId,L=t=>e=>{e.preventDefault();const n=M(e,I),o=C(n);o&&t(o)},R=document.addEventListener,P=window.addEventListener,W=(t,e,n,o)=>R(t,(t=>{const o=t.target;(null==o?void 0:o.closest(e))&&n.call(o,t)}
2),o);const j={activateDelay:100,activateOnHover:!1,allowDuplicates:!0,allowMultiple:!1,anchorParentSelector:"sup",anchorPattern:/#(fn|footnote|note)[:\-_\d]/gi,dismissDelay:100,dismissOnUnhover:!1,dismissOnDocumentTouch:!0,footnoteSelector:"li",hoverDelay:250,numberResetSelector:"",scope:"",contentTemplate:`<aside class="littlefoot__popover" id="fncontent:<% id %>"><div class="${g}"><div class="${b}"><% content %></div></div><div class="${i}"></div></aside>`,buttonTemplate:'<button class="littlefoot__button" id="<% reference %>" title="See Footnote <% number %>"><svg role="img" aria-labelledby="title-<% reference %>" viewbox="0 0 31 6" preserveAspectRatio="xMidYMid"><title id="title-<% reference %>">Footnote <% number %></title><circle r="3" cx="3" cy="3" fill="white"></circle><circle r="3" cx="15" cy="3" fill="white"></circle><circle r="3" cx="27" cy="3" fill="white"></circle></svg></button>'};function k(t={}){const e=Object.assign(Object.assign({},j),t),n=function(t,e,n){let o;const i=t=>e=>{e.isReady()&&(e.dismiss(n.dismissCallback),setTimeout(e.remove,t))},r=e=>o=>{n.allowMultiple||t.filter((t=>t.id!==o.id)).forEach(i(n.dismissDelay)),o.isReady()&&(o.activate(n.activateCallback),o.reposition(),o.resize(),setTimeout(o.ready,e))},s=e=>n=>{const o=t.find((t=>t.id===n));o&&e(o)},l=()=>t.forEach(i(n.dismissDelay)),c=e=>{t.forEach((t=>{t[e]()}))};return{activate:(t,e)=>s(r(e))(t),dismiss:(t,e)=>s(i(e))(t),dismissAll:l,touchOutside:()=>{n.dismissOnDocumentTouch&&l()},repositionAll:()=>c("reposition"),resizeAll:()=>c("resize"),toggle:s((t=>t.isActive()?i(n.dismissDelay)(t):r(n.activateDelay)(t))),hover:s((t=>{o=t.id,n.activateOnHover&&!t.isActive()&&r(n.hoverDelay)(t)})),unhover:s((e=>{e.id===o&&(o=null),n.dismissOnUnhover&&setTimeout((()=>t.filter((t=>t.id!==o)).forEach(i(n.dismissDelay))),n.hoverDelay)})),unmount:()=>{c("destroy"),e()}}}(N(e),_,e),o=function(t){const e=e=>{const n=M(e,"[data-footnote-button]"),o=C(n);o?(e.preventDefault(),t.toggle(o)):M(e,"[data-footnote-popover]")||t.touchOutside()},n=m(t.repositionAll,16),o=m(t.resizeAll,16),i=L(t.hover),r=L(t.unhover),s=new AbortController,l={signal:s.signal};return R("touchend",e,l),R("click",e,l),R("keyup",(e=>{27!==e.keyCode&&"Escape"!==e.key&&"Esc"!==e.key||t.dismissAll()}),l),R("gestureend",n,l),P("scroll",n,l),P("resize",o,l),W("mouseover",I,i,l),W("mouseout",I,r,l),()=>{s.abort()}}(n);return{activate(t,o=e.activateDelay){n.activate(t,o)},dismiss(t,o=e.dismissDelay){void 0===t?n.dismissAll():n.dismiss(t,o)},unmount(){o(),n.unmount()},getSetting:t=>e[t],updateSetting(t,n){e[t]=n}}}t.default=k,t.littlefoot=k,Object.defineProperty(t,"__esModule",{value:!0})}));

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.