MediaWiki:Common.js: Difference between revisions

No edit summary
No edit summary
Line 945: Line 945:
     var currentPath = window.location.pathname;
     var currentPath = window.location.pathname;
     var storedPath  = stored.pathname || '';
     var storedPath  = stored.pathname || '';
     function normPath(p) { return decodeURIComponent(p).replace(/\/+$/, ''); }
     function normPath(p) {
     if ( storedPath && normPath(storedPath) !== normPath(currentPath) ) {
      return decodeURIComponent(p).replace(/\/+$/, '').replace(/_/g,' ');
    }
    var storedNorm  = normPath(storedPath);
    var currentNorm = normPath(currentPath);
    /* Allow match when current path ends with the stored page slug
    * (handles MW short URLs vs /index.php?title= discrepancies) */
     if ( storedPath && storedNorm !== currentNorm &&
        !currentNorm.endsWith(storedNorm.split('/').pop()) ) {
       try { sessionStorage.removeItem( 'gr_search_hl' ); } catch(e) {}
       try { sessionStorage.removeItem( 'gr_search_hl' ); } catch(e) {}
       return;
       return;
Line 1,061: Line 1,068:
     if ( isMob ) {
     if ( isMob ) {
       bar.style.cssText = [
       bar.style.cssText = [
         'position:fixed',
         'position:fixed', 'bottom:0', 'left:0', 'right:0',
        'top:calc(var(--gr-header-height,56px) + var(--gr-toc-top,52px) + 8px)',
        'left:50%', 'transform:translateX(-50%)',
         'z-index:10200',
         'z-index:10200',
         'background:#b5451b', 'color:#fff',
         'background:#b5451b', 'color:#fff',
         'padding:8px 14px',
         'padding:0',
        'border-radius:24px',
         'display:flex', 'align-items:stretch',
         'display:flex', 'align-items:center', 'gap:8px',
         'font-family:system-ui,sans-serif',
         'font-family:system-ui,sans-serif', 'font-size:13px',
         'box-shadow:0 -2px 12px rgba(0,0,0,0.25)',
         'box-shadow:0 3px 12px rgba(0,0,0,0.25)',
        'white-space:nowrap',
        'max-width:calc(100vw - 32px)'
       ].join(';');
       ].join(';');
     } else {
     } else {
Line 1,087: Line 1,089:


     if ( isMob ) {
     if ( isMob ) {
      var mobBtnStyle = 'flex:1;display:flex;flex-direction:column;align-items:center;' +
        'justify-content:center;background:none;border:none;color:#fff;cursor:pointer;' +
        'padding:6px 4px;font-family:system-ui,sans-serif;font-size:11px;font-weight:500;' +
        'gap:3px;letter-spacing:0.02em;-webkit-tap-highlight-color:rgba(0,0,0,0.12);';
       bar.innerHTML =
       bar.innerHTML =
         '<span style="flex-shrink:0">🔍 ' + count + '</span>' +
         '<button id="gr-hl-prev" style="' + mobBtnStyle + '">' +
        '<button id="gr-hl-prev" style="background:rgba(255,255,255,0.2);border:none;color:#fff;min-width:36px;height:36px;border-radius:50%;cursor:pointer;font-size:16px;display:flex;align-items:center;justify-content:center;"></button>' +
          '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><polyline points="15 18 9 12 15 6"/></svg>' +
         '<button id="gr-hl-next" style="background:rgba(255,255,255,0.2);border:none;color:#fff;min-width:36px;height:36px;border-radius:50%;cursor:pointer;font-size:16px;display:flex;align-items:center;justify-content:center;"></button>' +
          '<span>Prev</span>' +
         '<button id="gr-hl-results" style="background:rgba(255,255,255,0.2);border:none;color:#fff;min-width:36px;height:36px;border-radius:50%;cursor:pointer;font-size:14px;display:flex;align-items:center;justify-content:center;"></button>' +
        '</button>' +
         '<button id="gr-hl-dismiss" style="background:rgba(255,255,255,0.15);border:none;color:#fff;min-width:36px;height:36px;border-radius:50%;cursor:pointer;font-size:16px;display:flex;align-items:center;justify-content:center;"></button>';
         '<button id="gr-hl-next" style="' + mobBtnStyle + '">' +
          '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><polyline points="9 18 15 12 9 6"/></svg>' +
          '<span>Next</span>' +
        '</button>' +
         '<button id="gr-hl-results" style="' + mobBtnStyle + 'flex:1.6;border-left:1px solid rgba(255,255,255,0.2);border-right:1px solid rgba(255,255,255,0.2);">' +
          '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="7"/><line x1="16.5" y1="16.5" x2="22" y2="22"/></svg>' +
          '<span>' + count + ' match' + ( count === 1 ? '' : 'es' ) + '</span>' +
        '</button>' +
         '<button id="gr-hl-dismiss" style="' + mobBtnStyle + '">' +
          '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>' +
          '<span>Close</span>' +
        '</button>';
     } else {
     } else {
       var nav = document.createElement( 'div' );
       var nav = document.createElement( 'div' );