1/*globals jQuery */ 2 3(function ($) { 4 "use strict"; 5 6 var karmaId = 'comment_karma'; 7 8 function doHover( e ) { 9 $( e.currentTarget ) 10 .prevAll().addBack()[(e.type === 'mouseenter' ? 'add' : 'remove') + 'Class']('rover'); 11 } 12 13 function setUI( elem ) { 14 elem.prevAll().addBack() 15 .addClass( 'whole' ).removeClass( 'empty half rover' ); 16 17 elem.nextAll() 18 .addClass( 'empty' ).removeClass( 'whole half rover' ); 19 } 20 21 function doFormRating( e ) { 22 var elem = $( e.currentTarget ), 23 indx, 24 ctx, 25 field, 26 $karma; 27 28 $karma = $('#comment_karma'); 29 30 setUI( elem ); 31 32 ctx = elem.parent(); 33 indx = ctx.find('li').index( e.currentTarget ) + 1; 34 35 if ( ! $karma.length ) { 36 field = $('<input type="hidden" />').attr({ 37 name : karmaId, 38 id : karmaId, 39 value : indx 40 }); 41 ctx.after( field ); 42 } else { 43 $karma.val( indx ); 44 } 45 } 46 47 function doRating( e ) { 48 var elem = $( e.currentTarget ), indx, ctx; 49 50 setUI( elem ); 51 52 ctx = elem.parent(); 53 indx = ctx.find('li').index( e.currentTarget ) + 1; 54 55 $.ajax({ 56 type : 'post', 57 url : '/wp-admin/admin-ajax.php', 58 data : { 59 action : 'rate_item', 60 rating : indx, 61 comment_post_ID : ctx.data('id'), 62 comment_ID : ctx.data('comment-id') 63 } 64 }); 65 66 return false; 67 } 68 69 $(document).ready(function () { 70 var hoverEvents = 'mouseenter mouseleave'; 71 72 $('.form-rating li') 73 .bind( hoverEvents, doHover ) 74 .click( doFormRating ); 75 76 $('.needs-rating li') 77 .bind( hoverEvents, doHover ) 78 .click( doRating ); 79 }); 80}(jQuery));
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.