feat(mobile,pwa): implement responsive viewport, mobile drawer and pwa support
Deploy Development / deploy (push) Successful in 20s
Deploy Development / deploy (push) Successful in 20s
This commit is contained in:
1 parent
83177f31f8
commit
5c99ce6f22
11 files changed
+367
-12
No files matched your search
@@ -709,47 +709,156 @@ body.mediawiki:not(.mw-special-Userlogin) .mw-body-content h3 {
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
body.mediawiki.km-sidebar-open:not(.mw-special-Userlogin)::before {
|
||||
content: '';
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background: rgba(0, 0, 0, 0.65);
|
||||
backdrop-filter: blur(2px);
|
||||
z-index: 999;
|
||||
}
|
||||
|
||||
body.mediawiki:not(.mw-special-Userlogin) #mw-panel {
|
||||
position: fixed !important;
|
||||
left: -13em !important;
|
||||
left: -14em !important;
|
||||
top: 0 !important;
|
||||
bottom: 0 !important;
|
||||
width: 12.2em !important;
|
||||
width: 13em !important;
|
||||
overflow-y: auto !important;
|
||||
transition: left 0.22s ease !important;
|
||||
transition: left 0.24s cubic-bezier(0.4, 0, 0.2, 1) !important;
|
||||
z-index: 1000 !important;
|
||||
box-shadow: 4px 0 24px rgba(0, 0, 0, 0.3) !important;
|
||||
}
|
||||
|
||||
body.mediawiki.km-sidebar-open:not(.mw-special-Userlogin) #mw-panel {
|
||||
left: 0 !important;
|
||||
}
|
||||
|
||||
body.mediawiki:not(.mw-special-Userlogin) #content.mw-body,
|
||||
body.mediawiki:not(.mw-special-Userlogin) #mw-head-base {
|
||||
margin-left: 0 !important;
|
||||
height: auto !important;
|
||||
}
|
||||
|
||||
body.mediawiki:not(.mw-special-Userlogin) #mw-head {
|
||||
position: relative !important;
|
||||
width: 100% !important;
|
||||
box-sizing: border-box !important;
|
||||
padding: 6px 12px !important;
|
||||
background: #ffffff !important;
|
||||
border-bottom: 1px solid #e5e7eb !important;
|
||||
}
|
||||
|
||||
body.mediawiki:not(.mw-special-Userlogin) #left-navigation,
|
||||
body.mediawiki:not(.mw-special-Userlogin) #right-navigation {
|
||||
float: none !important;
|
||||
margin-left: 0 !important;
|
||||
margin-right: 0 !important;
|
||||
display: flex !important;
|
||||
flex-wrap: wrap !important;
|
||||
align-items: center !important;
|
||||
width: 100% !important;
|
||||
}
|
||||
|
||||
body.mediawiki:not(.mw-special-Userlogin) #p-personal {
|
||||
position: relative !important;
|
||||
top: auto !important;
|
||||
right: auto !important;
|
||||
float: none !important;
|
||||
margin: 4px 0 8px 0 !important;
|
||||
}
|
||||
|
||||
body.mediawiki:not(.mw-special-Userlogin) #p-personal ul {
|
||||
display: flex !important;
|
||||
flex-wrap: wrap !important;
|
||||
gap: 6px 12px !important;
|
||||
padding: 0 !important;
|
||||
margin: 0 !important;
|
||||
}
|
||||
|
||||
body.mediawiki:not(.mw-special-Userlogin) #p-search {
|
||||
float: none !important;
|
||||
margin: 6px 0 !important;
|
||||
width: 100% !important;
|
||||
}
|
||||
|
||||
body.mediawiki:not(.mw-special-Userlogin) #p-search form {
|
||||
display: flex !important;
|
||||
width: 100% !important;
|
||||
}
|
||||
|
||||
body.mediawiki:not(.mw-special-Userlogin) #searchInput {
|
||||
width: 100% !important;
|
||||
box-sizing: border-box !important;
|
||||
height: 38px !important;
|
||||
font-size: 16px !important;
|
||||
}
|
||||
|
||||
body.mediawiki:not(.mw-special-Userlogin) #content.mw-body,
|
||||
body.mediawiki:not(.mw-special-Userlogin) #footer {
|
||||
margin-left: 0.6em !important;
|
||||
margin-right: 0.6em !important;
|
||||
margin-left: 0.5rem !important;
|
||||
margin-right: 0.5rem !important;
|
||||
}
|
||||
|
||||
body.mediawiki:not(.mw-special-Userlogin) #content.mw-body {
|
||||
padding: 1.1em 1.1em 1.8em 1.1em !important;
|
||||
padding: 1rem 1rem 1.6rem 1rem !important;
|
||||
border-radius: 10px !important;
|
||||
}
|
||||
|
||||
body.mediawiki:not(.mw-special-Userlogin) .mw-body-content {
|
||||
font-size: 1.02rem !important;
|
||||
line-height: 1.7 !important;
|
||||
}
|
||||
|
||||
body.mediawiki:not(.mw-special-Userlogin) h1.firstHeading {
|
||||
font-size: 1.55rem !important;
|
||||
}
|
||||
|
||||
.kd-hero {
|
||||
padding: 20px 18px;
|
||||
padding: 18px 16px;
|
||||
}
|
||||
|
||||
.kd-hero-title {
|
||||
font-size: 1.35rem !important;
|
||||
font-size: 1.3rem !important;
|
||||
}
|
||||
|
||||
.kd-hero-search {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.kd-hero-search-btn {
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.kd-belt-grid {
|
||||
grid-template-columns: repeat(2, 1fr) !important;
|
||||
gap: 8px !important;
|
||||
}
|
||||
|
||||
.kd-cards-grid {
|
||||
grid-template-columns: 1fr !important;
|
||||
gap: 14px !important;
|
||||
}
|
||||
|
||||
#mw-content-text table {
|
||||
display: block !important;
|
||||
width: 100% !important;
|
||||
max-width: 100% !important;
|
||||
overflow-x: auto !important;
|
||||
-webkit-overflow-scrolling: touch !important;
|
||||
}
|
||||
|
||||
.karate-media-wrapper {
|
||||
width: 100% !important;
|
||||
max-width: 100% !important;
|
||||
}
|
||||
|
||||
.karate-video-player {
|
||||
width: 100% !important;
|
||||
height: auto !important;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -66,4 +66,11 @@
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
// 3. PWA Service Worker Registrierung
|
||||
if ( 'serviceWorker' in navigator && ( window.location.protocol === 'https:' || window.location.hostname === 'localhost' || window.location.hostname === '192.168.2.49' ) ) {
|
||||
window.addEventListener( 'load', function () {
|
||||
navigator.serviceWorker.register( '/sw.js' ).catch( function () {} );
|
||||
} );
|
||||
}
|
||||
}() );
|
||||
@@ -133,8 +133,83 @@ class KarateMediaHooks {
|
||||
public static function onBeforePageDisplay( $out, $skin ): void {
|
||||
$out->addModules( [ 'ext.karateMedia' ] );
|
||||
|
||||
// Wichtig fuer moderne Smartphone- & Tablet-Darstellung
|
||||
$out->addMeta( 'viewport', 'width=device-width, initial-scale=1.0' );
|
||||
// 1. Skin als responsive kennzeichnen, damit MediaWiki den Standard-Viewport (width=device-width)
|
||||
// akzeptiert und das veraltete Desktop-width=1120 unterlaesst:
|
||||
try {
|
||||
$skinRefl = new \ReflectionClass( $skin );
|
||||
if ( $skinRefl->hasProperty( 'options' ) ) {
|
||||
$optProp = $skinRefl->getProperty( 'options' );
|
||||
$optProp->setAccessible( true );
|
||||
$opts = $optProp->getValue( $skin ) ?: [];
|
||||
$opts['responsive'] = true;
|
||||
$optProp->setValue( $skin, $opts );
|
||||
}
|
||||
} catch ( \Throwable $e ) {
|
||||
$bindSkin = \Closure::bind( function () {
|
||||
$this->options['responsive'] = true;
|
||||
}, $skin, $skin );
|
||||
if ( $bindSkin ) {
|
||||
$bindSkin();
|
||||
}
|
||||
}
|
||||
|
||||
// 2. Etwaige alte oder doppelte Viewport-Tags (insbesondere width=1120) aus mMetatags entfernen
|
||||
try {
|
||||
$outRefl = new \ReflectionClass( $out );
|
||||
if ( $outRefl->hasProperty( 'mMetatags' ) ) {
|
||||
$metaProp = $outRefl->getProperty( 'mMetatags' );
|
||||
$metaProp->setAccessible( true );
|
||||
$tags = $metaProp->getValue( $out ) ?: [];
|
||||
$cleaned = [];
|
||||
foreach ( $tags as $t ) {
|
||||
if ( isset( $t[0] ) && strtolower( $t[0] ) === 'viewport' ) {
|
||||
continue;
|
||||
}
|
||||
$cleaned[] = $t;
|
||||
}
|
||||
$metaProp->setValue( $out, $cleaned );
|
||||
}
|
||||
} catch ( \Throwable $e ) {
|
||||
$bindOut = \Closure::bind( function () {
|
||||
$this->mMetatags = array_values( array_filter(
|
||||
$this->mMetatags,
|
||||
static fn( $t ) => !( isset( $t[0] ) && strtolower( $t[0] ) === 'viewport' )
|
||||
) );
|
||||
}, $out, $out );
|
||||
if ( $bindOut ) {
|
||||
$bindOut();
|
||||
}
|
||||
}
|
||||
|
||||
// 3. Garantierter, fluessiger mobiler Viewport fuer alle Smartphones & Tablets
|
||||
$out->addMeta( 'viewport', 'width=device-width, initial-scale=1.0, maximum-scale=5.0' );
|
||||
|
||||
// 4. PWA Web App Manifest, App-Icons & Mobile-Fullscreen-Metatags
|
||||
$pwaHead = implode( "\n", [
|
||||
'<link rel="manifest" href="/manifest.webmanifest">',
|
||||
'<link rel="icon" type="image/svg+xml" href="/resources/assets/icon.svg">',
|
||||
'<link rel="apple-touch-icon" href="/resources/assets/icon.svg">',
|
||||
'<meta name="theme-color" content="#1a1a1a">',
|
||||
'<meta name="apple-mobile-web-app-capable" content="yes">',
|
||||
'<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">',
|
||||
'<meta name="apple-mobile-web-app-title" content="Karate-Wiki">',
|
||||
'<meta name="mobile-web-app-capable" content="yes">'
|
||||
] );
|
||||
$out->addHeadItem( 'karate-pwa-meta', $pwaHead );
|
||||
|
||||
// 5. Client-seitige Absicherung: Falls die Skin nachtraeglich noch width=1120 einfuegt,
|
||||
// wird dies sofort beim Head-Parsing entfernt, bevor der Browser skaliert:
|
||||
$inlineGuard = '<script>(function(){' .
|
||||
'var metas=document.querySelectorAll(\'meta[name="viewport"]\');' .
|
||||
'if(metas.length>1){' .
|
||||
'for(var i=0;i<metas.length;i++){' .
|
||||
'if((metas[i].getAttribute(\'content\')||\'\').indexOf(\'1120\')!==-1){' .
|
||||
'metas[i].remove();' .
|
||||
'}' .
|
||||
'}' .
|
||||
'}' .
|
||||
'})();</script>';
|
||||
$out->addHeadItem( 'karate-viewport-guard', $inlineGuard );
|
||||
|
||||
$title = $out->getTitle();
|
||||
$user = $out->getUser();
|
||||
|
||||
Reference in new issue
Block a user