From c201ff8f63d54166b2ac71a3933d82b0d81c3f1d Mon Sep 17 00:00:00 2001 From: "Alexander (M2)" Date: Tue, 3 Sep 2024 17:55:37 -0400 Subject: [PATCH] Fixes #11 Second Parameter to false will not add spacer li --- public/assets/scaffolding-min.js | 43 ++++++++++++++++++++++------ public/patterns/core/tabs/index.html | 23 +++++++++++---- src/js/core/_core.js | 6 ++-- src/js/scaffolding.js | 3 -- src/pg/patterns/core/tabs/_tabs.js | 4 +-- 5 files changed, 57 insertions(+), 22 deletions(-) diff --git a/public/assets/scaffolding-min.js b/public/assets/scaffolding-min.js index 879cb7e..596ecef 100644 --- a/public/assets/scaffolding-min.js +++ b/public/assets/scaffolding-min.js @@ -108,7 +108,19 @@ const getURLVars = () => { } module.exports = { - url: getURLVars(), + url: (() => { + var v = {}; + if (location.search.length > 0) { + var qs = (location.search.substr(1)).split("&"); + for (var i = 0; i < qs.length; i++) { + var t = qs[i].split("="); + if (t[1].length > 0) { + v[t[0]] = decodeURIComponent(t[1].replace(/\+/g, '%20')); + } + } + } + return v; + })(), cookie: { set: (name, value, expires, path, domain, secure) => { switch(typeof expires) { @@ -172,6 +184,9 @@ module.exports = { }) } }, + // getCSS: (el, prop, b = false) { + // return window.getComputedStyle(el, null).getPropertyValue(prop); + // }, init: (args = {}) => { const url = getURLVars(); font.size = parseFloat(getComputedStyle(document.documentElement).fontSize.replace("px","")); @@ -3187,11 +3202,17 @@ __webpack_require__.r(__webpack_exports__); /* harmony export */ init: function() { return /* binding */ init; } /* harmony export */ }); /* DS2 core (c) 2024 Alexander McIlwraith - import * as tabs from "../pg/patterns/layouts/tabs/_tabs.js"; - tabs.init(); + Released under Creative Commons Attribution-ShareAlike 4.0 International */ -function init(p = document) { +// create a pure JS mouse click event +const click = new MouseEvent('click', { + view: window, + bubbles: false, + cancelable: true +}); + +function init(p = document, s = true) { p.querySelectorAll(".tab-group, tabset").forEach(tabGroup => { if (tabGroup.querySelector("[role=tablist]") === null) { @@ -3218,7 +3239,7 @@ function init(p = document) { const ul = document.createElement('ul'); ul.setAttribute("role", "tablist"); - ul.innerHTML = `${tablist}`; + ul.innerHTML = s != true ? `${tablist}` : `${tablist}`; tabGroup.insertBefore(ul, tabGroup.firstChild); tabGroup.querySelectorAll('[role="tab"]').forEach(tab => { @@ -3234,8 +3255,15 @@ function init(p = document) { 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); + } + }) }); - } }); } @@ -3371,9 +3399,6 @@ _core_core_js__WEBPACK_IMPORTED_MODULE_0__.init({ } }); - - - // deprecated switch handler const flipInfoSwitch = (e, s = e.currentTarget) => { diff --git a/public/patterns/core/tabs/index.html b/public/patterns/core/tabs/index.html index 54abab0..d12530c 100644 --- a/public/patterns/core/tabs/index.html +++ b/public/patterns/core/tabs/index.html @@ -159,11 +159,17 @@ $tab-notselected: #f0f0f0 !default;
import * as tabs from "./js/core/tabs/_tabs.js";
 tabs.init();
/*  DS2 core (c) 2024 Alexander McIlwraith 
-	import * as tabs from "../pg/patterns/layouts/tabs/_tabs.js";
-	tabs.init();
+	Released under Creative Commons Attribution-ShareAlike 4.0 International
  */
 
-export function init(p = document) { 
+// create a pure JS mouse click event
+const click = new MouseEvent('click', {
+	view: window,
+	bubbles: false,
+	cancelable: true
+});
+
+export function init(p = document, s = true) { 
 	p.querySelectorAll(".tab-group, tabset").forEach(tabGroup => {
 
 		if (tabGroup.querySelector("[role=tablist]") === null) {
@@ -190,7 +196,7 @@ export function init(p = document) {
 
 			const ul = document.createElement('ul');
 			ul.setAttribute("role", "tablist");
-			ul.innerHTML = `${tablist}`;
+			ul.innerHTML = s != true ? `${tablist}` : `${tablist}`;
 			tabGroup.insertBefore(ul, tabGroup.firstChild);
 
 			tabGroup.querySelectorAll('[role="tab"]').forEach(tab => {
@@ -206,8 +212,15 @@ export function init(p = document) {
 					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);
+					}
+				})
 			});
-			
 		}
 	});
 }
diff --git a/src/js/core/_core.js b/src/js/core/_core.js
index 964c9a6..ffceca2 100644
--- a/src/js/core/_core.js
+++ b/src/js/core/_core.js
@@ -178,9 +178,9 @@ module.exports = {
 			})
 		}
 	},
-	getCSS: (el, prop, b = false) {
-		return window.getComputedStyle(el, null).getPropertyValue(prop);
-	},
+	// getCSS: (el, prop, b = false) {
+	// 	return window.getComputedStyle(el, null).getPropertyValue(prop);
+	// },
 	init: (args = {}) => {
 		const url = getURLVars();
 		font.size = parseFloat(getComputedStyle(document.documentElement).fontSize.replace("px",""));
diff --git a/src/js/scaffolding.js b/src/js/scaffolding.js
index e903c6a..5dc1423 100644
--- a/src/js/scaffolding.js
+++ b/src/js/scaffolding.js
@@ -24,9 +24,6 @@ core.init({
 	}
 });
 
-
-
-
 // deprecated switch handler
 const flipInfoSwitch = (e, s = e.currentTarget) => {
 	
diff --git a/src/pg/patterns/core/tabs/_tabs.js b/src/pg/patterns/core/tabs/_tabs.js
index c865fe6..d8027ba 100644
--- a/src/pg/patterns/core/tabs/_tabs.js
+++ b/src/pg/patterns/core/tabs/_tabs.js
@@ -9,7 +9,7 @@ const click = new MouseEvent('click', {
 	cancelable: true
 });
 
-export function init(p = document) { 
+export function init(p = document, s = true) { 
 	p.querySelectorAll(".tab-group, tabset").forEach(tabGroup => {
 
 		if (tabGroup.querySelector("[role=tablist]") === null) {
@@ -36,7 +36,7 @@ export function init(p = document) {
 
 			const ul = document.createElement('ul');
 			ul.setAttribute("role", "tablist");
-			ul.innerHTML = `${tablist}`;
+			ul.innerHTML = s != true ? `${tablist}` : `${tablist}`;
 			tabGroup.insertBefore(ul, tabGroup.firstChild);
 
 			tabGroup.querySelectorAll('[role="tab"]').forEach(tab => {