about summary refs log tree commit diff stats
path: root/wiki/lib/scripts/search.js
diff options
context:
space:
mode:
authorahriman <ahriman@falte.red>2018-12-03 19:22:25 -0500
committerahriman <ahriman@falte.red>2018-12-03 19:22:25 -0500
commit0ae8cbf5c0b1a198b963490985b7738392ebcb97 (patch)
treeb2c77ae72c6b717e2b97492065196ac5ffb2d9e2 /wiki/lib/scripts/search.js
parentf57f6cc5a2d159f90168d292437dc4bd8cd7f934 (diff)
downloadsite-0ae8cbf5c0b1a198b963490985b7738392ebcb97.tar.gz
installed dokuwiki, added to navbar, updated news
Diffstat (limited to 'wiki/lib/scripts/search.js')
-rw-r--r--wiki/lib/scripts/search.js48
1 files changed, 48 insertions, 0 deletions
diff --git a/wiki/lib/scripts/search.js b/wiki/lib/scripts/search.js
new file mode 100644
index 0000000..3631708
--- /dev/null
+++ b/wiki/lib/scripts/search.js
@@ -0,0 +1,48 @@
+jQuery(function () {
+    'use strict';
+
+    const $searchForm = jQuery('.search-results-form');
+    if (!$searchForm.length) {
+        return;
+    }
+
+    const $toggleAssistanceButton = jQuery('<button>')
+        .addClass('toggleAssistant')
+        .attr('type', 'button')
+        .attr('aria-expanded', 'false')
+        .text(LANG.search_toggle_tools)
+        .prependTo($searchForm.find('fieldset'))
+    ;
+
+    $toggleAssistanceButton.on('click', function () {
+        jQuery('.advancedOptions').toggle(0, function () {
+            var $me = jQuery(this);
+            if ($me.attr('aria-hidden')) {
+                $me.removeAttr('aria-hidden');
+                $toggleAssistanceButton.attr('aria-expanded', 'true');
+                DokuCookie.setValue('sa', 'on');
+            } else {
+                $me.attr('aria-hidden', 'true');
+                $toggleAssistanceButton.attr('aria-expanded', 'false');
+                DokuCookie.setValue('sa', 'off');
+            }
+        });
+    });
+
+    if (DokuCookie.getValue('sa') === 'on') {
+        $toggleAssistanceButton.click();
+    }
+
+    $searchForm.find('.advancedOptions .toggle div.current').on('click', function () {
+        var $me = jQuery(this);
+        $me.parent().siblings().removeClass('open');
+        $me.parent().siblings().find('ul:first').attr('aria-expanded', 'false');
+        $me.parent().toggleClass('open');
+        if ($me.parent().hasClass('open')) {
+            $me.parent().find('ul:first').attr('aria-expanded', 'true');
+        } else {
+            $me.parent().find('ul:first').attr('aria-expanded', 'false');
+        }
+    });
+
+});