PageSourceSearch

https://formatura.ru/catalog/view/javascript/jquery/multimodals/multimodals.js

js formatura.ru collected 2026-10-07 18:15:57 UTC 4,790 bytes, 147 lines download raw bytes

1var idsModalTrackTime = {};
2
3function closeAllPopups(){
4    $('.popup_content').each(function(){
5        $('#'+ $(this).attr('id') ).popup('hide');
6    })
7}
8function openWithTimeout(idModal, time, type){
9    if(typeof window.openModal === 'undefined'){
10        clearTimeout(window.openModal);
11    }
12    window.openModal = setTimeout(function(){
13        closeAllPopups();
14        $('#popup-'+type+'-'+idModal).popup('show');
15        if(type=='offer') setTimeout(function() { $('#offer-your-price').focus() }, 500);
16    }, time * 1000);
17}
18function openMouseOut(idModal, type) {
19    var openedModalStatus;
20    $(document).mouseleave(function () {
21        if (!openedModalStatus) {
22            closeAllPopups();
23            openedModalStatus = 1;
24            $('#popup-' + type + '-' + idModal).popup('show');
25            if (type == 'offer')  setTimeout(function () {
26                $('#offer-your-price').focus()
27            }, 500);
28        }
29    });
30}
31function trackTime(){
32    window.mm_track_time = getCookie('__track_time') || 0;
33    window.track_time = setInterval(function() {
34        window.mm_track_time++;
35        setCookie('__track_time', window.mm_track_time);
36    }, 1000);
37}
38
39function openWithTimeTrack(){
40
41    /** if all modals opened - clear interval **/
42    if(Object.keys(idsModalTrackTime).length === 0) {
43        clearInterval(window.intervalTrackFunc);
44        return;
45    }
46
47    var setTime = Math.floor( (new Date().getTime()/ 1000) + (7 * 86400) );
48
49    loop1:
50    for(var modal in idsModalTrackTime) {
51
52        var openTime = idsModalTrackTime[modal],
53            partsModalId = modal.split('-');
54
55        if (window.mm_track_time <= openTime) continue;
56
57        /** each cookie opened modals - add current - save **/
58        var dataToCookie = [],
59            getData = getCookie('__vmow');
60
61        if (getData) {
62            var parseCookie = decodeURIComponent(getData).split(';');
63
64            for (var i = 0; i < parseCookie.length; i++) {
65                var parts = parseCookie[i].split(',');
66                dataToCookie.push(parseCookie[i]);
67
68                if (parts[0] == partsModalId[1]) {
69                    delete idsModalTrackTime[modal];
70                    continue loop1; /** if isset - continue **/
71                }
72            }
73        }
74
75        dataToCookie.push(partsModalId[1] + ',' + setTime);
76        setCookie('__vmow', encodeURIComponent(dataToCookie.join(';')));
77
78        closeAllPopups();
79
80        $('#popup-' + modal).popup('show');
81        if (partsModalId[0] == 'offer') setTimeout(function () {
82            $('#offer-your-price').focus()
83        }, 500);
84        delete idsModalTrackTime[modal];
85    }
86}
87
88function sendFormRequest(idModal){
89
90    var $form = $('#modal-form-'+idModal),
91        data = $form.serializeArray();
92
93    data.push({name: 'url',value: encodeURIComponent(location.href)});
94
95    $form.find('.error').remove();
96    $.ajax({
97        url: 'index.php?route=module/multimodals/sendFormRequest&form='+idModal,
98        dataType: 'json',
99        type: 'post',
100        data: data,
101        success: function(res){
102            if(res.errors){
103                for(var i in res.errors){
104                    $form.find('[name="f_modal['+i+']"]').after( $('<span class="error" />').text(res.errors[i]) );
105                }
106            }
107            if(res.success){
108                $form.html(res.success);
109                setTimeout(function(){
110                    $('#popup-form-'+idModal).popup('hide');
111                },5000);
112            }
113        }
114    })
115}
116function roundNumber(num){
117    return (Math.round(parseFloat( num )*100)/100);
118}
119
120/** Wotk with cookie  **/
121function setCookie(name, value, expire){
122    var time = expire || (7 * 24 * 60 * 60); /** 1 week by default  **/
123    var date = new Date(new Date().getTime() + time * 1000);
124    document.cookie = name+"="+value+"; path=/; domain=."+location.host+"; expires="+date.toUTCString();
125}
126function getCookie(name) {
127    var value = "; " + document.cookie;
128    var parts = value.split("; " + name + "=");
129    if (parts.length == 2) return parts.pop().split(";").shift();
130}
131function deleteCookie(name) {
132    setCookie(name, "", -1);
133}
134
135$(document).ready( function(){
136    $('.btn-send-modal-form').on('click', function(e){
137        e.preventDefault();
138        sendFormRequest($(this).attr('data-id-form'));
139    });
140    $('#selected-offer-options .heading-options').on('click', function(){
141        if($(this).next().hasClass('opened')){
142            $(this).removeClass('opened').next().removeClass('opened');
143        } else {
144            $(this).addClass('opened').next().addClass('opened');
145        }
146    });
147});

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.