Commit d0bc4884 authored by jan.koester's avatar jan.koester
Browse files

rc 1

parent f2cbd6bd
Loading
Loading
Loading
Loading
+212 −18
Changes for data/template/default/editor.html: 212 added lines, 18 removed lines.
Original line number Diff line number Diff line
@@ -1220,7 +1220,8 @@
        // Fields define the form controls to render.
        const WIDGET_SCHEMAS = {
            'Container': [
                { key: 'background_color', label: 'Background Color', type: 'color', responsive: true },
                { key: 'background_color', label: 'Background Color (Dark)', type: 'color', responsive: true },
                { key: 'l_background_color', label: 'Background Color (Light)', type: 'color' },
                { key: 'css_class', label: 'CSS Class', type: 'text', placeholder: 'e.g. my-container' },
                { key: 'border_radius', label: 'Border Radius', type: 'text', placeholder: 'e.g. 8px', responsive: true },
                { key: 'border_style', label: 'Border', type: 'text', placeholder: 'e.g. 1px solid #ccc', responsive: true },
@@ -1232,7 +1233,8 @@
                { key: 'content', label: 'Content', type: 'richtext' },
                { key: 'font_family', label: 'Font Family', type: 'text', placeholder: 'e.g. Arial, sans-serif' },
                { key: 'font_size', label: 'Font Size', type: 'text', placeholder: 'e.g. 16px', responsive: true },
                { key: 'font_color', label: 'Font Color', type: 'color', responsive: true },
                { key: 'font_color', label: 'Font Color (Dark)', type: 'color', responsive: true },
                { key: 'l_font_color', label: 'Font Color (Light)', type: 'color' },
                { key: 'text_align', label: 'Text Align', type: 'select', options: ['left','center','right','justify'], responsive: true },
                { key: 'font_weight', label: 'Font Weight', type: 'select', options: ['normal','bold','lighter','bolder'] },
                { key: 'font_style', label: 'Font Style', type: 'select', options: ['normal','italic','oblique'] },
@@ -1244,8 +1246,10 @@
                { key: 'link_url', label: 'Link URL', type: 'text', placeholder: 'https://...', visibleWhen: { key: 'link_type', value: 'url' } },
                { key: 'open_new_tab', label: 'Open in New Tab', type: 'checkbox', visibleWhen: { key: 'link_type', value: 'url' } },
                { key: 'section_id', label: 'Target Section', type: 'section_select', visibleWhen: { key: 'link_type', value: 'section' } },
                { key: 'background_color', label: 'Background Color', type: 'color' },
                { key: 'text_color', label: 'Text Color', type: 'color' },
                { key: 'background_color', label: 'Background Color (Dark)', type: 'color' },
                { key: 'l_background_color', label: 'Background Color (Light)', type: 'color' },
                { key: 'text_color', label: 'Text Color (Dark)', type: 'color' },
                { key: 'l_text_color', label: 'Text Color (Light)', type: 'color' },
                { key: 'font_size', label: 'Font Size', type: 'text', placeholder: '16px', responsive: true },
                { key: 'border_radius', label: 'Border Radius', type: 'text', placeholder: '4px', responsive: true },
                { key: 'padding', label: 'Padding', type: 'text', placeholder: '10px 20px', responsive: true },
@@ -1255,7 +1259,8 @@
                { key: 'columns', label: 'Columns', type: 'text', placeholder: 'e.g. 1fr 1fr 1fr', responsive: true },
                { key: 'rows', label: 'Rows', type: 'text', placeholder: 'e.g. auto auto', responsive: true },
                { key: 'gap', label: 'Gap', type: 'text', placeholder: '10px', responsive: true },
                { key: 'background_color', label: 'Background Color', type: 'color', responsive: true },
                { key: 'background_color', label: 'Background Color (Dark)', type: 'color', responsive: true },
                { key: 'l_background_color', label: 'Background Color (Light)', type: 'color' },
                { key: 'padding', label: 'Padding', type: 'text', placeholder: '10px', responsive: true },
                { key: 'css_class', label: 'CSS Class', type: 'text', placeholder: 'e.g. my-grid' },
                { key: 'border_radius', label: 'Border Radius', type: 'text', placeholder: 'e.g. 8px', responsive: true },
@@ -1280,7 +1285,8 @@
                { key: 'has_header', label: 'Has Header Row', type: 'checkbox' },
                { key: 'border_style', label: 'Border Style', type: 'text', placeholder: '1px solid #ccc', responsive: true },
                { key: 'cell_padding', label: 'Cell Padding', type: 'text', placeholder: '8px', responsive: true },
                { key: 'background_color', label: 'Background Color', type: 'color' },
                { key: 'background_color', label: 'Background Color (Dark)', type: 'color' },
                { key: 'l_background_color', label: 'Background Color (Light)', type: 'color' },
                { key: 'vertical_align', label: 'Vertical Align', type: 'select', options: ['top','center','bottom'], responsive: true },
                { key: 'hidden', label: 'Hidden', type: 'checkbox', responsive: true }
            ],
@@ -1291,7 +1297,8 @@
                { key: 'hidden', label: 'Hidden', type: 'checkbox', responsive: true }
            ],
            'Section': [
                { key: 'background_color', label: 'Background Color', type: 'color', responsive: true },
                { key: 'background_color', label: 'Background Color (Dark)', type: 'color', responsive: true },
                { key: 'l_background_color', label: 'Background Color (Light)', type: 'color' },
                { key: 'css_class', label: 'CSS Class', type: 'text', placeholder: 'e.g. hero-section' },
                { key: 'padding', label: 'Padding', type: 'text', placeholder: 'e.g. 40px 20px', responsive: true },
                { key: 'margin', label: 'Margin', type: 'text', placeholder: 'e.g. 0 auto', responsive: true },
@@ -1449,6 +1456,9 @@

            elementSettingsPanel.innerHTML = html;

            // Initialize canvas-based color pickers after DOM is ready
            initColorPickers(schema);

            // Apply conditional visibility rules
            applyConditionalVisibility(schema, properties);

@@ -1533,6 +1543,196 @@
            }
        }

        /**
         * Canvas-based RGBA color picker (HSV model).
         * Usage: new BlogiCP(uid) where uid is the id of a hidden input with the current color value,
         * and uid+'_wrap' is an empty div where the picker canvas will be rendered.
         */
        if (!window.BlogiCP) {
            window.BlogiCP = function(uid) {
                var hd = document.getElementById(uid);
                var wr = document.getElementById(uid + '_wrap');
                if (!hd || !wr) return;
                var H = 0, S = 1, V = 1, A = 1;
                // Parse initial value into HSV+A
                function parseInit() {
                    var v = (hd.value || '').trim();
                    var r = 0, g = 0, b = 0;
                    if (v.startsWith('rgba(')) {
                        var p = v.slice(5, -1).split(','); r = +p[0]; g = +p[1]; b = +p[2]; A = parseFloat(p[3]);
                    } else if (v.startsWith('rgb(')) {
                        var p = v.slice(4, -1).split(','); r = +p[0]; g = +p[1]; b = +p[2]; A = 1;
                    } else {
                        if (!v.startsWith('#') && /^[0-9a-fA-F]{6}$/.test(v)) v = '#' + v;
                        if (v.startsWith('#')) {
                            if (v.length === 4) v = '#' + v[1]+v[1] + v[2]+v[2] + v[3]+v[3];
                            r = parseInt(v.substr(1,2),16); g = parseInt(v.substr(3,2),16); b = parseInt(v.substr(5,2),16); A = 1;
                        }
                    }
                    var mx = Math.max(r,g,b)/255, mn = Math.min(r,g,b)/255, d = mx - mn;
                    V = mx; S = mx ? d/mx : 0;
                    if (!d) H = 0;
                    else if (mx === r/255) H = 60 * ((g/255 - b/255)/d % 6);
                    else if (mx === g/255) H = 60 * ((b/255 - r/255)/d + 2);
                    else H = 60 * ((r/255 - g/255)/d + 4);
                    if (H < 0) H += 360;
                }
                // HSV to RGB
                function hsv2rgb(h, s, v) {
                    var c = v*s, x = c*(1 - Math.abs((h/60)%2 - 1)), m = v - c;
                    var r = 0, g = 0, b = 0;
                    if (h < 60) { r=c; g=x; } else if (h < 120) { r=x; g=c; } else if (h < 180) { g=c; b=x; }
                    else if (h < 240) { g=x; b=c; } else if (h < 300) { r=x; b=c; } else { r=c; b=x; }
                    return [Math.round((r+m)*255), Math.round((g+m)*255), Math.round((b+m)*255)];
                }
                // Build DOM
                var W = 160, SH = 120, BH = 14, gap = 6;
                wr.style.cssText = 'display:inline-block;';
                var row = document.createElement('div');
                row.style.cssText = 'display:flex;gap:' + gap + 'px;';
                // SV canvas
                var svC = document.createElement('canvas');
                svC.width = W; svC.height = SH;
                svC.style.cssText = 'cursor:crosshair;border:1px solid #555;border-radius:3px;';
                var svCtx = svC.getContext('2d');
                // Hue bar (vertical)
                var huC = document.createElement('canvas');
                huC.width = BH; huC.height = SH;
                huC.style.cssText = 'cursor:pointer;border:1px solid #555;border-radius:3px;';
                var huCtx = huC.getContext('2d');
                row.appendChild(svC); row.appendChild(huC);
                wr.appendChild(row);
                // Alpha bar (horizontal)
                var alC = document.createElement('canvas');
                alC.width = W + BH + gap; alC.height = BH;
                alC.style.cssText = 'cursor:pointer;border:1px solid #555;border-radius:3px;margin-top:' + gap + 'px;display:block;';
                var alCtx = alC.getContext('2d');
                wr.appendChild(alC);
                // Info row: swatch + text input
                var info = document.createElement('div');
                info.style.cssText = 'display:flex;align-items:center;gap:6px;margin-top:' + gap + 'px;';
                var sw = document.createElement('span');
                sw.style.cssText = 'display:inline-block;width:24px;height:24px;border-radius:4px;border:1px solid #666;flex-shrink:0;';
                var ti = document.createElement('input');
                ti.type = 'text';
                ti.style.cssText = 'width:180px;font-size:0.85em;padding:2px 4px;background:var(--blogi-surface,#333);color:var(--blogi-text,#eee);border:1px solid #555;border-radius:3px;';
                info.appendChild(sw); info.appendChild(ti);
                wr.appendChild(info);
                // Draw SV surface
                function drawSV() {
                    var rgb = hsv2rgb(H, 1, 1);
                    svCtx.fillStyle = 'rgb(' + rgb[0] + ',' + rgb[1] + ',' + rgb[2] + ')';
                    svCtx.fillRect(0, 0, W, SH);
                    var gw = svCtx.createLinearGradient(0, 0, W, 0);
                    gw.addColorStop(0, '#fff'); gw.addColorStop(1, 'rgba(255,255,255,0)');
                    svCtx.fillStyle = gw; svCtx.fillRect(0, 0, W, SH);
                    var gb = svCtx.createLinearGradient(0, 0, 0, SH);
                    gb.addColorStop(0, 'rgba(0,0,0,0)'); gb.addColorStop(1, '#000');
                    svCtx.fillStyle = gb; svCtx.fillRect(0, 0, W, SH);
                    // cursor
                    var cx = S * W, cy = (1 - V) * SH;
                    svCtx.beginPath(); svCtx.arc(cx, cy, 5, 0, 6.28);
                    svCtx.strokeStyle = '#fff'; svCtx.lineWidth = 2; svCtx.stroke();
                    svCtx.strokeStyle = '#000'; svCtx.lineWidth = 1; svCtx.stroke();
                }
                function drawHue() {
                    var g = huCtx.createLinearGradient(0, 0, 0, SH);
                    for (var i = 0; i <= 6; i++) g.addColorStop(i/6, ['#f00','#ff0','#0f0','#0ff','#00f','#f0f','#f00'][i]);
                    huCtx.fillStyle = g; huCtx.fillRect(0, 0, BH, SH);
                    var y = H / 360 * SH;
                    huCtx.fillStyle = '#fff'; huCtx.fillRect(0, y-1, BH, 3);
                    huCtx.fillStyle = '#000'; huCtx.fillRect(0, y, BH, 1);
                }
                function drawAlpha() {
                    var aw = alC.width;
                    alCtx.fillStyle = '#ccc'; alCtx.fillRect(0, 0, aw, BH);
                    for (var x = 0; x < aw; x += 7) for (var y = 0; y < BH; y += 7)
                        if ((Math.floor(x/7) + Math.floor(y/7)) % 2) { alCtx.fillStyle = '#999'; alCtx.fillRect(x, y, 7, 7); }
                    var rgb = hsv2rgb(H, S, V);
                    var ga = alCtx.createLinearGradient(0, 0, aw, 0);
                    ga.addColorStop(0, 'rgba(' + rgb[0] + ',' + rgb[1] + ',' + rgb[2] + ',0)');
                    ga.addColorStop(1, 'rgba(' + rgb[0] + ',' + rgb[1] + ',' + rgb[2] + ',1)');
                    alCtx.fillStyle = ga; alCtx.fillRect(0, 0, aw, BH);
                    var ax = A * aw;
                    alCtx.fillStyle = '#fff'; alCtx.fillRect(ax-1, 0, 3, BH);
                    alCtx.fillStyle = '#000'; alCtx.fillRect(ax, 0, 1, BH);
                }
                function update() {
                    drawSV(); drawHue(); drawAlpha();
                    var rgb = hsv2rgb(H, S, V);
                    var rgba = 'rgba(' + rgb[0] + ',' + rgb[1] + ',' + rgb[2] + ',' + Math.round(A*100)/100 + ')';
                    hd.value = rgba; ti.value = rgba;
                    sw.style.backgroundColor = rgba;
                    hd.dispatchEvent(new Event('input', {bubbles: true}));
                }
                // Drag helpers
                function drag(el, fn) {
                    function mv(e) { var r = el.getBoundingClientRect(); fn(e.clientX - r.left, e.clientY - r.top, r); }
                    el.addEventListener('pointerdown', function(e) { el.setPointerCapture(e.pointerId); mv(e); });
                    el.addEventListener('pointermove', function(e) { if (e.buttons) mv(e); });
                }
                drag(svC, function(x, y) { S = Math.max(0, Math.min(1, x/W)); V = Math.max(0, Math.min(1, 1-y/SH)); update(); });
                drag(huC, function(x, y) { H = Math.max(0, Math.min(360, y/SH*360)); update(); });
                drag(alC, function(x, y, r) { A = Math.max(0, Math.min(1, x/r.width)); update(); });
                // Text input handler
                ti.addEventListener('change', function() { hd.value = ti.value; parseInit(); update(); });
                // Init
                parseInit(); update();
            };
        }

        /**
         * Initializes BlogiCP color pickers for all color fields in the current property form.
         * Call after the form HTML has been inserted into the DOM.
         */
        function initColorPickers(schema) {
            if (!schema) return;
            var fields = schema.filter(function(f) { return f.type === 'color'; });
            for (var i = 0; i < fields.length; i++) {
                var key = fields[i].key;
                var inputId = 'prop-' + key;
                var noneBox = document.getElementById(inputId + '-none');
                var wrap = document.getElementById(inputId + '_wrap');
                if (noneBox && noneBox.checked && wrap) {
                    wrap.style.display = 'none';
                } else if (wrap) {
                    new BlogiCP(inputId);
                }
                // Also init mobile override if responsive
                if (fields[i].responsive) {
                    var mId = 'prop-m_' + key;
                    var mNone = document.getElementById(mId + '-none');
                    var mWrap = document.getElementById(mId + '_wrap');
                    if (mNone && mNone.checked && mWrap) {
                        mWrap.style.display = 'none';
                    } else if (mWrap) {
                        new BlogiCP(mId);
                    }
                }
            }
        }

        /**
         * Toggles the none state of a BlogiCP color picker.
         */
        function toggleBlogiCPNone(inputId) {
            var noneBox = document.getElementById(inputId + '-none');
            var wrap = document.getElementById(inputId + '_wrap');
            var hd = document.getElementById(inputId);
            if (!noneBox) return;
            if (noneBox.checked) {
                if (wrap) wrap.style.display = 'none';
                if (hd) hd.value = 'none';
            } else {
                if (wrap) {
                    wrap.style.display = '';
                    wrap.innerHTML = '';
                    new BlogiCP(inputId);
                }
            }
            if (typeof scheduleAutoSave === 'function') scheduleAutoSave();
        }

        /**
         * Renders a single form field based on its type.
         */
@@ -1547,15 +1747,9 @@
                    break;
                case 'color': {
                    const isNone = (!val || val === 'none' || val === '');
                    html += `<div style="display:flex;align-items:center;gap:8px;">`;
                    html += `<input class="prop-input" type="color" id="${inputId}" name="${field.key}" value="${isNone ? '#000000' : val}"${isNone ? ' disabled' : ''} style="${isNone ? 'opacity:0.4;' : ''}">`;
                    html += `<label style="display:flex;align-items:center;gap:4px;font-size:0.85rem;color:#ccc;"><input type="checkbox" id="${inputId}-none"${isNone ? ' checked' : ''} onchange="
                        const ci = document.getElementById('${inputId}');
                        if(this.checked){ ci.disabled=true; ci.style.opacity='0.4'; ci.dataset.noneVal='true'; }
                        else { ci.disabled=false; ci.style.opacity='1'; delete ci.dataset.noneVal; }
                        scheduleAutoSave();
                    "> none</label>`;
                    html += `</div>`;
                    html += `<input type="hidden" id="${inputId}" name="${field.key}" value="${isNone ? '' : escapeHtml(String(val))}">`;
                    html += `<div id="${inputId}_wrap"></div>`;
                    html += `<label style="display:flex;align-items:center;gap:4px;font-size:0.85rem;color:#ccc;margin-top:4px;"><input type="checkbox" id="${inputId}-none"${isNone ? ' checked' : ''} onchange="toggleBlogiCPNone('${inputId}')"> none</label>`;
                    break;
                }
                case 'select':
@@ -1688,7 +1882,7 @@
                    properties[field.key] = el.innerHTML;
                } else if (field.type === 'color') {
                    const noneBox = document.getElementById(`prop-${field.key}-none`);
                    properties[field.key] = (noneBox && noneBox.checked) ? 'none' : el.value;
                    properties[field.key] = (noneBox && noneBox.checked) ? 'none' : (el.value || 'none');
                } else {
                    properties[field.key] = el.value;
                }
@@ -1700,7 +1894,7 @@
                    if (mEl) {
                        if (field.type === 'color') {
                            const mNoneBox = document.getElementById(`prop-${mKey}-none`);
                            properties[mKey] = (mNoneBox && mNoneBox.checked) ? 'none' : mEl.value;
                            properties[mKey] = (mNoneBox && mNoneBox.checked) ? 'none' : (mEl.value || 'none');
                        } else if (field.type === 'checkbox') {
                            properties[mKey] = mEl.checked;
                        } else {
+6 −18
Changes for data/template/default/public/mstyle.css: 6 added lines, 18 removed lines.
Original line number Diff line number Diff line
@@ -114,20 +114,20 @@ body {

#headnav li:hover {
    background:var(--blogi-nav-hover);
    border-top: solid 1px transparent;
    border-bottom: solid 1px transparent;
    border-top: solid 1px rgba(0,0,0,0);
    border-bottom: solid 1px rgba(0,0,0,0);
}

#headnav li.active {
    border-top: solid 1px var(--blogi-nav-active);
    background:var(--blogi-bg);
    border-right:solid 1px var(--blogi-nav-border);
    border-bottom: solid 1px transparent;
    border-bottom: solid 1px rgba(0,0,0,0);
}

#headnav li.inactive {
    border-top:solid 1px var(--blogi-bg);
    border-bottom: solid 1px transparent;    
    border-bottom: solid 1px rgba(0,0,0,0);    
}

#headnav li.active:hover {
@@ -209,10 +209,6 @@ a {
    color:var(--blogi-text);
}

.staticpage {
    background: var(--blogi-surface);
}

.gameserver {
    background: var(--blogi-surface);
    margin:20px 0;
@@ -223,12 +219,6 @@ a {
    width:100%;
}

.projects {
    background: var(--blogi-surface);
    width:100%;
    margin:20px 0;
}

#pager {
  background: var(--blogi-surface);
  text-align: center;
@@ -267,8 +257,7 @@ a {
  position:fixed;
  width:100%;
  height:100%;
  opacity:0.7;
  background:rgb(0,0,0);
  background:rgba(0,0,0,0.7);
}

#cookiecontent {
@@ -279,8 +268,7 @@ a {
  right: 0%;
  z-index: 100;
  color: var(--blogi-accent);
  opacity: 1;
  background: rgb(0,0,0);
  background: rgba(0,0,0,1);
  padding: 20px;
  border-top: solid var(--blogi-surface) 1em;
  border-left: solid var(--blogi-surface) 1em;
+0 −10
Changes for data/template/default/public/style.css: 0 added lines, 10 removed lines.
Original line number Diff line number Diff line
@@ -366,10 +366,6 @@ a {
    margin: 10px;
}

.staticpage {
    background: var(--blogi-surface);
}

.gameserver {
    background: var(--blogi-surface);
    margin:20px 0;
@@ -380,12 +376,6 @@ a {
    width:100%;
}

.projects {
    background: var(--blogi-surface);
    width:100%;
    margin:20px 0;
}

#pager {
  background: var(--blogi-surface);
  text-align: center;
+159 −3

File changed.

Preview size limit exceeded, changes collapsed.

+109 −75

File changed.

Preview size limit exceeded, changes collapsed.

Loading