İçeriğe geç
Tüm kodlar

ER3NSHOP

Kurulum sihirbazlı online mağaza sistemi

62 satır · 2,9 KBHamİndir
<script>
// Özelleştirici önizlemesi: işaretli alanların üzerine gelince "düzenle" butonu çıkar,
// tıklayınca soldaki ilgili panel açılır. Sadece yöneticiye ve sadece özelleştirici içinde çalışır.
(() => {
    let inCustomizer = false;
    try {
        inCustomizer = window.parent !== window && window.parent.location.pathname.endsWith('/admin/tema');
    } catch (error) {}
    if (!inCustomizer) return;

    const style = document.createElement('style');
    style.textContent = '[data-customize-hover]{outline:2px solid #2563eb!important;outline-offset:-2px;transition:outline-color .15s}'
        + '#customize-edit{position:fixed;z-index:2147483000;display:none;align-items:center;gap:6px;padding:6px 12px 6px 9px;border-radius:999px;background:#2563eb;color:#fff;font:600 12px/1 system-ui,sans-serif;box-shadow:0 8px 24px rgba(37,99,235,.35);cursor:pointer;border:0}'
        + '#customize-edit:hover{background:#1d4ed8}';
    document.head.append(style);

    const button = document.createElement('button');
    button.id = 'customize-edit';
    button.type = 'button';
    button.innerHTML = '<svg width="14" height="14" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2.2"><path stroke-linecap="round" stroke-linejoin="round" d="m16.862 4.487 1.687-1.688a1.875 1.875 0 1 1 2.652 2.652L6.832 19.82a4.5 4.5 0 0 1-1.897 1.13l-2.685.8.8-2.685a4.5 4.5 0 0 1 1.13-1.897L16.863 4.487Z"/></svg><span></span>';
    document.body.append(button);

    let current = null;
    const place = () => {
        if (!current) return;
        const box = current.getBoundingClientRect();
        button.style.top = Math.min(window.innerHeight - 40, Math.max(8, box.top + 8)) + 'px';
        button.style.left = Math.max(8, box.left + 8) + 'px';
    };
    const show = element => {
        if (element === current) return;
        current?.removeAttribute('data-customize-hover');
        current = element;
        if (!element) {
            button.style.display = 'none';
            return;
        }
        element.setAttribute('data-customize-hover', '');
        button.lastElementChild.textContent = element.dataset.customizeLabel || 'Düzenle';
        button.style.display = 'flex';
        place();
    };

    document.addEventListener('mouseover', event => {
        if (event.target.closest('#customize-edit')) return;
        show(event.target.closest('[data-customize], [data-customize-section]'));
    });
    document.documentElement.addEventListener('mouseleave', () => show(null));
    window.addEventListener('scroll', place, { passive: true });

    button.addEventListener('click', event => {
        event.preventDefault();
        event.stopPropagation();
        if (!current) return;
        window.parent.postMessage({
            type: 'customize',
            panel: current.dataset.customize || null,
            section: current.dataset.customizeSection || null,
        }, location.origin);
    });
})();
</script>

Lisans bilgisi projenin LICENSE dosyasında.