]> BookStack Code Mirror - bookstack/blobdiff - resources/assets/js/services/util.js
Add error messages, fix LDAP error
[bookstack] / resources / assets / js / services / util.js
index 727c723c6001a53786fdce0620cb3d324a5967cf..b2f2918725004920543a439d6031e3cce57aecc1 100644 (file)
@@ -24,4 +24,25 @@ export function debounce(func, wait, immediate) {
         timeout = setTimeout(later, wait);
         if (callNow) func.apply(context, args);
     };
-};
\ No newline at end of file
+};
+
+/**
+ * Scroll and highlight an element.
+ * @param {HTMLElement} element
+ */
+export function scrollAndHighlightElement(element) {
+    if (!element) return;
+    element.scrollIntoView({behavior: 'smooth'});
+
+    const color = document.getElementById('custom-styles').getAttribute('data-color-light');
+    const initColor = window.getComputedStyle(element).getPropertyValue('background-color');
+    element.style.backgroundColor = color;
+    setTimeout(() => {
+        element.classList.add('selectFade');
+        element.style.backgroundColor = initColor;
+    }, 10);
+    setTimeout(() => {
+        element.classList.remove('selectFade');
+        element.style.backgroundColor = '';
+    }, 3000);
+}
\ No newline at end of file