PageSourceSearch

https://aromaray.co.il/wp-content/plugins/mylo-loyalty-club/inc/assets/js/club-register.js?ver=1.0.3

js aromaray.co.il collected 2026-10-06 16:27:13 UTC 14,665 bytes, 339 lines download raw bytes

1function openClubForm() {
2    jQuery(document.body).addClass('club_popup_active');
3    jQuery('html').addClass('matat_popup_active');
4    jQuery(document).trigger('matat_popup_open');
5    setTimeout(() => jQuery(document).trigger('matat_popup_opened'), 301);
6}
7function closeClubForm() {
8    jQuery(document.body).removeClass('club_popup_active');
9    jQuery('html').removeClass('matat_popup_active');
10    jQuery(document).trigger('matat_popup_close');
11    setTimeout(() => jQuery(document).trigger('matat_popup_closed'), 301);
12}
13document.addEventListener('DOMContentLoaded', function () {
14    jQuery(document).ready(function () {
15
16        jQuery(document).on('found_variation', 'form.cart', function (event, variation) {
17            if (variation.display_price) {
18                // Fetch a live nonce — admin-ajax.php is never cached by LiteSpeed
19                jQuery.post(maylo_login_register_object.ajaxurl, {
20                    action: 'mylo_get_redeem_nonce'
21                }, function (nonceResult) {
22                    var redeemSecurity = (nonceResult.success && nonceResult.data.nonce)
23                        ? nonceResult.data.nonce
24                        : maylo_login_register_object.ajax_nonce;
25
26                    jQuery.post(maylo_login_register_object.ajaxurl, {
27                        action: 'get_product_redeem_points',
28                        price: variation.display_price,
29                        variation_id: variation.variation_id,
30                        product_id: variation.parent_id || variation.variation_id,
31                        redeem_security: redeemSecurity
32                    }, function (result) {
33                        if (result.success) {
34                            var redeemMessage = result.redeemMessage;
35                            if (redeemMessage != '') {
36                                jQuery('.redeem-earning-points').html(redeemMessage);
37                            }
38                        }
39                    });
40                });
41            }
42        });
43
44        jQuery('#mflow_club_date').mask('00/00/0000', {});
45        jQuery('#matat-club-register-edit-form').validate({
46            ignore: "not:hidden",
47            rules: {
48                register_first_name: {
49                    required: true,
50                    minlength: 2,
51                    maxlength: 10,
52                    lettersRequired: true
53                },
54                register_last_name: {
55                    required: true,
56                    minlength: 2,
57                    maxlength: 10,
58                    lettersRequired: true
59                },
60                register_email: {
61                    required: true,
62                },
63                newsletter_approval: {
64                    required: true,
65                },
66                club_terms_approval: {
67                    required: {
68                        depends: function () {
69                            return jQuery("input[name='club_terms_approval']").length > 0; // only required if field exists
70                        }
71                    }
72                },
73                privacy_policy: {
74                    required: {
75                        depends: function () {
76                            return jQuery("input[name='privacy_policy']").length > 0; // only required if field exists
77                        }
78                    }
79                },
80                mflow_date: {
81                    required: true,
82                    dateFormat: true,
83                    maxDate: true,
84                    minDate: true
85                },
86                register_phone: {
87                    required: true,
88                    israeliPhoneNumber: true
89                }
90            }
91        });
92        jQuery(document).on('submit', '#matat-club-register-edit-form', function (e) {
93            var self = jQuery(this);
94            var submit_btn = self.find('button[type="submit"]');
95            const this_edit_form = self;
96
97            e.preventDefault();
98            if (jQuery(this).valid()) {
99                var form1 = jQuery(this);
100                var data = form1.serialize();
101                var errors = form1.find('.errors');
102                submit_btn.prop('disabled', true);
103                this_edit_form.addClass("loading");
104                errors.html("");
105                // Fetch a live nonce — admin-ajax.php is never cached by LiteSpeed
106                jQuery.post(maylo_login_register_object.ajaxurl, {
107                    action: 'mylo_get_club_register_edit_nonce'
108                }, function (nonceResult) {
109                    var mlcSecurity = (nonceResult.success && nonceResult.data.nonce)
110                        ? nonceResult.data.nonce
111                        : jQuery('#matat-club-register_security_edit').val();
112
113                    jQuery.post(maylo_login_register_object.ajaxurl, {
114                        action: 'matat_site_user_register_for_club',
115                        data: data,
116                        mlc_security: mlcSecurity
117                    }, function (result) {
118                        console.log(result);
119                        errors.removeClass('matat-alert-danger');
120                        if (result.success) {
121                            this_edit_form.removeClass("loading");
122                            errors.addClass('alert-success');
123                            errors.html(result.data);
124                            setTimeout(function () {
125                                location.reload()
126                            }, 2000);
127                        } else {
128                            errors.removeClass('alert-success');
129                            errors.addClass('matat-alert-danger');
130                            submit_btn.prop('disabled', false);
131                            this_edit_form.removeClass("loading");
132                            errors.html(result.data);
133                        }
134                    });
135                })
136            }
137        });
138
139        jQuery('#mflow_profile_date').mask('00/00/0000', {});
140        jQuery('#matat-club-profile-update-form').validate({
141            ignore: "not:hidden",
142            rules: {
143                mflow_date: {
144                    required: true,
145                    dateFormat: true,
146                    maxDate: true,
147                    minDate: true
148                },
149                register_phone: {
150                    required: true,
151                    israeliPhoneNumber: true
152                }
153            }
154        });
155
156        jQuery(document).on('submit', '#matat-club-profile-update-form', function (e) {
157            var self = jQuery(this);
158            var submit_btn = self.find('button[type="submit"]');
159            const this_profile_form = self;
160
161            e.preventDefault();
162            if (jQuery(this).valid()) {
163                var profile_data = self.serialize();
164                var errors = self.find('.errors');
165                submit_btn.prop('disabled', true);
166                this_profile_form.addClass("loading");
167                errors.html("");
168                // Fetch a live nonce — admin-ajax.php is never cached by LiteSpeed
169                jQuery.post(maylo_login_register_object.ajaxurl, {
170                    action: 'mylo_get_club_profile_update_nonce'
171                }, function (nonceResult) {
172                    var mlcSecurity = (nonceResult.success && nonceResult.data.nonce)
173                        ? nonceResult.data.nonce
174                        : jQuery('#matat-club-profile_security').val();
175
176                    jQuery.post(maylo_login_register_object.ajaxurl, {
177                        action: 'mylo_club_update_profile',
178                        data: profile_data,
179                        mlc_security: mlcSecurity
180                    }, function (result) {
181                        errors.removeClass('matat-alert-danger');
182                        if (result.success) {
183                            this_profile_form.removeClass("loading");
184                            errors.addClass('alert-success');
185                            errors.html(result.data);
186                            setTimeout(function () {
187                                location.reload()
188                            }, 2000);
189                        } else {
190                            errors.removeClass('alert-success');
191                            errors.addClass('matat-alert-danger');
192                            submit_btn.prop('disabled', false);
193                            this_profile_form.removeClass("loading");
194                            errors.html(result.data);
195                        }
196                    });
197                })
198            }
199        });
200
201        jQuery('#matat-club-register-form').validate({
202            ignore: "not:hidden",
203            rules: {
204                register_first_name: {
205                    required: true,
206                    minlength: 2,
207                    maxlength: 10,
208                    lettersRequired: true
209                },
210                register_last_name: {
211                    required: true,
212                    minlength: 2,
213                    maxlength: 10,
214                    lettersRequired: true
215                },
216                register_password: {
217                    required: true,
218                    minlength: 6,
219                },
220                confirm_password: {
221                    required: true,
222                    minlength: 6,
223                    equalTo: "#matat_club_register_password"
224                },
225                register_email: {
226                    required: true,
227                },
228                newsletter_approval: {
229                    required: true,
230                },
231                club_terms_approval: {
232                    required: {
233                        depends: function () {
234                            return jQuery("input[name='club_terms_approval']").length > 0; // only required if field exists
235                        }
236                    }
237                },
238                privacy_policy: {
239                    required: {
240                        depends: function () {
241                            return jQuery("input[name='privacy_policy']").length > 0; // only required if field exists
242                        }
243                    }
244                },
245                mflow_date: {
246                    required: true,
247                    dateFormat: true,
248                    maxDate: true,
249                    minDate: true
250                },
251                register_phone: {
252                    required: true,
253                    israeliPhoneNumber: true
254                }
255            }
256        });
257        jQuery(document).on('submit', '#matat-club-register-form', function (e) {
258            var self = jQuery(this);
259            var submit_btn = self.find('button[type="submit"]');
260            const this_form = self;
261
262            e.preventDefault();
263            if (jQuery(this).valid()) {
264                var form = jQuery(this);
265                var data = form.serialize();
266                var errors = form.find('.errors');
267                submit_btn.prop('disabled', true);
268                this_form.addClass("loading");
269                this_form.addClass("matat_club_form_loading");
270
271                errors.html("");
272                jQuery.post(maylo_login_register_object.ajaxurl, {
273                    action: 'matat_plugin_club_register',
274                    data: data,
275                    security: jQuery('#matat-club-register_security').val()
276                }, function (result) {
277                    errors.removeClass('matat-alert-danger');
278                    if (result.success) {
279                        errors.addClass('alert-success');
280                        errors.html(result.data.message);
281                        if (result.data.type && (result.data.type === 'new_user' || result.data.type === 'existing_customer_joined' || result.data.type === 'already_club_member')) {
282                            setTimeout(function () {
283                                location.reload()
284                            }, 2000);
285                        } else {
286                            errors.html(result.data.message + ' <a href="#loginModal" class="mlr_club_login matat-login-trigger">לחץ כאן כדי להתחבר</a>');
287                        }
288
289                    } else {
290                        errors.removeClass('alert-success');
291                        errors.addClass('matat-alert-danger');
292                        submit_btn.prop('disabled', false);
293                        errors.html(result.data.message);
294                    }
295                    this_form.removeClass("loading");
296                    this_form.removeClass("matat_club_form_loading");
297                })
298            }
299        });
300        jQuery(document).on('click', '.matat_club_popup_control', function () {
301            closeClubForm()
302        });
303        jQuery(document).on('click', '.showlogin', function (e) {
304            e.preventDefault();
305            closeClubForm();
306            jQuery('.matat-modal').removeClass('show');
307            var loginModal = jQuery('.matat-modal-login');
308            if (!jQuery('body').hasClass('logged-in')) {
309                loginModal.addClass('show');
310            } else if (window.location.href.indexOf(maylo_login_register_object.my_account_url) === -1) {
311                window.location = maylo_login_register_object.my_account_url;
312            }
313        })
314
315        const popupContainer = document.querySelector('.matat_sticky_club_popup');
316        if (popupContainer && !jQuery('.matat_sticky_club_popup').hasClass('is_loggedin_member')) {
317
318            if (typeof Cookies !== 'undefined') {
319                if (!Cookies.get('join_club_popup')) {
320                    document.querySelector('.matat_sticky_club_popup').classList.add('club_popup_active');
321                    document.querySelector('.matat_sticky_club_popup').classList.remove('hide_popup');
322                }
323            }
324
325            popupContainer.querySelector('.matat_sticky_club_popup--close').addEventListener('click', () => {
326                if (typeof Cookies !== 'undefined') {
327                    Cookies.set('join_club_popup', 1, 1);
328                }
329                document.querySelector('.matat_sticky_club_popup').classList.remove('club_popup_active');
330            });
331            popupContainer.querySelector('.matat_sticky_club_popup--btn').addEventListener('click', () => {
332                if (typeof Cookies !== 'undefined') {
333                    Cookies.set('join_club_popup', 1, 1);
334                }
335            });
336        }
337
338    });
339});

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.