website/docs/plugins/bundle-pluginListPage.js

1 line
4.3 KiB
JavaScript

(()=>{"use strict";var t={7986:function(t,e,n){var o=this&&this.__awaiter||function(t,e,n,o){return new(n||(n=Promise))((function(a,r){function c(t){try{l(o.next(t))}catch(t){r(t)}}function s(t){try{l(o.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?a(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,s)}l((o=o.apply(t,e||[])).next())}))},a=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=a(n(9698)),c=a(n(3674));window.addEventListener("DOMContentLoaded",(()=>o(void 0,void 0,void 0,(function*(){(0,c.default)()})))),(0,r.default)()},3674:function(t,e,n){var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const a=o(n(4859)),r=o(n(7210));e.default=()=>{(0,r.default)(),(0,a.default)()}},4859:(t,e)=>{var n;Object.defineProperty(e,"__esModule",{value:!0}),function(t){t.Default="default",t.LastUpdated="last-updated",t.Alphabetical="alphabetic"}(n||(n={}));let o=0;const a=t=>{const e=document.createElement("div"),a=document.createElement("select");a.classList.add("form-select","sort-dropdown"),a.id="sort-method-select-"+o++;const r="Sort by";a.setAttribute("aria-label",r),a.setAttribute("title",r);const c={[n.Default]:"Popularity",[n.LastUpdated]:"Last Updated",[n.Alphabetical]:"Alphabetical"};for(const t in c){const e=c[t],o=document.createElement("option");o.innerText=e,o.value=t,t===n.Default&&(o.selected=!0),a.appendChild(o)}return a.onchange=()=>{t(a.value)},e.appendChild(a),{container:e,setValue:t=>{a.value=t}}},r=(t,e)=>{if(t===n.Default)return e.slice();const o=e=>{var o,a;if(t===n.Alphabetical)return null!==(o=e.getAttribute("data-sort-title"))&&void 0!==o?o:"";if(t===n.LastUpdated){const t=null!==(a=e.getAttribute("data-sort-updated"))&&void 0!==a?a:"";if("N/A"===t)return-1/0;const n=Date.parse(t);return isNaN(n)?1/0:-n}return t},a=e.slice();return a.sort(((t,e)=>{const n=o(t),a=o(e);return n<a?-1:n===a?0:1})),a};e.default=()=>{const t=document.querySelectorAll(".plugin-section"),e=[],n=t=>{for(const n of e)n(t)};for(const o of t){const t=o.querySelector(":scope > .heading.-with-sort-option");if(!t)continue;const c=a(n);t.appendChild(c.container);const s=o.querySelector(":scope > .content"),l=[...s.querySelectorAll(":scope > .card")],i=t=>{c.setValue(t),s.replaceChildren();const e=r(t,l);s.replaceChildren(...e)};e.push(i)}}},7210:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0});const{Tab:n}=window.bootstrap,o="home";e.default=()=>{const t=document.querySelector("nav#nav-tab"),e=document.querySelector("#active-tab-breadcrumb");let a=!1;for(const r of t.querySelectorAll("[role=tab]"))new n(r),r.addEventListener("shown.bs.tab",(()=>{const t=r.getAttribute("href");location.hash!==t&&(a=!0,location.hash=t),e.textContent=r.textContent;const n=document.querySelector("#home-tab-breadcrumb");t===`#tab-${o}`?(e.style.display="none",n.classList.add("active")):(e.style.display="",n.classList.remove("active"))}));const r=e=>{const a=e.match(/#.+$/);if(!a)return;const r=a[0];r.startsWith("#tab-")?(e=>{const a=e.match(/#tab-([a-zA-Z0-9\-_%]+)$/);let r=a?a[1]:o;r=r.replace(/%20/g,"-");const c=t.querySelector(`#nav-${r}-tab`);c&&n.getOrCreateInstance(c).show()})(r):(t=>{const e=t.substring(1),o=document.getElementById(e);let a=o;for(;a&&!a.matches(".tab-pane");)a=a.parentElement;if(a){const e=a.getAttribute("aria-labelledby"),o=document.querySelector(`#${e}`);o?(n.getOrCreateInstance(o).show(),location.hash=t):console.warn("No tab associated with hash",t)}o&&o.scrollIntoView()})(r)};r(location.href),window.addEventListener("hashchange",(t=>{a?a=!1:r(t.newURL)})),(()=>{const t=document.querySelectorAll(".tab-pane");for(const e of t){const t=e.getAttribute("data-tab-name");if(!t){console.error("A tab is missing the data-tab-name attribute!");continue}const n=e.querySelectorAll("a.plugin-link-card");for(const e of n)e.href+=`?from-tab=${t}`}})()}},9698:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=()=>{const t=new URL(location.href);if("joplin.github.io"===t.host){const e=t.pathname.replace(/^[/]?website-plugin-discovery[/]/,"");location.href=`https://joplinapp.org/plugins/${e}${t.search}${t.hash}`}}}},e={};!function n(o){var a=e[o];if(void 0!==a)return a.exports;var r=e[o]={exports:{}};return t[o].call(r.exports,r,r.exports,n),r.exports}(7986)})();