Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
CSU
tweeki
Commits
42f41913
Commit
42f41913
authored
Apr 27, 2019
by
Tobias Haider
Browse files
Manipulate headings for proper padding on the server and not via javascript
parent
d1936ec7
Changes
3
Hide whitespace changes
Inline
Side-by-side
includes/Hooks.php
View file @
42f41913
...
...
@@ -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
...
...
skin.json
View file @
42f41913
...
...
@@ -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"
:
{
...
...
tweeki.js
View file @
42f41913
...
...
@@ -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);
});
*/
/**
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment