From 108393daf11e2d4364e695ed3ba2a456ad8dacb7 Mon Sep 17 00:00:00 2001 From: Stephen Niedzielski Date: Mon, 11 May 2020 15:29:56 -0600 Subject: [PATCH] [dev][Legacy][JS] Split Legacy mode JavaScript into new ResourceLoader module The collapsible sidebar adds a new JavaScript dependency and behavior to Latest mode only. There are a number of ways of to make the deviation but we think now is the time to start splitting by module. This patch adds a new ResourceLoader module, skins.vector.legacy.js, and moves the existing JavaScript into it. The old module, skins.vector.js, has been given a currently matching index.js entry point that references the collapsible tabs' files by reaching across directories. It's not quite ideal as usually ResourceLoader modules and directory structures strive for 1:1 correspondence but this patch makes the bold assertions that it's better than a file copy, better than a new "skins.vector.common.js" ResourceLoader module, more compatible than a symlink, and the existing jQuery tabs implementation will eventually be replaced in Latest mode. A "Legacy" module was added instead of a "Latest" with the assumption that active development should generally be considered "latest" and Legacy an intentional distinction. Bug: T246419 Change-Id: I9980403f1ee5897c27ac0331f0b51a5bcbdff778 --- includes/SkinVector.php | 2 +- resources/skins.vector.js/index.js | 4 ++-- .../collapsibleTabs.js | 0 resources/skins.vector.legacy.js/index.js | 10 ++++++++++ .../vector.js | 0 skin.json | 14 ++++++++++++-- 6 files changed, 25 insertions(+), 5 deletions(-) rename resources/{skins.vector.js => skins.vector.legacy.js}/collapsibleTabs.js (100%) create mode 100644 resources/skins.vector.legacy.js/index.js rename resources/{skins.vector.js => skins.vector.legacy.js}/vector.js (100%) diff --git a/includes/SkinVector.php b/includes/SkinVector.php index 1bb556a9b..bdde33cce 100644 --- a/includes/SkinVector.php +++ b/includes/SkinVector.php @@ -84,7 +84,7 @@ class SkinVector extends SkinTemplate { $module = $this->isLegacy() ? 'skins.vector.styles.legacy' : 'skins.vector.styles'; $modules['styles']['skin'][] = $module; - $modules['core'][] = 'skins.vector.js'; + $modules['core'][] = $this->isLegacy() ? 'skins.vector.legacy.js' : 'skins.vector.js'; return $modules; } diff --git a/resources/skins.vector.js/index.js b/resources/skins.vector.js/index.js index 40eff8a10..1bdf0695b 100644 --- a/resources/skins.vector.js/index.js +++ b/resources/skins.vector.js/index.js @@ -1,6 +1,6 @@ var - collapsibleTabs = require( './collapsibleTabs.js' ), - vector = require( './vector.js' ); + collapsibleTabs = require( '../skins.vector.legacy.js/collapsibleTabs.js' ), + vector = require( '../skins.vector.legacy.js/vector.js' ); function main() { collapsibleTabs.init(); diff --git a/resources/skins.vector.js/collapsibleTabs.js b/resources/skins.vector.legacy.js/collapsibleTabs.js similarity index 100% rename from resources/skins.vector.js/collapsibleTabs.js rename to resources/skins.vector.legacy.js/collapsibleTabs.js diff --git a/resources/skins.vector.legacy.js/index.js b/resources/skins.vector.legacy.js/index.js new file mode 100644 index 000000000..40eff8a10 --- /dev/null +++ b/resources/skins.vector.legacy.js/index.js @@ -0,0 +1,10 @@ +var + collapsibleTabs = require( './collapsibleTabs.js' ), + vector = require( './vector.js' ); + +function main() { + collapsibleTabs.init(); + $( vector.init ); +} + +main(); diff --git a/resources/skins.vector.js/vector.js b/resources/skins.vector.legacy.js/vector.js similarity index 100% rename from resources/skins.vector.js/vector.js rename to resources/skins.vector.legacy.js/vector.js diff --git a/skin.json b/skin.json index f36d5dd81..e0b0869e7 100644 --- a/skin.json +++ b/skin.json @@ -67,8 +67,18 @@ "skins.vector.js": { "packageFiles": [ "resources/skins.vector.js/index.js", - "resources/skins.vector.js/collapsibleTabs.js", - "resources/skins.vector.js/vector.js" + "resources/skins.vector.legacy.js/collapsibleTabs.js", + "resources/skins.vector.legacy.js/vector.js" + ], + "dependencies": [ + "mediawiki.util" + ] + }, + "skins.vector.legacy.js": { + "packageFiles": [ + "resources/skins.vector.legacy.js/index.js", + "resources/skins.vector.legacy.js/collapsibleTabs.js", + "resources/skins.vector.legacy.js/vector.js" ], "dependencies": [ "mediawiki.util"