Plugin Directory

Changeset 816812


Ignore:
Timestamp:
12/08/2013 10:58:48 AM (12 years ago)
Author:
andrex84
Message:

fixed js errors

Location:
this-or-that/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • this-or-that/trunk/js/this-or-that.js

    r797990 r816812  
     1/*global jQuery*/
     2
     3"use strict";
     4
    15jQuery(document).ready(function(){
    2 
    3     if( jQuery('#this-or-that').length == 0 ){
    4         return false
     6    if( jQuery("#this-or-that").length === 0){
     7        return false;
    58    }
    6 
    79    set_thisorthat_links();
    810    set_keypress();
    9 
    1011});
    1112
    1213function set_thisorthat_links(){
    13 
    14     jQuery('.this-or-that-btn').click(function(e){
    15 
     14    jQuery(".this-or-that-btn").click(function(e){
     15        var link = jQuery(this).attr("href"),
     16            h = jQuery(this).parents("#this-or-that").height();
    1617        e.preventDefault();
    1718
    18         if( jQuery(this).parents('.thisthat_column').is(':animated') ){
     19        if( jQuery(this).parents(".thisthat_column").is(":animated")){
    1920            return false; //Make sure you have to wait till the previous animation stopped
    2021        }
    21 
    22         var link = jQuery(this).attr("href");
    2322
    2423        /* ANIMATION */
    2524
    2625        //fix the height of the container
    27         var h = jQuery(this).parents('#this-or-that').height();
    28         jQuery(this).parents('#this-or-that').css({'min-height': h });
    29        
    30         jQuery(this).parents('.this-or-that_item')
     26        jQuery(this).parents("#this-or-that").css({ "min-height": h });
     27
     28        jQuery(this).parents(".this-or-that_item")
    3129            .animate({opacity: "0"}, { queue: false, duration: 300 })
    32             .toggle("scale",{percent: "140"}, 400, function(){
     30            .toggle("scale",{ percent: "140" }, 400, function(){
     31
     32                jQuery("#this-or-that").animate({ opacity: 0 }, 200);
     33
     34                // Do an AJAX request to save the 'favorite', simultaniously with retrieving the 'new' items.
     35                jQuery("#this-or-that").load(link + " #this-or-that .this-or-that-wrapper", function(){
     36
     37                    jQuery("#this-or-that").animate({ opacity: 1 }, 200);
     38                    set_thisorthat_links(); //make sure the links in the loaded HTML
     39                });
    3340               
    34                 jQuery('#this-or-that').animate({ opacity: '0'}, 200)
    35                
    36                 // Do an AJAX request to save the 'favorite', simultaniously with retrieving the 'new' items.
    37                 jQuery('#single-project-content').load( link + ' #this-or-that .this-or-that-wrapper', function(){
    38                
    39                 });
    40 
    41                     jQuery('#this-or-that').animate({ opacity: '1'}, 200)
    42                     set_thisorthat_links(); //make sure the links in the loaded HTML
    43 
    44                     //jQuery(this).css({height: 'auto' }); 
    45 
    46                 });
    47            
     41                //jQuery(this).css({height: "auto" });
    4842            });
    49     })
     43    });
    5044}
    5145
     
    5347    jQuery("body").keydown(function(e) {
    5448        if(e.keyCode == 37) { // left
    55             jQuery('.this-or-that_item').eq(0).find("a.this-or-that-btn").first().trigger("click");
    56         }
    57         if(e.keyCode == 39) { // right
    58             jQuery('.this-or-that_item').eq(1).find("a.this-or-that-btn").first().trigger("click");
    59         }
     49            jQuery(".this-or-that_item").eq(0).find("a.this-or-that-btn").first().trigger("click");
     50        }
     51        if(e.keyCode == 39) { // right
     52            jQuery(".this-or-that_item").eq(1).find("a.this-or-that-btn").first().trigger("click");
     53        }
    6054    });
    6155}
  • this-or-that/trunk/readme.txt

    r798438 r816812  
    1313
    1414Inspired by Facemash, Facebook's predecessor, this plugin sets up two items next to each other and lets visitors choose which one they favor. Each 'vote' adjusts the rating of both items. You can then easily create lists with your visitors favorite items.
     15
     16
     17See this [plugin in action](http://andreboekhorst.nl/wordpress/this-or-that-plugin/example-moviemash/ "Moviemash").
    1518
    1619= Works with content already on your site! =
     
    4447* Etc...
    4548
    46 Read more on the [authors website](http://andreboekhorst.nl/wordpress/this-or-that-plugin/ "Andr&eactute Boekhorst").
     49Read more on the [plugin website](http://andreboekhorst.nl/wordpress/this-or-that-plugin/ "Andr&eactute Boekhorst").
    4750
    4851== Installation ==
     
    9396= 1.0.2 =
    9497* Readme.txt changes.
     98
     99= 1.0.3 =
     100- Fixed several Javascript bugs. With help from gdibble.
Note: See TracChangeset for help on using the changeset viewer.