From 60c6595f3f55ead487bf10ca3092429d410a3e85 Mon Sep 17 00:00:00 2001
From: weru <fromweru@gmail.com>
Date: Sat, 05 Dec 2020 19:55:14 +0000
Subject: [PATCH] add helper functions

---
 assets/js/index.js     |   11 +++++++++++
 assets/js/functions.js |    5 +++++
 2 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/assets/js/functions.js b/assets/js/functions.js
index 9653394..c0208f3 100644
--- a/assets/js/functions.js
+++ b/assets/js/functions.js
@@ -110,6 +110,11 @@
   }
 }
 
+function wrapEl(el, wrapper) {
+  el.parentNode.insertBefore(wrapper, el);
+  wrapper.appendChild(el);
+}
+
 function wrapText(text, context, wrapper = 'mark') {
   let open = `<${wrapper}>`;
   let close = `</${wrapper}>`;
diff --git a/assets/js/index.js b/assets/js/index.js
index e72bce6..a5b1bba 100644
--- a/assets/js/index.js
+++ b/assets/js/index.js
@@ -290,6 +290,17 @@
     lazyLoadMedia('img');
   })();
 
+  (function makeTablesResponsive(){
+    const tables = elems('table');
+    if (tables) {
+      tables.forEach(function(table){
+        const tableWrapper = createEl();
+        pushClass(tableWrapper, 'scrollable');
+        wrapEl(table, tableWrapper);
+      });
+    }
+  })();
+
   function pickModePicture(user, system, context) {
     const pictures = elems('picture');
     if(pictures) {

--
Gitblit v1.10.0