]> git.mxchange.org Git - friendica.git/commitdiff
We now store the state in a cookie
authorMichael <heluecht@pirati.ca>
Sat, 11 Jan 2020 08:41:14 +0000 (08:41 +0000)
committerMichael <heluecht@pirati.ca>
Sat, 11 Jan 2020 08:41:14 +0000 (08:41 +0000)
view/js/main.js
view/templates/group_side.tpl
view/templates/widget/filter.tpl
view/templates/widget/saved_searches.tpl
view/templates/widget_forumlist.tpl
view/theme/frio/templates/group_side.tpl
view/theme/frio/templates/widget/saved_searches.tpl

index 37975dd3385b57db1d3692cefe56a5e7738d6a81..c6cf0a85b337b2f60e0a518df6a43770c1b19464 100644 (file)
@@ -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) {
index 31b9287ba826d2ff2c93bdcf93571e3e08c677ba..029a0464e25403e45a21d64c606b604851578d28 100644 (file)
@@ -1,5 +1,10 @@
-<div class="widget" id="group-sidebar">
+<span id="group-sidebar-inflated" class="widget fakelink" style="display: none;" onclick="openCloseWidget('group-sidebar', 'group-sidebar-inflated');">
        <h3>{{$title}}</h3>
+</span>
+<div class="widget" id="group-sidebar">
+       <span class="fakelink" onclick="openCloseWidget('group-sidebar', 'group-sidebar-inflated');">
+               <h3>{{$title}}</h3>
+       </span>
 
        <div id="sidebar-group-list">
                <ul role="menu" id="sidebar-group-ul">
index f710978d9005888c6583b60f70235d0bbf93d4d1..557b8794be9991bda30c0874b0a084358069d3e6 100644 (file)
@@ -1,8 +1,8 @@
-<span id="{{$type}}-sidebar-inflated" class="widget fakelink" style="display: none;" onclick="openClose('{{$type}}-sidebar'); openClose('{{$type}}-sidebar-inflated');">
+<span id="{{$type}}-sidebar-inflated" class="widget fakelink" onclick="openCloseWidget('{{$type}}-sidebar', '{{$type}}-sidebar-inflated');">
        <h3>{{$title}}</h3>
 </span>
-<div id="{{$type}}-sidebar" class="widget" style="display: block;">
-       <span class="fakelink" onclick="openClose('{{$type}}-sidebar'); openClose('{{$type}}-sidebar-inflated');">
+<div id="{{$type}}-sidebar" class="widget">
+       <span class="fakelink" onclick="openCloseWidget('{{$type}}-sidebar', '{{$type}}-sidebar-inflated');">
                <h3>{{$title}}</h3>
        </span>
        <div id="{{$type}}-desc">{{$desc nofilter}}</div>
@@ -13,3 +13,6 @@
                {{/foreach}}
        </ul>
 </div>
+<script>
+initWidget('{{$type}}-sidebar', '{{$type}}-sidebar-inflated');
+</script>
index 4b23ff9253fd8f46afa0cf3a4e24ef8db8a2957a..6957e706d2545ab899d62ee18f8b9276d830639d 100644 (file)
@@ -1,8 +1,8 @@
-<span id="saved-search-list-inflated" class="widget fakelink" style="display: none;" onclick="openClose('saved-search-list'); openClose('saved-search-list-inflated');">
+<span id="saved-search-list-inflated" class="widget fakelink" onclick="openCloseWidget('saved-search-list', 'saved-search-list-inflated');">
        <h3>{{$title}}</h3>
 </span>
-<div class="widget" id="saved-search-list" style="display: block;">
-       <span class="fakelink" onclick="openClose('saved-search-list'); openClose('saved-search-list-inflated');">
+<div class="widget" id="saved-search-list">
+       <span class="fakelink" onclick="openCloseWidget('saved-search-list', 'saved-search-list-inflated');">
                <h3 id="search">{{$title}}</h3>
        </span>
        {{$searchbox nofilter}}
@@ -17,3 +17,6 @@
        </ul>
        <div class="clear"></div>
 </div>
+<script>
+initWidget('saved-search-list', 'saved-search-list-inflated');
+</script>
index a742a13b21f87a98c42174c2e2f7c34dc6ddee52..8f049d9b0f136c2646d241349d91b6a62ae2bd19 100644 (file)
@@ -11,11 +11,11 @@ function showHideForumlist() {
        }
 }
 </script>
-<span id="forumlist-sidebar-inflated" class="widget fakelink" style="display: none;" onclick="openClose('forumlist-sidebar'); openClose('forumlist-sidebar-inflated');">
+<span id="forumlist-sidebar-inflated" class="widget fakelink" onclick="openCloseWidget('forumlist-sidebar', 'forumlist-sidebar-inflated');">
        <h3>{{$title}}</h3>
 </span>
-<div id="forumlist-sidebar" class="widget" style="display: block;">
-       <span class="fakelink" onclick="openClose('forumlist-sidebar'); openClose('forumlist-sidebar-inflated');">
+<div id="forumlist-sidebar" class="widget">
+       <span class="fakelink" onclick="openCloseWidget('forumlist-sidebar', 'forumlist-sidebar-inflated');">
                <h3 id="forumlist">{{$title}}</h3>
        </span>
        <ul id="forumlist-sidbar-ul" role="menu">
@@ -46,3 +46,6 @@ function showHideForumlist() {
                {{/if}}
        </ul>
 </div>
+<script>
+initWidget('forumlist-sidebar', 'forumlist-sidebar-inflated');
+</script>
index 75983b36eea365b6e269a587b44c14047574c6eb..0c5e76a05e6fa2d5755ed6a97586c86609ab6b84 100644 (file)
@@ -1,6 +1,11 @@
+<span id="group-sidebar-inflated" class="widget fakelink" onclick="openCloseWidget('group-sidebar', 'group-sidebar-inflated');">
+        <h3>{{$title}}</h3>
+</span>
 <div class="widget" id="group-sidebar">
        <div id="sidebar-group-header">
-               <h3>{{$title}}</h3>
+               <span class="fakelink" onclick="openCloseWidget('group-sidebar', 'group-sidebar-inflated');">
+                       <h3>{{$title}}</h3>
+               </span>
                {{if ! $newgroup}}
                <a class="group-edit-tool pull-right widget-action faded-icon" id="sidebar-edit-group" href="{{$grouppage}}" data-toggle="tooltip" title="{{$editgroupstext}}">
                        <i class="fa fa-pencil" aria-hidden="true"></i>
@@ -49,6 +54,7 @@
                        {{if $ungrouped}}<li class="{{if $ungrouped_selected}}selected{{/if}} sidebar-group-li" id="sidebar-ungrouped"><a href="nogroup">{{$ungrouped}}</a></li>{{/if}}
                </ul>
        </div>
-
-
 </div>
+<script>
+initWidget('group-sidebar', 'group-sidebar-inflated');
+</script>
index a9745550699091e71a487d253689a18b0e6b76fd..88a69066787e424f9e6cdc56dbfae047e09336e2 100644 (file)
@@ -1,9 +1,9 @@
 {{if $saved}}
-<span id="saved-search-list-inflated" class="widget fakelink" style="display: none;" onclick="openClose('saved-search-list'); openClose('saved-search-list-inflated');">
+<span id="saved-search-list-inflated" class="widget fakelink" onclick="openCloseWidget('saved-search-list', 'saved-search-list-inflated');">
        <h3>{{$title}}</h3>
 </span>
-<div class="widget" id="saved-search-list" style="display: block;">
-       <span class="fakelink" onclick="openClose('saved-search-list'); openClose('saved-search-list-inflated');">
+<div class="widget" id="saved-search-list">
+       <span class="fakelink" onclick="openCloseWidget('saved-search-list', 'saved-search-list-inflated');">
                <h3 id="search">{{$title}}</h3>
        </span>
        <ul role="menu" id="saved-search-ul">
@@ -18,4 +18,7 @@
        </ul>
        <div class="clearfix"></div>
 </div>
+<script>
+initWidget('saved-search-list', 'saved-search-list-inflated');
+</script>
 {{/if}}