Merge "ve.init.mw.DesktopArticleTarget.init: Make multi-tab mode compatible with Minerva"

This commit is contained in:
jenkins-bot 2018-11-07 12:26:38 +00:00 committed by Gerrit Code Review
commit 45c9ff5e21
3 changed files with 87 additions and 1 deletions

View file

@ -295,6 +295,10 @@
],
"apex": [
"modules/ve-mw/init/styles/ve.init.mw.DesktopArticleTarget.init-apextheme.css"
],
"minerva": [
"modules/ve-mw/init/styles/ve.init.mw.DesktopArticleTarget.init-wikimediatheme.css",
"modules/ve-mw/init/styles/ve.init.mw.DesktopArticleTarget.init-minerva.css"
]
},
"dependencies": [

View file

@ -0,0 +1,48 @@
/*!
* VisualEditor MediaWiki DesktopArticleTarget Minerva skin init styles.
*
* @copyright 2011-2018 VisualEditor Team and others; see AUTHORS.txt
* @license The MIT License (MIT); see LICENSE.txt
*/
/* stylelint-disable selector-max-id */
.ve-edit-source .mw-ui-icon,
.ve-edit-visual .mw-ui-icon {
position: absolute;
opacity: 0.65;
transform: scale( 0.6 );
right: 0.5em;
bottom: 0;
transform-origin: bottom right;
}
.ve-edit-source .mw-ui-icon:before,
.ve-edit-visual .mw-ui-icon:before {
/* Override weird styles from MW-UI */
margin-right: 0;
}
/* Silly selector for high specificity to override Minerva styles */
#page-actions li#ca-edit {
margin-right: 0;
}
#page-actions li#ca-edit:first-child,
#page-actions li#ca-ve-edit:first-child {
margin-right: -0.5em;
}
.mw-editsection-divider {
display: none;
}
/* Swap the order to visually match the order in the actions menu */
/* Silly selector for high specificity to override Minerva styles */
.content .mw-parser-output > * > span.mw-editsection {
display: flex;
}
.content .mw-parser-output > * > span.mw-editsection .ve-edit-visual {
order: 2;
}

View file

@ -626,7 +626,10 @@
setupMultiTabs: function () {
var caVeEdit,
action = pageExists ? 'edit' : 'create',
pTabsId = $( '#p-views' ).length ? 'p-views' : 'p-cactions',
isMinerva = mw.config.get( 'skin' ) === 'minerva',
// HACK: Minerva doesn't have a normal tabs container, this only kind of works
pTabsId = isMinerva ? 'mw-mf-page-center' :
$( '#p-views' ).length ? 'p-views' : 'p-cactions',
$caSource = $( '#ca-viewsource' ),
$caEdit = $( '#ca-edit' ),
$caVeEdit = $( '#ca-ve-edit' ),
@ -668,6 +671,10 @@
);
$caVeEdit = $( caVeEdit );
// HACK: Copy the 'class' attribute, otherwise the link is invisible on Minerva
if ( isMinerva ) {
$caVeEdit.attr( 'class', $caEdit.attr( 'class' ) );
}
$caVeEditLink = $caVeEdit.find( 'a' );
}
} else if ( $caEdit.length && $caVeEdit.length ) {
@ -714,6 +721,19 @@
}
}
if ( isMinerva ) {
// Minerva hides the link text - display tiny icons instead
mw.loader.load( [ 'oojs-ui.styles.icons-editing-advanced', 'oojs-ui.styles.icons-accessibility' ] );
$caEdit.find( 'a' ).each( function () {
var $icon = $( '<span>' ).addClass( 'mw-ui-icon mw-ui-icon-before mw-ui-icon-wikiText' );
$( this ).addClass( 've-edit-source' ).prepend( $icon );
} );
$caVeEdit.find( 'a' ).each( function () {
var $icon = $( '<span>' ).addClass( 'mw-ui-icon mw-ui-icon-before mw-ui-icon-eye' );
$( this ).addClass( 've-edit-visual' ).prepend( $icon );
} );
}
if ( init.isVisualAvailable ) {
if ( conf.tabPosition === 'before' ) {
$caEdit.addClass( 'collapsible' );
@ -725,6 +745,7 @@
setupMultiSectionLinks: function () {
var $editsections = $( '#mw-content-text .mw-editsection' ),
isMinerva = mw.config.get( 'skin' ) === 'minerva',
bodyDir = $( 'body' ).css( 'direction' );
// Match direction of the user interface
@ -766,6 +787,19 @@
} );
}
if ( isMinerva ) {
// Minerva hides the link text - display tiny icons instead
mw.loader.load( [ 'oojs-ui.styles.icons-editing-advanced', 'oojs-ui.styles.icons-accessibility' ] );
$( '#mw-content-text .mw-editsection a:not(.mw-editsection-visualeditor)' ).each( function () {
var $icon = $( '<span>' ).addClass( 'mw-ui-icon mw-ui-icon-before mw-ui-icon-wikiText' );
$( this ).addClass( 've-edit-source' ).prepend( $icon );
} );
$( '#mw-content-text .mw-editsection a.mw-editsection-visualeditor' ).each( function () {
var $icon = $( '<span>' ).addClass( 'mw-ui-icon mw-ui-icon-before mw-ui-icon-eye' );
$( this ).addClass( 've-edit-visual' ).prepend( $icon );
} );
}
if ( pageCanLoadEditor ) {
// Only init without refresh if we're on a view page. Though section edit links
// are rarely shown on non-view pages, they appear in one other case, namely