PageSourceSearch

https://ecofamily.hu/!common_packages/jquery/own/shop_common/exploded/common_modal.js?mod_time=1789024948

js ecofamily.hu collected 2026-10-06 13:28:47 UTC 15,228 bytes, 419 lines download raw bytes

1var allow_shop_popup=true;
2var popup_open = false;
3var allow_cookie_popup = 1;
4
5/*** OVERLAY BASE ***/
6(function($) {
7    var instances = [];
8
9    function Overlay(trigger, conf) {
10        var self = this;
11        var fire = trigger.add(self);
12        var opened = false;
13        var uid = Math.random().toString().slice(10);
14
15        $.extend(self, {
16            load: function (e) {
17                e = e || $.Event();
18                e.type = "onBeforeLoad";
19                fire.trigger(e);
20                if (e.isDefaultPrevented()) { return self; }
21
22                opened = true;
23
24                if (opened) {
25                    e.type = "onLoad";
26                    fire.trigger(e);
27                }
28
29                if (conf.closeOnClick) {
30                    $(document).on("click." + uid, function(e) {
31                        if (trigger.length && trigger.hasClass('show') && $(e.target).closest('.modal').attr('id') != trigger.attr('id') && (modalCount == trigger.data('stack-level') || trigger.attr('id') == $(e.target).attr('data-id'))){
32                            self.close(e);
33                        }
34                    });
35                }
36
37                if (conf.closeOnEsc) {
38                    $(document).on("keydown." + uid, function(e) {
39                        if (e.keyCode == 27 && modalCount == trigger.data('stack-level')) {
40                            self.close(e);
41                        }
42                    });
43                }
44
45                return self;
46            },
47
48            close: function (e) {
49                e = e || $.Event();
50
51                opened = false;
52
53                e.type = "onClose";
54                fire.trigger(e);
55
56                trigger.modal('hide');
57
58                $(document).off("click." + uid + " keydown." + uid);
59            }
60        });
61
62        $.each("onBeforeLoad,onStart,onLoad,onBeforeClose,onClose".split(","), function(i, name) {
63            if ($.isFunction(conf[name])) {
64                $(self).on(name, conf[name]);
65            }
66
67            self[name] = function(fn) {
68                if (fn) { $(self).on(name, fn); }
69                return self;
70            };
71        });
72
73        if (conf.load) {
74            self.load();
75
76            const urlParams = new URLSearchParams(window.location.search);
77            const urlValue = urlParams.get('overlay');
78            if (urlValue !== '' && urlValue !== undefined && urlValue !== null) {
79                $(trigger).modal('show');
80            }
81        }
82    }
83
84    $.fn.overlay = function(conf) {
85        var el = this.data("overlay");
86        if (el) { return el; }
87
88        if ($.isFunction(conf)) {
89            conf = {onBeforeLoad: conf};
90        }
91
92        this.each(function() {
93            el = new Overlay($(this), conf);
94            instances.push(el);
95            $(this).data("overlay", el);
96        });
97
98        return conf.api ? el: this;
99    };
100
101})(jQuery);
102
103/*** SHOP POPUP BASE ***/
104(function($) {
105    let ajax = null;
106    let popup_id = null;
107
108    $.shop_popup = function (method, options) {
109        let settings = $.extend({
110            ajax_url: null,
111            ajax_data: null,
112            ajax_loader: true,
113            iframe_url: null,
114            close: true,
115            closeEsc: (config_plus['overlay_close_on_esc_forced'] === 1 ? true : null),
116            closeClick: (config_plus['overlay_close_on_click_forced'] === 1 ? true : null),
117            modal: 1
118        }, options);
119
120        popup_id = settings.popupId;
121
122        if (method === "open") {
123            /* NINCS MÉG DIV AKKOR BESZÚRJUK */
124            if ($('#modal-' + popup_id).length === 0) {
125                $('#modal-focus-trap-fix').remove();
126                $('body').append(`<div id="modal-${popup_id}" tabindex="-1" role="dialog" aria-labelledby="modal-title-${popup_id}" aria-describedby="modal-desc-${popup_id}" class="modal fade"></div><div id="modal-focus-trap-fix" tabindex="0" role="presentation" aria-hidden="true" aria-disabled="true" style="position: fixed; top: 0; left: 0; width: 0; height: 0; opacity: 0; pointer-events: none;"></div>`);
127            }
128
129            if (settings.ajax_url != null && settings.ajax_url !== 'no') {
130                if (ajax) {
131                    ajax.abort();
132                    ajax = null;
133                }
134
135                ajax = $.ajax({
136                    type: 'GET',
137                    url: settings.ajax_url,
138                    data: settings.ajax_data,
139                    success: function (data) {
140                        if (data !== "") {
141                            const $modal = $('#modal-' + popup_id);
142                            $modal.html(data);
143
144                            let modalInstance = new bootstrap.Modal($modal[0], {
145                                backdrop: (settings.closeClick ? true : 'static'),
146                                keyboard: settings.closeEsc
147                            });
148
149                            $modal.off('hide.bs.modal').on('hide.bs.modal', function () {
150                                if ($.isFunction(settings.onClose)) settings.onClose.apply();
151                                $(document).trigger("popupClosed", { popupId: popup_id, reason: "close", id: settings.popupId });
152                            });
153
154                            modalInstance.show();
155
156                            $(document).trigger("popupOpen", { popupId: popup_id });
157                        } else {
158                            if ($.isFunction(settings.onClose)) settings.onClose.apply();
159                            if ($.isFunction(settings.onEmpty)) settings.onEmpty.apply();
160
161                            $(document).trigger("popupClosed", { popupId: popup_id, reason: "empty", id: settings.popupId});
162                        }
163
164                        $(document).trigger("popupContentLoaded", { popupId: popup_id });
165                    }
166                });
167            } else if (settings.iframe_url != null) {
168                $('#modal-' + popup_id).html('<iframe style="position:relative;" src="' + settings.iframe_url + '" id="modal-' + popup_id + '-iframe" width="' + (settings.width - 10) + '" height="' + (settings.height - 10) + '" frameborder="0" marginwidth="0" marginheight="0" allowtransparency="true"></iframe>');
169            }
170        }
171
172        if (method === "close") {
173            if($.isFunction(settings.onClose)) settings.onClose.apply();
174
175            $("#modal-" + popup_id).modal('hide');
176        }
177    }
178})(jQuery)
179
180/*** OTHERS ***/
181var overlay_type="";
182var overlay_title="";
183var overlay_text="";
184function overlay_load(type,title,text,params) {
185    overlay_type=type;
186    overlay_title=title;
187    overlay_text=text;
188
189    if (typeof params === "undefined") {
190        params = {};
191    }
192
193    if ($.inArray(type,['error','info','warning','dialog']) > -1 && params['overlay_type'] === undefined){
194        params['overlay_type'] = type;
195    }
196
197    let overlay_id="script";
198    if (params.custom === true) {
199        overlay_ajax("custom", params);
200        overlay_id=type;
201        overlay_type = "custom";
202    } else {
203        overlay_ajax(overlay_id, params);
204    }
205
206    $(document).on("overlayAjaxLoaded",function(event, params) {
207        if (params['id'] == overlay_id) {
208            let overlay_el = $("#overlay_" + overlay_id);
209
210            if (overlay_title != '') $(".overlay_title", overlay_el).html(overlay_title).addClass('loaded');
211            if (text != "") {
212                $(".overlay_text", overlay_el).html(overlay_text).show();
213            } else {
214                $(".overlay_text", overlay_el).hide();
215            }
216            overlay_el.modal('show');
217        }
218    });
219}
220function overlay_init(id,config) {
221    let selector = "#overlay_"+id;
222    let params = {};
223
224    if (config !== undefined && config['overlay_type'] !== '') {
225        params['overlay_type'] = config['overlay_type'];
226    }
227
228    var config_act = $.extend({
229        closeOnClick: (($.inArray(id,["cookie_alert","explicit","close"]) > -1 || (id === "test" && config['overlay_type'] === "error")) ? false : (config_plus['overlay_close_on_click_forced'] === 1)),
230        closeOnEsc: $.inArray(id,["cookie_alert","explicit","close"]) > -1 || (id === "test" && config['overlay_type'] === "error"),
231        load: false,
232        onBeforeLoad: true
233    }, config);
234
235    if ($(selector).length === 0) {
236        $('<div id="overlay_'+ id +'" class="modal fade" tabindex="-1" role="dialog"></div>').appendTo('body');
237    }
238
239    let overlay_el = $(selector);
240
241    overlay_el.overlay({
242        onBeforeLoad: function () {
243            if (config_act.onBeforeLoad === true && overlay_el.attr("data-content") !== 1) {
244                overlay_ajax(id, params, config_act);
245            } else {
246                overlay_el.modal({
247                    backdrop: (($.inArray(id,["cookie_alert","explicit","close"]) > -1 || (id === "test" && config['overlay_type'] === "error") ? false : (config_plus['overlay_close_on_click_forced'] === 1 ? true : config_act.closeOnClick)) ? true : 'static'),
248                    keyboard: ($.inArray(id,["cookie_alert","explicit","close"]) > -1 || (id === "test" && config['overlay_type'] === "error") ? false : (config_plus['overlay_close_on_esc_forced'] === 1 ? true : config_act.closeOnEsc)),
249                }).modal('show');
250            }
251        },
252        closeOnClick: ($.inArray(id,["cookie_alert","explicit","close"]) > -1 || (id === "test" && config['overlay_type'] === "error") ? false : (config_plus['overlay_close_on_click_forced'] === 1 ? true : config_act.closeOnClick)),
253        closeOnEsc: ($.inArray(id,["cookie_alert","explicit","close"]) > -1 || (id === "test" && config['overlay_type'] === "error") ? false : (config_plus['overlay_close_on_esc_forced'] === 1 ? true : config_act.closeOnEsc)),
254        load: config_act.load
255    });
256
257    $(document).trigger("overlayInited",{id:id});
258    overlay_el.attr("data-inited",1);
259}
260function overlay_ajax(id, params, config) {
261    if (typeof params === "undefined") {
262        params = {};
263    }
264
265    let config_act = $.extend({
266        closeOnClick: ($.inArray(id,["cookie_alert","explicit","close"]) > -1 ? false : (config_plus['overlay_close_on_click_forced'] === 1)),
267        closeOnEsc: $.inArray(id,["cookie_alert","explicit","close"]) == -1,
268        load: false,
269        onBeforeLoad: true
270    }, config);
271
272    temp_data = {
273        lang_master: actual_lang,
274        overlay_id: id,
275        layout_plus: UNAS.design.page,
276        overlay_parameters: params,
277        get_ajax: "1"
278    }
279
280    if (typeof config_plus['unas_design'] !== 'undefined') {
281        temp_data['unas_design'] = config_plus['unas_design'];
282    }
283
284    if (service_type == "cms") {
285        temp_data['home_id'] = home_id;
286        temp_overlay_url = shop_url_main + "/ajax/ajax_overlay.php";
287    } else {
288        temp_data['shop_id'] = shop_id;
289        temp_overlay_url = shop_url_main + "/shop_ajax/ajax_overlay.php";
290    }
291
292    if (params.custom === true) {
293        id = params.overlay_type;;
294    }
295
296    let overlay_el = $("#overlay_" + id);
297
298    if (overlay_el.attr("data-content") !== 1) {
299        overlay_el.attr("data-content", 1);
300
301        $.ajax({
302            type: "GET",
303            async: true,
304            url: temp_overlay_url,
305            data: temp_data,
306            success: function (data) {
307                if (data !== "") overlay_el.html(data);
308                overlay_el.modal({
309                    backdrop: config_act.closeOnClick ? true : 'static',
310                    keyboard: config_act.closeOnEsc
311                }).modal('show');
312                $(document).trigger("overlayAjaxLoaded",{id:id,params:params});
313            }
314        });
315    } else {
316        overlay_el.modal({
317            backdrop: config_act.closeOnClick ? true : 'static',
318            keyboard: config_act.closeOnEsc
319        }).modal('show');
320        $(document).trigger("overlayAjaxLoaded",{id:id,params:params});
321    }
322}
323
324function overlay_close(id) {
325    $("#"+id).overlay().close();
326}
327
328function cookie_alert_overlay() {
329    if (allow_cookie_popup !== 0) {
330        $("#overlay_cookie_alert").overlay().load();
331        $('#overlay_cookie_alert').removeClass('cookie-alert-closed');
332    }
333}
334
335function cart_add_overlay() {
336    if (cart_add_warning !== 1) {
337        $('#overlay_cart_add_ok').overlay().load();
338        $(document).trigger("addToCartOverlay");
339    }
340}
341/*** MODAL PART ***/
342let modalCount = 0;
343document.addEventListener('show.bs.modal', function (e) {
344    const $modal = $(e.target);
345    const modalId = e.target.id;
346
347    if (!(modalId === 'overlay_cookie_alert' && $modal.hasClass('modal-auto-show'))) {
348        UNAS.design.active_element = document.activeElement;
349    }
350    modalCount++;
351    let zIndex = 1055 + (10 * modalCount);
352    if (modalId === 'overlay_cookie_alert') zIndex = 10000010;
353    else if (modalId === 'overlay_explicit') zIndex = 10000000;
354
355    $modal.css('z-index', zIndex).attr('data-stack-level', modalCount);
356    $('body').attr('data-opened-modal-counter', modalCount);
357
358    setTimeout(() => {
359        const $backdrop = $('.modal-backdrop').not('.modal-stack').first();
360
361        if ($backdrop.length) {
362            $backdrop.addClass('modal-stack').attr('data-id', modalId);
363        }
364
365        const $currentBackdrop = $(`.modal-backdrop[data-id="${modalId}"]`);
366        $currentBackdrop.css('z-index', zIndex - 1);
367
368        if (modalId === 'overlay_cookie_alert') {
369            $currentBackdrop.addClass('cookie_overlay');
370        } else if (modalId === 'overlay_explicit') {
371            $currentBackdrop.addClass('explicit_overlay');
372        }
373    }, 0);
374
375    if (modalId.includes('overlay_')) {
376        $(document).trigger("overlayOpen", { id: modalId });
377    }
378});
379
380document.addEventListener('shown.bs.modal', function (e) {
381    const $modal = $(e.target);
382    const modalId = e.target.id;
383
384    if (modalId === 'modal-exitpopup' || modalId === 'overlay_explicit') {
385        $modal.attr({'role':'alert','aria-atomic':'false'});
386    }
387});
388
389document.addEventListener('hide.bs.modal', function (e) {
390    const $modal = $(e.target);
391    const modalId = e.target.id;
392    const stackLevel = $modal.data('stack-level') || 0;
393
394    if (modalId === 'modal-exitpopup') {
395        $modal.find('iframe, video').attr('src', '');
396    }
397    if (stackLevel > 1) {
398        setTimeout(() => {
399            $(`.modal[data-stack-level="${stackLevel - 1}"]`).focus();
400        }, 0);
401    } else if (UNAS.design.active_element) {
402        setTimeout(() => UNAS.design.active_element.focus(), 0);
403    }
404    modalCount = Math.max(0, modalCount - 1);
405    $('body').attr('data-opened-modal-counter', modalCount);
406    if (modalId.includes('overlay_')) {
407        $(document).trigger("overlayClose", { id: modalId.replace('overlay_', '') });
408    }
409});
410document.addEventListener('hidden.bs.modal', function (e) {
411    if (UNAS.design.active_element) {
412        UNAS.design.active_element.focus();
413    }
414    announceToScreenReader?.('modalClose');
415});
416
417$(document).on('click', '.modal-backdrop.cookie_overlay, #overlay_explicit, .modal-backdrop.explicit_overlay, #overlay_cookie_alert, .offcanvas-cookie-alert.show, .offcanvas-cookie-alert.show ~ .offcanvas-backdrop', function(event){
418    event.stopPropagation();
419});

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.