Commit 42f41913 authored by Tobias Haider's avatar Tobias Haider
Browse files

Manipulate headings for proper padding on the server and not via javascript

parent d1936ec7
......@@ -47,6 +47,28 @@ class TweekiHooks {
return true;
}
public static function onOutputPageBeforeHTML( &$out, &$text ) {
/* $text = preg_replace( '|(^.*<span class="mw-headline".*?>)(.*?)(</span>)(.*$)|m', '$1$3$2$4', $text ); */
$text = preg_replace_callback(
'/^.*<span class="mw-headline".*$/m',
function( $matches ) {
$doc = new DOMDocument();
$doc->loadHTML( $matches[0] );
$span = $doc->getElementsByTagName('span')[0];
$heading = $doc->createElement("span");
$heading->setAttribute( 'class', 'mw-headline-content' );
while( $span->firstChild ) {
$heading->appendChild( $span->removeChild( $span->firstChild ) );
}
$span->parentNode->insertBefore( $heading, $span );
$span->parentNode->insertBefore( $span, $heading );
return( $doc->saveHTML( $span->parentNode ) );
},
$text
);
}
/**
* Customizing registration
......
......@@ -36,7 +36,8 @@
"AfterFinalPageOutput": "TweekiHooks::onAfterFinalPageOutput",
"MagicWordMagicWords": "TweekiHooks::onMagicWordMagicWords",
"MagicWordwgVariableIDs": "TweekiHooks::onMagicWordwgVariableIDs",
"InternalParseBeforeLinks": "TweekiHooks::onInternalParseBeforeLinks"
"InternalParseBeforeLinks": "TweekiHooks::onInternalParseBeforeLinks",
"OutputPageBeforeHTML": "TweekiHooks::onOutputPageBeforeHTML"
},
"ResourceModules": {
"skins.tweeki.bootstrap.styles": {
......
......@@ -84,10 +84,12 @@ jQuery( function( $ ) {
* If the headline is inside the span it's padding will prevent
* links directly above the headline to be accessible
*/
/* this is done on the server now
$( '.mw-headline' ).each(function( i ) {
$headline_contents = $( this ).contents();
$(this).text('').after($headline_contents);
});
*/
/**
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment