From 75ff121b290ce0cd6b4d783fbce310887753f3cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartosz=20Dziewo=C5=84ski?= Date: Tue, 26 Mar 2019 20:54:04 +0100 Subject: [PATCH] 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 --- ...t.mw.DesktopArticleTarget.init-minerva.css | 32 +++++++------------ .../ve.init.mw.DesktopArticleTarget.init.js | 16 +++++++--- 2 files changed, 22 insertions(+), 26 deletions(-) diff --git a/modules/ve-mw/init/styles/ve.init.mw.DesktopArticleTarget.init-minerva.css b/modules/ve-mw/init/styles/ve.init.mw.DesktopArticleTarget.init-minerva.css index 1c28a3f5c0..5f0de204d2 100644 --- a/modules/ve-mw/init/styles/ve.init.mw.DesktopArticleTarget.init-minerva.css +++ b/modules/ve-mw/init/styles/ve.init.mw.DesktopArticleTarget.init-minerva.css @@ -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; } diff --git a/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.init.js b/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.init.js index 83e132be66..933b9549ac 100644 --- a/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.init.js +++ b/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.init.js @@ -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 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' ) {