mirror of
https://github.com/Terranom674/Piwigo_Bratonien_Tools.git
synced 2026-09-20 12:13:16 +00:00
Group watermark sections under one admin tab
This commit is contained in:
@@ -19,9 +19,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
function initBratonienTabs() {
|
function initBratonienTabs() {
|
||||||
var definitions = [
|
var definitions = [
|
||||||
{ id:'uebersicht', label:'Übersicht' },
|
{ id:'wasserzeichen', label:'Wasserzeichen', sections:['uebersicht','wasserzeichen','regeln'] },
|
||||||
{ id:'wasserzeichen', label:'Wasserzeichen' },
|
|
||||||
{ id:'regeln', label:'Albumregeln' },
|
|
||||||
{ id:'auswahl-download', label:'Fotoauswahl & Downloads' },
|
{ id:'auswahl-download', label:'Fotoauswahl & Downloads' },
|
||||||
{ id:'bilddateien', label:'Bilddateien & Pfade' },
|
{ id:'bilddateien', label:'Bilddateien & Pfade' },
|
||||||
{ id:'wartung', label:'Wartung / Cache' },
|
{ id:'wartung', label:'Wartung / Cache' },
|
||||||
@@ -29,11 +27,10 @@
|
|||||||
];
|
];
|
||||||
var panels = [];
|
var panels = [];
|
||||||
definitions.forEach(function (d) {
|
definitions.forEach(function (d) {
|
||||||
var panel = document.getElementById(d.id);
|
var ids=d.sections||[d.id], elements=[];
|
||||||
if (!panel) return;
|
ids.forEach(function(id){var el=document.getElementById(id);if(el){el.classList.add('bratonien-tab-panel');elements.push(el);}});
|
||||||
panel.classList.add('bratonien-tab-panel');
|
if (!elements.length) return;
|
||||||
panel.setAttribute('role','tabpanel');
|
panels.push({definition:d,elements:elements});
|
||||||
panels.push({definition:d,panel:panel});
|
|
||||||
});
|
});
|
||||||
if (!panels.length) return;
|
if (!panels.length) return;
|
||||||
|
|
||||||
@@ -51,10 +48,9 @@
|
|||||||
b.id='bratonien-tab-'+item.definition.id;
|
b.id='bratonien-tab-'+item.definition.id;
|
||||||
b.dataset.tab=item.definition.id;
|
b.dataset.tab=item.definition.id;
|
||||||
b.setAttribute('role','tab');
|
b.setAttribute('role','tab');
|
||||||
b.setAttribute('aria-controls',item.definition.id);
|
|
||||||
b.textContent=item.definition.label;
|
b.textContent=item.definition.label;
|
||||||
tabs.appendChild(b);
|
tabs.appendChild(b);
|
||||||
item.panel.setAttribute('aria-labelledby',b.id);
|
item.elements.forEach(function(el){el.setAttribute('role','tabpanel');el.setAttribute('aria-labelledby',b.id);});
|
||||||
});
|
});
|
||||||
anchor.replaceWith(tabs);
|
anchor.replaceWith(tabs);
|
||||||
|
|
||||||
@@ -62,7 +58,7 @@
|
|||||||
var valid=false;
|
var valid=false;
|
||||||
panels.forEach(function (item) {
|
panels.forEach(function (item) {
|
||||||
var active=item.definition.id===id;
|
var active=item.definition.id===id;
|
||||||
item.panel.hidden=!active;
|
item.elements.forEach(function(el){el.hidden=!active;});
|
||||||
var b=tabs.querySelector('[data-tab="'+item.definition.id+'"]');
|
var b=tabs.querySelector('[data-tab="'+item.definition.id+'"]');
|
||||||
if (b) {
|
if (b) {
|
||||||
b.classList.toggle('is-active',active);
|
b.classList.toggle('is-active',active);
|
||||||
@@ -85,7 +81,8 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
var initial='';
|
var initial='';
|
||||||
if(location.hash && panels.some(function(i){return i.definition.id===location.hash.slice(1)})) initial=location.hash.slice(1);
|
var hash=location.hash?location.hash.slice(1):'';
|
||||||
|
panels.forEach(function(item){if(item.definition.id===hash||(item.definition.sections||[]).indexOf(hash)!==-1)initial=item.definition.id;});
|
||||||
if(!initial){ try { initial=localStorage.getItem('bratonien-tools-active-tab')||''; } catch(e){} }
|
if(!initial){ try { initial=localStorage.getItem('bratonien-tools-active-tab')||''; } catch(e){} }
|
||||||
if(!panels.some(function(i){return i.definition.id===initial})) initial=panels[0].definition.id;
|
if(!panels.some(function(i){return i.definition.id===initial})) initial=panels[0].definition.id;
|
||||||
activate(initial,false);
|
activate(initial,false);
|
||||||
|
|||||||
Reference in New Issue
Block a user