Merge "mediawiki.htmlform.checker: Remove use of deprecated jquery.throttle-debounce"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 5 Sep 2019 22:16:49 +0000 (22:16 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 5 Sep 2019 22:16:49 +0000 (22:16 +0000)
resources/Resources.php
resources/src/mediawiki.htmlform.checker.js

index 1eee348..5527867 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;
        };