PageSourceSearch

https://thelaunch.nl/wp-content/plugins/cool-formkit-for-elementor…/js/shared/rating-field.js?ver=1.7.10

js thelaunch.nl collected 2026-10-05 09:36:40 UTC 3,359 bytes, 93 lines download raw bytes

1/**
2 * Shared rating field handler for Elementor Pro and Cool Form / Hello Plus.
3 * Platform wrappers call CFKEF.initRatingField({ selectors }).
4 */
5window.CFKEF = window.CFKEF || {};
6
7CFKEF.initRatingField = function (opts) {
8  opts = opts || {};
9  var selectors = Object.assign(
10    {
11      rating: '.elementor-rating',
12      ratingInput: '.elementor-rating-input',
13      ratingValue: '.elementor-rating-value',
14      fieldType: '.elementor-field-type-rating',
15    },
16    opts.selectors || {}
17  );
18
19  jQuery(document).ready(function ($) {
20    $(document).on('mouseenter', selectors.rating + ' .rating-icon', function () {
21      var $icon = $(this);
22      var $field = $icon.closest(selectors.rating);
23      var value = parseFloat($icon.data('value'));
24
25      $field.find('.rating-icon').each(function () {
26        var iconValue = parseFloat($(this).data('value'));
27        if (iconValue <= value) {
28          $(this).addClass('hover');
29        } else {
30          $(this).removeClass('hover');
31        }
32      });
33
34      if ($field.data('show-rating-value')) {
35        $field.find(selectors.ratingValue).text('(' + value + '/' + $field.data('rating-scale') + ')');
36      }
37    });
38
39    $(document).on('mouseleave', selectors.rating, function () {
40      var $field = $(this);
41      $(this).find('.rating-icon').removeClass('hover');
42      var value = $field.find(selectors.ratingInput).val();
43      if ($field.data('show-rating-value')) {
44        $field.find(selectors.ratingValue).text('(' + value + '/' + $field.data('rating-scale') + ')');
45      }
46    });
47
48    $(document).on('click', selectors.rating + ' .rating-icon', function () {
49      var $icon = $(this);
50      var $field = $icon.closest(selectors.rating);
51      var value = parseFloat($icon.data('value'));
52
53      $field.find('.rating-icon').removeClass('marked');
54      $field.find('.rating-icon').each(function () {
55        var iconValue = parseFloat($(this).data('value'));
56        if (iconValue <= value) {
57          $(this).addClass('marked');
58        }
59      });
60      $field.find(selectors.ratingInput).val(value);
61      $field.find(selectors.ratingInput).trigger('change');
62      $field.find(selectors.ratingInput).trigger('input');
63
64      if ($field.data('show-rating-value')) {
65        $field.find(selectors.ratingValue).text('(' + value + '/' + $field.data('rating-scale') + ')');
66      }
67    });
68
69    $('form button[type="submit"]').on('click', function (event) {
70      var form = $(this).closest('form');
71      var isValid = true;
72
73      form.find(selectors.rating + '[data-required="true"]').each(function () {
74        if ($(this).find(selectors.ratingInput).val() === '0') {
75          isValid = false;
76          $(this).parent().find('.error-rating-message').remove();
77          $(this).parent().append('<div class="error-rating-message">This field is required and cannot be left blank.</div>');
78        } else {
79          $(this).parent().find('.error-rating-message').remove();
80        }
81      });
82
83      if (!isValid) {
84        event.preventDefault();
85      }
86    });
87
88    $(document).find('.rating-icon-wrapper').on('click', function () {
89      var parentFieldGroup = $(this).closest(selectors.fieldType);
90      parentFieldGroup.find('.error-rating-message').remove();
91    });
92  });
93};

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.