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 && | 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', | ||
'z-index:10200', | 'z-index:10200', | ||
'background:#b5451b', 'color:#fff', | 'background:#b5451b', 'color:#fff', | ||
'padding: | 'padding:0', | ||
'display:flex', 'align-items:stretch', | |||
'display:flex', 'align-items: | 'font-family:system-ui,sans-serif', | ||
'font-family:system-ui,sans-serif | 'box-shadow:0 -2px 12px rgba(0,0,0,0.25)', | ||
'box-shadow:0 | |||
].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 = | ||
'< | '<button id="gr-hl-prev" 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="15 18 9 12 15 6"/></svg>' + | |||
'<button id="gr-hl-next" style=" | '<span>Prev</span>' + | ||
'<button id="gr-hl-results" style=" | '</button>' + | ||
'<button id="gr-hl-dismiss" style=" | '<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' ); | ||