Mercurial > hg > cmmr2012-drupal-site
comparison core/misc/debounce.js @ 0:c75dbcec494b
Initial commit from drush-created site
author | Chris Cannam |
---|---|
date | Thu, 05 Jul 2018 14:24:15 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:c75dbcec494b |
---|---|
1 /** | |
2 * DO NOT EDIT THIS FILE. | |
3 * See the following change record for more information, | |
4 * https://www.drupal.org/node/2815083 | |
5 * @preserve | |
6 **/ | |
7 | |
8 Drupal.debounce = function (func, wait, immediate) { | |
9 var timeout = void 0; | |
10 var result = void 0; | |
11 return function () { | |
12 for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | |
13 args[_key] = arguments[_key]; | |
14 } | |
15 | |
16 var context = this; | |
17 var later = function later() { | |
18 timeout = null; | |
19 if (!immediate) { | |
20 result = func.apply(context, args); | |
21 } | |
22 }; | |
23 var callNow = immediate && !timeout; | |
24 clearTimeout(timeout); | |
25 timeout = setTimeout(later, wait); | |
26 if (callNow) { | |
27 result = func.apply(context, args); | |
28 } | |
29 return result; | |
30 }; | |
31 }; |