mediawiki.htmlform.checker: Remove use of deprecated jquery.throttle-debounce
authorTimo Tijhof <krinklemail@gmail.com>
Thu, 5 Sep 2019 21:14:16 +0000 (22:14 +0100)
committerTimo Tijhof <krinklemail@gmail.com>
Thu, 5 Sep 2019 21:14:49 +0000 (22:14 +0100)
Bug: T213426
Change-Id: I21874161dbe258c56376f3761e523dac543db8f4

resources/Resources.php
resources/src/mediawiki.htmlform.checker.js

index 8234e89..9dc99ff 100644 (file)
@@ -942,9 +942,6 @@ return [
                'scripts' => [
                        'resources/src/mediawiki.htmlform.checker.js',
                ],
-               'dependencies' => [
-                       'jquery.throttle-debounce',
-               ],
                'targets' => [ 'desktop', 'mobile' ],
        ],
        'mediawiki.htmlform.ooui' => [
index 674584b..33207d4 100644 (file)
@@ -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;
        };