Restore table of contents and error logging

When moving to packageFiles, the modules errorLogging and toc
were not imported by init.js meaning they were not run.

ResourceLoader should probably error in this situation, but until
then we should fix this problem.

This is a follow up to I44790dd3fc6fe42bb502d79c39c4081c223bf2b1

Bug: T212944
Change-Id: I86efb7be1c39b03f63c8f1e0b107216cd30ff6de
This commit is contained in:
jdlrobson 2019-07-16 14:41:37 -07:00
parent 6076c61772
commit a9d73060fa
3 changed files with 20 additions and 15 deletions

View file

@ -1,5 +1,5 @@
( function ( M, requestIdleCallback, track, config, trackSubscribe, user, experiments ) {
requestIdleCallback( function () {
( function ( M, track, config, trackSubscribe, user, experiments ) {
module.exports = function () {
/**
* Handle an error and log it if necessary
* @param {string} errorMessage to be logged
@ -61,10 +61,9 @@
trackSubscribe( 'global.error', function ( topic, error ) {
handleError( error.errorMessage, error.lineNumber, error.columnNumber, error.url );
} );
} );
};
}(
mw.mobileFrontend,
mw.requestIdleCallback,
mw.track,
mw.config,
mw.trackSubscribe,

View file

@ -4,6 +4,8 @@
PageGateway = mobile.PageGateway,
toast = mobile.toast,
time = mobile.time,
toc = require( './toc.js' ),
errorLogging = require( './errorLogging.js' ),
notifications = require( './notifications.js' ),
preInit = require( './preInit.js' ),
initLogging = require( './initLogging.js' ),
@ -338,7 +340,8 @@
}
$( function () {
var toolbarElement = document.querySelector( Toolbar.selector );
var $toc,
toolbarElement = document.querySelector( Toolbar.selector );
// Init:
// - main menu closes when you click outside of it
// - redirects show a toast.
@ -372,6 +375,15 @@
if ( !mw.user.isAnon() && mw.config.get( 'wgEchoMaxNotificationCount' ) !== undefined ) {
notifications();
}
// add a ToC only for "view" action (user is reading a page)
// provided a table of contents placeholder has been rendered
// eslint-disable-next-line no-jquery/no-global-selector
$toc = $( '#toc' );
if ( mw.config.get( 'wgAction' ) === 'view' && $toc.length > 0 ) {
toc( currentPage, $toc );
}
mw.requestIdleCallback( errorLogging );
} );
module.exports = {
overlayManager: overlayManager

View file

@ -1,20 +1,18 @@
( function ( M ) {
var mobile = M.require( 'mobile.startup' ),
currentPage = mobile.currentPage(),
Toggler = mobile.Toggler,
TableOfContents = mobile.toc.TableOfContents,
eventBus = mobile.eventBusSingleton,
// eslint-disable-next-line no-jquery/no-global-selector
$toc = $( '#toc' );
eventBus = mobile.eventBusSingleton;
/**
* Create TableOfContents if the given Page has sections and is not the main page
* and wgMFTocEnabled config variable is set to true.
* @method
* @param {Page} page for which a TOC is generated
* @param {jQuery.Object} $toc container to replace
* @ignore
*/
function init( page ) {
function init( page, $toc ) {
var sections = page.getSections(),
toc = new TableOfContents( {
sections: sections
@ -38,10 +36,6 @@
}
}
// add a ToC only for "view" action (user is reading a page)
// provided a table of contents placeholder has been rendered
if ( mw.config.get( 'wgAction' ) === 'view' && $toc.length > 0 ) {
init( currentPage );
}
module.exports = init;
}( mw.mobileFrontend ) );