PageSourceSearch

https://sirius-remont.ru/modules/mod_jc_quizz_gavrilin_v2/css/quiz.js?v=1.002

js sirius-remont.ru collected 2026-10-04 09:37:16 UTC 13,886 bytes, 364 lines download raw bytes

1$(function () {
2    /*скрываю блок квиза
3     $("#quiz").parent('.moduletable').attr('style', $("#quiz").data('parent'));*/
4    progressBar(1);
5    csscol(1);
6    var countStep = eachStep();
7
8    /*закрыть попуп уходящего окна*/
9    $(".bottom_format_text").on("click", function () {
10        $('.arcticmodal-overlay').remove();
11        $('.arcticmodal-container').remove();
12    });
13
14    /*открыть openQuizz*/
15    $(".openQuizz").on("click", function () {
16        $('.arcticmodal-overlay').hide();
17        $('.arcticmodal-container').hide();
18//        $('#header').remove();
19//        $('#customElement').hide();
20//        $('#preimushestva').remove();
21
22        $("#quiz").parent('.blokQwizz').attr("style", "display:blok ;position: absolute;top: 0;left: 0;z-index: 6000;width: 100%;");
23        $("#quiz").show();
24
25    });
26
27
28
29    // установливаем обработчик события resize
30    $(window).resize(function () {
31//        var ishod = $('.ishod img').width();//размер фото
32//        alert(ishod);
33        //    alert($( window ).width());
34        ///$( "#width" ).text( $( window ).width() );
35        var w_mobile = '';
36        if ($(window).width() < 980) {
37            var newH = $(window).height();
38            w_mobile = 320;
39        } else {
40            var newH = $(window).height() / 2;//+ ($(window).height() * 40) / 100;
41        }
42        /*
43         * берем даныне по фоновой фото
44         */
45        $("#quiz").css('backgroundImage', 'url(' + $("#quiz").data("bg") + w_mobile + '.jpg)');
46        //  alert($("#quiz").data("bg"));
47
48        $("#quiz").css('min-height', newH);
49        // $('h1').text(newH);
50        //  $("#quiz .goquiz ").text(newH);
51    });
52
53// вызовем событие resize
54    $(window).resize();
55    resizeBloki();
56//запустить квиз
57    $(".goquiz").on("click", function () {
58        $('#step_1').show();
59        $('.wellcome-screen').hide();
60        $("#quiz").css('padding-bottom', '4%');
61    });
62//отправить данные
63    $("#quiz .quiz-subject").on("click", function () {
64        var then = $(this).data('then');
65        console.log('отправить данные #step_' + then);
66        var flag = formValid2('#quiz  #step_' + then);
67        if (flag == 0) {
68            var data = {}; //родительский массив
69            $("#quiz .step").each(function () {
70                var $self = $(this);
71                var step = $(this).attr('id');
72                var steptitle = $('#' + step + ' .step-title').text().trim();
73                console.log("console->" + steptitle + ':');
74                data[step] = [steptitle]; //родительский массив
75
76                $('#' + step + ' input[type="checkbox"]:checked').each(function () {
77                    console.log(this.value);
78                    data[step].push(this.value);
79                });
80                /*инпуты*/
81                $('#' + step + ' input[type="text"]').each(function () {
82                    console.log(this.value);
83                    data[step].push(this.value);
84                });
85                /*radio*/
86                $('#' + step + ' input[type="radio"]:checked').each(function () {
87                    console.log(this.value);
88                    data[step].push(this.value);
89                });
90
91            });
92            send(data);
93        } else {
94            $('#step_' + then + ' .errorBlok').text('Выберите или заполните подходящий ответ!');
95        }
96    });
97
98    $("#quiz .quiz-next").on("click", function () {
99        quizStep('next', $(this).data('prev'), $(this).data('then'), $(this).data('next'));
100
101    });
102    $("#quiz .quiz-prev").on("click", function () {
103        quizStep('prev', $(this).data('prev'), $(this).data('then'), $(this).data('next'));
104    });
105    /*
106     * закрыть квиз по весь экран
107     */
108    $('#closeQuiz').on("click", function () {
109        $('#quizOpen').removeClass('quizOpenFix');
110        $('#closeQuiz').hide();
111
112    });
113    function quizStep(actions, prev, then, next) {
114        $(window).resize();
115        $("html, body").animate({scrollTop: $('#quiz').offset().top + "px"});//прокрутка к верху квеста
116        if (actions == 'next') {
117            // resizeBlok('#step_' + next);
118            var flag = formValid2('#quiz  #step_' + then);
119            //   alert(flag);
120            //  $('#step_' + then + ' .step-title').text(flag);
121            if (flag == 0) {
122                if (then == 1) {
123                    $('#quiz .big-background-container').hide();
124                    $('#quiz .h1').hide();
125                    $('#quiz .step-title').addClass('h2');
126                    //$('#quizOpen').addClass('quizOpenFix');
127                    //  $('#closeQuiz').show();
128                }
129                if (then == (countStep - 1)) {//на поледнем вопросе
130                    $('#quiz .h1').attr('data-text', $('#quiz .h1').text());
131                    $('#quiz .h1').show().text('Остался последний шаг!');
132                    // $('#quiz #step_'+countStep).css({'max-width': '650px'});
133                }
134                $('#step_' + next).show();
135                $('#step_' + next).addClass('active');
136                $('#step_' + then).hide();
137            } else {
138                $('#step_' + then + ' .errorBlok').text('Выберите или заполните подходящий ответ!');
139            }
140            progressBar(next);
141            csscol(next);
142        } else if (actions == 'prev') {
143            if (then == 2) {
144                $('#quiz .big-background-container').show();
145                $('#quiz .h1').show();
146                $('#quiz .step-title').removeClass('h2');
147                // $('#quizOpen').removeClass('quizOpenFix');
148                // $('#closeQuiz').hide();
149            }
150            //    alert(then +'==' +countStep);
151            if (then == countStep) {//на поледнем вопросе
152                $('#quiz .h1').text($('#quiz .h1').data('text'));
153                $('#quiz .h1').hide();
154                // $('#quiz #step_'+countStep).css({'max-width': '650px'});
155
156            }
157
158
159
160            $('#step_' + then).removeClass('active');
161            $('#step_' + prev).show();
162            //resizeBlok('#step_' + prev);
163            $('#step_' + prev).addClass('active');
164            $('#step_' + then).hide();
165            progressBar(prev);
166            csscol(prev);
167        }
168    }
169    /*
170     * 
171     * @param {type} elem
172     * @returns {Number}
173     * НЕ РАБЬОАТЕТ ПОККА ЧТО
174     */
175    function  formValid(elem) {
176        var value = $(elem + ' #phone_elem').val();
177        $(elem + ' #phone_elem').removeClass('redErrorBolder');
178        $(elem + ' .errorBlok').html('');
179        if (value == '') {
180            $(elem + ' #phone_elem').addClass('redErrorBolder');
181            $(elem + ' .errorBlok').html('Пожалуйста заполните необходимые поля для связи с вами!');
182            return 1;
183        } else {
184            return 0;
185        }
186    }
187    /*
188     * 
189     * @returns {Number} валидация телефона
190     * Этот рабочий
191     */
192    function  formValid2(elem) {
193        var flag = 0;
194        var arr = []; //родительский массив
195        $(elem + ' input[type="checkbox"]:checked').each(function () {
196            console.log(this.value);
197            // alert('checkbox ' + this.value);
198            arr.push(this.value);
199        });
200
201        /*инпуты*/
202        $(elem + ' input[type="text"]').each(function () {
203            console.log('input^ ' + this.value + ' control:' + $(this).data('control') + 'length: ' + this.value.length);
204            //  alert('input ' + this.value);
205            //    alert($(this).attr('id'));//phone_elem
206            //  alert($(this).data('control'));
207
208            if ($(this).data('control') == 1) {
209
210                if (this.value.length != 0) {
211                    arr.push(this.value);
212                } else {
213                    if (arr.length == 0) {
214                        $(this).addClass('errorElem');
215                    } else {
216                        $(this).removeClass('errorElem');
217                    }
218                }
219
220            } else {
221                if (this.value.length != 0) {
222                    arr.push(this.value);
223                }
224            }
225
226        });
227        /*radio*/
228        $(elem + ' input[type="radio"]:checked').each(function () {
229            console.log(this.value);
230            //   alert('radio ' + this.value);
231            arr.push(this.value);
232        });
233
234        if (arr.length == 0) {
235            //  alert(elem + ' Массив dataFull пустой');
236            flag = 1;
237        } else {
238            //   alert(elem + ' В массиве dataFull что-то есть ' + arr.length);
239            flag = 0;
240        }
241        return flag;
242    }
243
244
245
246
247
248
249
250    /*выбираем блоки ответов*/
251    $(".form-field-image-item").on("click", function (e) {
252        var t = $(e.currentTarget).find("input");
253        t[0].checked = !t[0].checked;
254    });
255    $(".form-field-radio-item").on("click", function (r) {
256        // $(this).hide();
257        var t = $(r.currentTarget).find("radio");
258        t[0].checked = !t[0].checked;
259    });
260    /*кнопка заказа звонка*/
261    //   $('#submit_tel').on("click", function () {
262    function send(ar, elemFinish) {
263        var blok_titlepage = $('#quiz .blok_titlepage').val(); 
264        var blok_linkpage = $('#quiz .blok_linkpage').val();
265        var flag = formValid();
266        if (flag == 0) {
267            var url = '/modules/mod_jc_quizz_gavrilin_v2/send.php';
268            $.post(
269                    url,
270                    {
271                        ar: ar,
272                        titlepage: blok_titlepage,
273                        linkpage: blok_linkpage
274
275                    },
276                    function (result) {
277                        if (result.error == 0) {
278                            //   $('#modal .text').html('<span>' + result.info + '</span><div class="blok"><p>и ответим на все ваши вопросы!</p></div>').attr('style', ' margin: 24% auto;');
279                            $('#' + result.elemFinish).html('<div class="title-1 text-style-title-main" style="font-size: 4rem;">СПАСИБО ЗА ОТВЕТЫ!</div>  <div class="btn-note"><p>Наши менеджеры с вами свяжется в ближайшее время!</p></div>').attr('style', ' margin: 14% auto;');
280							ym(93333600,'reachGoal','ZAKAZ_QVIZ');
281                            setTimeout(function () {
282                                Redirect(document.location.href);
283                            }, 2000);
284                        } else {
285                            $('#modal .text .blok p').text(result.info).attr('style', ' color:red;');
286                        }
287                    },
288                    "json"
289                    );
290        }
291    }
292
293    function Redirect(realurl) {
294        setTimeout('location.replace("' + realurl + '")', 500);
295        $('title').after('<meta http-equiv="refresh" content="1; url=' + realurl + '">');
296    }
297
298    /*
299     * 
300     * @param {type} step
301     * @returns {undefined}
302     */
303    function  csscol(step) {
304        // alert('#step_' + step + ' .form-field-image-item');
305        var arr = []; //родительский массив
306        $('#step_' + step + ' .form-field-image-item').each(function () {
307            arr.push(this.value);
308        });
309        //alert('.form-field-image-item ' + arr.length);
310        if (arr.length >= 8) {
311            $('#step_' + step + ' .form-field-image-item').each(function () {
312                //  $(this).addClass('col-lg-2 col-md-2');
313
314            });
315        }
316
317    }
318    /*
319     * расчет прогресс бара
320     * @param {type} elem
321     * @returns {Number}
322     */
323    function  progressBar(step) {
324        // console.log('step ' + step);
325        var proc = 100;
326        var countquiz = $("#quiz").data('countquiz');//всего вопросов
327        //   console.log('countquiz ' + countquiz);
328        if (step == countquiz) {
329            //   step = step - 1;
330        }
331        // if (step == 0) {
332        // step = step + 1;
333        //   }
334        var chast = 100 / countquiz * (countquiz - step);
335        console.log('countquiz ' + chast);
336        $('#quiz-progress .progress-text span.current').text(step);
337        $('#quiz-progress  .progress-text span.total').text(countquiz);
338        $('#quizPoligon circle.current').attr("stroke-dashoffset", chast);
339    }
340
341    /*колчиество вопросов*/
342    function eachStep() {
343        var arr = []; //родительский массив
344        $('#quiz .step').each(function (index, value) {
345            // действия, которые будут выполняться для каждого элемента массива
346            // index - это текущий индекс элемента массива (число)
347            // value - это значение текущего элемента массива
348            //выведем индекс и значение массива в консоль
349            // console.log('Индекс: ' + index + '; Значение: ' + value);
350            arr.push(this.index);
351        });
352        return arr.length;
353    }
354    /*колчиество вопросов*/
355    function resizeBloki() {
356        var column = 0;
357        $('#quizPoligon .form-field-image-text').each(function () {
358            h = $(this).height();
359            if (h > column) {
360                column = h;
361            }
362        }).height(column);
363    }
364});

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.