Fix mobile catalog header and controls

This commit is contained in:
pavlov346346-source 2026-09-08 20:11:11 +03:00
parent c0409234df
commit 893de0e726

View File

@ -70,14 +70,55 @@
let box=document.getElementById('sunDevMemoryV1761');if(!box){box=document.createElement('div');box.id='sunDevMemoryV1761';box.className='sun-dev-grid';box.style.marginBottom='12px';body.prepend(box);} let box=document.getElementById('sunDevMemoryV1761');if(!box){box=document.createElement('div');box.id='sunDevMemoryV1761';box.className='sun-dev-grid';box.style.marginBottom='12px';body.prepend(box);}
box.innerHTML=`<div class="sun-dev-kpi"><small>Память сервера</small><b>${esc(d.server_size||d.database_size||'—')}</b></div><div class="sun-dev-kpi"><small>База PostgreSQL</small><b>${esc(d.database_size||'—')}</b></div><div class="sun-dev-kpi"><small>Файлы Storage</small><b>${esc(d.storage_size||'—')}</b></div><div class="sun-dev-kpi"><small>Объектов Storage</small><b>${Number(d.storage_objects||0)}</b></div>`; box.innerHTML=`<div class="sun-dev-kpi"><small>Память сервера</small><b>${esc(d.server_size||d.database_size||'—')}</b></div><div class="sun-dev-kpi"><small>База PostgreSQL</small><b>${esc(d.database_size||'—')}</b></div><div class="sun-dev-kpi"><small>Файлы Storage</small><b>${esc(d.storage_size||'—')}</b></div><div class="sun-dev-kpi"><small>Объектов Storage</small><b>${Number(d.storage_objects||0)}</b></div>`;
} }
const MOBILE_STYLE_ID='sun-mobile-catalog-v1761-style';
function installMobileCatalogStyle(){
if(document.getElementById(MOBILE_STYLE_ID))return;
const style=document.createElement('style');style.id=MOBILE_STYLE_ID;style.textContent=`
@media(max-width:900px){
.sun-enterprise-sidebar header>.sun-side-tools{display:none!important}
#new .catalog .catalog-head{display:grid!important;grid-template-columns:minmax(0,1fr)!important;align-items:stretch!important;gap:10px!important}
#new .catalog .catalog-head>h1{margin:0!important}
#new .catalog .sun-catalog-actions{display:grid!important;grid-template-columns:repeat(3,minmax(0,1fr))!important;gap:8px!important;width:100%!important;align-items:stretch!important;justify-content:stretch!important}
#new .catalog .sun-catalog-view-switch{display:none!important}
#new .catalog .sun-catalog-search{grid-column:1/-1!important;order:-20!important;width:100%!important;min-width:0!important;height:42px!important;margin:0!important;padding:8px 12px!important;border-radius:10px!important}
#new .catalog #sunLiveCatalogPdfButton,#new .catalog #sunCatalogTabsButton,#new .catalog .sun-catalog-menu-button{width:100%!important;min-width:0!important;height:42px!important;min-height:42px!important;margin:0!important;padding:0 8px!important;border-radius:10px!important;display:inline-flex!important;align-items:center!important;justify-content:center!important;gap:6px!important;white-space:nowrap!important;line-height:1!important}
#new .catalog #sunLiveCatalogPdfButton{order:1!important}
#new .catalog #sunCatalogTabsButton{order:2!important}
#new .catalog .sun-catalog-menu-button{order:3!important;font-size:0!important}
#new .catalog .sun-catalog-menu-button::before{content:'☰';font-size:16px!important;line-height:1!important;font-weight:700!important}
#new .catalog .sun-catalog-menu-button::after{content:'Меню';font-size:13px!important;line-height:1!important;font-weight:700!important}
#new .cats{display:flex!important;flex-wrap:nowrap!important;gap:8px!important;overflow-x:auto!important;overflow-y:hidden!important;-webkit-overflow-scrolling:touch!important;scrollbar-width:none!important;padding:9px 4px 10px!important}
#new .cats::-webkit-scrollbar{display:none!important}
#new .cats button{flex:0 0 auto!important;width:auto!important;min-width:max-content!important;margin:0!important;padding:10px 14px!important;white-space:nowrap!important}
#new .cats p{display:none!important}
}
@media(max-width:430px){
#new .catalog .sun-catalog-actions{gap:6px!important}
#new .catalog #sunLiveCatalogPdfButton,#new .catalog #sunCatalogTabsButton,#new .catalog .sun-catalog-menu-button{height:40px!important;min-height:40px!important;padding-inline:6px!important;font-size:12px!important}
#new .catalog .sun-catalog-menu-button::after{font-size:12px!important}
}
`;document.head.appendChild(style);
}
function installMobileCatalogUi(){
installMobileCatalogStyle();
const head=document.querySelector('#new .catalog .catalog-head');if(!head)return;
const menu=[...head.querySelectorAll('button')].find(b=>b.classList.contains('sun-catalog-menu-button')||(b.textContent||'').trim()==='Настроить');
if(menu){menu.classList.add('sun-catalog-menu-button');menu.setAttribute('aria-label','Меню каталога');menu.title='Меню каталога';}
const search=document.getElementById('sunCatalogSearch');if(search&&!search.getAttribute('aria-label'))search.setAttribute('aria-label','Поиск по каталогу');
const tabs=document.getElementById('sunCatalogTabsButton');if(tabs){tabs.setAttribute('aria-label','Вкладки каталога');tabs.title='Вкладки каталога';}
const pdf=document.getElementById('sunLiveCatalogPdfButton');if(pdf){pdf.setAttribute('aria-label','PDF каталога');}
}
window.SunMobileCatalogV1761={install:installMobileCatalogUi};
const start=()=>{ const start=()=>{
scan(document); scan(document);installMobileCatalogUi();
const mo=new MutationObserver(records=>{records.forEach(r=>r.addedNodes.forEach(n=>{if(n.nodeType===1)scan(n)}));enhanceDeveloperMemory();}); const mo=new MutationObserver(records=>{records.forEach(r=>r.addedNodes.forEach(n=>{if(n.nodeType===1)scan(n)}));installMobileCatalogUi();enhanceDeveloperMemory();});
mo.observe(document.documentElement,{childList:true,subtree:true}); mo.observe(document.documentElement,{childList:true,subtree:true});
document.addEventListener('click',e=>{if(e.target.closest('#sunDeveloperNavV22,[data-dev-tab],#sunDevRefresh'))setTimeout(enhanceDeveloperMemory,100)},true); document.addEventListener('click',e=>{if(e.target.closest('#sunDeveloperNavV22,[data-dev-tab],#sunDevRefresh'))setTimeout(enhanceDeveloperMemory,100)},true);
window.addEventListener('sun:cloud-state-applied',()=>setTimeout(enhanceDeveloperMemory,150)); window.addEventListener('sun:cloud-state-applied',()=>setTimeout(enhanceDeveloperMemory,150));
setInterval(()=>{if(document.getElementById('sun-developer-console-v22')?.classList.contains('on'))enhanceDeveloperMemory();},5000); setInterval(()=>{if(document.getElementById('sun-developer-console-v22')?.classList.contains('on'))enhanceDeveloperMemory();},5000);
window.SunPerformance={scanImages:()=>scan(document),refreshDeveloperMemory:enhanceDeveloperMemory,disconnect:()=>mo.disconnect()}; window.SunPerformance={scanImages:()=>scan(document),refreshDeveloperMemory:enhanceDeveloperMemory,refreshMobileCatalog:installMobileCatalogUi,disconnect:()=>mo.disconnect()};
}; };
if(document.readyState==='loading')document.addEventListener('DOMContentLoaded',start,{once:true});else start(); if(document.readyState==='loading')document.addEventListener('DOMContentLoaded',start,{once:true});else start();
})(); })();