Jdlrobson has uploaded a new change for review.
https://gerrit.wikimedia.org/r/197998
Change subject: Delegate main menu generation to MobileFrontend + generalise EL
......................................................................
Delegate main menu generation to MobileFrontend + generalise EL
SkinMinerva should make its own decisions about its preferred default
menu on available extensions.
This change:
* Adds collections when available to main menu
* Generalises event logging for main menu moving it to MainMenu.js
* Kill MobilePersonalTools hook
Change-Id: Ie70d08c9272e584a73d1ba6d08543327716f9420
---
M includes/skins/SkinMinerva.php
M includes/skins/SkinMinervaBeta.php
M javascripts/loggingSchemas/init.js
M javascripts/modules/mainMenu/MainMenu.js
M javascripts/modules/mainMenu/init.js
5 files changed, 54 insertions(+), 29 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend
refs/changes/98/197998/1
diff --git a/includes/skins/SkinMinerva.php b/includes/skins/SkinMinerva.php
index 9a53858..1087c97 100644
--- a/includes/skins/SkinMinerva.php
+++ b/includes/skins/SkinMinerva.php
@@ -348,6 +348,7 @@
'text' => wfMessage(
'mobile-frontend-main-menu-watchlist' )->escaped(),
'href' =>
$this->getPersonalUrl( $watchTitle, $watchlistQuery ),
'class' => MobileUI::iconClass(
'watchlist', 'before' ),
+ 'data-event-name' =>
'watchlist',
),
),
'class' => 'jsonly'
@@ -361,6 +362,7 @@
'text' => wfMessage(
'mobile-frontend-main-menu-upload' )->escaped(),
'href' =>
$this->getPersonalUrl( $donateTitle ),
'class' =>
MobileUI::iconClass( 'uploads', 'before' ),
+ 'data-event-name' =>
'uploads',
),
),
'class' => 'jsonly',
@@ -373,6 +375,7 @@
'href' =>
SpecialPage::getTitleFor( 'MobileOptions' )->
getLocalUrl( array(
'returnto' => $returnToTitle ) ),
'class' => MobileUI::iconClass(
'settings', 'before' ),
+ 'data-event-name' => 'settings',
),
),
);
@@ -383,14 +386,12 @@
'text' => wfMessage(
'preferences' )->escaped(),
'href' =>
$this->getPersonalUrl( SpecialPage::getTitleFor( 'Preferences' ) ),
'class' => MobileUI::iconClass(
'settings', 'before' ),
+ 'data-event-name' =>
'preferences',
),
),
);
}
$items['auth'] = $this->getLogInOutLink();
-
- // Allow other extensions to add or override tools
- Hooks::run( 'MobilePersonalTools', array( &$items ) );
return $items;
}
@@ -429,6 +430,7 @@
'text' => wfMessage(
'mobile-frontend-home-button' )->escaped(),
'href' =>
Title::newMainPage()->getLocalUrl(),
'class' => MobileUI::iconClass(
'home', 'before' ),
+ 'data-event-name' => 'home',
),
),
),
@@ -441,6 +443,7 @@
'#/random',
'class' => MobileUI::iconClass(
'random', 'before' ),
'id' => 'randomButton',
+ 'data-event-name' => 'random',
),
),
),
@@ -450,6 +453,7 @@
'text' => wfMessage(
'mobile-frontend-main-menu-nearby' )->escaped(),
'href' =>
SpecialPage::getTitleFor( 'Nearby' )->getLocalURL(),
'class' => MobileUI::iconClass(
'nearby', 'before', 'nearby' ),
+ 'data-event-name' => 'nearby',
),
),
'class' => 'jsonly',
@@ -522,12 +526,14 @@
'text' => $username,
'href' =>
SpecialPage::getTitleFor( 'UserProfile', $username )->getLocalUrl(),
'class' => MobileUI::iconClass(
'profile', 'before', 'truncated-text' ),
+ 'data-event-name' => 'profile',
),
array(
'text' => wfMessage(
'mobile-frontend-main-menu-logout' )->escaped(),
'href' => $url,
'class' => MobileUI::iconClass(
'secondary-logout',
'element', 'icon-24px icon-secondary truncated-text' ),
+ 'data-event-name' => 'logout',
),
),
);
@@ -545,6 +551,7 @@
'text' => wfMessage(
'mobile-frontend-main-menu-login' )->escaped(),
'href' => $url,
'class' => MobileUI::iconClass(
'anonymous-white', 'before', 'icon-anon' ),
+ 'data-event-name' => 'login',
),
),
'class' => 'jsonly'
diff --git a/includes/skins/SkinMinervaBeta.php
b/includes/skins/SkinMinervaBeta.php
index 54a0784..9bd6fdc 100644
--- a/includes/skins/SkinMinervaBeta.php
+++ b/includes/skins/SkinMinervaBeta.php
@@ -12,6 +12,32 @@
/** @var string $mode Describes 'stability' of the skin - alpha, beta,
stable */
protected $mode = 'beta';
+ /**
+ * @inheritdoc
+ */
+ protected function getPersonalTools() {
+ $items = parent::getPersonalTools();
+ if ( class_exists( 'Gather\models\Collection' ) ) {
+ $itemArray = array_slice( $items, 0, 1, true ) +
+ array(
+ 'collections' => array(
+ 'links' => array(
+ array(
+ 'text' =>
wfMessage( 'gather-lists-title' )->escaped(),
+ 'href' =>
SpecialPage::getTitleFor( 'Gather' )->getLocalURL(),
+ // FIXME:
Temporarily watchlist icon
+ 'class' =>
MobileUI::iconClass( 'watchlist', 'before' ),
+
'data-event-name' => 'collections',
+ ),
+ ),
+ ),
+ ) +
+ array_slice( $items, 1, count( $items ) - 1,
true );
+ $items = $itemArray;
+ }
+ return $items;
+ }
+
/** @inheritdoc **/
protected function getHeaderHtml() {
$html = parent::getHeaderHtml();
diff --git a/javascripts/loggingSchemas/init.js
b/javascripts/loggingSchemas/init.js
index 11a4d8a..52fc466 100644
--- a/javascripts/loggingSchemas/init.js
+++ b/javascripts/loggingSchemas/init.js
@@ -1,24 +1,9 @@
// Add EventLogging to hamburger menu
( function ( M, $ ) {
var SchemaMobileWebClickTracking = M.require(
'loggingSchemas/SchemaMobileWebClickTracking' ),
- context = M.require( 'context' ),
+ mainMenu = M.require( 'mainMenu' ),
mainMenuSchema = new SchemaMobileWebClickTracking( {},
'MobileWebMainMenuClickTracking' ),
uiSchema = new SchemaMobileWebClickTracking( {},
'MobileWebUIClickTracking' );
-
- /**
- * Get the icon selector for the given main menu element (depending on
alpha/stable mode)
- * @ignore
- * @param {String} name Name of the main menu element
- * @return {String} Complete selector
- */
- function mainMenuIconSelector( name ) {
- // FIXME: Remove when mw-ui-icon is in stable
- if ( !context.isAlphaGroupMember() ) {
- return '#mw-mf-page-left .icon-' + name;
- } else {
- return '#mw-mf-page-left .mw-ui-icon-' + name;
- }
- }
$( function () {
var $profileLink = $( '#mw-mf-last-modified a' )
@@ -32,15 +17,7 @@
} );
} );
- mainMenuSchema.hijackLink( '.icon-home', 'home' );
- mainMenuSchema.hijackLink( mainMenuIconSelector( 'random' ),
'random' );
- mainMenuSchema.hijackLink( mainMenuIconSelector( 'nearby' ),
'nearby' );
- mainMenuSchema.hijackLink( mainMenuIconSelector( 'watchlist' ),
'watchlist' );
- mainMenuSchema.hijackLink( mainMenuIconSelector( 'settings' ),
'settings' );
- mainMenuSchema.hijackLink( mainMenuIconSelector( 'uploads' ),
'uploads' );
- mainMenuSchema.hijackLink( mainMenuIconSelector( 'profile' ),
'profile' );
- mainMenuSchema.hijackLink( mainMenuIconSelector( 'anon' ),
'login' );
- mainMenuSchema.hijackLink( mainMenuIconSelector(
'secondary-logout' ), 'logout' );
+ mainMenu.enableLogging( mainMenuSchema );
uiSchema.hijackLink( $( '#mw-mf-last-modified a span'
).parent(), 'lastmodified-history' );
uiSchema.hijackLink( $profileLink, 'lastmodified-profile' );
uiSchema.hijackLink( '.nearby-button', 'nearby-button' );
diff --git a/javascripts/modules/mainMenu/MainMenu.js
b/javascripts/modules/mainMenu/MainMenu.js
index 57a93e9..726b335 100644
--- a/javascripts/modules/mainMenu/MainMenu.js
+++ b/javascripts/modules/mainMenu/MainMenu.js
@@ -19,7 +19,21 @@
el: '#mw-mf-page-left',
mainMenuButton: '#mw-mf-main-menu-button'
},
-
+ /**
+ * Turn on event logging on the existing main menu by reading
`event-name` data
+ * attributes on elements.
+ * @param {SchemaMobileWebClickTracking} schema to use
+ */
+ enableLogging: function ( schema ) {
+ // FIXME: Should be this.$('a') but doesn't work here.
+ $( '#mw-mf-page-left a' ).each( function () {
+ var $link = $( this ),
+ eventName = $link.data( 'event-name' );
+ if ( eventName ) {
+ schema.hijackLink( $link, eventName );
+ }
+ } );
+ },
/**
* @inheritdoc
* Remove the nearby menu entry if the browser doesn't support
geo location
diff --git a/javascripts/modules/mainMenu/init.js
b/javascripts/modules/mainMenu/init.js
index 692f2c8..d9eec0f 100644
--- a/javascripts/modules/mainMenu/init.js
+++ b/javascripts/modules/mainMenu/init.js
@@ -21,5 +21,6 @@
} );
}
} );
+ M.define( 'mainMenu', mainMenu );
}( mw.mobileFrontend, jQuery ) );
--
To view, visit https://gerrit.wikimedia.org/r/197998
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie70d08c9272e584a73d1ba6d08543327716f9420
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits