revert "convert into ES6"

Signed-off-by: WaitSpring <me@waitspring.com>
这个提交包含在:
WaitSpring 2023-11-21 22:55:54 +08:00
父节点 fb066a5b31
当前提交 6b1229e981
找不到此签名对应的密钥
共有 7 个文件被更改,包括 58 次插入57 次删除

查看文件

@ -2,7 +2,7 @@
"root": true, "root": true,
"extends": [ "extends": [
"wikimedia/client-common", "wikimedia/client-common",
"wikimedia/language/es2022", "wikimedia/language/es2015",
"wikimedia/mediawiki", "wikimedia/mediawiki",
"wikimedia/jquery" "wikimedia/jquery"
] ]

查看文件

@ -1,7 +1,7 @@
{ {
"root": true, "root": true,
"extends": [ "extends": [
"wikimedia/client-es6", "wikimedia/client-es5",
"wikimedia/jquery", "wikimedia/jquery",
"wikimedia/mediawiki" "wikimedia/mediawiki"
], ],

查看文件

@ -19,10 +19,10 @@
*/ */
'use strict'; 'use strict';
$( () => { $( function () {
// sidebar-inner only applies to desktop-small, but the toggles are hidden at // sidebar-inner only applies to desktop-small, but the toggles are hidden at
// other resolutions regardless and the css overrides any visible effects. // other resolutions regardless and the css overrides any visible effects.
const $dropdowns = $( '#personal, #p-variants-desktop, .sidebar-inner' ); var $dropdowns = $( '#personal, #p-variants-desktop, .sidebar-inner' );
/** /**
* Desktop menu click-toggling * Desktop menu click-toggling
@ -30,10 +30,11 @@ $( () => {
* We're not even checking if it's desktop because the classes in play have no effect * We're not even checking if it's desktop because the classes in play have no effect
* on mobile regardless... this may break things at some point, though. * on mobile regardless... this may break things at some point, though.
*/ */
/** /**
* Close all dropdowns * Close all dropdowns
*/ */
const closeOpen = () => { var closeOpen = function closeOpen() {
$dropdowns.removeClass( 'dropdown-active' ); $dropdowns.removeClass( 'dropdown-active' );
}; };
@ -55,8 +56,8 @@ $( () => {
$( this ).addClass( 'dropdown-active' ); $( this ).addClass( 'dropdown-active' );
} }
} ); } );
$( document ).on( 'click', ( { target } ) => { $( document ).on( 'click', function ( e ) {
if ( $( target ).closest( $dropdowns ).length > 0 ) { if ( $( e.target ).closest( $dropdowns ).length > 0 ) {
// Clicked inside an open menu; don't close anything // Clicked inside an open menu; don't close anything
} else { } else {
closeOpen(); closeOpen();

查看文件

@ -21,11 +21,11 @@
'use strict'; 'use strict';
$( () => { $( function () {
const toggleTime = 150; var toggleTime = 150;
// Open the various menus // Open the various menus
$( '#user-tools h2' ).on( 'click', () => { $( '#user-tools h2' ).on( 'click', function () {
if ( $( window ).width() < 851 ) { if ( $( window ).width() < 851 ) {
$( '#personal-inner' ).css( $( '#personal-inner' ).css(
'left', 'left',
@ -39,7 +39,7 @@ $( () => {
$( '#personal .mobile-close-button' ).fadeToggle( toggleTime ); $( '#personal .mobile-close-button' ).fadeToggle( toggleTime );
} }
} ); } );
$( '#sidebar-tools h2' ).on( 'click', () => { $( '#sidebar-tools h2' ).on( 'click', function () {
if ( $( window ).width() < 851 ) { if ( $( window ).width() < 851 ) {
$( '#site-navigation .sidebar-inner' ).css( $( '#site-navigation .sidebar-inner' ).css(
'left', 'left',
@ -53,7 +53,7 @@ $( () => {
$( '#site-navigation .mobile-close-button' ).fadeToggle( toggleTime ); $( '#site-navigation .mobile-close-button' ).fadeToggle( toggleTime );
} }
} ); } );
$( '#search-button h2' ).on( 'click', () => { $( '#search-button h2' ).on( 'click', function () {
if ( $( window ).width() < 851 ) { if ( $( window ).width() < 851 ) {
$( '#p-search .mobile-close-button' ) $( '#p-search .mobile-close-button' )
.css( 'top', $( '#search-button h2' ).offset().top - 4 ) .css( 'top', $( '#search-button h2' ).offset().top - 4 )
@ -63,7 +63,7 @@ $( () => {
$( '#p-search .mobile-close-button' ).fadeToggle( toggleTime ); $( '#p-search .mobile-close-button' ).fadeToggle( toggleTime );
} }
} ); } );
$( '#ca-more' ).on( 'click', () => { $( '#ca-more' ).on( 'click', function () {
$( '#page-more .sidebar-inner' ).css( 'top', $( '#ca-more' ).offset().top + 25 ); $( '#page-more .sidebar-inner' ).css( 'top', $( '#ca-more' ).offset().top + 25 );
$( '#page-more .mobile-close-button' ) $( '#page-more .mobile-close-button' )
.css( 'top', $( '#ca-more' ).offset().top - 4 ) .css( 'top', $( '#ca-more' ).offset().top - 4 )
@ -74,7 +74,7 @@ $( () => {
$( '#page-more .mobile-close-button' ).fadeToggle( toggleTime ); $( '#page-more .mobile-close-button' ).fadeToggle( toggleTime );
} }
} ); } );
$( '#ca-tools' ).on( 'click', () => { $( '#ca-tools' ).on( 'click', function () {
$( '#page-tools .sidebar-inner' ).css( $( '#page-tools .sidebar-inner' ).css(
'top', 'top',
$( '#ca-tools' ).offset().top + 25 $( '#ca-tools' ).offset().top + 25
@ -88,7 +88,7 @@ $( () => {
$( '#page-tools .mobile-close-button' ).fadeToggle( toggleTime ); $( '#page-tools .mobile-close-button' ).fadeToggle( toggleTime );
} }
} ); } );
$( '#ca-languages' ).on( 'click', () => { $( '#ca-languages' ).on( 'click', function () {
$( '#other-languages .sidebar-inner' ).css( $( '#other-languages .sidebar-inner' ).css(
'top', 'top',
$( '#ca-languages' ).offset().top + 25 $( '#ca-languages' ).offset().top + 25
@ -104,10 +104,10 @@ $( () => {
} ); } );
// Close menus on click outside // Close menus on click outside
$( document ).on( 'click touchstart', ( { target } ) => { $( document ).on( 'click touchstart', function ( e ) {
if ( if (
$( target ).closest( '#menus-cover' ).length > 0 || $( e.target ).closest( '#menus-cover' ).length > 0 ||
$( target ).closest( '.mobile-close-button' ).length > 0 $( e.target ).closest( '.mobile-close-button' ).length > 0
) { ) {
$( '#personal-inner' ).fadeOut( toggleTime ); $( '#personal-inner' ).fadeOut( toggleTime );
$( '.sidebar-inner' ).fadeOut( toggleTime ); $( '.sidebar-inner' ).fadeOut( toggleTime );

查看文件

@ -20,7 +20,7 @@
'use strict'; 'use strict';
mw.hook( 'wikipage.content' ).add( ( $content ) => { mw.hook( 'wikipage.content' ).add( function ( $content ) {
// Skip on Special:Recentchanges // Skip on Special:Recentchanges
if ( mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Recentchanges' ) { if ( mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Recentchanges' ) {
return; return;
@ -45,11 +45,11 @@ mw.hook( 'wikipage.content' ).add( ( $content ) => {
* *
* @param {jQuery} $table * @param {jQuery} $table
*/ */
const setScrollClass = ( $table ) => { function setScrollClass( $table ) {
const $tableWrapper = $table.parent(); var $tableWrapper = $table.parent(),
const $wrapper = $tableWrapper.parent(); $wrapper = $tableWrapper.parent(),
// wtf browser rtl implementations
const scroll = Math.abs( $tableWrapper.scrollLeft() ); // wtf browser rtl implementations scroll = Math.abs( $tableWrapper.scrollLeft() );
// 1 instead of 0 because of weird rtl rounding errors or something // 1 instead of 0 because of weird rtl rounding errors or something
if ( scroll > 1 ) { if ( scroll > 1 ) {
@ -62,27 +62,27 @@ mw.hook( 'wikipage.content' ).add( ( $content ) => {
} else { } else {
$wrapper.removeClass( 'scroll-right' ); $wrapper.removeClass( 'scroll-right' );
} }
}; }
$content.find( '.content-table' ).on( 'scroll', function () { $content.find( '.content-table' ).on( 'scroll', function () {
setScrollClass( $( this ).children( 'table' ).first() ); setScrollClass( $( this ).children( 'table' ).first() );
if ( $content.attr( 'dir' ) === 'rtl' ) { if ( $content.attr( 'dir' ) === 'rtl' ) {
$( this ) $( this )
.find( 'caption' ) .find( 'caption' )
.css( 'margin-right', `${Math.abs( $( this ).scrollLeft() )}px` ); .css( 'margin-right', Math.abs( $( this ).scrollLeft() ) + 'px' );
} else { } else {
$( this ) $( this )
.find( 'caption' ) .find( 'caption' )
.css( 'margin-left', `${$( this ).scrollLeft()}px` ); .css( 'margin-left', $( this ).scrollLeft() + 'px' );
} }
} ); } );
/** /**
* Mark overflowed tables for scrolling * Mark overflowed tables for scrolling
*/ */
const unOverflowTables = () => { function unOverflowTables() {
$content.find( '.content-table > table' ).each( function () { $content.find( '.content-table > table' ).each( function () {
const $table = $( this ); var $table = $( this ),
const $wrapper = $table.parent().parent(); $wrapper = $table.parent().parent();
if ( $table.outerWidth() > $wrapper.outerWidth() ) { if ( $table.outerWidth() > $wrapper.outerWidth() ) {
$wrapper.addClass( 'overflowed' ); $wrapper.addClass( 'overflowed' );
setScrollClass( $table ); setScrollClass( $table );
@ -95,10 +95,10 @@ mw.hook( 'wikipage.content' ).add( ( $content ) => {
// Set up sticky captions // Set up sticky captions
$content.find( '.content-table > table > caption' ).each( function () { $content.find( '.content-table > table > caption' ).each( function () {
let $container; var $container,
let tableHeight; tableHeight,
const $table = $( this ).parent(); $table = $( this ).parent(),
const $wrapper = $table.parent().parent(); $wrapper = $table.parent().parent();
if ( $table.outerWidth() > $wrapper.outerWidth() ) { if ( $table.outerWidth() > $wrapper.outerWidth() ) {
$container = $( this ).parents( '.content-table-wrapper' ); $container = $( this ).parents( '.content-table-wrapper' );
$( this ).width( $content.width() ); $( this ).width( $content.width() );
@ -107,7 +107,7 @@ mw.hook( 'wikipage.content' ).add( ( $content ) => {
$container.find( '.content-table-right' ).height( tableHeight ); $container.find( '.content-table-right' ).height( tableHeight );
} }
} ); } );
}; }
unOverflowTables(); unOverflowTables();
$( window ).on( 'resize', unOverflowTables ); $( window ).on( 'resize', unOverflowTables );
@ -115,14 +115,15 @@ mw.hook( 'wikipage.content' ).add( ( $content ) => {
* Sticky scrollbars maybe?! * Sticky scrollbars maybe?!
*/ */
$content.find( '.content-table' ).each( function () { $content.find( '.content-table' ).each( function () {
const $tableWrapper = $( this ); var $table, $tableWrapper, $spoof, $scrollbar;
const $table = $tableWrapper.children( 'table' ).first(); $tableWrapper = $( this );
$table = $tableWrapper.children( 'table' ).first();
// Assemble our silly crap and add to page // Assemble our silly crap and add to page
const $scrollbar = $( '<div>' ) $scrollbar = $( '<div>' )
.addClass( 'content-table-scrollbar inactive' ) .addClass( 'content-table-scrollbar inactive' )
.width( $content.width() ); .width( $content.width() );
const $spoof = $( '<div>' ) $spoof = $( '<div>' )
.addClass( 'content-table-spoof' ) .addClass( 'content-table-spoof' )
.width( $table.outerWidth() ); .width( $table.outerWidth() );
$tableWrapper.parent().prepend( $scrollbar.prepend( $spoof ) ); $tableWrapper.parent().prepend( $scrollbar.prepend( $spoof ) );
@ -133,11 +134,11 @@ mw.hook( 'wikipage.content' ).add( ( $content ) => {
*/ */
$content.find( '.content-table' ).on( 'scroll', function () { $content.find( '.content-table' ).on( 'scroll', function () {
// Only do this here if we're not already mirroring the spoof // Only do this here if we're not already mirroring the spoof
const $mirror = $( this ).siblings( '.inactive' ).first(); var $mirror = $( this ).siblings( '.inactive' ).first();
$mirror.scrollLeft( $( this ).scrollLeft() ); $mirror.scrollLeft( $( this ).scrollLeft() );
} ); } );
$content.find( '.content-table-scrollbar' ).on( 'scroll', function () { $content.find( '.content-table-scrollbar' ).on( 'scroll', function () {
const $mirror = $( this ).siblings( '.content-table' ).first(); var $mirror = $( this ).siblings( '.content-table' ).first();
// Only do this here if we're not already mirroring the table // Only do this here if we're not already mirroring the table
// eslint-disable-next-line no-jquery/no-class-state // eslint-disable-next-line no-jquery/no-class-state
@ -149,10 +150,13 @@ mw.hook( 'wikipage.content' ).add( ( $content ) => {
/** /**
* Set active when actually over the table it applies to... * Set active when actually over the table it applies to...
*/ */
const determineActiveSpoofScrollbars = () => { function determineActiveSpoofScrollbars() {
$content.find( '.overflowed .content-table' ).each( function () { $content.find( '.overflowed .content-table' ).each( function () {
const $scrollbar = $( this ).siblings( '.content-table-scrollbar' ).first(); var $scrollbar = $( this ).siblings( '.content-table-scrollbar' ).first(),
let captionHeight; tableTop,
tableBottom,
viewBottom,
captionHeight;
// Skip caption // Skip caption
captionHeight = $( this ).find( 'caption' ).outerHeight(); captionHeight = $( this ).find( 'caption' ).outerHeight();
@ -162,25 +166,25 @@ mw.hook( 'wikipage.content' ).add( ( $content ) => {
// Pad slightly for reasons // Pad slightly for reasons
captionHeight += 8; captionHeight += 8;
} }
const tableTop = $( this ).offset().top; tableTop = $( this ).offset().top;
const tableBottom = tableTop + $( this ).outerHeight(); tableBottom = tableTop + $( this ).outerHeight();
const viewBottom = window.scrollY + document.documentElement.clientHeight; viewBottom = window.scrollY + document.documentElement.clientHeight;
if ( tableTop + captionHeight < viewBottom && tableBottom > viewBottom ) { if ( tableTop + captionHeight < viewBottom && tableBottom > viewBottom ) {
$scrollbar.removeClass( 'inactive' ); $scrollbar.removeClass( 'inactive' );
} else { } else {
$scrollbar.addClass( 'inactive' ); $scrollbar.addClass( 'inactive' );
} }
} ); } );
}; }
determineActiveSpoofScrollbars(); determineActiveSpoofScrollbars();
$( window ).on( 'scroll resize', determineActiveSpoofScrollbars ); $( window ).on( 'scroll resize', determineActiveSpoofScrollbars );
/** /**
* Make sure tablespoofs remain correctly-sized? * Make sure tablespoofs remain correctly-sized?
*/ */
$( window ).on( 'resize', () => { $( window ).on( 'resize', function () {
$content.find( '.content-table-scrollbar' ).each( function () { $content.find( '.content-table-scrollbar' ).each( function () {
const width = $( this ).siblings().first().find( 'table' ).first().width(); var width = $( this ).siblings().first().find( 'table' ).first().width();
$( this ).find( '.content-table-spoof' ).first().width( width ); $( this ).find( '.content-table-spoof' ).first().width( width );
$( this ).width( $content.width() ); $( this ).width( $content.width() );
} ); } );

查看文件

@ -18,10 +18,10 @@
*/ */
'use strict'; 'use strict';
$( () => { $( function () {
if ( $( '#toc>ul' ).length !== 0 ) { if ( $( '#toc>ul' ).length !== 0 ) {
/* TOC (Left) */ /* TOC (Left) */
const $div = $( '<div>' ).attr( 'id', 'site-toc' ).addClass( 'sidebar-chunk' ), var $div = $( '<div>' ).attr( 'id', 'site-toc' ).addClass( 'sidebar-chunk' ),
$title = $( '#mw-toc-heading' ).html(), $title = $( '#mw-toc-heading' ).html(),
$titleH2 = $( '<h2>' ).append( $( '<span>' ).text( $title ) ), $titleH2 = $( '<h2>' ).append( $( '<span>' ).text( $title ) ),
$titleH3 = $( '<h3>' ).attr( 'id', 'p-toc-label' ).text( $title ), $titleH3 = $( '<h3>' ).attr( 'id', 'p-toc-label' ).text( $title ),
@ -44,7 +44,7 @@ $( () => {
.appendTo( $( '#mw-site-navigation' ) ); .appendTo( $( '#mw-site-navigation' ) );
/* TOC (Right) */ /* TOC (Right) */
const $divNavi = $( '<div>' ).attr( 'id', 'mw-toc-navigation' ), var $divNavi = $( '<div>' ).attr( 'id', 'mw-toc-navigation' ),
$divRight = $( '<div>' ) $divRight = $( '<div>' )
.attr( 'id', 'site-toc-right' ) .attr( 'id', 'site-toc-right' )
.addClass( 'sidebar-chunk' ), .addClass( 'sidebar-chunk' ),

查看文件

@ -123,22 +123,18 @@
"@NOTE": "Remember to also update variables.less if you change the width cutoffs here. screen-misc.less and mobile.js may also need updating." "@NOTE": "Remember to also update variables.less if you change the width cutoffs here. screen-misc.less and mobile.js may also need updating."
}, },
"skins.gongbi.main": { "skins.gongbi.main": {
"es6": true,
"targets": [ "desktop", "mobile" ], "targets": [ "desktop", "mobile" ],
"packageFiles": [ "resources/scripts/main.js" ] "packageFiles": [ "resources/scripts/main.js" ]
}, },
"skins.gongbi.mobile": { "skins.gongbi.mobile": {
"es6": true,
"targets": [ "desktop", "mobile" ], "targets": [ "desktop", "mobile" ],
"packageFiles": [ "resources/scripts/mobile.js" ] "packageFiles": [ "resources/scripts/mobile.js" ]
}, },
"skins.gongbi.toc": { "skins.gongbi.toc": {
"es6": true,
"targets": [ "desktop", "mobile" ], "targets": [ "desktop", "mobile" ],
"packageFiles": [ "resources/scripts/toc.js" ] "packageFiles": [ "resources/scripts/toc.js" ]
}, },
"skins.gongbi.table-scroll": { "skins.gongbi.table-scroll": {
"es6": true,
"targets": [ "desktop", "mobile" ], "targets": [ "desktop", "mobile" ],
"packageFiles": [ "resources/scripts/table-scroll.js" ] "packageFiles": [ "resources/scripts/table-scroll.js" ]
} }