From a10359e6e67ed85a191a2a94ed36cc31b6ab1c2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Beyou?= Date: Tue, 27 Apr 2021 20:30:33 +0200 Subject: [PATCH] Replace deprecated jQuery.throttle/debounce This requires MediaWiki 1.38 for mw.util.throttle. Bug: T213426 Change-Id: I3f689eea837ef72de9ab7afb68578093eab8db20 --- extension.json | 3 +-- resources/mmv/mmv.lightboxinterface.js | 4 ++-- resources/mmv/ui/mmv.ui.canvas.js | 4 ++-- resources/mmv/ui/mmv.ui.metadataPanelScroller.js | 4 ++-- resources/mmv/ui/mmv.ui.truncatableTextField.js | 2 +- 5 files changed, 8 insertions(+), 9 deletions(-) diff --git a/extension.json b/extension.json index 0e339cf3a..13bc12c5b 100644 --- a/extension.json +++ b/extension.json @@ -28,7 +28,7 @@ "license-name": "GPL-2.0-or-later", "type": "other", "requires": { - "MediaWiki": ">= 1.35.0" + "MediaWiki": ">= 1.38.0" }, "MessagesDirs": { "MultimediaViewer": [ @@ -106,7 +106,6 @@ "oojs", "oojs-router", "jquery.fullscreen", - "jquery.throttle-debounce", "jquery.color", "jquery.tipsy", "mmv.bootstrap", diff --git a/resources/mmv/mmv.lightboxinterface.js b/resources/mmv/mmv.lightboxinterface.js index 954c5b202..c6942083c 100644 --- a/resources/mmv/mmv.lightboxinterface.js +++ b/resources/mmv/mmv.lightboxinterface.js @@ -189,9 +189,9 @@ this.handleEvent( 'keydown', function ( e ) { ui.keydown( e ); } ); // mousemove generates a ton of events, which is why we throttle it - this.handleEvent( 'mousemove.lip', $.throttle( 250, function ( e ) { + this.handleEvent( 'mousemove.lip', mw.util.throttle( function ( e ) { ui.mousemove( e ); - } ) ); + }, 250 ) ); this.handleEvent( 'mmv-faded-out', function ( e ) { ui.fadedOut( e ); } ); this.handleEvent( 'mmv-fade-stopped', function ( e ) { ui.fadeStopped( e ); } ); diff --git a/resources/mmv/ui/mmv.ui.canvas.js b/resources/mmv/ui/mmv.ui.canvas.js index 3272b530a..f0b8b18d2 100644 --- a/resources/mmv/ui/mmv.ui.canvas.js +++ b/resources/mmv/ui/mmv.ui.canvas.js @@ -231,9 +231,9 @@ C.attach = function () { var canvas = this; - $( window ).on( 'resize.mmv-canvas', $.debounce( 100, function () { + $( window ).on( 'resize.mmv-canvas', mw.util.debounce( function () { canvas.$mainWrapper.trigger( $.Event( 'mmv-resize-end' ) ); - } ) ); + }, 100 ) ); this.$imageWrapper.on( 'click.mmv-canvas', function () { if ( canvas.$container.closest( '.metadata-panel-is-open' ).length > 0 ) { diff --git a/resources/mmv/ui/mmv.ui.metadataPanelScroller.js b/resources/mmv/ui/mmv.ui.metadataPanelScroller.js index e8e6d9a23..b594a1bad 100644 --- a/resources/mmv/ui/mmv.ui.metadataPanelScroller.js +++ b/resources/mmv/ui/mmv.ui.metadataPanelScroller.js @@ -67,9 +67,9 @@ panel.keydown( e ); } ); - $( window ).on( 'scroll.mmvp', $.throttle( 250, function () { + $( window ).on( 'scroll.mmvp', mw.util.throttle( function () { panel.scroll(); - } ) ); + }, 250 ) ); this.$container.on( 'mmv-metadata-open', function () { if ( !panel.hasOpenedMetadata && panel.localStorage.store ) { diff --git a/resources/mmv/ui/mmv.ui.truncatableTextField.js b/resources/mmv/ui/mmv.ui.truncatableTextField.js index 272eb1b6d..df3e794ce 100644 --- a/resources/mmv/ui/mmv.ui.truncatableTextField.js +++ b/resources/mmv/ui/mmv.ui.truncatableTextField.js @@ -106,7 +106,7 @@ }; TTFP.attach = function () { - $( window ).on( 'resize.mmv-ttf', $.debounce( 100, this.repaint.bind( this ) ) ); + $( window ).on( 'resize.mmv-ttf', mw.util.debounce( this.repaint.bind( this ), 100 ) ); }; TTFP.unattach = function () {