PageSourceSearch

https://knowledgecheckr.at/tmp/assets/97cb283d/template-core.js

js knowledgecheckr.at collected 2026-10-06 07:59:35 UTC 8,566 bytes, 186 lines download raw bytes

1/**
2 * @file Default template functionnality
3 * @copyright LimeSurvey <http://www.limesurvey.org>
4 * @license magnet:?xt=urn:btih:1f739d935676111cfff4b4693e3816e664797050&dn=gpl-3.0.txt GPL-v3-or-Later
5 */
6
7var TemplateCoreClass = function () {
8    return {
9        /**
10         * Dialog and confirm
11         */
12        /* showStartPopups : replace core function : allow HTML and use it. Unusuable with ajax */
13        showStartPopups: function () {
14            if (LSvar.showpopup == 1  && $.isArray(LSvar.startPopups)) {
15                startPopups = LSvar.startPopups.map( function (text) {
16                    return "<p>"+text+"</p>";
17                });
18                window.templateCore.alertSurveyDialog(startPopups.join(""));
19            }
20        },
21        /* alertSurveyDialog @see application/core/package/limesurvey
22         * @var string[] startPopups array of text to be shown
23         * @var string title
24         */
25        alertSurveyDialog: function (startPopups, title) {
26            text = "";
27            if (LSvar.showpopup == 1  && $.isArray(startPopups)) {
28                startPopups = startPopups.map(function (text) {
29                    return "<p>"+text+"</p>";
30                });
31                text = startPopups.join("");
32            }
33            if (text) {
34                $("#bootstrap-alert-box-modal .modal-header .modal-title").text(title || "");
35                $("#bootstrap-alert-box-modal .modal-body").html(text);
36                $("#bootstrap-alert-box-modal").modal('show');
37            }
38        },
39        /* confirmSurveyDialog @see application/core/package/limesurvey */
40        confirmSurveyDialog: function (text, title, submits) {
41            $("#bootstrap-alert-box-modal .modal-header .modal-title").text(title);
42            $("#bootstrap-alert-box-modal .modal-body").html("<p>" + text + "</p>" + "<div class='btn-group btn-group-justified' role='group'><a class='btn btn-warning btn-confirm' data-dismiss='modal'>" + LSvar.lang.yes + "</a><a class='btn btn-default btn-cancel' data-dismiss='modal'>" + LSvar.lang.no + "</a></div>");
43            $("#bootstrap-alert-box-modal").modal('show');
44            $("#bootstrap-alert-box-modal .btn-confirm").on('click', function () {
45                $.each(submits, function (name, value) {
46                    $("<input/>", {
47                        'type': "hidden",
48                        'name': name,
49                        'value': value,
50                    }).appendTo('form#limesurvey');
51                });
52                $('form#limesurvey').submit();
53            });
54        },
55
56        /**
57         * Add class hover to column in table-col-hover
58         * We can't use CSS solution : need no background
59         */
60        addHoverColumn: function () {
61            $(".table-col-hover").on({
62                mouseenter: function () {
63                    $(this).closest(".table-col-hover").find("col").eq($(this).parent(".answers-list").children().index($(this))).addClass("hover");
64                },
65                mouseleave: function () {
66                    $(this).closest(".table-col-hover").find("col").removeClass("hover");
67                }
68            }, ".answer-item");
69        },
70
71        /**
72         * Update some class when em-tips is success/error
73         * @see core/package/limesurvey/survey.js:triggerEmClassChange
74         */
75        triggerEmClassChangeTemplate: function () {
76            $('.ls-em-tip').each(function () {
77                $(this).on('classChangeError', function () {
78                    /* If user choose hide-tip : leave it */
79                    $parent = $(this).parent('div.hide-tip');
80                    if ($parent.hasClass('hide-tip')) {
81                        $parent.removeClass('hide-tip', 1);
82                        $parent.addClass('tip-was-hidden', 1);
83                    }
84                    var questionContainer = $(this).parents('div.question-container');
85                    window.templateCore.updateQuestionClassFromTips(questionContainer);
86                });
87
88                $(this).on('classChangeGood', function () {
89                    /* If user choose hide-tip : leave it */
90                    $parent = $(this).parents('div.hide-tip');
91                    $parent.removeClass('text-danger');
92                    $parent.addClass('text-info');
93                    if ($parent.hasClass('tip-was-hidden')) {
94                        $parent.removeClass('tip-was-hidden').addClass('hide-tip');
95                    }
96                    var questionContainer = $(this).parents('div.question-container');
97                    window.templateCore.updateQuestionClassFromTips(questionContainer);
98                });
99            });
100        },
101        /**
102         * Set error class on question container depending on validation tips status.
103         * 
104         * If any tip is marked as error (has 'text-danger' class), 'input-error' is added to
105         * the question container. Otherwise, 'input-error' is removed from the question container.
106         * 
107         * @param {Element} questionContainer 
108         */
109        updateQuestionClassFromTips: function(questionContainer) {
110            if (questionContainer.find('.question-valid-container .text-danger').length == 0) {
111                questionContainer.removeClass('input-error');
112            } else {
113                questionContainer.addClass('input-error');
114            }
115        },
116        /**
117         * Hide/show question if all sub-questions is hidden
118         * @see core/package/limesurvey/survey.js:triggerEmRelevanceSubQuestion
119         * @see https://bugs.limesurvey.org/view.php?id=10055 (partial)
120         * Must be before ready (event happen before ready)
121         */
122        hideQuestionWithRelevanceSubQuestion: function () {
123            $(".question-container:not(.ls-irrelevant)").on('relevance:on', "[id^='javatbd']", function (event, data) {
124                if (event.target != this) return; // not needed now, but after (2016-11-07)
125                data = $.extend({
126                    style: 'hidden'
127                }, data);
128                if (data.style == 'hidden') {
129                    $(this).closest(".question-container").removeClass("ls-hidden");
130                }
131            });
132            $(".question-container:not(.ls-hidden)").on('relevance:off', "[id^='javatbd']", function (event, data) {
133                if (event.target != this) return; // not needed now, but after (2016-11-07)
134                data = $.extend({
135                    style: 'hidden'
136                }, data);
137                if (data.style == 'hidden') {
138                    var questionContainer = $(this).closest(".question-container");
139                    $(this).addClass("ls-hidden");
140                    if ($(questionContainer).find("[id^='javatbd']").filter(':not(.ls-hidden)').length == 0) {
141                        $(questionContainer).addClass("ls-hidden");
142                    }
143                }
144            });
145        },
146        /**
147         * Hide/show parent multiple list
148         * @see core/package/limesurvey/survey.js:triggerEmRelevanceSubQuestion
149         * @see https://bugs.limesurvey.org/view.php?id=11787
150         * Must be before ready (event happen before ready)
151         */
152        hideMultipleColumn: function () {
153            $("[id^='question']").on('relevance:on', ".multiple-list [id^='javatbd']", function (event, data) {
154                if (event.target != this) return;
155                data = $.extend({
156                    style: 'hidden'
157                }, data);
158                if (data.style == 'hidden') {
159                    $(this).closest(".list-unstyled").removeClass("ls-hidden")
160                }
161            });
162            $("[id^='question']").on('relevance:off', ".multiple-list [id^='javatbd']", function (event, data) {
163                if (event.target != this) return;
164                data = $.extend({
165                    style: 'hidden'
166                }, data);
167                if (data.style == 'hidden') {
168                    if ($(this).closest(".list-unstyled").find("[id^='javatbd']:visible").length == 0) {
169                        $(this).closest(".list-unstyled").addClass("ls-hidden");
170                    }
171                }
172            });
173        }
174    }
175};
176
177
178if (!window.templateCore) {
179    window.templateCore = new TemplateCoreClass();
180}
181
182/* document ready function */
183$(document).on('ready pjax:scriptcomplete', function () {
184    window.templateCore.addHoverColumn();
185    window.templateCore.triggerEmClassChangeTemplate();
186});

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.