diff --git a/src/pg/patterns/core/sticky-note/_sticky-note.js b/src/pg/patterns/core/sticky-note/_sticky-note.js
index 2a81cb5..980c099 100644
--- a/src/pg/patterns/core/sticky-note/_sticky-note.js
+++ b/src/pg/patterns/core/sticky-note/_sticky-note.js
@@ -95,37 +95,39 @@ const calculateStickyPosition = (s) => {
}
}
-export function init(p = document){
- font.size = parseFloat(getComputedStyle(document.documentElement).fontSize.replace("px",""));
-
- p.querySelectorAll("sticky-note").forEach((s) => {
- if (s.querySelectorAll("svg").length == 0) {
-
- let wrapper = document.createElement("sticky-note-wrapper");
-
- s.parentNode.insertBefore(wrapper, s);
- wrapper.appendChild(s);
-
- s.setAttribute("content", s.innerHTML.replace(/"/g, "\""));
- s.innerHTML = `
`;
- }
- calculateStickyPosition(s);
- drag(s);
- s.ondblclick = (e) => {
- if (e.ctrlKey) {
- calculateStickyPosition(s);
- } else {
- // add one click select
- }
- }
- })
-
-
- window.onresize = () => {
+module.exports = {
+ init: (p = document) => {
font.size = parseFloat(getComputedStyle(document.documentElement).fontSize.replace("px",""));
- let stickies = p.querySelectorAll("sticky-note");
- stickies.forEach((s) => {
+
+ p.querySelectorAll("sticky-note").forEach((s) => {
+ if (s.querySelectorAll("svg").length == 0) {
+
+ let wrapper = document.createElement("sticky-note-wrapper");
+
+ s.parentNode.insertBefore(wrapper, s);
+ wrapper.appendChild(s);
+
+ s.setAttribute("content", s.innerHTML.replace(/"/g, "\""));
+ s.innerHTML = ``;
+ }
calculateStickyPosition(s);
- });
+ drag(s);
+ s.ondblclick = (e) => {
+ if (e.ctrlKey) {
+ calculateStickyPosition(s);
+ } else {
+ // add one click select
+ }
+ }
+ })
+
+
+ window.onresize = () => {
+ font.size = parseFloat(getComputedStyle(document.documentElement).fontSize.replace("px",""));
+ let stickies = p.querySelectorAll("sticky-note");
+ stickies.forEach((s) => {
+ calculateStickyPosition(s);
+ });
+ }
}
}
\ No newline at end of file
diff --git a/src/pg/patterns/core/tabs/_tabs.js b/src/pg/patterns/core/tabs/_tabs.js
index 96c0ff9..4818c2b 100644
--- a/src/pg/patterns/core/tabs/_tabs.js
+++ b/src/pg/patterns/core/tabs/_tabs.js
@@ -31,76 +31,78 @@ const waitForElement = (selector) => {
}
-export function init(container = document, spacer = true, args = {}) {
+module.exports = {
+ init: (container = document, spacer = true, args = {}) => {
- container.querySelectorAll(".tab-group, tabset").forEach(tabGroup => {
+ container.querySelectorAll(".tab-group, tabset").forEach(tabGroup => {
- if (tabGroup.querySelector("[role=tablist]") === null) {
- const tabgroup = tabGroup.getAttribute("id");
- let tablist = "";
+ if (tabGroup.querySelector("[role=tablist]") === null) {
+ const tabgroup = tabGroup.getAttribute("id");
+ let tablist = "";
- Array.from(tabGroup.children).forEach(child => {
- const tab = child.getAttribute("tab") || child.getAttribute("data-tab");
- if (tab !== null) {
- const tabID = tab.replace(/\W+/g, "-").toLowerCase();
- const tabPanel = document.createElement('div');
- tabPanel.id = `tab-panel-${tabgroup}-${tabID}`;
- tabPanel.className = tablist === "" ? "open" : "";
- tabPanel.setAttribute("role", "tabpanel");
- tabPanel.setAttribute("tabindex", "0");
- tabPanel.setAttribute("aria-labelledby", `tab-${tabgroup}-${tabID}`);
- tabPanel.appendChild(child.cloneNode(true));
- child.parentNode.replaceChild(tabPanel, child);
- tablist += `${tab}`;
- } else {
- child.classList.add("tab-hidden");
- }
- });
-
- const ul = document.createElement('ul');
- ul.setAttribute("role", "tablist");
- ul.innerHTML = spacer != true ? `${tablist}` : `${tablist}`;
- tabGroup.insertBefore(ul, tabGroup.firstChild);
-
- tabGroup.querySelectorAll('[role="tab"]').forEach(tab => {
- tab.addEventListener("click", (e) => {
- if (e.altKey && typeof args.altModifier == "function") {
- args.altModifier(tab);
- } else if (e.shiftKey && typeof args.shiftModifier == "function") {
- args.shiftModifier(tab);
- } else if (e.metaKey && typeof args.metaModifier == "function") {
- args.metaModifier(tab);
+ Array.from(tabGroup.children).forEach(child => {
+ const tab = child.getAttribute("tab") || child.getAttribute("data-tab");
+ if (tab !== null) {
+ const tabID = tab.replace(/\W+/g, "-").toLowerCase();
+ const tabPanel = document.createElement('div');
+ tabPanel.id = `tab-panel-${tabgroup}-${tabID}`;
+ tabPanel.className = tablist === "" ? "open" : "";
+ tabPanel.setAttribute("role", "tabpanel");
+ tabPanel.setAttribute("tabindex", "0");
+ tabPanel.setAttribute("aria-labelledby", `tab-${tabgroup}-${tabID}`);
+ tabPanel.appendChild(child.cloneNode(true));
+ child.parentNode.replaceChild(tabPanel, child);
+ tablist += `${tab}`;
} else {
- const siblings = Array.from(tab.parentNode.children);
- siblings.forEach(sibling => sibling.classList.remove("selected"));
- tab.classList.add("selected");
-
- const tabPanels = Array.from(tab.parentNode.parentNode.children)
- .filter(child => child.getAttribute("role") === "tabpanel");
- tabPanels.forEach(panel => panel.classList.remove("open"));
-
- const tabPanelId = tab.getAttribute("id").replace("tab", "tab-panel");
- document.getElementById(tabPanelId).classList.add("open");
+ child.classList.add("tab-hidden");
}
});
+ const ul = document.createElement('ul');
+ ul.setAttribute("role", "tablist");
+ ul.innerHTML = spacer != true ? `${tablist}` : `${tablist}`;
+ tabGroup.insertBefore(ul, tabGroup.firstChild);
- tab.addEventListener("keypress", (e) => {
- e.preventDefault();
- if( e.which == 32 || e.which == 13 ) {
- e.currentTarget.dispatchEvent(click);
- }
- })
- });
- }
+ tabGroup.querySelectorAll('[role="tab"]').forEach(tab => {
+ tab.addEventListener("click", (e) => {
+ if (e.altKey && typeof args.altModifier == "function") {
+ args.altModifier(tab);
+ } else if (e.shiftKey && typeof args.shiftModifier == "function") {
+ args.shiftModifier(tab);
+ } else if (e.metaKey && typeof args.metaModifier == "function") {
+ args.metaModifier(tab);
+ } else {
+ const siblings = Array.from(tab.parentNode.children);
+ siblings.forEach(sibling => sibling.classList.remove("selected"));
+ tab.classList.add("selected");
- if (document.location.hash != "" && document.location.hash.substring(0,5) == "#tab-") {
- waitForElement(document.location.hash).then((el) => {
- el.scrollIntoView();
- el.focus();
- el.dispatchEvent(click);
- });
+ const tabPanels = Array.from(tab.parentNode.parentNode.children)
+ .filter(child => child.getAttribute("role") === "tabpanel");
+ tabPanels.forEach(panel => panel.classList.remove("open"));
- }
- });
-}
+ const tabPanelId = tab.getAttribute("id").replace("tab", "tab-panel");
+ document.getElementById(tabPanelId).classList.add("open");
+ }
+ });
+
+
+ tab.addEventListener("keypress", (e) => {
+ e.preventDefault();
+ if( e.which == 32 || e.which == 13 ) {
+ e.currentTarget.dispatchEvent(click);
+ }
+ })
+ });
+ }
+
+ if (document.location.hash != "" && document.location.hash.substring(0,5) == "#tab-") {
+ waitForElement(document.location.hash).then((el) => {
+ el.scrollIntoView();
+ el.focus();
+ el.dispatchEvent(click);
+ });
+
+ }
+ });
+ }
+}
\ No newline at end of file