• Resolved gdibble

    (@gdibble)


    Chrome Dev Console:
    Uncaught SyntaxError: Unexpected token ) this-or-that.js:49

    [Basically, ‘set_keypress’ (function) was never being defined because ‘set_thisorthat_links’ (function) had one too many ‘})’ at the end. If you diff old vs this new (below) you will see changes.]

    I linted the code and resolved the error for you 🙂

    /*global jQuery*/
    
    "use strict";
    
    jQuery(document).ready(function(){
    	if( jQuery("#this-or-that").length === 0){
    		return false;
    	}
    	set_thisorthat_links();
    	set_keypress();
    });
    
    function set_thisorthat_links(){
    	jQuery(".this-or-that-btn").click(function(e){
    		var link = jQuery(this).attr("href"),
    		    h = jQuery(this).parents("#this-or-that").height();
    		e.preventDefault();
    
    		if( jQuery(this).parents(".thisthat_column").is(":animated")){
    			return false; //Make sure you have to wait till the previous animation stopped
    		}
    
    		/* ANIMATION */
    
    		//fix the height of the container
    		jQuery(this).parents("#this-or-that").css({ "min-height": h });
    
    		jQuery(this).parents(".this-or-that_item")
    			.animate({opacity: "0"}, { queue: false, duration: 300 })
    			.toggle("scale",{ percent: "140" }, 400, function(){
    
    				jQuery("#this-or-that").animate({ opacity: 0 }, 200);
    
    				// Do an AJAX request to save the 'favorite', simultaniously with retrieving the 'new' items.
    				jQuery("#single-project-content").load(link + " #this-or-that .this-or-that-wrapper", function(){});
    
    				jQuery("#this-or-that").animate({ opacity: 1 }, 200);
    				set_thisorthat_links(); //make sure the links in the loaded HTML
    
    				//jQuery(this).css({height: "auto" });
    			});
    	});
    }
    
    function set_keypress(){
    	jQuery("body").keydown(function(e) {
    		if(e.keyCode == 37) { // left
    			jQuery(".this-or-that_item").eq(0).find("a.this-or-that-btn").first().trigger("click");
    		}
    		if(e.keyCode == 39) { // right
    			jQuery(".this-or-that_item").eq(1).find("a.this-or-that-btn").first().trigger("click");
    		}
    	});
    }

    http://wordpress.org/plugins/this-or-that/

Viewing 1 replies (of 1 total)
  • Plugin Author André Boekhorst

    (@andrex84)

    Thanks, something went wrong there. This JS file has some more bugs…. think this has gone wrong when playing around with SVN.

    Anyway, you should change “#single-project-content” to “#this-or-that” too….

    Thanks for the help!

Viewing 1 replies (of 1 total)
  • The topic ‘fixed js error in this-or-that.js’ is closed to new replies.