PageSourceSearch

https://www.nac.gov.sg/Frontend-Assembly/Telerik.Sitefinity.Fronte…/Form/form.all.js?v=MTQuNC44MTUyLjA%3d

js nac.gov.sg collected 2026-10-02 06:04:55 UTC 58,495 bytes, 1,497 lines download raw bytes

1//form-ajax.js
2(function ($) {
3    if (typeof window.FormData === 'undefined')
4        return;
5
6    $(function () {
7        var formContainers = $('[data-sf-role="form-container"]:has([data-sf-role="ajax-submit-url"])');
8        formContainers.each(function (i, element) {
9            var formContainer = $(element);
10            var loadingImg = formContainer.find('[data-sf-role="loading-img"]');
11            var fieldsContainer = formContainer.find('[data-sf-role="fields-container"]');
12            var successMessage = formContainer.find('[data-sf-role="success-message"]');
13            var errorMessage = formContainer.find('[data-sf-role="error-message"]');
14            var generalErrorMessage = formContainer.find('[data-sf-role="general-error-message"]');
15            var redirectUrl = formContainer.find('input[data-sf-role="redirect-url"]').val();
16            var submitUrl = formContainer.find('input[data-sf-role="ajax-submit-url"]').val();
17
18            var submitClickHandler = function () {
19                var parentForm = formContainer.closest('form');
20                var parentFormChildren = parentForm.children();
21
22                if (parentForm.length > 0)
23                    parentFormChildren.unwrap();
24
25                var newForm = formContainer.find('form');
26                var wrapped = false;
27                if (newForm.length === 0) {
28                    wrapped = true;
29                    formContainer.wrap('<form />');
30                    newForm = formContainer.parent();
31                }
32
33                newForm.one('submit', function () {
34                    var inputs = formContainer.find('input');
35                    var isValid = true;
36                    for (var i = 0; i < inputs.length; i++) {
37                        var jInput = $(inputs[i]);
38                        if (typeof (jInput.data('sfvalidator')) === 'function')
39                            isValid = jInput.data('sfvalidator')() && isValid;
40                    }
41
42                    if (!isValid)
43                        return false;
44
45                    if (typeof MarketoSubmitScript !== 'undefined') {
46                        MarketoSubmitScript._populateFormId($(newForm).find('input[data-sf-role="form-id"]').val());
47                        var newSubmitButtons = $(newForm).find(MarketoSubmitScript._settings.externalFormSubmitButtonsQuery);
48                        if (newSubmitButtons.length > 0)
49                            MarketoSubmitScript._formFields = Mar
49ketoSubmitScript._getExternalFormFields(newSubmitButtons[0]);
50                        if (MarketoSubmitScript._formFields && MarketoSubmitScript._formFields.length === 0)
51                            MarketoSubmitScript._populateFieldsFromLabels(newForm);
52                        MarketoSubmitScript._formSubmitHandler(newForm);
53                    }
54
55                    var formData = new FormData(newForm[0]);
56                    var request = new XMLHttpRequest();
57                    request.open('POST', submitUrl);
58                    request.onload = function () {
59                        if (request.status === 200) {
60                            var responseJson = JSON.parse(request.response);
61                            if (responseJson.success) {
62                                if (responseJson.redirectUrl && responseJson.redirectUrl !== '') {
63                                    document.location.replace(responseJson.redirectUrl);
64                                } else if (responseJson.message && responseJson.message !== '') {
65                                    successMessage.text(responseJson.message);
66                                    successMessage.show();
67                                    loadingImg.hide();
68                                } else {
69                                    if (redirectUrl) {
70                                        document.location.replace(redirectUrl);
71                                    }
72                                    else {
73                                        successMessage.show();
74                                        loadingImg.hide();
75                                    }
76                                }
77                            }
78                            else {
79                                generalErrorMessage.text(responseJson.error);
80                                generalErrorMessage.show();
81                                fieldsContainer.show();
82                                fieldsContainer.find('[data-sf-role="captcha-refresh-button"]').click();
83                                loadingImg.hide();
84                            }
85                        }
86                    };
87
88                    loadingImg.show();
89                    fieldsContainer.hide();
90                    errorMessage.hide();
91                    generalErrorMessage.hide();
92
93                    request.send(formData);
94
95                    if (wrapped)
96                        formContainer.unwrap();
97
98                    if (parentForm.length > 0)
99                        parentFormChildren.wrapAll(parentForm);
100
101                    return false;
102                });
103            };
104
105            formContainer.find('button[type="submit"],input[type="submit"]').click(submitClickHandler);
106        });
107    });
108})(jQuery);
109
110//captcha.js
111(function ($) {
112    'use strict';
113
114    /*
115        Rest Api
116    */
117    var CaptchaRestApi = function (rootUrl) {
118        this.rootUrl = (rootUrl && rootUrl[rootUrl.length - 1] !== '/') ? (rootUrl + '/') : rootUrl;
119    };
120
121    CaptchaRestApi.prototype = {
122        makeAjax: function (url, type, data) {
123            var options = {
124                type: type || 'GET',
125                url: url,
126                contentType: 'application/json',
127                accepts: {
128                    text: 'application/json'
129                },
130                cache: false
131            };
132
133            if (data) {
134                options.data = JSON.stringify(data);
135            }
136
137            return $.ajax(options);
138        },
139
140        getCaptcha: function () {
141            var getCaptchaUrl = this.rootUrl;
142            return this.makeAjax(getCaptchaUrl);
143        },
144
145        validateCaptcha: function (data) {
146            var validateCaptchaUrl = this.rootUrl;
147            return this.makeAjax(validateCaptchaUrl, 'POST', data);
148        }
149    };
150
151    /*
152        Widget
153    */
154    var CaptchaWidget = function (wrapper, settings, resources) {
155        this.wrapper = wrapper;
156        this.settings = settings;
157        this.resources = resources;
158    };
159
160    CaptchaWidget.prototype = {
161        /*
162            Elements
163        */
164        getOrInitializeProperty: function (property, sfRole) {
165            if (!this[property]) {
166                this[property] = this.getElementByDataSfRole(sfRole);
167            }
168
169            return this[property];
170        },
171        getElementByDataSfRole: function (sfRole) {
172            return this.wrapper.find('[data-sf-role="' + sfRole + '"]');
173        },
174        captchaImage: function () { return this.getOrInitializeProperty('_captchaImage', 'captcha-image'); },
175        captchaAudio: function () { return this.getOrInitializeProperty('_captchaAudio', 'captcha-audio'); },
176        captchaAudioBtn: function () { return this.getOrInitializeProperty('_captchaAudioBtn', 'captcha-audio-btn'); },
177        captchaInput: function () { return this.getOrInitializeProperty('_captchaInput', 'captcha-input'); },
178        captchaRefreshLink: function () { return this.getOrInitializeProperty('_captchaRefreshLink', 'captcha-refresh-button'); },
179        captchaDataKey: function () { return this.getOrInitializeProperty('_captchaDataKey', 'captcha-k'); },
180        captchaDataInvalidAnswerMessage: function () { return this.getOrInitializeProperty('_captchaDataInvalidAnswerMessage', 'captcha-iam'); },
181        errorMessage: function () { return this.getOrInitializeProperty('_errorMessage', 'error-message'); },
182
183        /*
184            Logic
185        */
186        captchaRefresh: function () {
187            var self = this;
188            var deferred = $.Deferred();
189
190            self.captchaImage().attr("src", "");
191            self.captchaInput().hide();
192
193            self.restApi.getCaptcha().then(function (data) {
194                if (data) {
195                    self.captchaImage().attr("src", "data:image/png;base64," + data.Image);
196                    self.captchaAudio().attr("src", "data:audio/wav;base64," + data.Audio);
197                    self.captchaAudioBtn().click(function () { self.captchaAudio()[0].play(); });
198                    self.captchaDataKey().val(data.Key);
199                    self.captchaInput().val("");
200                    self.captchaInput().show();
201                    self.wrapper.show();
202                }
203
204                deferred.resolve(true);
205            });
206
207            return deferred;
208        },
209
210        validateInput: function () {
211            var self = this;
212            var deferred = $.Deferred(),
213                data = {
214                    Answer: self.captchaInput().val(),
215                    Key: self.captchaDataKey().val()
216                };
217
218            self.restApi.validateCaptcha(data).then(function (validationResult) {
219                if (validationResult.IsValid) {
220                    self.hideInvalidMessage();
221                } else {
222                    self.showInvalidMessage();
223                    if (validationResult.RefreshCaptcha) {
224                        self.captchaRefresh();
225                    } else {
226                        self.wrapper.find('input').focus();
227                        self.wrapper.find('input').select();
228                    }
229                }
230
231                deferred.resolve(validationResult.IsValid);
232            });
233
234            return deferred;
235        },
236
237        /*
238            Initialization
239        */
240        initializeProperties: function () {
241            this.restApi = new CaptchaRestApi(this.settings.rootUrl);
242
243            this.captchaData = {
244                key: null
245            };
246        },
247
248        initializeCaptcha: function () {
249            this.captchaRefresh();
250        },
251
252        initializeHandlers: function () {
253            var self = this;
254
255            self.captchaRefreshLink().click(function () {
256                self.captchaRefresh();
257                return false;
258            });
259        },
260
261        showInvalidMessage: function () {
262            // If there is no error message container the old logic is required
263            if (this.errorMessage().length > 0) {
264                var messasge = this.captchaDataInvalidAnswerMessage().val();
265                this.errorMessage().text(messasge);
266                this.errorMessage().show();
267            } else {
268                this.getElementByDataSfRole('invalid-captcha-input').css('visibility', 'visible');
269            }
270        },
271
272        hideInvalidMessage: function () {
273            // If there is no error message container the old logic is required
274            if (this.errorMessage().length > 0) {
275                this.errorMessage().hide();
276            } else {
277                this.getElementByDataSfRole('invalid-captcha-input').css('visibility', 'hidden');
278            }
279        },
280
281        initialize: function () {
282            this.initializeProperties();
283            this.initializeCaptcha();
284            this.initializeHandlers();
285            this.hideInvalidMessage();
286        }
287    };
288
289    function getValidationMessages(input) {
290        var container = $(input).parents('[data-sf-role="field-captcha-container"]');
291        var validationMessagesInput = $(container).find('[data-sf-role="violation-messages"]');
292        var validationMessages = JSON.parse(validationMessagesInput.val());
293
294        return validationMessages;
295    }
296
297    function setErrorMessage(input, message) {
298        var errorMessagesContainer = _getErrorMessageContainer(input);
299
300        if (errorMessagesContainer) {
301            _toggleCustomErrorMessage(errorMessagesContainer, message);
302        } else {
303            input.setCustomValidity(message);
304        }
305    }
306
307    function _toggleCustomErrorMessage(container, message) {
308        container.innerText = message;
309
310        if (message === '') {
311            container.style.display = 'none';
312        } else {
313            container.style.display = 'block';
314        }
315    }
316
317    function _getErrorMessageContainer(input) {
318        var container = $(input).closest('[data-sf-role="field-captcha-container"]')[0];
319        if (container) {
320            var errorMessagesContainer = container.querySelector('[data-sf-role="error-message"]');
321            return errorMessagesContainer;
322        }
323
324        return null;
325    }
326
327    function changeOrInput(e) {
328        if (typeof e.target.validity == 'undefined')
329            return;
330
331        if (e.target.required && e.target.validity.valueMissing) {
332            var validationMessages = getValidationMessages(e.target);
333            setErrorMessage(e.target, validationMessages.required);
334        } else {
335            setErrorMessage(e.target, '');
336        }
337
338        // If there is no error message container the old logic is required
339        if (!_getErrorMessageContainer(e.target)) {
340            e.data.hideInvalidMessage();
341        }
342    }
343
344    function invalid(e) {
345        if (typeof e.target.validity == 'undefined')
346            return;
347
348        if (_getErrorMessageContainer(e.target)) {
349            e.preventDefault();
350        }
351
352        var validationMessages = getValidationMessages(e.target);
353
354        if (e.target.validity.valueMissing) {
355            setErrorMessage(e.target, validationMessages.required);
356        }
357    }
358
359    /*
360        Widget creation
361    */
362    $(function () {
363        $('[data-sf-role="field-captcha-container"]').each(function () {
364            var container = $(this);
365            var rootUrl = container.find('[data-sf-role="captcha-settings"]').val();
366            var captcha = new CaptchaWidget(container, { rootUrl: rootUrl });
367            captcha.initialize();
368
369            var input = container.find('[data-sf-role="captcha-input"]');
370
371            if (input) {
372                input.on('change', captcha, changeOrInput);
373                input.on('input', captcha, changeOrInput);
374                input.on('invalid', invalid);
375                input.data('widget-validator', function () {
376                    return captcha.validateInput();
377                });
378            }
379        });
380    });
381}(jQuery));
382//checkboxes-field.js
383(function ($) {
384    var changeOrInput = function (e) {
385        var container = $(e.target).parents('[data-sf-role="checkboxes-field-container"]');
386        var inputs = $(container).find('[data-sf-role="checkboxes-field-input"]');
387        var hasChecked = $(container).find('input[data-sf-role="checkboxes-field-input"]:checked').length > 0;
388
389        if (hasChecked || container.find('[data-sf-role="required-validator"]').val() === 'False') {
390            $(inputs[0]).removeAttr('required');
391            setErrorMessage(inputs[0], '');
392        }
393        else {
394            $(inputs[0]).attr('required', 'required');
395        }
396    };
397
398    var invalid = function (e) {
399        var validationMessages = getValidationMessages(e.target);
400
401        if (_getErrorMessageContainer(e.target)) {
402            e.preventDefault();
403        }
404
405        if (e.target.validity.valueMissing) {
406            setErrorMessage(e.target, validationMessages.required);
407        }
408    };
409
410    var getValidationMessages = function (input) {
411        var container = $(input).parents('[data-sf-role="checkboxes-field-container"]');
412        var validationMessagesInput = $(container).find('[data-sf-role="violation-messages"]');
413        var validationMessages = JSON.parse(validationMessagesInput.val());
414
415        return validationMessages;
416    };
417
418    var setErrorMessage = function (input, message) {
419        var errorMessagesContainer = _getErrorMessageContainer(input);
420
421        if (errorMessagesContainer) {
422            _toggleCustomErrorMessage(errorMessagesContainer, message);
423        } else {
424            input.setCustomValidity(message);
425        }
426    };
427
428    var _toggleCustomErrorMessage = function (container, message) {
429        container.innerText = message;
430
431        if (message === '') {
432            container.style.display = 'none';
433        } else {
434            container.style.display = 'block';
435        }
436    };
437
438    var _getErrorMessageContainer = function (input) {
439        var container = $(input).closest('[data-sf-role="checkboxes-field-container"]')[0];
440        if (container) {
441            var errorMessagesContainer = container.querySelector('[data-sf-role="error-message"]');
442            return errorMessagesContainer;
443        }
444
445        return null;
446    };
447
448    $(function () {
449        var containers = $('[data-sf-role="checkboxes-field-container"]');
450
451        if (!containers || containers.length < 1)
452            return;
453
454        var attachHandlers = function (input) {
455            input.on('change', function (e) {
456                changeOrInput(e);
457                if (typeof $.fn.processFormRules == 'function') {
458                    $(e.target).processFormRules();
459                }
460            });
461            input.on('input', changeOrInput);
462            input.on('invalid', invalid);
463        };
464
465        var checkboxClickHandler = function (e) {
466            var container = $(e.target).parents('[data-sf-role="checkboxes-field-container"]');
467            var checkboxes = container.find('input[data-sf-role="checkboxes-field-input"]');
468            var otherInput = $(container.find('[data-sf-checkboxes-role="other-choice-text"]').first());
469            var otherCheckbox = $(container.find('[data-sf-checkboxes-role="other-choice-checkbox"]').first());
470            var otherCheckboxIndex = checkboxes.index(otherCheckbox);
471            var currentIndex = checkboxes.index($(e.target));
472            var isRequired = container.find('[data-sf-role="required-validator"]').val() === 'True';
473
474            if (otherCheckbox.is(':checked')) {
475                otherInput.attr('type', 'text');
476
477                if (isRequired)
478                    otherInput.attr('required', 'required');
479                else
480                    otherInput.removeAttr('required');
481            }
482            else {
483                otherInput.attr('type', 'hidden');
484                otherInput.removeAttr('required');
485            }
486        };
487
488        var inputChangeHandler = function (e) {
489            var container = $(e.target).parents('[data-sf-role="checkboxes-field-container"]');
490            var otherCheckbox = $(container.find('[data-sf-checkboxes-role="other-choice-checkbox"]').first());
491            otherCheckbox.val($(e.target).val());
492
493            if (typeof $.fn.processFormRules == 'function') {
494                $(e.target).processFormRules();
495            }
496        };
497
498        for (var i = 0; i < containers.length; i++) {
499            var container = $(containers[i]);
500            var inputs = container.find('[data-sf-role="checkboxes-field-input"]');
501
502            if (container.find('[data-sf-role="required-validator"]').val() === 'True' && !inputs.is(':checked'))
503                $(inputs[0]).attr('required', 'required');
504
505            attachHandlers(inputs);
506
507            var checkboxes = container.find('input[data-sf-role="checkboxes-field-input"]');
508
509            var otherInput = $(container.find('[data-sf-checkboxes-role="other-choice-text"]').first());
510
511            checkboxes.click(checkboxClickHandler);
512            otherInput.change(inputChangeHandler);
513        }
514    });
515}(jQuery));
516//dropdown-list-field.js
517(function ($) {
518    $(function () {
519        function changeOrInput(e) {
520            if (e.target.value === '') {
521                var validationMessages = getValidationMessages(e.target);
522                setErrorMessage(e.target, validationMessages.required);
523            }
524            else {
525                setErrorMessage(e.target, '');
526            }
527
528            if (typeof $.fn.processFormRules == 'function') {
529                $(e.target).processFormRules();
530            }
531        }
532
533        function invalid(e) {
534            var validationMessages = getValidationMessages(e.target);
535
536            if (_getErrorMessageContainer(e.target)) {
537                e.preventDefault();
538            }
539
540            if (e.target.validity.valueMissing) {
541                setErrorMessage(e.target, validationMessages.required);
542            }
543        }
544
545        function getValidationMessages(input) {
546            var container = $(input).parents('[data-sf-role="dropdown-list-field-container"]');
547            var validationMessagesInput = $(container).find('[data-sf-role="violation-messages"]');
548            var validationMessages = JSON.parse(validationMessagesInput.val());
549
550            return validationMessages;
551        }
552
553        function setErrorMessage(input, message) {
554            var errorMessagesContainer = _getErrorMessageContainer(input);
555
556            if (errorMessagesContainer) {
557                _toggleCustomErrorMessage(errorMessagesContainer, message);
558            } else {
559                input.setCustomValidity(message);
560            }
561        }
562
563        function _toggleCustomErrorMessage(container, message) {
564            container.innerText = message;
565
566            if (message === '') {
567                container.style.display = 'none';
568            } else {
569                container.style.display = 'block';
570            }
571        }
572
573        function _getErrorMessageContainer(input) {
574            var container = $(input).closest('[data-sf-role="dropdown-list-field-container"]')[0];
575            if (container) {
576                var errorMessagesContainer = container.querySelector('[data-sf-role="error-message"]');
577                return errorMessagesContainer;
578            }
579
580            return null;
581        }
582
583        function init() {
584            var containers = $('[data-sf-role="dropdown-list-field-container"]');
585
586            if (!containers || containers.length < 1)
587                return;
588
589            for (var i = 0; i < containers.length; i++) {
590                var select = $(containers[i]).find('[data-sf-role="dropdown-list-field-select"]');
591
592                if (select) {
593                    select.on('change', changeOrInput);
594                    select.on('invalid', invalid);
595                }
596            }
597        }
598
599        init();
600    });
601}(jQuery));
602//file-field.js
603(function ($) {
604    var htmlDecode = function (html) {
605        var a = document.createElement('a'); a.innerHTML = html;
606        return a.textContent;
607    };
608
609    var adjustVisibility = function (container) {
610        var allRemoveLinks = container.find('[data-sf-role="remove-input"]');
611        allRemoveLinks.toggle(allRemoveLinks.length > 1);
612    };
613
614    var initInput = function (template, container, config) {
615        var input = $(template);
616        input.appendTo(container);
617
618        input.on('change', function (e) {
619            if (typeof $.fn.processFormRules === 'function') {
620                $(e.target).processFormRules();
621            }
622        });
623
624        if (config.AllowMultipleFiles) {
625            adjustVisibility(container);
626
627            input.find('[data-sf-role="remove-input"]').click(function () {
628                input.remove();
629                adjustVisibility(container);
630                if (typeof $.fn.processFormRules === 'function') {
631                    $(container).processFormRules();
632                }
633            });
634        }
635    };
636
637    var checkRequired = function (container) {
638        // This is called only for input[type="file"]
639        // If the fields is hidden, don't check for required
640        if (container.is(":hidden"))
641            return true;
642
643        var violationMessage = $('[data-sf-role="required-violation-message"]');
644
645        var inputs = container.find('input[type="file"]');
646        var firstInvalidInput = null;
647        for (var i = 0; i < inputs.length; i++) {
648            if (inputs[i].value) {
649                violationMessage.hide();
650                return true;
651            } else if (!firstInvalidInput) {
652                firstInvalidInput = inputs[i];
653            }
654        }
655
656        violationMessage.show();
657        firstInvalidInput.focus();
658        return false;
659    };
660
661    var checkFileTypes = function (container, fileTypes) {
662        var hasViolations = false;
663        var inputs = container.find('input[type="file"]');
664        for (var i = 0; i < inputs.length; i++) {
665            var violationMessage = $(inputs[i]).closest('[data-sf-role="single-file-input"]').find('[data-sf-role="filetype-violation-message"]');
666            if (inputs[i].value) {
667                var stopIndex = inputs[i].value.lastIndexOf('.');
668                if (stopIndex >= 0) {
669                    var extension = inputs[i].value.substring(stopIndex).toLowerCase();
670                    if (fileTypes.indexOf(extension) < 0) {
671                        violationMessage.show();
672                        hasViolations = true;
673                        inputs[i].focus();
674                        continue;
675                    }
676                }
677            }
678
679            violationMessage.hide();
680        }
681
682        return !hasViolations;
683    };
684
685    var checkFileSizes = function (container, min, max) {
686        if (typeof window.File == 'undefined' || typeof window.FileList == 'undefined')
687            return true;
688
689        var hasViolations = false;
690        var inputs = container.find('input[type="file"]');
691        for (var i = 0; i < inputs.length; i++) {
692            var violationMessage = $(inputs[i]).closest('[data-sf-role="single-file-input"]').find('[data-sf-role="filesize-violation-message"]');
693            if (inputs[i].files.length > 0) {
694                var file = inputs[i].files[0];
695                if ((min > 0 && file.size < min) || (max > 0 && file.size > max)) {
696                    violationMessage.show();
697                    hasViolations = true;
698                    inputs[i].focus();
699                    continue;
700                }
701            }
702
703            violationMessage.hide();
704        }
705
706        return !hasViolations;
707    };
708
709    var formValidation = function (ev) {
710        var requiredValidationResult = !ev.data.config.IsRequired || checkRequired(ev.data.container);
711        var fileTypesValidationResult = ev.data.config.AcceptedFileTypes.length === 0 || checkFileTypes(ev.data.container, ev.data.config.AcceptedFileTypes);
712        var fileSizesValidationResult = !(ev.data.config.MinFileSizeInMb || ev.data.config.MaxFileSizeInMb) || checkFileSizes(ev.data.container, ev.data.config.MinFileSizeInMb * 1024 * 1024, ev.data.config.MaxFileSizeInMb * 1024 * 1024);
713
714        return requiredValidationResult && fileTypesValidationResult && fileSizesValidationResult;
715    };
716
717    var init = function (element) {
718        var jElement = $(element);
719        var config = JSON.parse(htmlDecode(jElement.attr('data-sf-config')));
720
721        var inputContainer = jElement.find('[data-sf-role="file-field-inputs"]');
722        var inputTemplate = jElement.find('[data-sf-role="file-input-template"]').html();
723        var form = jElement.closest('form');
724        initInput(inputTemplate, inputContainer, config);
725
726        if (config.AllowMultipleFiles) {
727            $(jElement).find('[data-sf-role="add-input"]').click(function () {
728                initInput(inputTemplate, inputContainer, config);
729            });
730        }
731
732        jElement.find('input[type="file"]').data('sfvalidator', function () {
733            return formValidation({ data: { config: config, container: inputContainer } });
734        });
735
736        form.submit({ config: config, container: inputContainer }, formValidation);
737    };
738
739    $(function () {
740        var containers = $('[data-sf-role="file-field-container"]');
741        if (!containers || containers.length < 1)
742            return;
743
744        for (var i = 0; i < containers.length; i++) {
745            init(containers[i]);
746        }
747    });
748}(jQuery));
749//multiple-choice-field.js
750(function ($) {
751    var changeOrInput = function (e) {
752        var container = $(e.target).parents('[data-sf-role="multiple-choice-field-container"]');
753        var inputs = $(container).find('[data-sf-role="multiple-choice-field-input"]');
754        inputs.each(function (index, input) {
755            input.validity.valueMissing = false;
756            setErrorMessage(input, '');
757        });
758    };
759
760    var invalid = function (e) {
761        var validationMessages = getValidationMessages(e.target);
762
763        if (_getErrorMessageContainer(e.target)) {
764            e.preventDefault();
765        }
766
767        if (e.target.validity.valueMissing) {
768            setErrorMessage(e.target, validationMessages.required);
769        }
770
771        var isValidLength = e.target.value.length <= 255;
772        if (e.target.validity.patternMismatch && !isValidLength) {
773            setErrorMessage(e.target, validationMessages.maxLength);
774        }
775    };
776
777    var getValidationMessages = function (input) {
778        var container = $(input).parents('[data-sf-role="multiple-choice-field-container"]');
779        var validationMessagesInput = $(container).find('[data-sf-role="violation-messages"]');
780        var validationMessages = JSON.parse(validationMessagesInput.val());
781
782        return validationMessages;
783    };
784
785    var setErrorMessage = function (input, message) {
786        var errorMessagesContainer = _getErrorMessageContainer(input);
787
788        if (errorMessagesContainer) {
789            _toggleCustomErrorMessage(errorMessagesContainer, message);
790        } else {
791            input.setCustomValidity(message);
792        }
793    };
794
795    var _toggleCustomErrorMessage = function (container, message) {
796        container.innerText = message;
797
798        if (message === '') {
799            container.style.display = 'none';
800        } else {
801            container.style.display = 'block';
802        }
803    };
804
805    var _getErrorMessageContainer = function (input) {
806        var container = $(input).closest('[data-sf-role="multiple-choice-field-container"]')[0];
807        if (container) {
808            var errorMessagesContainer = container.querySelector('[data-sf-role="error-message"]');
809            return errorMessagesContainer;
810        }
811
812        return null;
813    };
814
815    $(function () {
816        var containers = $('[data-sf-role="multiple-choice-field-container"]');
817
818        if (!containers || containers.length < 1)
819            return;
820
821        var attachHandlers = function (input) {
822            input.on('change', function (e) {
823                changeOrInput(e);
824                if (typeof $.fn.processFormRules == 'function')
825                    $(e.target).processFormRules();
826            });
827            input.on('input', changeOrInput);
828            input.on('invalid', invalid);
829        };
830
831        var radioClickHandler = function (e) {
832            var container = $(e.target).parents('[data-sf-role="multiple-choice-field-container"]');
833            var radios = container.find('input[data-sf-role="multiple-choice-field-input"]');
834            var otherInput = $(container.find('[data-sf-multiple-choice-role="other-choice-text"]').first());
835            var otherRadio = $(container.find('[data-sf-multiple-choice-role="other-choice-radio"]').first());
836            var otherRadioIndex = radios.index(otherRadio);
837            var currentIndex = radios.index($(e.target));
838            var isRequired = $(radios).first().attr('required');
839
840            if (currentIndex == otherRadioIndex) {
841                otherInput.attr('type', 'text');
842
843                if (isRequired)
844                    otherInput.attr('required', 'required');
845
846                otherInput.attr('pattern', '.{0,255}');
847                otherInput.on('invalid', invalid);
848            }
849            else {
850                otherInput.attr('type', 'hidden');
851                otherInput.removeAttr('required');
852            }
853        };
854
855        var inputChangeHandler = function (e) {
856            var container = $(e.target).parents('[data-sf-role="multiple-choice-field-container"]');
857            var otherRadio = $(container.find('[data-sf-multiple-choice-role="other-choice-radio"]').first());
858            otherRadio.val($(e.target).val());
859        };
860
861        for (var i = 0; i < containers.length; i++) {
862            var container = $(containers[i]);
863            var inputs = container.find('[data-sf-role="multiple-choice-field-input"]');
864
865            attachHandlers(inputs);
866
867            var radios = container.find('input[data-sf-role="multiple-choice-field-input"]');
868
869            var otherInput = $(container.find('[data-sf-multiple-choice-role="other-choice-text"]').first());
870
871            radios.click(radioClickHandler);
872            otherInput.change(inputChangeHandler);
873        }
874    });
875}(jQuery));
876//navigation-field.js
877; (function ($) {
878    if (typeof window.FormData === 'undefined')
879        return;
880
881    $(function () {
882        var formContainers = $('[data-sf-role="form-container"]');
883
884        var initializeFormContainer = function (element) {
885            var formElement = $(element);
886            var formStepsContainers = formElement.find('[data-sf-role="separator"]');
887            var navigationFieldContainers = formElement.find('[data-sf-role="navigation-field-container"]');
888            var srProgressbar = formElement.find('[data-sf-role="sr-progressbar"]');
889
890            // Selects element with class sf-sr-only and adds text: Step # of #
891            var modifySrOnlyData = function (currentPage, totalPages, pageTitle) {
892                // TODO: Accessibility is not implemented no logic is required
893                if (srProgressbar.length <= 0) {
894                    return;
895                }
896
897                var stepOfResource = $(element).find('[data-sf-role="step-of-resources"]').val();
898                var valueText = stepOfResource.replace("{0}", currentPage).replace("{1}", totalPages) + ": " + pageTitle;
899                srProgressbar.attr("aria-valuenow", currentPage);
900                srProgressbar.attr("aria-valueText", valueText);
901            };
902
903            var updateNavigationFields = function (navigationElements, index) {
904
905                navigationElements.each(function (navIndex, navigationElement) {
906                    var navElement = $(navigationElement);
907                    var pages = $(navigationElement).find('[data-sf-navigation-index]');
908                    var numberOfAllSteps = formStepsContainers.length;
909                    var progressInPercent = Math.round((index / numberOfAllSteps) * 100);
910
911                    var progressBar = formElement.find('[data-sf-role="progress-bar"]');
912                    var progressPercent = formElement.find('[data-sf-role="progress-percent"]');
913
914                    if (progressBar && progressBar.length > 0) {
915                        progressBar.width(progressInPercent + '%');
916                    }
917
918                    if (progressPercent && progressPercent.length > 0) {
919                        progressPercent.text(progressInPercent + '%');
920                    }
921
922                    if (pages && pages.length > 0) {
923                        pages.each(function (i, page) {
924                            var pageIndex = parseInt($(page).data("sfNavigationIndex"));
925                            var pageTitleWrp = $(page).find('[data-sf-page-title]');
926                            var pageTitle = "";
927
928                            var activeCssClass = $(navElement).attr("data-sf-active-css-class") || "active";
929                            var pastCssClass = $(navElement).attr("data-sf-past-css-class") || "past";
930                            var futureCssClass = $(navElement).attr("data-sf-future-css-class") || "future";
931
932                            var pastIndicatorPast = $(page).find("[data-sf-progress-indicator='past']");
933                            var pastIndicatorIncomplete = $(page).find("[data-sf-progress-indicator='incomplete']");
934
935                            // TODO: Accessibility is implemented
936                            if (pageTitleWrp.length > 0) {
937                                pageTitle = $(pageTitleWrp).data("sfPageTitle");
938                            }
939                            $(page).removeClass(activeCssClass).removeClass(futureCssClass).removeClass(pastCssClass);
940
941                            if (pageIndex !== index) {
942                                if (pageIndex < index) {
943                                    $(page).addClass(pastCssClass);
944                                    $(pastIndicatorPast).show();
945                                    $(pastIndicatorIncomplete).hide();
946                                } else if (pageIndex > index) {
947                                    $(page).addClass(futureCssClass);
948                                    $(pastIndicatorPast).hide();
949                                    $(pastIndicatorIncomplete).show();
950                                }
951                            } else {
952                                $(page).addClass(activeCssClass);
953                                $(pastIndicatorPast).hide();
954                                $(pastIndicatorIncomplete).show();
955
956                                // Because pageIndex starts from 0 we increase it by 1 so it is simple to read
957                                var currentPage = ++pageIndex;
958                                modifySrOnlyData(currentPage, pages.length, pageTitle);
959                            }
960                        });
961                    }
962
963                });
964            };
965
966            // Initialize navigation fields
967            updateNavigationFields(navigationFieldContainers, 0);
968
969            formElement.on("form-page-changed", function (e, index, previousIndex) {
970                updateNavigationFields(navigationFieldContainers, index);
971            });
972        };
973
974
975        formContainers.each(function (i, element) {
976            initializeFormContainer(element);
977        });
978
979        // This implementation is only for the Form preview mode 
980        var isPreviewMode = window.location.href.indexOf("/Preview") !== -1;
981        if (formContainers.length === 0 && isPreviewMode) {
982            var separator = $('[data-sf-role="separator"]');
983            if (separator.length > 0) {
984                initializeFormContainer(separator.parent());
985            }
986        }
987    });
988})(jQuery);
989//page-break.js
990; (function ($) {
991    if (typeof window.FormData === 'undefined')
992        return;
993
994    $(function () {
995        var selectors = {
996            separator: '[data-sf-role="separator"]',
997            formContainer: '[data-sf-role="form-container"]',
998            previousButton: '[data-sf-btn-role="prev"]',
999            nextButton: '[data-sf-btn-role="next"]'
1000        };
1001        var formContainers = $(selectors.formContainer);
1002
1003        var initializeFormContainer = function (element) {
1004            var formElement = $(element);
1005            var formStepsContainers = formElement.find(selectors.separator);
1006            var formStepIndex = 0;
1007            var skipToPageCollection = [];
1008            var submitButton = null;
1009            var isSubmitButtonAdded = false;
1010            var stepNewForm = null;
1011
1012            formElement.on("form-page-changed", function (e, index, previousIndex) {
1013                formStepIndex = index;
1014            });
1015
1016            formElement.on("form-page-skip", function (e, skipToPageList) {
1017                skipToPageCollection = skipToPageList;
1018            });
1019
1020            formStepsContainers.each(function (i, element) {
1021                $(element).hide();
1022            });
1023
1024            formStepsContainers.first().show();
1025            formStepsContainers.first().find(selectors.previousButton).hide();
1026            formStepsContainers.last().find(selectors.nextButton).hide();
1027
1028            var tryGoToNextStep = function (currentStepContainer, continueFunction) {
1029                var formContainer = $(currentStepContainer);
1030                stepNewForm = $('form#stepNewForm');
1031                if (stepNewForm.length === 0) {
1032                    formContainer.wrap('<form id="stepNewForm"></form>');
1033                    stepNewForm = formContainer.parent();
1034                }
1035
1036                stepNewForm.one('submit', function (e) {
1037                    e.preventDefault();
1038                    if (e.target.innerHTML.length > 0) {
1039                        var inputs = stepNewForm.find('input');
1040                        var isValid = true;
1041                        for (var i = 0; i < inputs.length; i++) {
1042                            var jInput = $(inputs[i]);
1043                            if (typeof (jInput.data('sfvalidator')) === 'function')
1044                                isValid = jInput.data('sfvalidator')() && isValid;
1045                        }
1046
1047                        if (!isValid) {
1048                            return false;
1049                        }
1050
1051                        formContainer.unwrap();
1052
1053                        if (isSubmitButtonAdded) {
1054                            submitButton.remove();
1055                        }
1056
1057                        continueFunction();
1058                    }
1059                });
1060
1061                submitButton = formContainer.find('input#stepNewFormSubmit');
1062
1063                if (submitButton.length === 0) {
1064                    // If we do not have submit button in this step we need to add a hidden submit button in order to click it and trigger the native HTML 5
1065                    // browser validation
1066                    submitButton = $('<input id="stepNewFormSubmit" style="display:none;" type="submit"/>');
1067                    formContainer.append(submitButton);
1068                    isSubmitButtonAdded = true;
1069                }
1070
1071                submitButton.click();
1072            };
1073
1074            var getSkipToPageItem = function (pageIndex) {
1075                var item = null;
1076                for (var i = 0; i < skipToPageCollection.length; i++) {
1077                    if (skipToPageCollection[i].SkipFromPage === pageIndex) return skipToPageCollection[i];
1078                }
1079
1080                return item;
1081            };
1082
1083            var getSkipFromPageItem = function (pageIndex) {
1084                var item = null;
1085                for (var i = 0; i < skipToPageCollection.length; i++) {
1086                    if (skipToPageCollection[i].SkipToPage === pageIndex) return skipToPageCollection[i];
1087                }
1088
1089                return item;
1090            };
1091
1092            var focusForm = function () {
1093                var form = $(formElement).find("form");
1094
1095                // TODO: Accessibility is not implemented no logic is required
1096                if (form.length <= 0) {
1097                    return;
1098                }
1099
1100                form.attr("tabindex", 0);
1101                form.focus();
1102                form.removeAttr("tabindex");
1103            };
1104
1105            var separatorsNext = formStepsContainers.find(selectors.nextButton);
1106
1107            separatorsNext.click(function (e) {
1108                e.preventDefault();
1109
1110                var currentStepContainer = $(e.target).closest(selectors.separator);
1111                tryGoToNextStep(currentStepContainer, function () {
1112                    var previousIndex = formStepIndex;
1113                    currentStepContainer.hide();
1114
1115                    if (skipToPageCollection && skipToPageCollection.length > 0) {
1116                        var skipItem = getSkipToPageItem(formStepIndex);
1117                        if (skipItem) {
1118                            formStepIndex = skipItem.SkipToPage;
1119                        }
1120                        else {
1121                            formStepIndex++;
1122                        }
1123                    }
1124                    else {
1125                        formStepIndex++;
1126                    }
1127
1128                    $(formStepsContainers[formStepIndex]).show();
1129                    formElement.trigger("form-page-changed", [formStepIndex, previousIndex]);
1130                    focusForm();
1131                });
1132            });
1133
1134            var separatorsPrev = formStepsContainers.find(selectors.previousButton);
1135            separatorsPrev.click(function (e) {
1136                e.preventDefault();
1137
1138                var previousIndex = formStepIndex;
1139                var stepNewForm = $('form#stepNewForm');
1140                var currentContainer = $(e.target).closest(selectors.separator);
1141                if (stepNewForm.children(selectors.separator).length > 0) {
1142                    currentContainer.unwrap();
1143                }
1144
1145                currentContainer.hide();
1146
1147                if (skipToPageCollection && skipToPageCollection.length > 0) {
1148                    var skipItem = getSkipFromPageItem(formStepIndex);
1149                    if (skipItem) {
1150                        formStepIndex = skipItem.SkipFromPage;
1151                    }
1152                    else {
1153                        formStepIndex--;
1154                    }
1155                }
1156                else {
1157                    formStepIndex--;
1158                }
1159
1160                $(formStepsContainers[formStepIndex]).show();
1161                formElement.trigger("form-page-changed", [formStepIndex, previousIndex]);
1162                focusForm();
1163            });
1164        };
1165
1166        formContainers.each(function (i, element) {
1167            initializeFormContainer(element);
1168        });
1169
1170        // This implementation is only for the Form preview mode 
1171        var isPreviewMode = window.location.href.indexOf("/Preview") !== -1;
1172        if (formContainers.length === 0 && isPreviewMode) {
1173            var separator = $(selectors.separator);
1174            if (separator.length > 0) {
1175                initializeFormContainer(separator.parent());
1176            }
1177        }
1178    });
1179})(jQuery);
1180//paragraph-text-field.js
1181(function ($) {
1182    $(function () {
1183
1184        function processRules(e) {
1185            if (typeof $.fn.processFormRules === 'function') {
1186                $(e.target).processFormRules();
1187            }
1188        }
1189
1190        var delayTimer;
1191        function processRulesWithDelay(e) {
1192            clearTimeout(delayTimer);
1193            delayTimer = setTimeout(function () {
1194                processRules(e);
1195            }, 300);
1196        }
1197
1198        function handleValidation(e) {
1199            if (typeof e.target.validity === 'undefined')
1200                return;
1201
1202            var validationMessages = getValidationMessages(e.target);
1203
1204            if (e.target.required && e.target.validity.valueMissing) {
1205                setErrorMessage(e.target, validationMessages.required);
1206            }
1207            else if (e.target.validity.tooShort || e.target.validity.tooLong) {
1208                setErrorMessage(e.target, validationMessages.maxLength);
1209            }
1210            else {
1211                setErrorMessage(e.target, '');
1212            }
1213        }
1214
1215        function onChange(e) {
1216            handleValidation(e);
1217            processRules(e);
1218        }
1219
1220        function onInput(e) {
1221            handleValidation(e);
1222            processRulesWithDelay(e);
1223        }
1224
1225        function invalid(e) {
1226            if (typeof e.target.validity === 'undefined')
1227                return;
1228
1229            if (_getErrorMessageContainer(e.target)) {
1230                e.preventDefault();
1231            }
1232
1233            var validationMessages = getValidationMessages(e.target);
1234
1235            if (e.target.validity.valueMissing) {
1236                setErrorMessage(e.target, validationMessages.required);
1237            }
1238            else if (e.target.validity.tooShort || e.target.validity.tooLong) {
1239                setErrorMessage(e.target, validationMessages.maxLength);
1240            }
1241            else if (e.target.validity.patternMismatch) {
1242                setErrorMessage(e.target, validationMessages.maxLength);
1243            }
1244        }
1245
1246        function getValidationMessages(input) {
1247            var container = $(input).parents('[data-sf-role="paragraph-text-field-container"]');
1248            var validationMessagesInput = $(container).find('[data-sf-role="violation-messages"]');
1249            var validationMessages = JSON.parse(validationMessagesInput.val());
1250
1251            return validationMessages;
1252        }
1253
1254        function setErrorMessage(input, message) {
1255            var errorMessagesContainer = _getErrorMessageContainer(input);
1256
1257            if (errorMessagesContainer) {
1258                _toggleCustomErrorMessage(errorMessagesContainer, message);
1259            } else {
1260                input.setCustomValidity(message);
1261            }
1262        }
1263
1264        function _toggleCustomErrorMessage(container, message) {
1265            container.innerText = message;
1266
1267            if (message === '') {
1268                container.style.display = 'none';
1269            } else {
1270                container.style.display = 'block';
1271            }
1272        }
1273
1274        function _getErrorMessageContainer(input) {
1275            var container = $(input).closest('[data-sf-role="paragraph-text-field-container"]')[0];
1276            if (container) {
1277                var errorMessagesContainer = container.querySelector('[data-sf-role="error-message"]');
1278                return errorMessagesContainer;
1279            }
1280
1281            return null;
1282        }
1283
1284        function init() {
1285            var containers = $('[data-sf-role="paragraph-text-field-container"]');
1286
1287            if (!containers || containers.length < 1)
1288                return;
1289
1290            for (var i = 0; i < containers.length; i++) {
1291                var textarea = $(containers[i]).find('[data-sf-role="paragraph-text-field-textarea"]');
1292
1293                if (textarea) {
1294                    textarea.on('change', onChange);
1295                    textarea.on('input', onInput);
1296                    textarea.on('invalid', invalid);
1297                }
1298            }
1299        }
1300
1301        init();
1302    });
1303}(jQuery));
1304//submit-button.js
1305(function ($) {
1306    $(function () {
1307        $('button[type="submit"]').each(function () {
1308            $(this).closest('form').submit(function (ev) {
1309                if (!ev.isDefaultPrevented()) {
1310                    var button = $(this).find('button[type="submit"]');
1311
1312                    // If the submit button is not visible and there is a page break button next that is visible 
1313                    // we asume that we are in case with multi step form, where the enter button is hit and the form is submited, 
1314                    // so that we need to click next instead of submitting the form.
1315                    var isSubmitButtonVisible = $(button).is(":visible");
1316                    var firstPageBreak = $(ev.target).find('[data-sf-btn-role="next"]:visible')[0];
1317                    if (!isSubmitButtonVisible && firstPageBreak) {
1318                        firstPageBreak.click();
1319                        ev.preventDefault();
1320
1321                        return;
1322                    }
1323
1324                    button.prop('disabled', true);
1325
1326                    //we need first to validate all inputs which require server side validation (cannot be validated client-side)
1327                    //before the form is submitted and submit the form only if all are valid - e.g. captcha is such control
1328                    var allInputs = ev.target.querySelectorAll('input, textarea', 'select');
1329                    var widgetValidators = [];
1330
1331                    for (var i = 0; i < allInputs.length; i++) {
1332                        if ($(allInputs[i]).data('widget-validator')) {
1333                            widgetValidators.push($(allInputs[i]).data('widget-validator'));
1334                        }
1335                    }
1336
1337                    if (widgetValidators.length) {
1338                        ev.preventDefault();
1339                        var deferreds = [];
1340                        for (i = 0; i < widgetValidators.length; i++) {
1341                            deferreds.push(widgetValidators[i]());
1342                        }
1343
1344                        $.when.apply($, deferreds).done(function () {
1345                            for (var i = 0; i < widgetValidators.length; i++) {
1346                                if (!arguments[i]) {
1347                                    return false;
1348                                }
1349                            }
1350
1351                            if (ev.target.checkValidity()) {
1352                                ev.target.submit();
1353                            }
1354                        }).always(function () {
1355                            button.prop('disabled', false);
1356                        });
1357                    }
1358                }
1359            });
1360        });
1361    });
1362}(jQuery));
1363//text-field.js
1364(function ($) {
1365    $(function () {
1366
1367        function processRules(e) {
1368            if (typeof $.fn.processFormRules === 'function') {
1369                $(e.target).processFormRules();
1370            }
1371        }
1372
1373        var delayTimer;
1374        function processRulesWithDelay(e) {
1375            clearTimeout(delayTimer);
1376            delayTimer = setTimeout(function () {
1377                processRules(e);
1378            }, 300);
1379        }
1380
1381        function handleValidation(e) {
1382            if (typeof e.target.validity === 'undefined')
1383                return;
1384
1385            if (e.target.required && e.target.validity.valueMissing) {
1386                var validationMessages = getValidationMessages(e.target);
1387                setErrorMessage(e.target, validationMessages.required);
1388            } else {
1389                setErrorMessage(e.target, '');
1390            }
1391        }
1392
1393        function onChange(e) {
1394            handleValidation(e);
1395            processRules(e);
1396        }
1397
1398        function onInput(e) {
1399            handleValidation(e);
1400            processRulesWithDelay(e);
1401        }
1402
1403        function invalid(e) {
1404            if (typeof e.target.validity === 'undefined')
1405                return;
1406
1407            if (_getErrorMessageContainer(e.target)) {
1408                e.preventDefault();
1409            }
1410
1411            var validationMessages = getValidationMessages(e.target);
1412            var validationRestrictions = getValidationRestrictions(e.target);
1413            var isValidLength = e.target.value.length >= validationRestrictions.minLength;
1414
1415            if (validationRestrictions.maxLength > 0)
1416                isValidLength &= e.target.value.length <= validationRestrictions.maxLength;
1417
1418            if (e.target.validity.valueMissing) {
1419                setErrorMessage(e.target, validationMessages.required);
1420            }
1421            else if (e.target.validity.patternMismatch && !isValidLength) {
1422                setErrorMessage(e.target, validationMessages.maxLength);
1423            }
1424            else if (e.target.validity.patternMismatch && isValidLength) {
1425                setErrorMessage(e.target, validationMessages.regularExpression);
1426            }
1427            else if (!e.target.validity.valid) {
1428                setErrorMessage(e.target, validationMessages.invalid);
1429            }
1430        }
1431
1432        function getValidationMessages(input) {
1433            var container = $(input).parents('[data-sf-role="text-field-container"]');
1434            var validationMessagesInput = $(container).find('[data-sf-role="violation-messages"]');
1435            var validationMessages = JSON.parse(validationMessagesInput.val());
1436
1437            return validationMessages;
1438        }
1439
1440        function getValidationRestrictions(input) {
1441            var container = $(input).parents('[data-sf-role="text-field-container"]');
1442            var validationRestrictionsInput = $(container).find('[data-sf-role="violation-restrictions"]');
1443            var validationRestrictions = JSON.parse(validationRestrictionsInput.val());
1444
1445            return validationRestrictions;
1446        }
1447
1448        function setErrorMessage(input, message) {
1449            var errorMessagesContainer = _getErrorMessageContainer(input);
1450
1451            if (errorMessagesContainer) {
1452                _toggleCustomErrorMessage(errorMessagesContainer, message);
1453            } else {
1454                input.setCustomValidity(message);
1455            }
1456        }
1457
1458        function _toggleCustomErrorMessage(container, message) {
1459            container.innerText = message;
1460
1461            if (message === '') {
1462                container.style.display = 'none';
1463            } else {
1464                container.style.display = 'block';
1465            }
1466        }
1467
1468        function _getErrorMessageContainer(input) {
1469            var container = $(input).closest('[data-sf-role="text-field-container"]')[0];
1470            if (container) {
1471                var errorMessagesContainer = container.querySelector('[data-sf-role="error-message"]');
1472                return errorMessagesContainer;
1473            }
1474
1475            return null;
1476        }
1477
1478        function init() {
1479            var containers = $('[data-sf-role="text-field-container"]');
1480
1481            if (!containers || containers.length < 1)
1482                return;
1483
1484            for (var i = 0; i < containers.length; i++) {
1485                var input = $(containers[i]).find('[data-sf-role="text-field-input"]');
1486
1487                if (input) {
1488                    input.on('change', onChange);
1489                    input.on('input', onInput);
1490                    input.on('invalid', invalid);
1491                }
1492            }
1493        }
1494
1495        init();
1496    });
1497}(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.