PageSourceSearch

https://ticketdirect.co.nz/wp-content/plugins/recipe-card-blocks-b…/assets/js/wpzoom-rating-stars.js?ver=3.6.1

js ticketdirect.co.nz collected 2026-10-03 21:19:25 UTC 31,589 bytes, 680 lines download raw bytes

1jQuery( function() {
2    const __slice = [].slice;
3
4    ( function( $, wpzoomRatingStars ) {
5        // Modal handling - initialize immediately
6        const RatingModal = {
7            $modal: null,
8            currentRecipeId: null,
9            currentPostId: null,
10            currentRating: 0,
11            initialized: false,
12
13            init: function() {
14                if ( this.initialized ) {
15                    return;
16                }
17
18                this.$modal = $( '#wpzoom-rating-modal' );
19                if ( ! this.$modal.length ) {
20                    return;
21                }
22
23                this.initialized = true;
24                this.bindEvents();
25            },
26
27            bindEvents: function() {
28                const self = this;
29
30                // Close modal
31                this.$modal.on( 'click', '.wpzoom-rating-modal-close, .wpzoom-rating-modal-overlay', function() {
32                    self.close();
33                } );
34
35                // Close on escape key
36                $( document ).on( 'keydown', function( e ) {
37                    if ( e.key === 'Escape' && self.$modal && self.$modal.is( ':visible' ) ) {
38                        self.close();
39                    }
40                } );
41
42                // Star click in modal
43                this.$modal.on( 'click', '.wpzoom-rating-modal-star', function() {
44                    const rating = $( this ).data( 'rating' );
45                    self.setModalRating( rating );
46                } );
47
48                // Star hover in modal
49                this.$modal.on( 'mouseenter', '.wpzoom-rating-modal-star', function() {
50                    const rating = $( this ).data( 'rating' );
51                    self.highlightStars( rating );
52                } );
53
54                this.$modal.on( 'mouseleave', '.wpzoom-rating-modal-stars', function() {
55                    self.highlightStars( self.currentRating );
56                } );
57
58                // Form submission
59                this.$modal.on( 'submit', '.wpzoom-rating-modal-form', function( e ) {
60                    e.preventDefault();
61                    self.submitRating();
62                } );
63            },
64
65            open: function( recipeId, recipeName, initialRating, postId ) {
66                // Initialize if not already done
67                if ( ! this.initialized ) {
68                    this.init();
69                }
70
71                if ( ! this.$modal || ! this.$modal.length ) {
72                    console.warn( 'WPZOOM Rating Modal: Modal element not found' );
73                    return;
74                }
75
76                this.currentRecipeId = recipeId;
77                this.currentPostId = postId || wpzoomRatingStars.current_post_id || recipeId; // Prefer current page/post for embedded recipes
78                this.currentRating = initialRating || 0;
79
80                // Set recipe info
81                this.$modal.find( '.wpzoom-rating-modal-recipe-name' ).text( recipeName || '' );
82                this.$modal.find( 'input[name="wpzoom_rating_recipe_id"]' ).val( recipeId );
83                this.$modal.find( 'input[name="wpzoom_rating_value"]' ).val( this.currentRating );
84
85                // Reset form
86                var $form = this.$modal.find( '.wpzoom-rating-modal-form' );
87                if ( $form.length && $form[0] ) {
88                    $form[0].reset();
89                }
90                this.$modal.find( 'input[name="wpzoom_rating_recipe_id"]' ).val( recipeId );
91
92                // Pre-fill user info if logged in
93                if ( wpzoomRatingStars.user_name ) {
94                    this.$modal.find( 'input[name="wpzoom_rating_name"]' ).val( wpzoomRatingStars.user_name );
95                }
96                if ( wpzoomRatingStars.user_email ) {
97                    this.$modal.find( 'input[name="wpzoom_rating_email"]' ).val( wpzoomRatingStars.user_email );
98                }
99
100                // Show form, hide thank you and loading
101                this.$modal.find( '.wpzoom-rating-modal-form-wrapper' ).show();
102                this.$modal.find( '.wpzoom-rating-modal-thank-you' ).hide();
103                this.$modal.find( '.wpzoom-rating-modal-loading' ).hide();
104                this.$modal.find( '.wpzoom-rating-modal-error' ).hide();
105
106                // Update stars
107                this.setModalRating( this.currentRating );
108
109                // Show modal
110                this.$modal.css( 'display', 'flex' );
111                $( 'body' ).css( 'overflow', 'hidden' );
112
113                // Focus first input or textarea
114                var self = this;
115                setTimeout( function() {
116                    var $firstInput = self.$modal.find( 'textarea, input[type="text"]' ).first();
117                    if ( $firstInput.length ) {
118                        $firstInput.focus();
119                    }
120                }, 100 );
121            },
122
123            close: function() {
124                if ( this.$modal ) {
125                    this.$modal.hide();
126                }
127                $( 'body' ).css( 'overflow', '' );
128                this.currentRecipeId = null;
129                this.currentPostId = null;
130                this.currentRating = 0;
131            },
132
133            setModalRating: function( rating ) {
134                this.currentRating = rating;
135                if ( this.$modal ) {
136                    this.$modal.find( 'input[name="wpzoom_rating_value"]' ).val( rating );
137                }
138                this.highlightStars( rating );
139                this.updateCommentRequirement( rating );
140            },
141
142            updateCommentRequirement: function( rating ) {
143                if ( ! this.$modal ) return;
144
145                var forceComment = wpzoomRatingStars.force_comment || 'disabled';
146                var commentRequired = false;
147
148                if ( forceComment === 'always' ) {
149                    commentRequired = true;
150                } else if ( forceComment !== 'disabled' && ! isNaN( parseInt( forceComment ) ) ) {
151                    commentRequired = rating <= parseInt( forceComment );
152                }
153
154                var $commentField = this.$modal.find( '.wpzoom-rating-modal-field-comment' );
155                var $textarea = $commentField.find( 'textarea' );
156                var $publishCommentCheckbox = $commentField.find( 'input[name="wpzoom_rating_publish_comment"]' );
157
158                if ( ! $textarea.length ) {
159                    return;
160                }
161
162                // Store original placeholder on first access
163                if ( ! $textarea.attr( 'data-original-placeholder' ) ) {
164                    $textarea.attr( 'data-original-placeholder', $textarea.attr( 'placeholder' ) || '' );
165                }
166
167                if ( commentRequired ) {
168                    $commentField.addClass( 'is-required' );
169                    if ( $publishCommentCheckbox.length ) {
170                        $publishCommentCheckbox.prop( 'checked', true ).prop( 'disabled', true );
171                    }
172                    // Update placeholder to indicate required - remove "(optional)" and add "*"
173                    var originalPlaceholder = $textarea.attr( 'data-original-placeholder' ) || '';
174                    var requiredPlaceholder = originalPlaceholder.replace( /\s*\(optional\)\s*/gi, '' ).trim() + ' *';
175                    $textarea.attr( 'placeholder', requiredPlaceholder );
176                } else {
177                    $commentField.removeClass( 'is-required' );
178                    if ( $publishCommentCheckbox.length ) {
179                        $publishCommentCheckbox.prop( 'disabled', false );
180                    }
181                    // Restore original placeholder
182                    var originalPlaceholder = $textarea.attr( 'data-original-placeholder' );
183                    if ( originalPlaceholder ) {
184                        $textarea.attr( 'placeholder', originalPlaceholder );
185                    }
186                }
187            },
188
189            highlightStars: function( rating ) {
190                if ( ! this.$modal ) return;
191
192                this.$modal.find( '.wpzoom-rating-modal-star' ).each( function() {
193                    var starRating = $( this ).data( 'rating' );
194                    if ( starRating <= rating ) {
195                        $( this ).removeClass( 'wpz-empty-star' ).addClass( 'wpz-full-star' );
196                    } else {
197                        $( this ).removeClass( 'wpz-full-star' ).addClass( 'wpz-empty-star' );
198                    }
199                } );
200            },
201
202            submitRating: function() {
203                var self = this;
204                var $form = this.$modal.find( '.wpzoom-rating-modal-form' );
205                var $submitBtn = $form.find( '.wpzoom-rating-modal-submit' );
206                var $error = this.$modal.find( '.wpzoom-rating-modal-error' );
207                var showNameField = wpzoomRatingStars.show_name !== '0';
208                var showEmailField = wpzoomRatingStars.show_email !== '0';
209
210                // Validate rating
211                if ( ! this.currentRating || this.currentRating < 1 ) {
212                    $error.text( wpzoomRatingStars.strings.rating_required || 'Please select a rating' ).show();
213                    return;
214                }
215
216                // Validate required fields
217                var name = showNameField ? $form.find( 'input[name="wpzoom_rating_name"]' ).val().trim() : '';
218                var email = showEmailField ? $form.find( 'input[name="wpzoom_rating_email"]' ).val().trim() : '';
219                var $commentInput = $form.find( 'textarea[name="wpzoom_rating_comment"]' );
220                var $publishCommentCheckbox = $form.find( 'input[name="wpzoom_rating_publish_comment"]' );
221                var comment = $commentInput.length ? ( $commentInput.val() || '' ).trim() : '';
222                var publishComment = $publishCommentCheckbox.length ? $publishCommentCheckbox.is( ':checked' ) : true;
223
224                if ( showNameField && wpzoomRatingStars.require_name === '1' && ! name ) {
225                    $error.text( wpzoomRatingStars.strings.name_required || 'Please enter your name' ).show();
226                    return;
227                }
228
229                if ( showEmailField ) {
230                    if ( wpzoomRatingStars.require_email === '1' && ! email ) {
231                        $error.text( wpzoomRatingStars.strings.email_required || 'Please enter your email' ).show();
232                        return;
233                    }
234                    // Validate any provided email, even when field is optional
235                    if ( email ) {
236                        var emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
237                        if ( ! emailRegex.test( email ) ) {
238                            $error.text( wpzoomRatingStars.strings.email_invalid || 'Please enter a valid email' ).show();
239                            return;
240                        }
241                    }
242                }
243
244                // Check if comment is required based on force_comment setting and current rating
245                var forceComment = wpzoomRatingStars.force_comment || 'disabled';
246                var commentRequired = false;
247
248                if ( forceComment === 'always' ) {
249                    commentRequired = true;
250                } else if ( forceComment !== 'disabled' && ! isNaN( parseInt( forceComment ) ) ) {
251                    // forceComment is a number (e.g., '3' means required for 3 stars or less)
252                    commentRequired = this.currentRating <= parseInt( forceComment );
253                }
254
255                if ( commentRequired && ! comment ) {
256                    $error.text( wpzoomRatingStars.strings.comment_required || 'Please leave a comment' ).show();
257                    return;
258                }
259
260                $error.hide();
261
262                // Show loading
263                $submitBtn.prop( 'disabled', true );
264                this.$modal.find( '.wpzoom-rating-modal-form-wrapper' ).hide();
265                this.$modal.find( '.wpzoom-rating-modal-loading' ).show();
266
267                var data = {
268                    action: 'wpzoom_user_vote_recipe',
269                    rating: this.currentRating,
270                    recipe_id: this.currentRecipeId,
271                    post_id: this.currentPostId,
272                    rating_name: name,
273                    rating_email: email,
274                    rating_comment: comment,
275                    publish_review_comment: publishComment ? '1' : '0',
276                    security: wpzoomRatingStars.ajax_nonce,
277                };
278
279                $.post( wpzoomRatingStars.ajaxurl, data, function( response ) {
280                    self.$modal.find( '.wpzoom-rating-modal-loading' ).hide();
281                    $submitBtn.prop( 'disabled', false );
282
283                    if ( response.success ) {
284                        // Update stars on the page
285                        var $container = $( '.wpzoom-rating-stars-container[data-recipe-id="' + self.currentRecipeId + '"]' );
286                        if ( $container.length ) {
287                            $container.find( '.wpzoom-rating-average' ).text( response.data.rating_avg );
288                            $container.find( '.wpzoom-rating-total-votes' ).text( response.data.rating_total );
289                            $container.data( 'rating', response.data.rating_avg );
290                            $container.data( 'rating-total', response.data.rating_total );
291                            $container.find( '.wpzoom-rating-stars' ).addClass( 'wpzoom-recipe-user-rated' );
292
293                            // Trigger syncRating on the star element
294                            var starInstance = $container.find( '.wpzoom-rating-stars' ).data( 'star-rating' );
295                            if ( starInstance ) {
296                                starInstance.options.rating = response.data.rating_avg;
297                                starInstance.options.rating_total = response.data.rating_total;
298                                starInstance.options.user_rating = self.currentRating;
299                                starInstance.syncRating();
300                            }
301                        }
302
303                        // Show thank you message
304                        self.$modal.find( '.wpzoom-rating-modal-thank-you' ).show();
305
306                        // Close modal after delay
307                        setTimeout( function() {
308                            self.close();
309                        }, 2500 );
310                    } else {
311                        // Show error
312                        self.$modal.find( '.wpzoom-rating-modal-form-wrapper' ).show();
313                        $error.text( response.data.message || 'An error occurred' ).show();
314                    }
315                } ).fail( function() {
316                    self.$modal.find( '.wpzoom-rating-modal-loading' ).hide();
317                    self.$modal.find( '.wpzoom-rating-modal-form-wrapper' ).show();
318                    $submitBtn.prop( 'disabled', false );
319                    $error.text( 'An error occurred. Please try again.' ).show();
320                } );
321            }
322        };
323
324        // Initialize modal immediately
325        RatingModal.init();
326
327        // Make globally accessible
328        window.WPZOOMRatingModal = RatingModal;
329
330        // Handle footer CTA "Rate this recipe" trigger.
331        $( document ).on( 'click', '.recipe-card-cta-rate-trigger', function( e ) {
332            e.preventDefault();
333
334            var $trigger = $( this );
335            var $card = $trigger.closest( '.wp-block-wpzoom-recipe-card-block-recipe-card' );
336            var $ratingContainer = $card.length ? $card.find( '.wpzoom-rating-stars-container' ).first() : $( '.wpzoom-rating-stars-container' ).first();
337
338            if ( ! $ratingContainer.length ) {
339                return;
340            }
341
342            var recipeId = parseInt( $ratingContainer.data( 'recipe-id' ), 10 ) || 0;
343            if ( ! recipeId ) {
344                return;
345            }
346
347            var postId = parseInt( $ratingContainer.data( 'post-id' ), 10 ) || parseInt( wpzoomRatingStars.current_post_id, 10 ) || recipeId;
348            var recipeName = '';
349            var ratingMode = wpzoomRatingStars.rating_mode || 'instant';
350
351            if ( $card.length ) {
352                recipeName = $.trim( $card.find( '.recipe-card-title' ).first().text() );
353            }
354
355            if ( ratingMode === 'modal' && window.WPZOOMRatingModal && typeof window.WPZOOMRatingModal.open === 'function' ) {
356                window.WPZOOMRatingModal.open( recipeId, recipeName, 0, postId );
357                return;
358            }
359
360            if ( ratingMode === 'jump_to_comments' ) {
361                var $comments = $( '#respond, #comments, .comments-area' ).first();
362                if ( $comments.length ) {
363                    var commentsNode = $comments.get( 0 );
364                    if ( commentsNode && typeof commentsNode.scrollIntoView === 'function' ) {
365                        commentsNode.scrollIntoView( { behavior: 'smooth', block: 'start' } );
366                        return;
367                    }
368                }
369
370                if ( window.WPZOOMRatingModal && typeof window.WPZOOMRatingModal.open === 'function' ) {
371                    window.WPZOOMRatingModal.open( recipeId, recipeName, 0, postId );
372                    return;
373                }
374            }
375
376            var ratingNode = $ratingContainer.get( 0 );
377            if ( ratingNode && typeof ratingNode.scrollIntoView === 'function' ) {
378                ratingNode.scrollIntoView( { behavior: 'smooth', block: 'center' } );
379            }
380        } );
381
382        class WPZOOM_Rating_Star {
383            constructor( $el, options ) {
384                let i,
385                    _,
386                    _ref,
387                    _this = this;
388                this.$el = $el;
389                this.defaults = {
390                    rating: this.$el.parent().data( 'rating' ),
391                    rating_total: this.$el.parent().data( 'rating-total' ),
392                    recipe_id: this.$el.parent().data( 'recipe-id' ),
393                    post_id: this.$el.parent().data( 'post-id' ),
394                    user_rating: void 0,
395                    numStars: 5,
396                    change: function( e, value ) { },
397                };
398                this.options = $.extend( {}, this.defaults, options );
399                _ref = this.defaults;
400                for ( i in _ref ) {
401                    _ = _ref[ i ];
402                    if ( this.$el.data( i ) != null ) {
403                        this.options[ i ] = this.$el.data( i );
404                    }
405                }
406                this.$el
407                    .next()
408                    .find( '.wpzoom-rating-average' )
409                    .html( this.options.rating );
410                this.$el
411                    .next()
412                    .find( '.wpzoom-rating-total-votes' )
413                    .html( this.options.rating_total );
414                this.syncRating();
415                this.$el.on( 'mouseover.starrr', 'li', function( e ) {
416                    return _this.syncRating(
417                        _this.$el.find( 'li' ).index( e.currentTarget ) + 1
418                    );
419                } );
420                this.$el.on( 'mouseout.starrr', function() {
421                    return _this.syncRating();
422                } );
423                this.$el.on( 'click.starrr', 'li', function( e ) {
424                    var element = $( this );
425                    var rating = _this.$el.find( 'li' ).index( e.currentTarget ) + 1;
426
427                    // Check rating mode
428                    var ratingMode = wpzoomRatingStars.rating_mode || 'instant';
429
430                    if ( ratingMode === 'modal' ) {
431                        // Get recipe name from the page
432                        var recipeName = '';
433                        var $recipeCard = element.closest( '.wp-block-wpzoom-recipe-card-block-recipe-card, .wpzoom-recipe-card' );
434                        if ( $recipeCard.length ) {
435                            recipeName = $recipeCard.find( '.recipe-card-title, .wpzoom-rcb-post-title' ).first().text();
436                        }
437                        if ( ! recipeName ) {
438                            recipeName = $( 'h1.entry-title, h1.post-title, .recipe-card-title' ).first().text();
439                        }
440
441                        RatingModal.open( _this.options.recipe_id, recipeName, rating, _this.options.post_id );
442                        return false;
443                    } else if ( ratingMode === 'jump_to_comments' ) {
444                        // Check if comment form exists - prioritize the form over comments list
445                        var $commentForm = $( '#respond, .comment-respond, #commentform' ).first();
446                        var $ratingForm = $( '.wpzoom-rcb-comment-rating-form' );
447
448                        if ( $commentForm.length && $commentForm.is( ':visible' ) ) {
449                            // Pre-select the rating in the comment form rating stars
450                            if ( $ratingForm.length ) {
451                                // Click the corresponding rating radio input
452                                var $ratingInput = $ratingForm.find( 'input[name="wpzoom-rcb-comment-rating"][value="' + rating + '"]' );
453                                if ( $ratingInput.length ) {
454                                    $ratingInput.prop( 'checked', true ).trigger( 'change' );
455
456                                    // Update star visual appearance
457                                    $ratingForm.find( '.wpzoom-rcb-comment-rating-stars label .wpz-star-icon' ).each( function() {
458                                        var $star = $( this );
459                                        var $label = $star.closest( 'label' );
460                                        var starValue = parseInt( $label.find( '
460input' ).val() );
461
462                                        if ( starValue > 0 && starValue <= rating ) {
463                                            $star.removeClass( 'wpz-empty-star' ).addClass( 'wpz-full-star' );
464                                        } else {
465                                            $star.removeClass( 'wpz-full-star' ).addClass( 'wpz-empty-star' );
466                                        }
467                                    } );
468                                }
469                            }
470
471                            // Scroll to comment form
472                            $( 'html, body' ).animate( {
473                                scrollTop: $commentForm.offset().top - 100
474                            }, 500, function() {
475                                // Focus on comment textarea after scroll
476                                var $textarea = $commentForm.find( 'textarea#comment, textarea[name="comment"]' ).first();
477                                if ( $textarea.length ) {
478                                    $textarea.focus();
479                                }
480                            } );
481                            return false;
482                        } else {
483                            // Fallback to modal if no comment form
484                            var recipeName = '';
485                            var $recipeCard = element.closest( '.wp-block-wpzoom-recipe-card-block-recipe-card, .wpzoom-recipe-card' );
486                            if ( $recipeCard.length ) {
487                                recipeName = $recipeCard.find( '.recipe-card-title, .wpzoom-rcb-post-title' ).first().text();
488                            }
489                            if ( ! recipeName ) {
490                                recipeName = $( 'h1.entry-title, h1.post-title, .recipe-card-title' ).first().text();
491                            }
492
493                            RatingModal.open( _this.options.recipe_id, recipeName, rating, _this.options.post_id );
494                            return false;
495                        }
496                    } else {
497                        // Instant mode (legacy)
498                        return _this.setRating( rating, element );
499                    }
500                } );
501                this.$el.on( 'starrr:change', this.options.change );
502            }
503            setRating( rating, element ) {
504                // prevent user multiple votes with same rating value
505                if (
506                    element.parent().hasClass( 'wpzoom-recipe-user-rated' ) &&
507                    parseInt( this.options.user_rating ) === rating
508                ) {
509                    return false;
510                }
511
512                let _this = this,
513                    rating_avg = this.options.rating,
514                    rating_total = this.options.rating_total,
515                    recipe_id = this.options.recipe_id;
516
517                // store user rating
518                this.options.user_rating = rating;
519
520                const data = {
521                    action: 'wpzoom_user_vote_recipe',
522                    rating: rating,
523                    recipe_id: recipe_id,
524                    security: wpzoomRatingStars.ajax_nonce,
525                };
526
527                element
528                    .parents( '.wpzoom-rating-stars-container' )
529                    .addClass( 'is-loading' );
530
531                $.post( wpzoomRatingStars.ajaxurl, data, function( response ) {
532                    const data = response.data;
533                    if ( response.success ) {
534                        rating_avg = data.rating_avg;
535                        rating_total = data.rating_total;
536
537                        element.parent().next().find( '.wpzoom-rating-average' ).html( rating_avg );
538                        element.parent().data( 'rating', rating_avg );
539                        element.parent().next().find( '.wpzoom-rating-total-votes' ).html( rating_total );
540                        element.parent().data( 'rating-total', rating_total );
541                        element.parents( '.wpzoom-rating-stars-container' ).removeClass( 'is-loading' );
542
543                        if ( ! element.parent().hasClass( 'wpzoom-recipe-user-rated' ) ) {
544                            element
545                                .parent()
546                                .addClass( 'wpzoom-recipe-user-rated' );
547                        }
548                    } else {
549                        element.parents( '.wpzoom-rating-stars-container' ).removeClass( 'is-loading' );
550                        element.parents( '.wpzoom-rating-stars-container' ).attr( 'data-user-can-rate', '0' );
551                        element.parents( '.wpzoom-rating-stars-container' ).find( '.wpzoom-rating-stars-tooltip' ).html( data.message );
552                    }
553                } ).done( function( response ) {
554                    const data = response.data;
555                    if ( response.success ) {
556                        _this.options.rating = data.rating_avg;
557                        _this.options.rating_total = data.rating_total;
558                        _this.syncRating();
559                        return _this.$el.trigger( 'starrr:change', data.rating_avg );
560                    }
561                } );
562            }
563            syncRating( rating ) {
564
565                let i, _i, _j, _ref;
566
567                // Make sure we make full stars
568                if ( rating ) {
569                    rating = parseFloat( rating );
570                } else {
571                    rating = parseFloat( this.options.rating );
572                }
573
574                this.$el
575                .find( 'li' )
576                .removeClass( 'wpz-one-fourth-star' )
577                .removeClass( 'wpz-one-half-star' )
578                .removeClass( 'wpz-three-quarters-star' );
579
580
581                let integer_average = Math.floor( rating ),
582                    float_average = rating - integer_average;
583
584                //Add full stars
585                for ( i = 0, _ref = integer_average; i < _ref; i++ ) {
586
587                    this.$el
588                        .find('li')
589                        .eq(i)
590                        .removeClass('wpz-empty-star')
591                        .addClass('wpz-full-star');
592                }
593
594                // check float value and add class to stars
595                if ( float_average > 0 ) {
596
597                    if ( 0.05 < float_average && 0.35 >= float_average ) {
598                        this.$el
599                        .find('li')
600                        .eq( integer_average )
601                        .removeClass('wpz-empty-star')
602                        .removeClass('wpz-full-star')
603                        .addClass('wpz-one-fourth-star');
604                    }
605                    else if( 0.35 < float_average && 0.65 >= float_average ) {
606                        this.$el
607                            .find('li')
608                            .eq( integer_average )
609                            .removeClass('wpz-empty-star')
610                            .removeClass('wpz-full-star')
611                            .addClass('wpz-one-half-star');
612                    } else if( 0.65 < float_average && 0.95 >= float_average ) {
613                        this.$el
614                            .find('li')
615                            .eq( integer_average )
616                            .removeClass('wpz-empty-star')
617                            .removeClass('wpz-full-star')
618                            .addClass('wpz-three-quarters-star');
619                    } else if( 0.95 < float_average ) {
620                        this.$el
621                            .find('li')
622                            .eq( integer_average )
623                            .removeClass('wpz-empty-star')
624                            .removeClass('wpz-full-star')
625                            .addClass('wpz-full-star');
626                    }
627                }
628
629                if ( rating && rating < 5 ) {
630                    // Calculate how many stars should be filled (including partial stars)
631                    let filledStars = integer_average + (float_average > 0 ? 1 : 0);
632                    for (
633                        i = filledStars;
634                        i < 5;
635                        i++
636                    ) {
637                        this.$el
638                            .find( 'li' )
639                            .eq( i )
640                            .removeClass( 'wpz-full-star' )
641                            .addClass( 'wpz-empty-star' );
642                    }
643                }
644
645                if ( ! rating ) {
646                    return this.$el
647                        .find( 'li' )
648                        .removeClass( 'wpz-full-star' )
649                       .addClass( 'wpz-empty-star' );
650                }
651
652            }
653        }
654
655        return $.fn.extend( {
656            starrr: function() {
657                let args, option;
658
659                ( option = arguments[ 0 ] ),
660                ( args = 2 <= arguments.length ? __slice.call( arguments, 1 ) : [] );
661                return this.each( function() {
662                    let data;
663
664                    data = $( this ).data( 'star-rating' );
665                    if ( ! data ) {
666                        $( this ).data(
667                            'star-rating',
668                            ( data = new WPZOOM_Rating_Star( $( this ), option ) )
669                        );
670                    }
671                    if ( typeof option === 'string' ) {
672                        return data[ option ].apply( data, args );
673                    }
674                } );
675            },
676        } );
677    }( jQuery, wpzoomRatingStars ) );
678
679    jQuery( 'ul.wpzoom-rating-stars' ).starrr();
680} );

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.