From 76be18c788cde7983c8c812b0ef476e2cccb9b87 Mon Sep 17 00:00:00 2001 From: jdlrobson Date: Thu, 10 Jan 2019 16:18:45 -0800 Subject: [PATCH] Tablet code no longer needs to be conditional The TableOfContents component is now inside mobile.startup so is readily available. Thus skins.minerva.tablet.scripts is removed and its code moved inside skins.minerva.scripts The check to whether the user is in tablet mode now happens inside toc.js The resize handler is dropped on the basis that this is an edge case that is not worth supporting at the cost of an eventBus. Depends-On: I353d6d7a6884dae03b55364150c6bb95cd4cc57f Change-Id: Id16a64573e020b4606fc9b11456163a4cd290e0b --- resources/skins.minerva.scripts/init.js | 15 --------------- .../toc.js | 7 ++++--- skin.json | 15 ++------------- 3 files changed, 6 insertions(+), 31 deletions(-) rename resources/{skins.minerva.tablet.scripts => skins.minerva.scripts}/toc.js (85%) diff --git a/resources/skins.minerva.scripts/init.js b/resources/skins.minerva.scripts/init.js index 5683f66..3918ff2 100644 --- a/resources/skins.minerva.scripts/init.js +++ b/resources/skins.minerva.scripts/init.js @@ -5,7 +5,6 @@ skin = M.require( 'mobile.init/skin' ), issues = M.require( 'skins.minerva.scripts/pageIssues' ), downloadPageAction = M.require( 'skins.minerva.scripts/downloadPageAction' ), - browser = M.require( 'mobile.startup/Browser' ).getSingleton(), loader = M.require( 'mobile.startup/rlModuleLoader' ), router = require( 'mediawiki.router' ), OverlayManager = M.require( 'mobile.startup/OverlayManager' ), @@ -93,18 +92,6 @@ return lang ? lang.toLowerCase() : undefined; } - /** - * Loads tablet modules when the skin is in tablet mode and the - * current page is in the main namespace. - * @method - * @ignore - */ - function loadTabletModules() { - if ( browser.isWideScreen() ) { - mw.loader.using( 'skins.minerva.tablet.scripts' ); - } - } - /** * Make an instance of an ImageOverlay. This function assumes that the module * providing the ImageOverlay has been asynchronously loaded. @@ -368,8 +355,6 @@ initModifiedInfo(); initRegistrationInfo(); initHistoryLink( $( '.last-modifier-tagline a' ) ); - eventBus.on( 'resize', loadTabletModules ); - loadTabletModules(); appendDownloadButton(); initRedlinksCta(); initEditLink(); diff --git a/resources/skins.minerva.tablet.scripts/toc.js b/resources/skins.minerva.scripts/toc.js similarity index 85% rename from resources/skins.minerva.tablet.scripts/toc.js rename to resources/skins.minerva.scripts/toc.js index bb74234..eedecf8 100644 --- a/resources/skins.minerva.tablet.scripts/toc.js +++ b/resources/skins.minerva.scripts/toc.js @@ -1,7 +1,8 @@ ( function ( M ) { - var TableOfContents = M.require( 'mobile.toc/TableOfContents' ), - Toggler = M.require( 'mobile.startup' ).Toggler, - eventBus = M.require( 'mobile.startup/eventBusSingleton' ); + var mobile = M.require( 'mobile.startup' ), + Toggler = mobile.Toggler, + TableOfContents = mobile.toc.TableOfContents, + eventBus = mobile.eventBusSingleton; /** * Create TableOfContents if the given Page has sections and is not the main page diff --git a/skin.json b/skin.json index 81315ca..65032e8 100644 --- a/skin.json +++ b/skin.json @@ -438,7 +438,8 @@ "resources/skins.minerva.scripts/initLogging.js", "resources/skins.minerva.scripts/mobileRedirect.js", "resources/skins.minerva.scripts/search.js", - "resources/skins.minerva.scripts/references.js" + "resources/skins.minerva.scripts/references.js", + "resources/skins.minerva.scripts/toc.js" ] }, "skins.minerva.scripts.top": { @@ -573,18 +574,6 @@ "scripts": [ "resources/skins.minerva.watchstar/init.js" ] - }, - "skins.minerva.tablet.scripts": { - "targets": [ - "mobile", - "desktop" - ], - "dependencies": [ - "mobile.toc" - ], - "scripts": [ - "resources/skins.minerva.tablet.scripts/toc.js" - ] } }, "manifest_version": 1