PageSourceSearch

https://re-vive.de/survey/tmp/assets/6ed62354/template-core.js

js re-vive.de collected 2026-10-08 19:22:51 UTC 7,981 bytes, 173 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                    $questionContainer = $(this).parents('div.question-container');
85                    $questionContainer.addClass('input-error'); /* No difference betwwen error after submit and error before submit : think (Shnoulle) it's better to have a difference */
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                    $questionContainer = $(this).parents('div.question-container');
97                    $questionContainer.removeClass('input-error'); /* Not working with mandatory question ... */
98                });
99            });
100
101
102        },
103        /**
104         * Hide/show question if all sub-questions is hidden
105         * @see core/package/limesurvey/survey.js:triggerEmRelevanceSubQuestion
106         * @see https://bugs.limesurvey.org/view.php?id=10055 (partial)
107         * Must be before ready (event happen before ready)
108         */
109        hideQuestionWithRelevanceSubQuestion: function () {
110            $(".question-container:not(.ls-irrelevant)").on('relevance:on', "[id^='javatbd']", function (event, data) {
111                if (event.target != this) return; // not needed now, but after (2016-11-07)
112                data = $.extend({
113                    style: 'hidden'
114                }, data);
115                if (data.style == 'hidden') {
116                    $(this).closest(".question-container").removeClass("ls-hidden");
117                }
118            });
119            $(".question-container:not(.ls-hidden)").on('relevance:off', "[id^='javatbd']", function (event, data) {
120                if (event.target != this) return; // not needed now, but after (2016-11-07)
121                data = $.extend({
122                    style: 'hidden'
123                }, data);
124                if (data.style == 'hidden') {
125                    var questionContainer = $(this).closest(".question-container");
126                    $(this).addClass("ls-hidden");
127                    if ($(questionContainer).find("[id^='javatbd']").filter(':not(.ls-hidden)').length == 0) {
128                        $(questionContainer).addClass("ls-hidden");
129                    }
130                }
131            });
132        },
133        /**
134         * Hide/show parent multiple list
135         * @see core/package/limesurvey/survey.js:triggerEmRelevanceSubQuestion
136         * @see https://bugs.limesurvey.org/view.php?id=11787
137         * Must be before ready (event happen before ready)
138         */
139        hideMultipleColumn: function () {
140            $("[id^='question']").on('relevance:on', ".multiple-list [id^='javatbd']", function (event, data) {
141                if (event.target != this) return;
142                data = $.extend({
143                    style: 'hidden'
144                }, data);
145                if (data.style == 'hidden') {
146                    $(this).closest(".list-unstyled").removeClass("ls-hidden")
147                }
148            });
149            $("[id^='question']").on('relevance:off', ".multiple-list [id^='javatbd']", function (event, data) {
150                if (event.target != this) return;
151                data = $.extend({
152                    style: 'hidden'
153                }, data);
154                if (data.style == 'hidden') {
155                    if ($(this).closest(".list-unstyled").find("[id^='javatbd']:visible").length == 0) {
156                        $(this).closest(".list-unstyled").addClass("ls-hidden");
157                    }
158                }
159            });
160        }
161    }
162};
163
164
165if (!window.templateCore) {
166    window.templateCore = new TemplateCoreClass();
167}
168
169/* document ready function */
170$(document).on('ready pjax:scriptcomplete', function () {
171    window.templateCore.addHoverColumn();
172    window.templateCore.triggerEmClassChangeTemplate();
173});

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.