mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2025-11-18 03:00:56 +01:00
Added JS logic to switch tabs
This commit is contained in:
@@ -4,11 +4,11 @@ import { Instance as Editors } from '../forms/fields/editor';
|
||||
|
||||
let Data = JSON.parse(Cookies.get('grav-tabs-state') || '{}');
|
||||
|
||||
$('body').on('touchstart click', '[name^="tab-"]', (event) => {
|
||||
$('body').on('touchstart click', '[data-tabid]', (event) => {
|
||||
event && event.stopPropagation();
|
||||
let target = $(event.currentTarget);
|
||||
|
||||
Data[target.attr('name')] = target.val();
|
||||
Data[target.data('tabkey')] = target.data('scope');
|
||||
Cookies.set('grav-tabs-state', JSON.stringify(Data), { expires: Infinity });
|
||||
|
||||
Editors.editors.each((index, editor) => {
|
||||
@@ -18,4 +18,12 @@ $('body').on('touchstart click', '[name^="tab-"]', (event) => {
|
||||
codemirror.refresh();
|
||||
}
|
||||
});
|
||||
|
||||
const panel = $(`[id="${target.data('tabid')}"]`);
|
||||
|
||||
target.siblings('[data-tabid]').removeClass('active');
|
||||
target.addClass('active');
|
||||
|
||||
panel.siblings('[id]').removeClass('active');
|
||||
panel.addClass('active');
|
||||
});
|
||||
|
||||
4
themes/grav/js/admin.min.js
vendored
4
themes/grav/js/admin.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -19,7 +19,7 @@
|
||||
<div class="tabs-nav">
|
||||
{% for tab in field.fields %}
|
||||
{% if tab.type == 'tab' and (tab.security is empty or authorize(array(tab.security))) %}
|
||||
<a class="tab__link {{ (storedTab == scope ~ tab.name) or active == loop.index ? 'active' : '' }}" href="#" data-tabid="tab-{{ tabsKey ~ loop.index }}">
|
||||
<a class="tab__link {{ (storedTab == scope ~ tab.name) or active == loop.index ? 'active' : '' }}" href="#" data-tabid="tab-{{ tabsKey ~ loop.index }}" data-tabkey="tab-{{ tabsKey }}" data-scope="{{ scope ~ tab.name }}">
|
||||
{% if grav.twig.twig.filters['tu'] is defined %}{{ tab.title|tu }}{% else %}{{ tab.title|t }}{% endif %}
|
||||
</a>
|
||||
{% endif %}
|
||||
|
||||
Reference in New Issue
Block a user