1
0
Fork 0
mirror of https://github.com/Oreolek/ifhub.club.git synced 2024-07-08 09:24:25 +03:00
ifhub.club/application/frontend/skin/developer/components/ls-core/timer.js
Denis Shakhov 42321428f8 Компоненты ls-core и ls-vendor
* Перенесены либы из фреймворка
2014-10-24 20:26:11 +07:00

41 lines
960 B
JavaScript

/**
* Таймер
*
* @module timer
*
* @license GNU General Public License, version 2
* @copyright 2013 OOO "ЛС-СОФТ" {@link http://livestreetcms.com}
* @author Denis Shakhov <denis.shakhov@gmail.com>
*/
var ls = ls || {};
ls.timer = (function ($) {
"use strict";
var _aTimers = {};
/**
* Запуск метода через определенный период, поддерживает пролонгацию
*/
this.run = function(oContext, fMethod, sUniqKey, aParams, iTime) {
iTime = iTime || 1500;
aParams = aParams || [];
sUniqKey = sUniqKey || Math.random();
if (_aTimers[sUniqKey]) {
clearTimeout(_aTimers[sUniqKey]);
_aTimers[sUniqKey] = null;
}
var timeout = setTimeout(function(){
clearTimeout(_aTimers[sUniqKey]);
_aTimers[sUniqKey] = null;
fMethod.apply(oContext, aParams);
}.bind(this), iTime);
_aTimers[sUniqKey] = timeout;
};
return this;
}).call(ls.timer || {},jQuery);