can3p (can3p) wrote in changelog,
can3p
can3p
changelog

[livejournal] r20569: LJSUP-10421: S1 Comments ?\226?\128?\148...

Committer: dpetrov
LJSUP-10421: S1 Comments ?\226?\128?\148 v.2: New Threads
U   branches/commenting-form/htdocs/js/jquery_fn.js
Modified: branches/commenting-form/htdocs/js/jquery_fn.js
===================================================================
--- branches/commenting-form/htdocs/js/jquery_fn.js	2011-11-17 14:24:57 UTC (rev 20568)
+++ branches/commenting-form/htdocs/js/jquery_fn.js	2011-11-17 14:39:19 UTC (rev 20569)
@@ -279,3 +279,28 @@
 		}
 	});
 };
+
+/**
+ * Function assures that callback will run not faster then minDelay.
+ *
+ * @param {Function} callback A callback to run.
+ * @param {Number} minDelay Minimum delay in ms.
+ *
+ * @return {Function} Callback wrapper to use as a collback in your code.
+ */
+jQuery.delayedCallback = function(callback, minDelay) {
+	var callCount = 2,
+		results,
+		checkFinish = function() {
+			callCount--;
+			if (callCount === 0) {
+				callback.apply(null, results);
+			}
+		}
+
+	setTimeout(checkFinish, minDelay);
+	return function() {
+		results = [].slice.apply(arguments);
+		checkFinish();
+	};
+};

Tags: can3p, dpetrov, js, livejournal
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments