mediawiki-extensions-Echo/modules/ext.echo.init.js

309 lines
11 KiB
JavaScript
Raw Normal View History

/**
* @module module:ext.echo.init
*/
/* eslint-disable no-jquery/no-global-selector */
Dormant mobile notifications overlay lives in Echo This code will be enabled when Iba1d7863171268066bf7597182c57a0a2041497f relinquishes the responsibility for rendering the Echo notification badge and wiring up of the related JS. It makes 3 assumptions: 1) Minerva will expose a VERSION property on the skins.minerva.scripts module to tell Echo it can begin control of the functionality 2) A new hook `SkinMinervaReplaceNotificationsBadge` will run on the server side allowing Echo extension to render the Notifications badge in Minerva. 3) A new client side hook (echo.mobile) will fire whenever the Echo dialog is opened or closed. All code relating to Echo inside MobileFrontend and Minerva is moved here. CSS for the modules is kept in Minerva as skinStyles This code remains dormant until Iba1d7863171268066bf7597182c57a0a2041497f lands. It pre-registers a "to-be-created" hook SkinMinervaReplaceNotificationsBadge that substitutes the Minerva badge. It also watches the export value of skins.minerva.scripts for a VERSION value - when this appears it will take the signal that it should manage the frontend code. In the new system the mobile specific code is limited to the mobile version of Minerva. The desktop version of Echo loads on Minerva desktop - presenting an opportunity in future to consolidate both implementations to use the same component. The mobile version of Vector and Timeless for example will load the mobile overlay (with existing styling issues that we don't need to worry about right now given we don't officially support skins other than Minerva as mobile) Testers: * Check require( 'ext.echo.mobile' )(); inside initMobile inside ext.echo.init does not fire until Iba1d7863171268066bf7597182c57a0a2041497f is checked out. Depends-On: I1a66939d2b596094b419de40b370e79f09c85581 Bug: T221007 Change-Id: I09c27a084100b223662f84de6cbe01bebe1fe774
2019-10-01 20:15:25 +00:00
mw.echo = mw.echo || {};
mw.echo.config = mw.echo.config || {};
// Set default max prioritized action links per item
mw.echo.config.maxPrioritizedActions = 2;
/**
* Initialise desktop Echo experience
*/
function initDesktop() {
Split alerts and messages in Echo Split the notifications into 'alert' and 'message' badget with two different flyouts. Also clean up styling and module behavior. ** Depends on ooui change Id4bbe14ba0bf6c for footers in popups. ** Depends on ooui change Ie93e4d6ed5637c for fixing a bug in inverted icons. ** MobileFrontend must also be updated to support the new modules in this patch I168f485d6e54cb4067 In this change: * Split notifcations into alert and messages and display those in two different badges. * Create two separate flyout/popups for each category with their notifications. * Create a view-model to control notification state and emit events for both the popup and the badge to intercept and react to. * Clean up module load and distribution: * Create an ext.echo.ui module for javascript-ui support and ooui widgets. * Create an ext.echo.nojs module that unifies all base classes that are needed for both nojs and js support, that the js version builds upon. * Create a separate ext.echo.logger module as a singleton that can be called to perform all logging. * Clean up style uses * Move the special page LESS file into nojs module so all styles load properly even in nojs mode. * Transfer some of the styling from JS to LESS for consistency. * Make the 'read more' button load already with the styles it needs to look like a button, since its behavior is similar in nojs and js vesions, but before its classes were applied only by the js, making it inconsistent and also making its appearance 'jump' from a link to a button. * Delete and clean up all old and unused files. * Moved 'Help.png' icon from modules/overlay to modules/icons for later use. Bug: T108190 Change-Id: I55f440ed9f64c46817f620328a6bb522d44c9ca9
2015-08-13 00:54:16 +00:00
'use strict';
// Remove ?markasread=XYZ from the URL
var url = new URL( location.href );
if ( url.searchParams.has( 'markasread' ) ) {
url.searchParams.delete( 'markasread' );
url.searchParams.delete( 'markasreadwiki' );
history.replaceState( null, '', url );
}
// Activate OOUI
$( function () {
var messageController,
alertController,
maxNotificationCount = require( './config.json' ).EchoMaxNotificationCount,
pollingRate = require( './config.json' ).EchoPollForUpdates,
documentTitle = document.title,
$existingAlertLink = $( '#pt-notifications-alert a' ),
$existingMessageLink = $( '#pt-notifications-notice a' ),
numAlerts = $existingAlertLink.attr( 'data-counter-num' ),
numMessages = $existingMessageLink.attr( 'data-counter-num' ),
badgeLabelAlerts = $existingAlertLink.attr( 'data-counter-text' ),
badgeLabelMessages = $existingMessageLink.attr( 'data-counter-text' ),
// eslint-disable-next-line no-jquery/no-class-state
hasUnseenAlerts = $existingAlertLink.hasClass( 'mw-echo-unseen-notifications' ),
// eslint-disable-next-line no-jquery/no-class-state
hasUnseenMessages = $existingMessageLink.hasClass( 'mw-echo-unseen-notifications' ),
// latestMessageNotifTime is the time of most recent notification that came when we called showNotificationSnippet last
// the function showNotificationSnippet returns the time of the latest notification and latestMessageNotifTime is updated
latestMessageNotifTime = new Date(),
latestAlertNotifTime = new Date(),
alertCount = parseInt( numAlerts ),
messageCount = parseInt( numMessages ),
loadingPromise = null,
Split alerts and messages in Echo Split the notifications into 'alert' and 'message' badget with two different flyouts. Also clean up styling and module behavior. ** Depends on ooui change Id4bbe14ba0bf6c for footers in popups. ** Depends on ooui change Ie93e4d6ed5637c for fixing a bug in inverted icons. ** MobileFrontend must also be updated to support the new modules in this patch I168f485d6e54cb4067 In this change: * Split notifcations into alert and messages and display those in two different badges. * Create two separate flyout/popups for each category with their notifications. * Create a view-model to control notification state and emit events for both the popup and the badge to intercept and react to. * Clean up module load and distribution: * Create an ext.echo.ui module for javascript-ui support and ooui widgets. * Create an ext.echo.nojs module that unifies all base classes that are needed for both nojs and js support, that the js version builds upon. * Create a separate ext.echo.logger module as a singleton that can be called to perform all logging. * Clean up style uses * Move the special page LESS file into nojs module so all styles load properly even in nojs mode. * Transfer some of the styling from JS to LESS for consistency. * Make the 'read more' button load already with the styles it needs to look like a button, since its behavior is similar in nojs and js vesions, but before its classes were applied only by the js, making it inconsistent and also making its appearance 'jump' from a link to a button. * Delete and clean up all old and unused files. * Moved 'Help.png' icon from modules/overlay to modules/icons for later use. Bug: T108190 Change-Id: I55f440ed9f64c46817f620328a6bb522d44c9ca9
2015-08-13 00:54:16 +00:00
// Store links
links = {
notifications: $existingAlertLink.attr( 'href' ) || mw.util.getUrl( 'Special:Notifications' ),
preferences: ( $( '#pt-preferences a' ).attr( 'href' ) || mw.util.getUrl( 'Special:Preferences' ) ) +
'#mw-prefsection-echo'
Split alerts and messages in Echo Split the notifications into 'alert' and 'message' badget with two different flyouts. Also clean up styling and module behavior. ** Depends on ooui change Id4bbe14ba0bf6c for footers in popups. ** Depends on ooui change Ie93e4d6ed5637c for fixing a bug in inverted icons. ** MobileFrontend must also be updated to support the new modules in this patch I168f485d6e54cb4067 In this change: * Split notifcations into alert and messages and display those in two different badges. * Create two separate flyout/popups for each category with their notifications. * Create a view-model to control notification state and emit events for both the popup and the badge to intercept and react to. * Clean up module load and distribution: * Create an ext.echo.ui module for javascript-ui support and ooui widgets. * Create an ext.echo.nojs module that unifies all base classes that are needed for both nojs and js support, that the js version builds upon. * Create a separate ext.echo.logger module as a singleton that can be called to perform all logging. * Clean up style uses * Move the special page LESS file into nojs module so all styles load properly even in nojs mode. * Transfer some of the styling from JS to LESS for consistency. * Make the 'read more' button load already with the styles it needs to look like a button, since its behavior is similar in nojs and js vesions, but before its classes were applied only by the js, making it inconsistent and also making its appearance 'jump' from a link to a button. * Delete and clean up all old and unused files. * Moved 'Help.png' icon from modules/overlay to modules/icons for later use. Bug: T108190 Change-Id: I55f440ed9f64c46817f620328a6bb522d44c9ca9
2015-08-13 00:54:16 +00:00
};
function updateDocumentTitleWithNotificationCount( totalAlertCount, totalMessageCount ) {
var totalCount = totalAlertCount + totalMessageCount,
newTitle = documentTitle;
if ( totalCount > 0 ) {
var convertedTotalCount = totalCount <= maxNotificationCount ? totalCount : maxNotificationCount + 1;
convertedTotalCount = mw.msg( 'echo-badge-count', mw.language.convertNumber( convertedTotalCount ) );
newTitle = mw.msg( 'parentheses', convertedTotalCount ) + ' ' + documentTitle;
}
document.title = newTitle;
}
/**
* Show notification snippet via mw.notify of notifications which came after highestNotifTime.
*
* @param {mw.echo.dm.ModelManager} modelManager
* @param {Date} highestNotifTime Timestamp of latest notification the last time function was called
* @return {Date} Timestamp of latest notification
*/
function showNotificationSnippet( modelManager, highestNotifTime ) {
var highestTime = highestNotifTime;
modelManager.getLocalNotifications().forEach( function ( notificationItem ) {
var timestampAsDate = new Date( notificationItem.timestamp );
if ( timestampAsDate > highestNotifTime ) {
if ( timestampAsDate > highestTime ) {
highestTime = timestampAsDate;
}
if ( !notificationItem.seen ) {
mw.notify( $.parseHTML( notificationItem.content.header ), { title: mw.msg( 'echo-displaysnippet-title' ) } );
}
}
}
);
return highestTime;
}
/**
* Change the seen state of badges if there are any unseen notifications.
*
* @param {mw.echo.dm.ModelManager} modelManager
* @param {mw.echo.ui.NotificationBadgeWidget} badgeWidget
*/
function updateBadgeState( modelManager, badgeWidget ) {
modelManager.getLocalNotifications().forEach( function ( notificationItem ) {
if ( !notificationItem.isSeen() ) {
badgeWidget.updateBadgeSeenState( true );
}
} );
}
function isLivePollingFeatureEnabledOnWiki() {
return pollingRate !== 0;
}
/**
* User has opted in to preference to show notification snippets and update document title with unread count.
*
* Only useful when isLivePollingFeatureEnabledOnWiki() returns true.
*
* @return {boolean} User preference
*/
function userHasOptedInToLiveNotifications() {
return mw.user.options.get( 'echo-show-poll-updates' ) === '1';
}
// Change document title on initialization only when polling rate feature flag is non-zero.
if ( isLivePollingFeatureEnabledOnWiki() && userHasOptedInToLiveNotifications() ) {
updateDocumentTitleWithNotificationCount( alertCount, messageCount );
}
function loadEcho() {
if ( loadingPromise !== null ) {
return loadingPromise;
}
// This part executes only once, either when header icons are clicked or after completion of 60secs whichever occur first.
var echoApi = new mw.echo.api.EchoApi();
loadingPromise = mw.loader.using( 'ext.echo.ui.desktop' ).then( function () {
// Overlay
mw.echo.ui.$overlay.appendTo( document.body );
var unreadAlertCounter = new mw.echo.dm.UnreadNotificationCounter( echoApi, 'alert', maxNotificationCount );
var alertModelManager = new mw.echo.dm.ModelManager( unreadAlertCounter, { type: 'alert' } );
alertController = new mw.echo.Controller( echoApi, alertModelManager );
mw.echo.ui.alertWidget = new mw.echo.ui.NotificationBadgeWidget(
alertController,
alertModelManager,
links,
{
numItems: Number( numAlerts ),
convertedNumber: badgeLabelAlerts,
hasUnseen: hasUnseenAlerts,
badgeIcon: 'bell',
$overlay: mw.echo.ui.$overlay,
href: $existingAlertLink.attr( 'href' )
}
);
// Replace the link button with the ooui button
$existingAlertLink.parent().replaceWith( mw.echo.ui.alertWidget.$element );
alertModelManager.on( 'allTalkRead', function () {
// If there was a talk page notification, get rid of it
$( '#pt-talk-alert' ).remove();
} );
// listen to event countChange and change title only if polling rate is non-zero
if ( isLivePollingFeatureEnabledOnWiki() ) {
alertModelManager.getUnreadCounter().on( 'countChange', function ( count ) {
alertController.fetchLocalNotifications().then( function () {
updateBadgeState( alertModelManager, mw.echo.ui.alertWidget );
if ( userHasOptedInToLiveNotifications() ) {
latestAlertNotifTime = showNotificationSnippet( alertModelManager, latestAlertNotifTime );
alertCount = count;
updateDocumentTitleWithNotificationCount( count, messageCount );
}
} );
} );
}
// Load message button and popup if messages exist
if ( $existingMessageLink.length ) {
var unreadMessageCounter = new mw.echo.dm.UnreadNotificationCounter( echoApi, 'message', maxNotificationCount );
var messageModelManager = new mw.echo.dm.ModelManager( unreadMessageCounter, { type: 'message' } );
messageController = new mw.echo.Controller( echoApi, messageModelManager );
mw.echo.ui.messageWidget = new mw.echo.ui.NotificationBadgeWidget(
messageController,
messageModelManager,
links,
{
$overlay: mw.echo.ui.$overlay,
numItems: Number( numMessages ),
hasUnseen: hasUnseenMessages,
badgeIcon: 'tray',
convertedNumber: badgeLabelMessages,
href: $existingMessageLink.attr( 'href' )
}
);
// Replace the link button with the ooui button
$existingMessageLink.parent().replaceWith( mw.echo.ui.messageWidget.$element );
// listen to event countChange and change title only if polling rate is non-zero
if ( isLivePollingFeatureEnabledOnWiki() ) {
messageModelManager.getUnreadCounter().on( 'countChange', function ( count ) {
messageController.fetchLocalNotifications().then( function () {
updateBadgeState( messageModelManager, mw.echo.ui.messageWidget );
if ( userHasOptedInToLiveNotifications() ) {
latestMessageNotifTime = showNotificationSnippet( messageModelManager, latestMessageNotifTime );
messageCount = count;
updateDocumentTitleWithNotificationCount( alertCount, count );
}
} );
} );
}
}
Split alerts and messages in Echo Split the notifications into 'alert' and 'message' badget with two different flyouts. Also clean up styling and module behavior. ** Depends on ooui change Id4bbe14ba0bf6c for footers in popups. ** Depends on ooui change Ie93e4d6ed5637c for fixing a bug in inverted icons. ** MobileFrontend must also be updated to support the new modules in this patch I168f485d6e54cb4067 In this change: * Split notifcations into alert and messages and display those in two different badges. * Create two separate flyout/popups for each category with their notifications. * Create a view-model to control notification state and emit events for both the popup and the badge to intercept and react to. * Clean up module load and distribution: * Create an ext.echo.ui module for javascript-ui support and ooui widgets. * Create an ext.echo.nojs module that unifies all base classes that are needed for both nojs and js support, that the js version builds upon. * Create a separate ext.echo.logger module as a singleton that can be called to perform all logging. * Clean up style uses * Move the special page LESS file into nojs module so all styles load properly even in nojs mode. * Transfer some of the styling from JS to LESS for consistency. * Make the 'read more' button load already with the styles it needs to look like a button, since its behavior is similar in nojs and js vesions, but before its classes were applied only by the js, making it inconsistent and also making its appearance 'jump' from a link to a button. * Delete and clean up all old and unused files. * Moved 'Help.png' icon from modules/overlay to modules/icons for later use. Bug: T108190 Change-Id: I55f440ed9f64c46817f620328a6bb522d44c9ca9
2015-08-13 00:54:16 +00:00
} );
return loadingPromise;
}
// Respond to click on the notification button and load the UI on demand
$( '.mw-echo-notification-badge-nojs' ).on( 'click', function ( e ) {
var timeOfClick = mw.now(),
$badge = $( this ),
clickedSection = $badge.parent().prop( 'id' ) === 'pt-notifications-alert' ? 'alert' : 'message';
if ( e.which !== 1 || $badge.data( 'clicked' ) ) {
// Do not return false (as that calls stopPropagation)
e.preventDefault();
return;
}
$badge.data( 'clicked', true );
// Dim the badge while we load
$badge.addClass( 'mw-echo-notifications-badge-dimmed' );
// Fire the notification API requests
var echoApi = new mw.echo.api.EchoApi();
echoApi.fetchNotifications( clickedSection )
.then( function ( data ) {
mw.track( 'timing.MediaWiki.echo.overlay.api', mw.now() - timeOfClick );
return data;
} );
loadEcho().then( function () {
// Now that the module loaded, show the popup
var selectedWidget = clickedSection === 'alert' ? mw.echo.ui.alertWidget : mw.echo.ui.messageWidget;
selectedWidget.once( 'finishLoading', function () {
// Log timing after notifications are shown
mw.track( 'timing.MediaWiki.echo.overlay', mw.now() - timeOfClick );
} );
selectedWidget.popup.toggle( true );
mw.track( 'timing.MediaWiki.echo.overlay.ooui', mw.now() - timeOfClick );
if ( hasUnseenAlerts || hasUnseenMessages ) {
// Clicked on the flyout due to having unread notifications
// This is part of tracking how likely users are to click a badge with unseen notifications.
// The other part is the 'echo.unseen' counter, see EchoHooks::onSkinTemplateNavigationUniversal().
mw.track( 'counter.MediaWiki.echo.unseen.click' );
}
}, function () {
// Un-dim badge if loading failed
$badge.removeClass( 'mw-echo-notifications-badge-dimmed' );
} );
// Prevent default. Do not return false (as that calls stopPropagation)
e.preventDefault();
Split alerts and messages in Echo Split the notifications into 'alert' and 'message' badget with two different flyouts. Also clean up styling and module behavior. ** Depends on ooui change Id4bbe14ba0bf6c for footers in popups. ** Depends on ooui change Ie93e4d6ed5637c for fixing a bug in inverted icons. ** MobileFrontend must also be updated to support the new modules in this patch I168f485d6e54cb4067 In this change: * Split notifcations into alert and messages and display those in two different badges. * Create two separate flyout/popups for each category with their notifications. * Create a view-model to control notification state and emit events for both the popup and the badge to intercept and react to. * Clean up module load and distribution: * Create an ext.echo.ui module for javascript-ui support and ooui widgets. * Create an ext.echo.nojs module that unifies all base classes that are needed for both nojs and js support, that the js version builds upon. * Create a separate ext.echo.logger module as a singleton that can be called to perform all logging. * Clean up style uses * Move the special page LESS file into nojs module so all styles load properly even in nojs mode. * Transfer some of the styling from JS to LESS for consistency. * Make the 'read more' button load already with the styles it needs to look like a button, since its behavior is similar in nojs and js vesions, but before its classes were applied only by the js, making it inconsistent and also making its appearance 'jump' from a link to a button. * Delete and clean up all old and unused files. * Moved 'Help.png' icon from modules/overlay to modules/icons for later use. Bug: T108190 Change-Id: I55f440ed9f64c46817f620328a6bb522d44c9ca9
2015-08-13 00:54:16 +00:00
} );
function pollForNotificationCountUpdates() {
alertController.refreshUnreadCount();
messageController.refreshUnreadCount();
// Make notification update after n*pollingRate(time in secs) where n depends on document.hidden
setTimeout( pollForNotificationCountUpdates, ( document.hidden ? 5 : 1 ) * pollingRate * 1000 );
}
function pollStart() {
if ( mw.config.get( 'skin' ) !== 'minerva' && isLivePollingFeatureEnabledOnWiki() ) {
// load widgets if not loaded already then start polling
loadEcho().then( pollForNotificationCountUpdates );
}
}
setTimeout( pollStart, 60 * 1000 );
Split alerts and messages in Echo Split the notifications into 'alert' and 'message' badget with two different flyouts. Also clean up styling and module behavior. ** Depends on ooui change Id4bbe14ba0bf6c for footers in popups. ** Depends on ooui change Ie93e4d6ed5637c for fixing a bug in inverted icons. ** MobileFrontend must also be updated to support the new modules in this patch I168f485d6e54cb4067 In this change: * Split notifcations into alert and messages and display those in two different badges. * Create two separate flyout/popups for each category with their notifications. * Create a view-model to control notification state and emit events for both the popup and the badge to intercept and react to. * Clean up module load and distribution: * Create an ext.echo.ui module for javascript-ui support and ooui widgets. * Create an ext.echo.nojs module that unifies all base classes that are needed for both nojs and js support, that the js version builds upon. * Create a separate ext.echo.logger module as a singleton that can be called to perform all logging. * Clean up style uses * Move the special page LESS file into nojs module so all styles load properly even in nojs mode. * Transfer some of the styling from JS to LESS for consistency. * Make the 'read more' button load already with the styles it needs to look like a button, since its behavior is similar in nojs and js vesions, but before its classes were applied only by the js, making it inconsistent and also making its appearance 'jump' from a link to a button. * Delete and clean up all old and unused files. * Moved 'Help.png' icon from modules/overlay to modules/icons for later use. Bug: T108190 Change-Id: I55f440ed9f64c46817f620328a6bb522d44c9ca9
2015-08-13 00:54:16 +00:00
} );
Dormant mobile notifications overlay lives in Echo This code will be enabled when Iba1d7863171268066bf7597182c57a0a2041497f relinquishes the responsibility for rendering the Echo notification badge and wiring up of the related JS. It makes 3 assumptions: 1) Minerva will expose a VERSION property on the skins.minerva.scripts module to tell Echo it can begin control of the functionality 2) A new hook `SkinMinervaReplaceNotificationsBadge` will run on the server side allowing Echo extension to render the Notifications badge in Minerva. 3) A new client side hook (echo.mobile) will fire whenever the Echo dialog is opened or closed. All code relating to Echo inside MobileFrontend and Minerva is moved here. CSS for the modules is kept in Minerva as skinStyles This code remains dormant until Iba1d7863171268066bf7597182c57a0a2041497f lands. It pre-registers a "to-be-created" hook SkinMinervaReplaceNotificationsBadge that substitutes the Minerva badge. It also watches the export value of skins.minerva.scripts for a VERSION value - when this appears it will take the signal that it should manage the frontend code. In the new system the mobile specific code is limited to the mobile version of Minerva. The desktop version of Echo loads on Minerva desktop - presenting an opportunity in future to consolidate both implementations to use the same component. The mobile version of Vector and Timeless for example will load the mobile overlay (with existing styling issues that we don't need to worry about right now given we don't officially support skins other than Minerva as mobile) Testers: * Check require( 'ext.echo.mobile' )(); inside initMobile inside ext.echo.init does not fire until Iba1d7863171268066bf7597182c57a0a2041497f is checked out. Depends-On: I1a66939d2b596094b419de40b370e79f09c85581 Bug: T221007 Change-Id: I09c27a084100b223662f84de6cbe01bebe1fe774
2019-10-01 20:15:25 +00:00
}
/**
* Initialise a mobile experience instead
*/
function initMobile() {
if ( !mw.user.isAnon() ) {
mw.loader.using( [ 'ext.echo.mobile', 'mobile.startup' ] ).then( function ( require ) {
require( 'ext.echo.mobile' ).init();
Dormant mobile notifications overlay lives in Echo This code will be enabled when Iba1d7863171268066bf7597182c57a0a2041497f relinquishes the responsibility for rendering the Echo notification badge and wiring up of the related JS. It makes 3 assumptions: 1) Minerva will expose a VERSION property on the skins.minerva.scripts module to tell Echo it can begin control of the functionality 2) A new hook `SkinMinervaReplaceNotificationsBadge` will run on the server side allowing Echo extension to render the Notifications badge in Minerva. 3) A new client side hook (echo.mobile) will fire whenever the Echo dialog is opened or closed. All code relating to Echo inside MobileFrontend and Minerva is moved here. CSS for the modules is kept in Minerva as skinStyles This code remains dormant until Iba1d7863171268066bf7597182c57a0a2041497f lands. It pre-registers a "to-be-created" hook SkinMinervaReplaceNotificationsBadge that substitutes the Minerva badge. It also watches the export value of skins.minerva.scripts for a VERSION value - when this appears it will take the signal that it should manage the frontend code. In the new system the mobile specific code is limited to the mobile version of Minerva. The desktop version of Echo loads on Minerva desktop - presenting an opportunity in future to consolidate both implementations to use the same component. The mobile version of Vector and Timeless for example will load the mobile overlay (with existing styling issues that we don't need to worry about right now given we don't officially support skins other than Minerva as mobile) Testers: * Check require( 'ext.echo.mobile' )(); inside initMobile inside ext.echo.init does not fire until Iba1d7863171268066bf7597182c57a0a2041497f is checked out. Depends-On: I1a66939d2b596094b419de40b370e79f09c85581 Bug: T221007 Change-Id: I09c27a084100b223662f84de6cbe01bebe1fe774
2019-10-01 20:15:25 +00:00
} );
}
}
$( function () {
if ( mw.config.get( 'wgMFMode' ) ) {
initMobile();
} else {
// Echo is intentionally disable for the Minerva desktop skin (https://phabricator.wikimedia.org/T343839)
// The suggested fix is documented in https://phabricator.wikimedia.org/T343838,
if ( mw.config.get( 'skin' ) !== 'minerva' ) {
initDesktop();
}
Dormant mobile notifications overlay lives in Echo This code will be enabled when Iba1d7863171268066bf7597182c57a0a2041497f relinquishes the responsibility for rendering the Echo notification badge and wiring up of the related JS. It makes 3 assumptions: 1) Minerva will expose a VERSION property on the skins.minerva.scripts module to tell Echo it can begin control of the functionality 2) A new hook `SkinMinervaReplaceNotificationsBadge` will run on the server side allowing Echo extension to render the Notifications badge in Minerva. 3) A new client side hook (echo.mobile) will fire whenever the Echo dialog is opened or closed. All code relating to Echo inside MobileFrontend and Minerva is moved here. CSS for the modules is kept in Minerva as skinStyles This code remains dormant until Iba1d7863171268066bf7597182c57a0a2041497f lands. It pre-registers a "to-be-created" hook SkinMinervaReplaceNotificationsBadge that substitutes the Minerva badge. It also watches the export value of skins.minerva.scripts for a VERSION value - when this appears it will take the signal that it should manage the frontend code. In the new system the mobile specific code is limited to the mobile version of Minerva. The desktop version of Echo loads on Minerva desktop - presenting an opportunity in future to consolidate both implementations to use the same component. The mobile version of Vector and Timeless for example will load the mobile overlay (with existing styling issues that we don't need to worry about right now given we don't officially support skins other than Minerva as mobile) Testers: * Check require( 'ext.echo.mobile' )(); inside initMobile inside ext.echo.init does not fire until Iba1d7863171268066bf7597182c57a0a2041497f is checked out. Depends-On: I1a66939d2b596094b419de40b370e79f09c85581 Bug: T221007 Change-Id: I09c27a084100b223662f84de6cbe01bebe1fe774
2019-10-01 20:15:25 +00:00
}
} );