Changes to portlets for greater compatibility with other skins

Rename `pagetools` to `views`, `pageactions` to `cactions`, and
`cactions` from last commit back to `pagemisc`.
Make empty portlets available on page but hidden (display:none)
 with css class emptyPortlet, which can be removed by scripts
that add links to portlets (mw.util.addPortletLink already does
this).

Bug: T181362
Change-Id: I56d5b9df529abbdfead26cc46b8fe28935b417c3
isekai
evad37 7 years ago
parent ca0e5e20f9
commit 212357d9b8

@ -74,7 +74,7 @@ class TimelessTemplate extends BaseTemplate {
'timeless-namespaces' 'timeless-namespaces'
) . ) .
$this->getPortlet( $this->getPortlet(
'pagetools', 'views',
$this->pileOfTools['page-primary'], $this->pileOfTools['page-primary'],
'timeless-pagetools' 'timeless-pagetools'
) )
@ -176,12 +176,14 @@ class TimelessTemplate extends BaseTemplate {
if ( is_array( $content ) ) { if ( is_array( $content ) ) {
$contentText = Html::openElement( 'ul' ); $contentText = Html::openElement( 'ul' );
foreach ( $content as $key => $item ) { if ( count( $content ) > 0 ) {
$contentText .= $this->makeListItem( foreach ( $content as $key => $item ) {
$key, $contentText .= $this->makeListItem(
$item, $key,
[ 'text-wrapper' => [ 'tag' => 'span' ] ] $item,
); [ 'text-wrapper' => [ 'tag' => 'span' ] ]
);
}
} }
// Add in SkinTemplateToolboxEnd, if any // Add in SkinTemplateToolboxEnd, if any
$contentText .= $hookContents; $contentText .= $hookContents;
@ -192,7 +194,7 @@ class TimelessTemplate extends BaseTemplate {
$html = Html::rawElement( 'div', [ $html = Html::rawElement( 'div', [
'role' => 'navigation', 'role' => 'navigation',
'class' => 'mw-portlet', 'class' => [ 'mw-portlet', 'emptyPortlet' => count( $content ) === 0 ],
'id' => Sanitizer::escapeId( 'p-' . $name ), 'id' => Sanitizer::escapeId( 'p-' . $name ),
'title' => Linker::titleAttrib( 'p-' . $name ), 'title' => Linker::titleAttrib( 'p-' . $name ),
'aria-labelledby' => $labelId 'aria-labelledby' => $labelId
@ -401,22 +403,18 @@ class TimelessTemplate extends BaseTemplate {
*/ */
protected function getPageToolSidebar() { protected function getPageToolSidebar() {
$pageTools = ''; $pageTools = '';
if ( count( $this->pileOfTools['page-secondary'] ) > 0 ) {
$pageTools .= $this->getPortlet(
'pageactions',
$this->pileOfTools['page-secondary'],
'timeless-pageactions'
);
}
if ( count( $this->pileOfTools['user'] ) > 0 ) {
$pageTools .= $this->getPortlet(
'userpagetools',
$this->pileOfTools['user'],
'timeless-userpagetools'
);
}
$pageTools .= $this->getPortlet( $pageTools .= $this->getPortlet(
'cactions', 'cactions',
$this->pileOfTools['page-secondary'],
'timeless-pageactions'
);
$pageTools .= $this->getPortlet(
'userpagetools',
$this->pileOfTools['user'],
'timeless-userpagetools'
);
$pageTools .= $this->getPortlet(
'pagemisc',
$this->pileOfTools['page-tertiary'], $this->pileOfTools['page-tertiary'],
'timeless-pagemisc' 'timeless-pagemisc'
); );

@ -228,7 +228,7 @@ div.suggestions {
margin-right: 1em; margin-right: 1em;
} }
} }
#p-pagetools { #p-views {
float: right; float: right;
li { li {
@ -522,10 +522,15 @@ table.wikitable > * > tr > th {
margin-right: @column-right-size + 1em; margin-right: @column-right-size + 1em;
} }
/* Portlets */
.emptyPortlet {
display: none;
}
/* Hidden stuff */ /* Hidden stuff */
#p-namespaces h3, #p-namespaces h3,
#p-pagetools h3, #p-views h3,
#p-search h3 { #p-search h3 {
.hidden; .hidden;
} }

Loading…
Cancel
Save