Changeset 816812
- Timestamp:
- 12/08/2013 10:58:48 AM (12 years ago)
- Location:
- this-or-that/trunk
- Files:
-
- 2 edited
-
js/this-or-that.js (modified) (2 diffs)
-
readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
this-or-that/trunk/js/this-or-that.js
r797990 r816812 1 /*global jQuery*/ 2 3 "use strict"; 4 1 5 jQuery(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; 5 8 } 6 7 9 set_thisorthat_links(); 8 10 set_keypress(); 9 10 11 }); 11 12 12 13 function 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(); 16 17 e.preventDefault(); 17 18 18 if( jQuery(this).parents( '.thisthat_column').is(':animated')){19 if( jQuery(this).parents(".thisthat_column").is(":animated")){ 19 20 return false; //Make sure you have to wait till the previous animation stopped 20 21 } 21 22 var link = jQuery(this).attr("href");23 22 24 23 /* ANIMATION */ 25 24 26 25 //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") 31 29 .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 }); 33 40 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" }); 48 42 }); 49 }) 43 }); 50 44 } 51 45 … … 53 47 jQuery("body").keydown(function(e) { 54 48 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) { // right58 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 } 60 54 }); 61 55 } -
this-or-that/trunk/readme.txt
r798438 r816812 13 13 14 14 Inspired 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 17 See this [plugin in action](http://andreboekhorst.nl/wordpress/this-or-that-plugin/example-moviemash/ "Moviemash"). 15 18 16 19 = Works with content already on your site! = … … 44 47 * Etc... 45 48 46 Read more on the [ authorswebsite](http://andreboekhorst.nl/wordpress/this-or-that-plugin/ "Andr&eactute Boekhorst").49 Read more on the [plugin website](http://andreboekhorst.nl/wordpress/this-or-that-plugin/ "Andr&eactute Boekhorst"). 47 50 48 51 == Installation == … … 93 96 = 1.0.2 = 94 97 * 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.