Valerii Vasin (valerii) wrote in changelog,
Valerii Vasin
valerii
changelog

[livejournal] r23388: LJSUP-14180: Replace lj-like buttons wit...

Committer: vvasin
LJSUP-14180: Replace lj-like buttons with preloader. Slightly optimize performance.
U   trunk/htdocs/js/jquery_fn.js
Modified: trunk/htdocs/js/jquery_fn.js
===================================================================
--- trunk/htdocs/js/jquery_fn.js	2012-11-29 09:14:04 UTC (rev 23387)
+++ trunk/htdocs/js/jquery_fn.js	2012-11-29 10:17:12 UTC (rev 23388)
@@ -552,20 +552,19 @@
 		// find elements with lj-likes class
 		likes = this.find('.lj-like')
 			.add( this.filter('.lj-like') )
-			// filter all previously used elements to prevent double parsing
+			// filter previously unused items only and mark them as used
 			.filter(function () {
-				return !this.used;
+				if (this.used) {
+					return false;
+				}
+				this.used = true;
+				return true;
 			});
 
 		if (likes.length === 0) {
 			return this;
 		}
 
-		// mark all items as used
-		likes.each(function () {
-			this.used = true;
-		});
-
 		if ( !opts.lazy ) {
 			// not lazy: immediately parsing
 			likes.each(function () {
@@ -582,14 +581,15 @@
 			// parse all added screenable elements
 			lazyLoad();
 		}
-
 		return this;
 	};
 
 	// default plugin options
 	$.fn.ljLikes.defaults = {
-		// lazy loading of likes - will be parsed when becomes screenable
-		// if false - we will parse likes at the moment
+		/**
+		 * Lazy loading of likes - will be parsed when becomes screenable
+		 * if false - we will parse likes at the moment
+		 */
 		lazy: true
 	};
 }(jQuery));

Tags: invis89, js, livejournal, vvasin
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