PageSourceSearch

https://www.jhrl.com/sites/all/modules/rescms/rc_riot/js/mixins/RCRiotValidation.js?tlse4v

js jhrl.com collected 2026-10-06 13:18:21 UTC 2,026 bytes, 66 lines download raw bytes

1/**
2 * RCRiotValidation RiotJS Mixin
3 *
4 * Add support to trigger validation in UI.
5 */
6
7(function($) {
8
9  // Define the actual validation functionality.
10  var RCRiotValidation = {
11    init: function() {
12      (function($, tag, opts) {
13        // All validation items store.
14        var validationItems = [];
15
16        // Add a validation and reject process into the queue.
17        tag.addValidation = function(validateFnt, rejectFnt) {
18          // Add validation/reject operations (if any).
19          if (typeof validateFnt === 'function' && typeof rejectFnt === 'function') {
20            validationItems.push({
21              validate: validateFnt,
22              reject: rejectFnt
23            });
24          }
25          else {
26            // Warn the developer about invalid passed params.
27            console.error("Validate and Reject must be functions");
28          }
29
30          return validationItems;
31        };
32
33        // Actual validation process trigger.
34        tag.validate = function() {
35          var output = true;
36
37          // Process validation items.
38          for (var i = 0; i < validationItems.length; i++) {
39            output = validationItems[i].validate();
40
41            // Verify actual validation process set returned a true/false value
42            if (typeof output !== 'boolean') {
43              // Warn the developer about invalid return value.
44              console.error("Validation function '" + validationItems[i].validate.name + "' must return true or false");
45
46              // Force an non-valid state. Reject callback is not called to avoid triggering
47              // false positives on the reason the validation didn't pass.
48              return false;
49            }
50
51            // Normal output validation verification.
52            if (!output) {
53              validationItems[i].reject();
54
55              break;
56            }
57          }
58
59          return output;
60        };
61      })(jQuery, this, this.opts);
62    }
63  };
64
65  riot.mixin('RCRiotValidation', RCRiotValidation);
66})(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.