Mercurial > hg > isophonics-drupal-site
annotate core/misc/debounce.js @ 19:fa3358dc1485 tip
Add ndrum files
author | Chris Cannam |
---|---|
date | Wed, 28 Aug 2019 13:14:47 +0100 |
parents | 1fec387a4317 |
children |
rev | line source |
---|---|
Chris@0 | 1 /** |
Chris@0 | 2 * DO NOT EDIT THIS FILE. |
Chris@0 | 3 * See the following change record for more information, |
Chris@0 | 4 * https://www.drupal.org/node/2815083 |
Chris@0 | 5 * @preserve |
Chris@0 | 6 **/ |
Chris@0 | 7 |
Chris@0 | 8 Drupal.debounce = function (func, wait, immediate) { |
Chris@0 | 9 var timeout = void 0; |
Chris@0 | 10 var result = void 0; |
Chris@0 | 11 return function () { |
Chris@14 | 12 for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { |
Chris@14 | 13 args[_key] = arguments[_key]; |
Chris@14 | 14 } |
Chris@14 | 15 |
Chris@0 | 16 var context = this; |
Chris@0 | 17 var later = function later() { |
Chris@0 | 18 timeout = null; |
Chris@0 | 19 if (!immediate) { |
Chris@0 | 20 result = func.apply(context, args); |
Chris@0 | 21 } |
Chris@0 | 22 }; |
Chris@0 | 23 var callNow = immediate && !timeout; |
Chris@0 | 24 clearTimeout(timeout); |
Chris@0 | 25 timeout = setTimeout(later, wait); |
Chris@0 | 26 if (callNow) { |
Chris@0 | 27 result = func.apply(context, args); |
Chris@0 | 28 } |
Chris@0 | 29 return result; |
Chris@0 | 30 }; |
Chris@0 | 31 }; |