1( function ( $ ) { 2 $( function () { 3 "use strict"; 4 5 var ratingField = $( '#rate-it' ); 6 7 if ( ratingField.hasClass( 'require-yes' ) ) { 8 var container = $( '#stars-rating-review' ); 9 var parentForm = ratingField.closest( 'form' ); 10 var submitButton = parentForm.find( 'input[type="submit"]' ); 11 12 ratingField.barrating( { 13 theme : 'fontawesome-stars', 14 initialRating : 5, 15 onSelect : function ( value, text, event ) { 16 17 if ( event !== null ) { 18 19 submitButton.addClass( 'reviewed' ); 20 21 if ( ratingField.hasClass( 'negative-alert-enable' ) && value <= ratingField.data( 'threshold' ) ) { 22 submitButton.addClass( 'lower-rating' ); 23 } else { 24 submitButton.removeClass( 'lower-rating' ); 25 } 26 } 27 } 28 } ); 29 30 parentForm.on( 'submit', function () { 31 if ( ! submitButton.hasClass( 'reviewed' ) && container.is( ':visible' ) ) { 32 showRatingError( container ); 33 return false; 34 } 35 36 if ( submitButton.hasClass( 'lower-rating' ) ) { 37 openPopup(); 38 return false; 39 } 40 } ); 41 42 // Show an inline error below the rating widget 43 function showRatingError( container ) { 44 var errorId = 'sr-rating-error-msg'; 45 var errorMsg = ( typeof srRatingVars !== 'undefined' ) 46 ? srRatingVars.requireMsg 47 : 'Please select a star rating before submitting your review.'; 48 49 if ( ! $( '#' + errorId ).length ) { 50 $( '<p id="' + errorId + '" class="sr-rating-error" role="alert"></p>' ) 51 .text( errorMsg ) 52 .insertAfter( container ); 53 } 54 55 $( '#' + errorId ).stop( true ).fadeIn(); 56 } 57 58 // Show the popup and overlay 59 function openPopup() { 60 $( ".low-rating-alert-overlay, .low-rating-alert-wrap" ).fadeIn(); 61 } 62 63 // Close the popup and overlay 64 function closePopup() { 65 $( ".low-rating-alert-overlay, .low-rating-alert-wrap" ).fadeOut(); 66 } 67 68 $( "#post-rating" ).on( "click", function () { 69 submitButton.removeClass( 'lower-rating' ); 70 submitButton.trigger( 'click' ); 71 } ); 72 73 $( ".low-rating-alert-overlay" ).on( "click", function () { 74 closePopup(); 75 } ); 76 77 } else { 78 ratingField.barrating( { 79 theme : 'fontawesome-stars', 80 initialRating : 5 81 } ); 82 } 83 84 } ); 85} )( 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.