@progress/telerik-jquery-report-viewer
Version:
Progress® Telerik® Report Viewer for jQuery
47 lines (46 loc) • 1.6 kB
JavaScript
/*!
* jQuery throttle / debounce - v1.1 - 3/7/2010
* http://benalman.com/projects/jquery-throttle-debounce-plugin/
*
* Copyright (c) 2010 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*/
(function(window2, undefined$1) {
"$:nomunge";
var $ = window2.Cowboy || (window2.Cowboy = {}), jq_throttle;
$.throttle = jq_throttle = function(delay, no_trailing, callback, debounce_mode) {
var timeout_id, last_exec = 0;
if (typeof no_trailing !== "boolean") {
debounce_mode = callback;
callback = no_trailing;
no_trailing = undefined$1;
}
function wrapper() {
var that = this, elapsed = +/* @__PURE__ */ new Date() - last_exec, args = arguments;
function exec() {
last_exec = +/* @__PURE__ */ new Date();
callback.apply(that, args);
}
function clear() {
timeout_id = undefined$1;
}
if (debounce_mode && !timeout_id) {
exec();
}
timeout_id && clearTimeout(timeout_id);
if (debounce_mode === undefined$1 && elapsed > delay) {
exec();
} else if (no_trailing !== true) {
timeout_id = setTimeout(debounce_mode ? clear : exec, debounce_mode === undefined$1 ? delay - elapsed : delay);
}
}
if ($.guid) {
wrapper.guid = callback.guid = callback.guid || $.guid++;
}
return wrapper;
};
$.debounce = function(delay, at_begin, callback) {
return callback === undefined$1 ? jq_throttle(delay, at_begin, false) : jq_throttle(delay, callback, at_begin !== false);
};
})(window);