From 4b7e22a01251110dbf934edc2edae0a122ff5c0e Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Thu, 5 Sep 2019 22:14:16 +0100 Subject: [PATCH] mediawiki.htmlform.checker: Remove use of deprecated jquery.throttle-debounce Bug: T213426 Change-Id: I21874161dbe258c56376f3761e523dac543db8f4 --- resources/Resources.php | 3 --- resources/src/mediawiki.htmlform.checker.js | 10 +++++++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/resources/Resources.php b/resources/Resources.php index 8234e8970c..9dc99ff55c 100644 --- a/resources/Resources.php +++ b/resources/Resources.php @@ -942,9 +942,6 @@ return [ 'scripts' => [ 'resources/src/mediawiki.htmlform.checker.js', ], - 'dependencies' => [ - 'jquery.throttle-debounce', - ], 'targets' => [ 'desktop', 'mobile' ], ], 'mediawiki.htmlform.ooui' => [ diff --git a/resources/src/mediawiki.htmlform.checker.js b/resources/src/mediawiki.htmlform.checker.js index 674584b14a..33207d49a7 100644 --- a/resources/src/mediawiki.htmlform.checker.js +++ b/resources/src/mediawiki.htmlform.checker.js @@ -3,6 +3,14 @@ // FIXME: mw.htmlform.Element also sets this to empty object mw.htmlform = {}; + function debounce( delay, callback ) { + var timeout; + return function () { + clearTimeout( timeout ); + timeout = setTimeout( Function.prototype.apply.bind( callback, this, arguments ), delay ); + }; + } + /** * @class mw.htmlform.Checker */ @@ -52,7 +60,7 @@ if ( $extraElements ) { $e = $e.add( $extraElements ); } - $e.on( events, $.debounce( 1000, this.validate.bind( this ) ) ); + $e.on( events, debounce( 1000, this.validate.bind( this ) ) ); return this; }; -- 2.20.1