JGonera has uploaded a new change for review.
https://gerrit.wikimedia.org/r/83597
Change subject: Override Skin::doEditSectionLink
......................................................................
Override Skin::doEditSectionLink
So that in future we can reduce the amount of hacks in editor.js
Change-Id: I8cfaed6313c398deabdea809f53f65d4b7f4da42
---
M MobileFrontend.php
M includes/Resources.php
M includes/formatters/MobileFormatter.php
M includes/formatters/MobileFormatterHTML.php
M includes/skins/SkinMobile.php
M javascripts/modules/editor/editor.js
M less/common/hacks.less
M less/modules/editor.less
M stylesheets/modules/editor.css
9 files changed, 67 insertions(+), 24 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend
refs/changes/97/83597/1
diff --git a/MobileFrontend.php b/MobileFrontend.php
index 73fe178..acc982b 100644
--- a/MobileFrontend.php
+++ b/MobileFrontend.php
@@ -240,11 +240,13 @@
'HTML' => array(),
// WML view
'WML' => array(
+ // FIXME: remove when SkinMobile::doEditSectionLink present in
cached pages
'.mw-editsection',
'sup.reference', // References generally don't work in WML due
to per-section views
),
// Text extracts
'extracts' => array(
+ // FIXME: remove .mw-editsection when
SkinMobile::doEditSectionLink present in cached pages
'table', 'div', '.mw-editsection', 'sup.reference',
'.noexcerpt', '.error'
),
);
diff --git a/includes/Resources.php b/includes/Resources.php
index 5a6fe91..e236fd2 100644
--- a/includes/Resources.php
+++ b/includes/Resources.php
@@ -128,6 +128,9 @@
// Important: This module is loaded on both mobile and desktop skin
'mobile.head' => $wgMFMobileResourceBoilerplate + array(
+ 'dependencies' => array(
+ 'mobile.stable.styles',
+ ),
'scripts' => array(
'javascripts/common/polyfills.js',
'javascripts/common/modules.js',
diff --git a/includes/formatters/MobileFormatter.php
b/includes/formatters/MobileFormatter.php
index 02d083c..e667570 100644
--- a/includes/formatters/MobileFormatter.php
+++ b/includes/formatters/MobileFormatter.php
@@ -154,7 +154,7 @@
// So, using old style for now.
$s = '<div id="content_0" class="content_block openSection">'
. preg_replace_callback(
- '%<h2(.*)<span class="mw-headline"
[^>]*>(.+)</span>[\s\r\n]*</h2>%sU',
+ '%<h2(.*)<span class="mw-headline"
[^>]*>(.+)</span>(.*)</h2>%sU',
array( $this, 'headingTransformCallback' ),
$s
);
diff --git a/includes/formatters/MobileFormatterHTML.php
b/includes/formatters/MobileFormatterHTML.php
index 6e43c02..d476d7c 100644
--- a/includes/formatters/MobileFormatterHTML.php
+++ b/includes/formatters/MobileFormatterHTML.php
@@ -53,7 +53,7 @@
$base .=
Html::rawElement( 'span',
array( 'id' => $headlineId ),
- $matches[2]
+ $matches[2] . $matches[3]
)
. Html::closeElement( 'h2' )
. Html::openElement( 'div',
diff --git a/includes/skins/SkinMobile.php b/includes/skins/SkinMobile.php
index 05159af..ad33665 100644
--- a/includes/skins/SkinMobile.php
+++ b/includes/skins/SkinMobile.php
@@ -23,6 +23,19 @@
}
}
+ /**
+ * Overrides Skin::doEditSectionLink
+ */
+ public function doEditSectionLink( Title $nt, $section, $tooltip =
null, $lang = false ) {
+ $lang = wfGetLangObj( $lang );
+ $message = wfMessage( 'mobile-frontend-editor-edit'
)->inLanguage( $lang )->text();
+ return Html::element( 'a', array(
+ 'href' => '#editor-' . $section,
+ 'data-section' => $section,
+ 'class' => 'edit-page'
+ ), $message );
+ }
+
public function outputPage( OutputPage $out = null ) {
global $wgMFNoindexPages;
wfProfileIn( __METHOD__ );
diff --git a/javascripts/modules/editor/editor.js
b/javascripts/modules/editor/editor.js
index 688377e..18b2481 100644
--- a/javascripts/modules/editor/editor.js
+++ b/javascripts/modules/editor/editor.js
@@ -16,23 +16,20 @@
function addEditButton( section, container ) {
return $( '<a class="edit-page" href="#editor-' + section +
'">' ).
text( mw.msg( 'mobile-frontend-editor-edit' ) ).
- prependTo( container ).
- // FIXME change when micro.tap.js in stable
- on( M.tapEvent( 'mouseup' ), function( ev ) {
- // prevent folding section when clicking Edit
- ev.stopPropagation();
- } );
+ prependTo( container );
}
- function addCtaButton( hash, container, returnToQuery ) {
- addEditButton( '', container ).
+ function makeCta( $el, hash, returnToQuery ) {
+ $el.
// FIXME change when micro.tap.js in stable
on( M.tapEvent( 'mouseup' ), function( ev ) {
ev.preventDefault();
+ // prevent folding section when clicking Edit
+ ev.stopPropagation();
// need to use toggle() because we do
ev.stopPropagation() (in addEditButton())
drawer.
render( { queryParams: {
- returnto: mw.config.get(
'wgPageName' ) + '#' + hash,
+ returnto: mw.config.get(
'wgPageName' ) + hash,
returntoquery: returnToQuery
} } ).
toggle();
@@ -41,7 +38,7 @@
on( 'click', false );
}
- // FIXME [ParserOutput]: This is nasty
+ // FIXME: remove when SkinMobile::doEditSectionLink present in cached
pages
function extractSectionIdFromEditLink( $a ) {
var editHref = $a.attr( 'href' ),
qs = editHref.split( '?' )[ 1 ],
@@ -77,10 +74,22 @@
addEditButton( 1, '#ca-edit' );
}
+ // FIXME change when micro.tap.js in stable
+ $( '.edit-page' ).on( M.tapEvent( 'mouseup' ), function( ev ) {
+ // prevent folding section when clicking Edit
+ ev.stopPropagation();
+ } );
+
+ // FIXME: remove when SkinMobile::doEditSectionLink present in
cached pages
$( 'h2 .mw-editsection' ).each( function() {
var section = extractSectionIdFromEditLink( $( this
).find( 'a' ) );
if ( section ) {
- addEditButton( section, $( this ).parent() );
+ addEditButton( section, $( this ).parent() ).
+ // FIXME change when micro.tap.js in
stable
+ on( M.tapEvent( 'mouseup' ), function(
ev ) {
+ // prevent folding section when
clicking Edit
+ ev.stopPropagation();
+ } );
}
$( this ).remove();
} );
@@ -92,17 +101,32 @@
drawer.render( { queryParams :{ returntoquery:
'article_action=edit' } } ).show();
} );
- $( 'h2 .mw-editsection' ).each( function() {
- var $heading = $( this ).parent(), section;
+ $( '.edit-page' ).each( function() {
+ var $a = $( this ), $heading = $( this ).closest( 'h2'
);
if ( mw.config.get( 'wgMFMode' ) === 'stable' ) {
- addCtaButton( $heading.attr( 'id' ), $heading );
+ makeCta( $a, '#' + $heading.attr( 'id' ) );
+ } else {
+ if ( !M.isTestA ) {
+ makeCta( $a, $a.attr( 'href' ) );
+ } else {
+ makeCta( $a, '#' + $heading.attr( 'id'
), 'article_action=edit' );
+ }
+ }
+ } );
+
+ // FIXME: remove when SkinMobile::doEditSectionLink present in
cached pages
+ $( 'h2 .mw-editsection' ).each( function() {
+ var $heading = $( this ).closest( 'h2' ), $a =
addEditButton( '', $heading ), section;
+
+ if ( mw.config.get( 'wgMFMode' ) === 'stable' ) {
+ makeCta( $a, '#' + $heading.attr( 'id' ) );
} else {
if ( !M.isTestA ) {
section = extractSectionIdFromEditLink(
$( this ).find( 'a' ) );
- addCtaButton( 'editor-' + section,
$heading );
+ makeCta( $a, '#editor-' + section );
} else {
- addCtaButton( $heading.attr( 'id' ),
$heading, 'article_action=edit' );
+ makeCta( $a, '#' + $heading.attr( 'id'
), 'article_action=edit' );
}
}
} );
@@ -118,8 +142,9 @@
}
} else {
// FIXME change when micro.tap.js in stable
- $( '#ca-edit' ).on( M.tapEvent( 'click' ), function() {
+ $( '#ca-edit, .edit-page' ).on( M.tapEvent( 'click' ),
function( ev ) {
popup.show( mw.msg( isEditingSupported ?
'mobile-frontend-editor-disabled' : 'mobile-frontend-editor-unavailable' ),
'toast' );
+ ev.preventDefault();
} );
}
diff --git a/less/common/hacks.less b/less/common/hacks.less
index aa5ea1b..6a99af7 100644
--- a/less/common/hacks.less
+++ b/less/common/hacks.less
@@ -89,7 +89,7 @@
}
}
-// FIXME: [ParserOutput] This hides the default edit link (see bug 49208)
+// FIXME: remove when SkinMobile::doEditSectionLink present in cached pages
.editsection,
.mw-editsection {
display: none;
diff --git a/less/modules/editor.less b/less/modules/editor.less
index 1441d77..dbaf5b8 100644
--- a/less/modules/editor.less
+++ b/less/modules/editor.less
@@ -1,6 +1,6 @@
@import "../mixins.less";
-.section_heading {
+.section {
.edit-page {
position: absolute;
background: url(../common/images/pagemenu/edit.png) 100%
@headingMargin no-repeat;
@@ -14,7 +14,7 @@
display: none;
}
- &.openSection .edit-page {
+ h2.openSection .edit-page {
display: block;
}
}
diff --git a/stylesheets/modules/editor.css b/stylesheets/modules/editor.css
index 3531c23..f2766a4 100644
--- a/stylesheets/modules/editor.css
+++ b/stylesheets/modules/editor.css
@@ -5,7 +5,7 @@
* Please edit the corresponding less file instead.
* See README.mediawiki for details on installing.
*/
-.section_heading .edit-page {
+.section .edit-page {
position: absolute;
background: url(../common/images/pagemenu/edit.png) 100% 9pt no-repeat;
/* use -webkit prefix for older android browsers eg. nexus 1 */
@@ -21,7 +21,7 @@
right: 0;
display: none;
}
-.section_heading.openSection .edit-page {
+.section h2.openSection .edit-page {
display: block;
}
.stub .edit-page {
--
To view, visit https://gerrit.wikimedia.org/r/83597
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I8cfaed6313c398deabdea809f53f65d4b7f4da42
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: JGonera <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits