1( function( $ ) { 2 $( document ).ready( function() { 3 $( '.rtng-star-rating' ).removeClass( 'rtng-no-js' ); 4 $( document ).on( 'change', '.rtng-star-rating.rtng-active .rtng-star input', function() { 5 var form = $( this ).closest( '.rtng-form' ); 6 7 form.before( '<div class="rtng-form-marker"></div>' ); 8 9 var val = $( this ).val(), 10 rating_id = $( this ).attr( 'name' ).match( /rtng_rating\[(\d)\]$/ )[1], 11 object_id = form.find( 'input[name="rtng_object_id"]' ).val(), 12 post_id = form.data( 'id' ), 13 object_type = form.find( 'input[name="rtng_object_type"]' ).val(); 14 show_title = form.find( 'input[name="rtng_show_title"]' ).val(); 15 16 $.ajax( { 17 url: rtng_vars.ajaxurl, 18 data: { 19 action: 'rtng_add_rating_db', 20 rtng_rating_val: val, 21 rtng_rating_id: rating_id, 22 rtng_object_type: object_type, 23 rtng_object_id: object_id, 24 rtng_post_id: post_id, 25 rtng_show_title: show_title, 26 rtng_nonce: rtng_vars.nonce 27 }, 28 type: 'POST', 29 success: function( data ) { 30 if ( data ) { 31 data = JSON.parse( data ); 32 33 $( '.rtng-rating-total[data-id="' + post_id + '"]' ).not( '.rtng-form-combined' ).replaceWith( data.total ); 34 $( '.rtng-form[data-id="' + post_id + '"]' ).not( '.rtng-form-combined' ).replaceWith( data.rate ); 35 $( '.rtng-form-combined[data-id="' + post_id + '"]' ).replaceWith( data.combined ); 36 37 form = $( '.rtng-form-marker + .rtng-form' ); 38 39 var $message_block = form.find( '.rtng-thankyou' ); 40 if ( $message_block.length ) { 41 $message_block.replaceWith( data.message ); 42 } else { 43 form.append( data.message ); 44 } 45 setTimeout( function() { 46 form.find( '.rtng-thankyou' ).fadeOut(); 47 }, 5000 ); 48 } 49 $( '.rtng-form-marker' ).remove(); 50 } 51 } ); 52 }); 53 54 $( document ).on( 'mouseenter', '.rtng-star-rating.rtng-active .rtng-star', function() { 55 $( this ) 56 .nextUntil( $( this ), '.rtng-star' ) 57 .children( 'span' ) 58 .removeClass( 'dashicons-star-filled dashicons-star-half' ) 59 .addClass( 'dashicons-star-empty' ); 60 $( this ) 61 .prevUntil( $( this ), '.rtng-star' ) 62 .children( 'span' ) 63 .removeClass( 'dashicons-star-empty dashicons-star-half' ) 64 .addClass( 'dashicons-star-filled rtng-hovered' ); 65 $( this ) 66 .children( 'span' ) 67 .removeClass( 'dashicons-star-empty dashicons-star-half' ) 68 .addClass( 'dashicons-star-filled rtng-hovered' ); 69 }).on( 'mouseleave', '.rtng-star-rating.rtng-active .rtng-star', function() { 70 if ( $( this ).parent().find( 'input[name^="rtng_rating"]:checked' ).val() ) { 71 rating = $( this ).parent().find( 'input[name^="rtng_rating"]:checked' ).val(); 72 } else { 73 rating = $( this ).parent().attr( 'data-rating' ); 74 rating = ( rating / 100 ) * 5; 75 } 76 if ( undefined != rating ) { 77 list = $( this ).parent().children( '.rtng-star' ); 78 list.children( 'span' ) 79 .removeClass( 'dashicons-star-filled rtng-hovered' ) 80 .addClass( 'dashicons-star-empty' ); 81 list.slice( 0, rating ) 82 .children( 'span' ) 83 .removeClass( 'dashicons-star-empty' ) 84 .addClass( 'dashicons-star-filled' ); 85 if ( ( rating * 10 % 10 ) != 0 && rating != 0 ) { 86 list.slice( parseFloat( rating ) - 0.5, parseFloat( rating ) + 0.5 ) 87 .children( 'span' ) 88 .removeClass( 'dashicons-star-empty' ) 89 .addClass( 'dashicons-star-half' ); 90 } 91 } 92 }); 93 }); 94})( 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.