ve.init.mw.DesktopArticleTarget.init: Update for Minerva changes

I think mostly the incompatible changes were made in commit
I5a7d73b20617cb3c6d6379084ac4bea23ec3bc74, but I didn't try
to track them down.

Also fix an issue where hrefs in section edit links generated
by this code were wrong.

Bug: T208102
Change-Id: Ibf6564bc0dcb7fcb420739a897b54346a01add02
This commit is contained in:
Bartosz Dziewoński 2019-03-26 20:54:04 +01:00
parent 4fb17205b6
commit 75ff121b29
2 changed files with 22 additions and 26 deletions

View file

@ -12,40 +12,30 @@
position: absolute;
opacity: 0.65;
transform: scale( 0.6 );
right: 0.5em;
right: 0;
bottom: 0;
transform-origin: bottom right;
}
.ve-edit-source .mw-ui-icon:before,
.ve-edit-visual .mw-ui-icon:before {
.ve-edit-source.mw-ui-icon:before,
.ve-edit-visual .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;
background-size: contain;
}
.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 */
/* stylelint-disable-next-line selector-class-pattern */
.content .mw-parser-output > * > span.mw-editsection {
display: flex;
.mw-editsection .ve-edit-source,
.mw-editsection .ve-edit-visual {
display: inline-block;
}
/* stylelint-disable-next-line selector-class-pattern */
.content .mw-parser-output > * > span.mw-editsection .ve-edit-visual {
order: 2;
#page-actions .ve-edit-source,
#page-actions .ve-edit-visual {
padding-right: 0.5em;
}

View file

@ -607,9 +607,10 @@
// 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' ),
// Minerva puts the '#ca-...' ids on <a> nodes
$caSource = $( 'li#ca-viewsource' ),
$caEdit = $( 'li#ca-edit, li#page-actions-edit' ),
$caVeEdit = $( 'li#ca-ve-edit' ),
$caEditLink = $caEdit.find( 'a' ),
$caVeEditLink = $caVeEdit.find( 'a' ),
caVeEditNextnode =
@ -641,11 +642,12 @@
);
$caVeEdit = $( caVeEdit );
$caVeEditLink = $caVeEdit.find( 'a' );
// HACK: Copy the 'class' attribute, otherwise the link is invisible on Minerva
if ( isMinerva ) {
$caVeEdit.attr( 'class', $caEdit.attr( 'class' ) );
$caVeEditLink.attr( 'class', $caEditLink.attr( 'class' ) );
}
$caVeEditLink = $caVeEdit.find( 'a' );
}
} else if ( $caEdit.length && $caVeEdit.length ) {
// Make the state of the page consistent with the config if needed
@ -745,7 +747,11 @@
// Don't mess with section edit links on foreign file description pages (T56259)
if ( !$( '#ca-view-foreign' ).length ) {
$editLink
.attr( 'href', new mw.Uri( veEditUri ) )
.attr( 'href', function ( i, href ) {
var veUri = new mw.Uri( veEditUri );
veUri.query.section = ( new mw.Uri( href ) ).query.section;
return veUri.toString();
} )
.addClass( 'mw-editsection-visualeditor' );
if ( conf.tabPosition === 'before' ) {