Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $.__queue = {
- _timer: null,
- _queue: [],
- add: function (fn, context, time) {
- var setTimer = function (time) {
- $.__queue._timer = setTimeout(function () {
- time = $.__queue.add();
- if ($.__queue._queue.length) {
- setTimer(time);
- }
- }, time || 2);
- }
- if (fn) {
- $.__queue._queue.push([fn, context, time]);
- if ($.__queue._queue.length == 1) {
- setTimer(time);
- }
- return;
- }
- var next = $.__queue._queue.shift();
- if (!next) {
- return 0;
- }
- next[0].call(next[1] || window);
- return next[2];
- },
- clear: function () {
- clearTimeout($.__queue._timer);
- $.__queue._queue = [];
- }
- };
Add Comment
Please, Sign In to add comment