From cfeef7afeddc92bb4159b20b32c052b908458deb Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 11 Jan 2020 08:41:14 +0000 Subject: [PATCH] We now store the state in a cookie --- view/js/main.js | 44 +++++++++++++++++++ view/templates/group_side.tpl | 7 ++- view/templates/widget/filter.tpl | 9 ++-- view/templates/widget/saved_searches.tpl | 9 ++-- view/templates/widget_forumlist.tpl | 9 ++-- view/theme/frio/templates/group_side.tpl | 12 +++-- .../frio/templates/widget/saved_searches.tpl | 9 ++-- 7 files changed, 83 insertions(+), 16 deletions(-) diff --git a/view/js/main.js b/view/js/main.js index 37975dd338..c6cf0a85b3 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -33,6 +33,50 @@ function _resizeIframe(obj, desth) { setTimeout(_resizeIframe, 100, obj, ch); } +function getCookie(name) { + var value = "; " + document.cookie; + var parts = value.split("; " + name + "="); + + if (parts.length == 2) { + return parts.pop().split(";").shift(); + } +} + +function initWidget(inflated, deflated) { + var elInf = document.getElementById(inflated); + var elDef = document.getElementById(deflated); + + if (!elInf || !elDef) { + return; + } + if (getCookie(window.location.pathname + ":" + inflated) != "none") { + elInf.style.display = "block"; + elDef.style.display = "none"; + } else { + elInf.style.display = "none"; + elDef.style.display = "block"; + } +} + +function openCloseWidget(inflated, deflated) { + var elInf = document.getElementById(inflated); + var elDef = document.getElementById(deflated); + + if (!elInf || !elDef) { + return; + } + + if (window.getComputedStyle(elInf).display === "none") { + elInf.style.display = "block"; + elDef.style.display = "none"; + document.cookie = window.location.pathname + ":" + inflated + "=block"; + } else { + elInf.style.display = "none"; + elDef.style.display = "block"; + document.cookie = window.location.pathname + ":" + inflated + "=none"; + } +} + function openClose(theID) { var el = document.getElementById(theID); if (el) { diff --git a/view/templates/group_side.tpl b/view/templates/group_side.tpl index 31b9287ba8..029a0464e2 100644 --- a/view/templates/group_side.tpl +++ b/view/templates/group_side.tpl @@ -1,5 +1,10 @@ -
+ +
+ +

{{$title}}

+
+ diff --git a/view/templates/widget/saved_searches.tpl b/view/templates/widget/saved_searches.tpl index 4b23ff9253..6957e706d2 100644 --- a/view/templates/widget/saved_searches.tpl +++ b/view/templates/widget/saved_searches.tpl @@ -1,8 +1,8 @@ -