mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2025-11-06 21:35:49 +01:00
Remember the open state of the sidebar (fixes #1973)
This commit is contained in:
@@ -5,7 +5,8 @@
|
||||
* Auto-link a plugin/theme license in details if it starts with `http`
|
||||
* Allow to fallback to `docs:` instead of `readme:`
|
||||
* Forward a `sid` to GPM when downloading a premium package
|
||||
* Better support for array field key/value when either key or value is empty [#1972](https://github.com/getgrav/grav-plugin-admin/issues/1972)
|
||||
* Better support for array field key/value when either key or value is stored empty [#1972](https://github.com/getgrav/grav-plugin-admin/issues/1972)
|
||||
* Remember the open state of the sidebar [#1973](https://github.com/getgrav/grav-plugin-admin/issues/1973)
|
||||
1. [](#bugfix)
|
||||
* Fixed Safari issue with new ACL picker field [#1955](https://github.com/getgrav/grav-plugin-admin/issues/1955)
|
||||
* Stop propagation of ACL add button in ACL picker [flex-objects#83](https://github.com/trilbymedia/grav-plugin-flex-objects/issues/83)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import $ from 'jquery';
|
||||
import Map from 'es6-map';
|
||||
import Cookies from 'cookies-js';
|
||||
|
||||
const MOBILE_BREAKPOINT = 48 - 0.062;
|
||||
const DESKTOP_BREAKPOINT = 75 + 0.063;
|
||||
@@ -123,6 +124,7 @@ export default class Sidebar {
|
||||
if (event) { event.preventDefault(); }
|
||||
clearTimeout(this.timeout);
|
||||
let isDesktop = global.matchMedia(DESKTOP_QUERY).matches;
|
||||
let cookie = null;
|
||||
|
||||
if (isDesktop) {
|
||||
this.body.removeClass('sidebar-open');
|
||||
@@ -135,6 +137,14 @@ export default class Sidebar {
|
||||
|
||||
this.body.toggleClass(`sidebar-${isDesktop ? 'closed' : 'open'}`);
|
||||
$(global).trigger('sidebar_state._grav', isDesktop);
|
||||
|
||||
if (isDesktop) {
|
||||
cookie = !this.body.hasClass('sidebar-closed');
|
||||
} else {
|
||||
cookie = this.body.hasClass('sidebar-open');
|
||||
}
|
||||
|
||||
Cookies.set('grav-admin-sidebar', cookie, { expires: Infinity });
|
||||
}
|
||||
|
||||
checkMatch(data) {
|
||||
|
||||
2
themes/grav/js/admin.min.js
vendored
2
themes/grav/js/admin.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -43,7 +43,9 @@
|
||||
|
||||
</head>
|
||||
{% block body %}
|
||||
<body class="ga-theme-17x {{ config.plugins.admin.sidebar.size == 'small' ? 'sidebar-closed' : '' }} {{ config.plugins.admin.body_classes }} {{ body_classes }}">
|
||||
{% set sidebarStatus = get_cookie('grav-admin-sidebar') %}
|
||||
{% set sidebarStatus = (sidebarStatus is not null and sidebarStatus == 'false') or config.plugins.admin.sidebar.size == 'small' ? 'sidebar-closed' : '' %}
|
||||
<body class="ga-theme-17x {{ sidebarStatus }} {{ config.plugins.admin.body_classes }} {{ body_classes }}">
|
||||
|
||||
{% if not authorize(['admin.login']) %}
|
||||
{% include 'partials/messages.html.twig' %}
|
||||
|
||||
Reference in New Issue
Block a user