PageSourceSearch

https://gruppi.hu/assets/js/newsletter-popup.js

js gruppi.hu collected 2026-10-08 20:50:11 UTC 2,393 bytes, 97 lines download raw bytes

1/* Főoldali hírlevél popup - megjelenítés, bezárás, feliratkozás (AJAX, task=signupNewsletter) */
2$(document).ready(function () {
3
4	var $overlay = $('#nlPopupOverlay');
5	if (!$overlay.length) { return; }
6
7	var CLOSE_COOKIE = 'gruppi_nl_popup_closed';
8	var OPEN_DELAY_MS = 800;
9	var CLOSE_COOKIE_MAX_AGE = 60 * 60 * 24 * 30; /* 30 nap */
10
11	function setClosedCookie() {
12		document.cookie = CLOSE_COOKIE + '=1;max-age=' + CLOSE_COOKIE_MAX_AGE + ';path=/';
13	}
14
15	function showMsg(text, isError) {
16		var $msg = $('#nlPopupMsg');
17		$msg.text(text);
18		$msg.removeClass('nl-popup-msg-error nl-popup-msg-ok');
19		$msg.addClass(isError ? 'nl-popup-msg-error' : 'nl-popup-msg-ok');
20		$msg.show();
21	}
22
23	function closePopup() {
24		$overlay.fadeOut(150);
25		setClosedCookie();
26	}
27
28	setTimeout(function () {
29		$overlay.fadeIn(200);
30	}, OPEN_DELAY_MS);
31
32	$('#nlPopupClose').on('click', function () {
33		closePopup();
34	});
35
36	/* Háttérre (overlay) kattintva is zárjon, de a kártyára kattintva ne */
37	$overlay.on('click', function (e) {
38		if (e.target === this) {
39			closePopup();
40		}
41	});
42
43	$('#nlPopupSubmit').on('click', function (e) {
44		e.preventDefault();
45
46		if ($(this).hasClass('nl-popup-submit-disabled')) { return; }
47
48		var email = $.trim($('#nlPopupEmail').val());
49		var name = $.trim($('#nlPopupName').val());
50
51		if (!$('#nlPopupAccept').prop('checked')) {
52			$('#nlPopupAccept').closest('label').css('color', '#c00');
53			showMsg('Az adatvédelmi szabályzat elfogadása kötelező.', true);
54			return;
55		}
56		$('#nlPopupAccept').closest('label').css('color', '');
57
58		if (email === '') {
59			showMsg('Add meg az e-mail címed.', true);
60			return;
61		}
62
63		var $submit = $(this);
64		$submit.addClass('nl-popup-submit-disabled');
65
66		$.post(
67			'index.php',
68			{
69				task: 'signupNewsletter',
70				newsletterEmail: email,
71				newsletterName: name
72			},
73			function (json) {
74				var j;
75				try {
76					j = $.parseJSON(json);
77				} catch (err) {
78					$submit.removeClass('nl-popup-submit-disabled');
79					showMsg('Hiba történt, próbáld újra később.', true);
80					return;
81				}
82
83				if (j.ok == 1) {
84					showMsg('Sikeres feliratkozás, köszönjük!', false);
85					setClosedCookie();
86					setTimeout(function () {
87						window.location = '/oldal/newsup?up=1';
88					}, 600);
89				} else {
90					$submit.removeClass('nl-popup-submit-disabled');
91					showMsg(j.message, true);
92				}
93			}
94		);
95	});
96
97});

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.