PageSourceSearch

https://www.artthema.com/lib/g/2.0/scripts/artlogic_modules/galler…=57db970&g=86fa599520a8e2968eb1fac1f53a968f

js artthema.com collected 2026-09-25 01:24:06 UTC 38,897 bytes, 720 lines download raw bytes

1import fancyboxPlugin from '../plugins/fancybox-2.1.3.js';
2import fancybox from './fancybox.js';
3import misc from './misc.js'
4
5var contact_form_popup = {
6
7    init: function() {
8
9
10        window.galleries.contact_form_popup.inline();
11        window.galleries.contact_form_popup.custom();
12
13        $('a[href$="/contact/form/"], .website_contact_form')
14            .off()
15            .addClass('website_contact_form')
16            .addClass('link-no-ajax')
17            .click(function() {
18                window.galleries.contact_form_popup.on_button_click();
19
20                // For accessibility - tracks which element to refocus on
21                try {
22                    h.accessibility.global_variables.element_to_refocus_to = $(this);
23                } catch(error) {
24                    console.error(error);
25                }
26
27                if (window.gtag) {
28                    gtag('event', 'contact_form_popup', {});
29                }
30
31                if (window.ga) {
32                    // Track the click in Analytics
33                    ga('send', {
34                        'hitType': 'event',
35                        'eventCategory': 'Contact form popup',
36                        'eventAction': window.location.pathname,
37                        'eventLabel': $(document).attr('title')
38                    });
39                    // Track the click in second Analytics account
40                    ga('tracker2.send', {
41                        'hitType': 'event',
42                        'eventCategory': 'Contact form popup',
43                        'eventAction': window.location.pathname,
44                        'eventLabel': $(document).attr('title')
45                    });
46                    ga('artlogic_tracker.send', {
47                        'hitType': 'event',
48                        'eventCategory': 'Contact form popup',
49                        'eventAction': window.location.pathname,
50                        'eventLabel': $(document).attr('title')
51                    });
52                }
53
54                var form_options = {
55                    'item_id': typeof $(this).attr('data-contact-form-item-id') != 'undefined' ? $(this).attr('data-contact-form-item-id') : '',
56                    'item_table': typeof $(this).attr('data-contact-form-item-table') != 'undefined' ? $(this).attr('data-contact-form-item-table') : '',
57                    'gallery_id': typeof $(this).attr('data-contact-form-gallery-id') != 'undefined' ? $(this).attr('data-contact-form-gallery-id') : '',
58                    'gallery_email_address': typeof $(this).attr('data-contact-form-to') != 'undefined' ? $(this).attr('data-contact-form-to') : '',
59                    'gallery_email_address_bcc': typeof $(this).attr('data-contact-form-to-bcc') != 'undefined' ? $(this).attr('data-contact-form-to-bcc') : '',
60                    'gallery_email_address_cc': typeof $(this).attr('data-contact-form-to-cc') != 'undefined' ? $(this).attr('data-contact-form-to-cc') : '',
61                    'form_heading': typeof $(this).attr('data-contact-form-heading') != 'undefined' ? $(this).attr('data-contact-form-heading') : '',
62                    'form_button_label': typeof $(this).attr('data-contact-form-button-label') != 'undefined' ? $(this).attr('data-contact-form-button-label') : '',
63                    'hide_additional_field_content': $(this).attr('data-contact-form-hide-context') && typeof $(this).attr('data-contact-form-hide-context') != 'undefined' ? ($(this).attr('data-contact-form-hide-context') == '1' ? true : false) : false,
64                    'additional_field_content': typeof $(this).attr('data-contact-form-details') != 'undefined' ? $(this).attr('data-contact-form-details') : '',
65                    'additional_field_image': $(this).attr('data-contact-form-image'),
66                    'additional_field_parent_id': $(this).attr('data-contact-form-parent-id'),
67                    'additional_field_type': $(this).attr('data-contact-form-type'),
68
69                    'additional_terms_url': typeof $(this).attr('data-contact-form-additional-terms-url') != 'undefined' ? $(this).attr('data-contact-form-additional-terms-url') : '',
70                    'additional_terms_label': typeof $(this).attr('data-contact-form-additional-terms-label') != 'undefined' ? $(this).attr('data-contact-form-additional-terms-label') : '',
71                    'stock_number': $(this).attr('data-contact-form-stock-number') || '',
72                    'default_message': typeof $(this).attr('data-contact-form-default-message') != 'undefined' ? $(this).attr('data-contact-form-default-message') : ''
73                };
74
75                if ($('#contact_form_overlay').length > 0) {
76
77                    // Existing form on the page
78
79                    window.galleries.contact_form_popup.form_setup(form_options);
80
81                    if (form_options.additional_field_type && typeof form_options.additional_field_type != 'undefined') {
82                        $('body').addClass('contact-form-overlay-type-' + form_options.additional_field_type);
83                        $('#contact_form_overlay').addClass('form-type-container-' + form_options.additional_field_type);
84                    } else {
85                        $("body").removeClass (function (index, className) {
86                            return (className.match (/(^|\s)contact-form-overlay-type-\S+/g) || []).join(' ');
87                        });
88                        $("#contact_form_overlay").removeClass (function (index, className) {
89                            return (className.match (/(^|\s)form-type-container-\S+/g) || []).join(' ');
90                        });
91                    }
92
93                    $('body').addClass('contact-form-init');
94
95                    if (typeof contact_form_overlay_timeout != 'undefined') {
96                        clearTimeout(contact_form_overlay_timeout);
97                    }
98                    var contact_form_overlay_timeout = setTimeout(function() {
99                        if (!$('#contact_form_overlay').hasClass('active')) {
100                            $('#contact_form_overlay').addClass('active');
101                            $('body, html').addClass('contact-form-overlay-open');
102                            h.accessibility.on_popup_opening('#contact_form_overlay', '#contact_form_header', '#contact_form_overlay_close a');
103                            h.accessibility.role_button();
104                        }
105                    }, 50);
106
107                    $('#contact_form_overlay_close a, #contact_form_overlay .overlay-bg').off().click(function() {
108                        if ($('#contact_form_overlay').hasClass('active')) {
109                            if (typeof contact_form_overlay_close_timeout != 'undefined') {
110                                clearTimeout(contact_form_overlay_close_timeout);
111                            }
112                            var contact_form_overlay_close_timeout = setTimeout(function() {
113                                $('body').removeClass('contact-form-init');
114                            }, 600);
115                            $('#contact_form_overlay').removeClass('active');
116                            $('body, html').removeClass('contact-form-overlay-open');
117
118                            h.accessibility.on_popup_closing();
119                        }
120                        return false;
121                    });
122
123                    if ($('.contact_form_captcha_enabled').length > 0) {
124                        if (typeof grecaptcha != 'undefined') {
125                            $.getScript('https://www.recaptcha.net/recaptcha/api.js?onload=google_captcha_onload', function(){
126                                grecaptcha.reset();
127                            });
128                        }
129                    }
130
131                    window.galleries.contact_form_popup.after_popup_callback();
132
133                } else {
134
135                    // Open in fancybox popup
136
137                    var form_url_params = '?modal=1';
138                    if (form_options.additional_field_parent_id) {
139                        var form_url_params = form_url_params + '&id=' + form_options.additional_field_parent_id;
140                    }
141
142                    var url_prefix = '';
143                    if (typeof window.archimedes.proxy_dir != 'undefined') {
144                        var url_prefix = window.archimedes.proxy_dir;
145                    }
146
147                    if (window.location.search && typeof window.location.search != 'undefined') {
148                        if (window.location.search.indexOf('_holding_preview_uid') > -1) {
149                            var form_url_params = form_url_params + '&' + window.location.search.replace('?', '');
150                        }
151                    }
152
153                    $.fancybox.open(
154                        url_prefix + '/contact/form/' + form_url_params,
155                        {
156                            type: 'ajax',
157                            autoSize: false,
158                            height: 'auto',
159                            width: 420,
160                            arrows: false,
161                            prevEffect: 'fade',
162                            nextEffect: 'fade',
163                            closeEffect: 'fade',
164                            openEffect: 'fade',
165                            wrapCSS: 'fancybox_ajax_popup',
166                            prevSpeed: 750,
167                            nextSpeed: 750,
168                            closeSpeed: 200,
169                            padding: 25,
170                            openSpeed: 400,
171                            overlayColor: 'transparent',
172                            keys: {close: null},
173                            afterLoad: function() {
174                                $('.fancybox-overlay').addClass('fancybox-overlay-ajax');
175                                $('.fancybox-overlay').addClass('fancybox-contact-form');
176                                setTimeout(function() {
177                                    if (form_options.form_heading && typeof form_options.form_heading != 'undefined') {
178
179                                        if ($('#contact_form #contact_form_header[data-default-label]').length == 0) {
180                                            $('#contact_form #contact_form_header').attr('data-default-label', $('#contact_form #contact_form_header').text());
181                                        }
182                                        $('#contact_form #contact_form_header').text(form_options.form_heading);
183                                    } else if ($('#contact_form #contact_form_header[data-default-label]').length > 0) {
184                                      
185                                        $('#contact_form #contact_form_header').text($('#contact_form #contact_form_header').attr('data-default-label'));
186                                    }
187
188                                    if (form_options.form_button_label && typeof form_options.form_button_label != 'undefined') {
189                                        if ($('#contact_form #contactFormSubmit > a[data-default-label]').length == 0) {
190                                            $('#contact_form #contactFormSubmit > a').attr('data-default-label', $('#contact_form #contactFormSubmit > a').text());
191                                        }
192                                        $('#contact_form #contactFormSubmit > a').text(form_options.form_button_label);
193                                    } else if ($('#contact_form #contactFormSubmit > a[data-default-label]').length > 0) {
194                                        $('#contact_form #contactFormSubmit > a').text($('#contact_form #contactFormSubmit > a').attr('data-default-label'));
195                                    }
196                                }, 20, form_options.form_heading);
197                            },
198                            afterShow: function() {
199                                window.galleries.contact_form_popup.form_setup(form_options);
200
201                                h.accessibility.on_popup_opening('.fancybox-opened .fancybox-skin', false, '.fancybox-wrap .fancybox-close');
202                                $('.fancybox-wrap .fancybox-skin').attr({role: "dialog", 'aria-modal'
202: true, 'aria-labelledby': "contact_form_header"});
203                                // Make the close link element act like a button
204                                $('.fancybox-skin a[title="Close"], .fancybox-skin a[title="Previous"], .fancybox-skin a[title="Next"]').attr("role", "button");
205                                h.accessibility.role_button();
206
207                                window.galleries.contact_form_popup.after_popup_callback();
208                            },
209
210                            afterClose: function () {
211                                h.accessibility.on_popup_closing();
212                            }
213                        }
214                    );
215                }
216
217                return false;
218            })
219        ;
220        if( $('#contact_form').length ){
221
222            window.galleries.contact_form_popup.after_popup();
223            $('#contact_form .link a, #contact_form .button a').off('click.contactform').on('click.contactform', function() {
224                window.galleries.contact_form_popup.submit_form($(this).closest('#contact_form'));
225                return false;
226            });
227            $('#contact_form_inline #contact_form').attr('role', 'region');
228
229            if ($('.contact_form_captcha_enabled').length > 0) {
230                if (typeof google_captcha_onload != 'undefined') {
231                    Artlogic.import('galleries_js/recaptcha.js').then(function (module) {
232                        google_captcha_onload();
233                    });
234                }
235            }
236
237        }
238
239    },
240
241    form_setup: function(form_options) {
242        $('#contact_form form').find('*').filter(':input:visible:first').focus();
243        window.galleries.contact_form_popup.after_popup();
244        $('#contact_form #contact_form_item_preview').hide();
245        $('#contact_form #contact_form_item_preview .inner').html('');
246        $('#f_terms_accepted_additional').html('');
247        if($('#contact_form #contact_form_header').text() == ''){
248            //default value if it is null
249            $('#contact_form #contact_form_header').text('Enquiry form');
250        }
251        if (form_options.additional_field_content || form_options.gallery_email_address || form_options.gallery_id != '') {
252            if ($('#contact_form #contact_form_item_preview').length) {
253                if (form_options.additional_field_content) {
254                    $('#contact_form #contact_form_item_preview .inner').html('<div class="content">' + decodeURIComponent(form_options.additional_field_content) + '</div>');
255                }
256                if (form_options.additional_field_image) {
257                    var website_domain = '';
258                    if (form_options.additional_field_image.substr(0,7) != 'http://' && form_options.additional_field_image.substr(0,8) != 'https://') {
259                        var website_domain = 'http://' + document.location.host;
260                    }
261                    $('#contact_form #contact_form_item_preview .inner').prepend('<div class="image"><img src="' + website_domain + form_options.additional_field_image + '" alt="' + jQuery(decodeURIComponent(form_options.additional_field_content)).text() + '"/></div>');
262                }
263                if (form_options.hide_additional_field_content) {
264                    $('#contact_form #contact_form_item_preview').hide();
265                } else {
266                    if ($('#contact_form_overlay').length > 0) {
267                        $('#contact_form #contact_form_item_preview').show();
268                    } else {
269                        $('#contact_form #contact_form_item_preview').slideDown(function() {
270                            if ($(window).height() < $('.fancybox-wrap').height()) {
271                                $.fancybox.update();
272                            }
273                        });
274                    }
275                }
276            } else {
277                $('#contact_form #f_message').val(form_options.additional_field_content);
278            }
279
280            if (form_options.additional_terms_url != '') {
281                var additional_terms_html = '';
282                var link_label = 'Privacy Policy';
283                if (form_options.additional_terms_label != '') {
284                    link_label = form_options.additional_terms_label;
285                }
286                $('#f_terms_accepted_additional').closest('label').addClass('additional-terms-enabled');
287                $('#f_terms_accepted_additional').html('<span class="f_terms_separator">and</span> <a href="' + form_options.additional_terms_url + '" target="_blank">' + link_label + '</a>');
288            }
289
290            $('#contact_form #f_item_id').val(form_options.item_id);
291            $('#contact_form #f_item_table').val(form_options.item_table);
292            $('#contact_form #f_gallery_id').val(form_options.gallery_id);
293            $('#contact_form #f_gallery_email_address').val(form_options.gallery_email_address);
294            $('#contact_form #f_gallery_email_address_bcc').val(form_options.gallery_email_address_bcc);
295            $('#contact_form #f_gallery_email_address_cc').val(form_options.gallery_email_address_cc);
296            $('#contact_form #f_item_stock_number').val(form_options.stock_number);
297
298            if (form_options.default_message) {
299                $('#contact_form #f_message').val(form_options.default_message);
300            }
301
302            if (form_options.form_heading && typeof form_options.form_heading != 'undefined') {
303                if ($('#contact_form #contact_form_header[data-default-label]').length == 0) {
304                    $('#contact_form #contact_form_header').attr('data-default-label', $('#contact_form #contact_form_header').text());
305                }
306                $('#contact_form #contact_form_header').text(form_options.form_heading);
307            } else if ($('#contact_form #contact_form_header[data-default-label]').length > 0) {
308                $('#contact_form #contact_form_header').text($('#contact_form #contact_form_header').attr('data-default-label'));
309            }
310
311            if (form_options.form_button_label && typeof form_options.form_button_label != 'undefined') {
312                if ($('#contact_form #contactFormSubmit > a[data-default-label]').length == 0) {
313                    $('#contact_form #contactFormSubmit > a').attr('data-default-label', $('#contact_form #contactFormSubmit > a').text());
314                }
315                $('#contact_form #contactFormSubmit > a').text(form_options.form_button_label);
316            } else if ($('#contact_form #contactFormSubmit > a[data-default-label]').length > 0) {
317                $('#contact_form #contactFormSubmit > a').text($('#contact_form #contactFormSubmit > a').attr('data-default-label'));
318            }
319
320            $('#contact_form #f_product').val(encodeURIComponent(($('#contact_form #contact_form_item_preview .inner').length ? $('#contact_form #contact_form_item_preview .inner').html() : $('#contact_form #contact_form_item_preview').html())));
321            let contact_form_header = $('#contact_form #contact_form_header').text()
322            if(contact_form_header == ''){
323                $('#contact_form #form_type').val('Enquiry form');
324            } else {
325                $('#contact_form #form_type').val(contact_form_header);
326            }
327            $('#contact_form #email_type').val('enquiry-form');
328            if (form_options.additional_field_type && typeof form_options.additional_field_type != 'undefined') {
329                $('#contact_form #form_type_name').val(form_options.additional_field_type);
330                $('#contact_form').addClass('form-type-' + form_options.additional_field_type);
331            } else {
332                $('#contact_form #form_type_name').val('enquiry');
333                $("#contact_form").removeClass (function (index, className) {
334                    return (className.match (/(^|\s)form-type-\S+/g) || []).join(' ');
335                });
336            }
337        }
338        // If the contact/enquiry form contains work/product info, set focus to the form header instead of first input field
339        if ($('#contact_form #contact_form_item_preview:visible').length && $('#contact_form_header').length) {
340            $('#contact_form_header')[0].focus({preventScroll:true});
341        }
342    },
343
344    custom: function() {
345
346        $('#contact_form_custom').each(function() {
347            $('#contact_form_custom .link a, #contact_form_custom .button:not(.custom_contact_form_button) a').off('click.contactform').on('click.contactform', function() {
348                window.galleries.contact_form_popup.submit_form($(this).closest('#contact_form'));
349                return false;
350            });
351        });
352
353    },
354
355    after_inline_callback: function() {
356
357    },
358
359    inline: function() {
360
361        var url_prefix = '';
362        if (typeof window.archimedes.proxy_dir != 'undefined') {
363            var url_prefix = window.archimedes.proxy_dir;
364        }
365        $('#contact_form_inline, .section-contact.page-form').each(function() {
366            $.ajax({
367                url: url_prefix + "/contact/form/",
368                data: 'modal=1&inline=1',
369                cache: false,
370                dataType: 'html',
371                success: function(data) {
372                    $('#contact_form_inline').html(data);
373                    window.galleries.contact_form_popup.after_popup();
374                    $('#contact_form .link a, #contact_form .button:not(.custom_contact_form_button) a').off('click.contactform').on('click.contactform', function() {
375                        window.galleries.contact_form_popup.submit_form($(this).closest('#contact_form'));
376                        return false;
377                    });
378                    $('#contact_form_inline #contact_form').attr('role', 'region');
379
380                    if ($('.contact_form_captcha_enabled').length > 0) {
381                        if (typeof google_captcha_onload != 'undefined') {
382                            Artlogic.import('galleries_js/recaptcha.js').then(function (module) {
383                                google_captcha_onload();
384                            });
385                        }
386                    }
387                    window.galleries.contact_form_popup.after_inline_callback();
388                }
389            });
390        });
391
392
393
394
395    },
396
397    after_popup_callback: function() {
398
399    },
400
401    after_popup: function() {
402
403        window.archimedes.archimedes_core.analytics.track_campaigns.set_forms();
404
405        window.galleries.misc.loaders();
406
407        $('#contact_form .link a, #contact_form .button:not(.custom_contact_form_button) a').off('click.contactform').on('click.contactform', function() {
408            var instance = $(this).closest('#contact_form');
409            if (!instance.hasClass('submitting')) {
410                window.galleries.contact_form_popup.submit_form(instance);
411            }
412            return false;
413        });
414
415        if ($('.contact_form_captcha_enabled').length > 0) {
416            if (typeof google_captcha_onload != 'undefined') {
417                Artlogic.import('galleries_js/recaptcha.js').then(function (module) {
418                    google_captcha_onload();
419                });
420            }
421        }
422
423    },
424
425    submit_form: function(instance) {
426
427        if (instance) {
428
429            var data = {};
430
431            var field_validation_error = false;
432
433
434            $('input, select, textarea', instance).each(function() {
435                if ($(this).closest('.form_row').hasClass('form_row_required')) {
436                    let field_invalid = false;
437                    if ($(this).is(':checkbox') && $(this).closest('form').find('input[name="' + $(this).attr('name') + '"]')) {
438                        var checked = $(this).closest('form').find('input[name="' + $(this).attr('name') + '"]:checked').length > 0;
439                        if (!checked || typeof checked == 'undefined') {
440                            field_validation_error = true;
441                            field_invalid = true;
442                        }
443                    } else if ($(this).is(':checkbox')) {
444                        var checked = $(this).is(':checked');
445                        if (!checked || typeof checked == 'undefined') {
446                            field_validation_error = true;
447                            field_invalid = true;
448                        }
449                    } else if ($(this).is(':radio')) {
450                        var checked_radio = $('input[name="' + $(this).attr('name') + '"]:checked').val();
451                        if (!checked_radio || typeof checked_radio == 'undefined') {
452                            field_validation_error = true;
453                            field_invalid = true;
454                        }
455                    } else if ($(this).is(':text') || $(this).is('textarea')) {
456                        if ($(this).val() == '') {
457                            field_validation_error = true;
458                            field_invalid = true;
459                        }
460                    }
461                    if (field_invalid) {
462                        $(this).attr('aria-invalid', "true");
463                        $(this).attr('aria-errormessage', "error");
464                    } else {
465                        $(this).removeAttr('aria-invalid');
466                        $(this).removeAttr('aria-errormessage');
467                    }
468                }
469                if ($(this).is(':checkbox') && $(this).closest('form').find('input[name="' + $(this).attr('name') + '"]')) {
470                    // Multi checkboxes
471                    var checked_options = $(this).closest('form').find('input[name="' + $(this).attr('name') + '"]:checked');
472                    var checked_values = $.map(checked_options, function(n, i){
473                        return n.value;
474                    }).join(', ');
475                    data[$(this).attr('name')] = checked_values;
476                } else if ($(this).is(':radio')) {
477                    var checked_radio = $('input[name="' + $(this).attr('name') + '"]:checked').val();
478                    if (!checked_radio || typeof checked_radio == 'undefined') {
479                        var checked_radio = '';
480                    }
481                    data[$(this).attr('name')] = checked_radio;
482                } else if ($(this).attr('name') == 'f_message') {
483                    data[$(this).attr('name')] = $(this).val().replace(/\n/g, '<br />');
484                } else {
485                    data[$(this).attr('name')] = $(this).val().replace(/\n/g, '<br />');
486                }
487            });
488
489            if (field_validation_error) {
490                $(instance).removeClass('submitting');
491
492                // For accessibility - tracks which element to refocus on
493                try {
494                    h.accessibility.global_variables.element_to_refocus_to = $('#contactFormSubmit a');
495                } catch(error) {
496                    console.error(error);
497                }
498
499                var alert_heading = $('#contact_form[data-field-alert-heading]').length ? $('#contact_form[data-field-alert-heading]').attr('data-field-alert-heading') : 'Sorry';
500                var alert_content = $('#contact_form[data-field-alert-content]').length ? $('#contact_form[data-field-alert-content]').attr('data-field-alert-content') : 'Please fill in all the required fields.';
501                var alert_content_terms = $('#contact_form[data-field-alert-terms-content]').length ? $('#contact_form[data-field-alert-terms-content]').attr('data-field-alert-terms-content') : 'Please fill in all the required fields and agree to the terms and conditions.';
502
503                if ($('#f_terms_accepted', instance).length && !$('#f_terms_accepted', instance).is(':checked')) {
504                    h.alert('<h2>' + alert_heading + '</h2>' + alert_content_terms + '');
505                } else {
506                    h.alert('<h2>' + alert_heading + '</h2>' + alert_content + '');
507                }
508                //$('.error_row', instance).text('Please fill in all the required fields');
509                //window.galleries.effects.pulsate($('.error_row', instance));
510                return;
511            }
512
513            $(instance).addClass('submitting');
514            $('.button', instance).addClass('loading');
515
516            window.archimedes.archimedes_core.analytics.track_campaigns.save_form_data($(instance));
517
518            // Process captcha
519
520            if ($(instance).find('form').hasClass('contact_form_captcha_enabled')) {
521                if (!$('body').hasClass('contact_form_captcha_challenge_passed')) {
522                    var captcha_error = '<h2>Sorry</h2>An error occurred, please refresh this page and try again. If you continue to have problems please contact us for support.';
523                    if (typeof grecaptcha != 'undefined') {
524                        window.recaptcha_success_callback_instance = instance;
525                        window.recaptcha_success_callback = function(instance) {
526                            window.galleries.contact_form_popup.submit_form(instance);
527                        };
528                        try {
529                            grecaptcha.execute();
530                        } catch(error_message) {
531                            h.alert(captcha_error);
532                            $(instance).removeClass('submitting');
533                            $('.button', instance).removeClass('loading');
534                            $.ajax({
535                                url: "/api/process_js_error/",
536                                data: 'type=captcha&message=Captcha error on page ' + window.location.pathname + ' Error message: ' + error_message + '&fullurl=' + window.location.href,
537                                cache: false
538                            });
539                        }
540                    } else {
541                        h.alert(captcha_error);
542                        $(instance).removeClass('submitting');
543                        $('.button', instance).removeClass('loading');
544                        var error_message = 'Unknown error - grecaptcha may be undefined'
545                        $.ajax({
546                            url: "/api/process_js_error/",
547                            data: 'type=captcha&message=Captcha error on page ' + window.location.pathname + ' Error message: ' + error_message + '&fullurl=' + window.location.href,
548                            cache: false
549                        });
550                    }
551                    return;
552
553                } else {
554                    $('body').removeClass('contact_form_captcha_challenge_passed');
555                }
556            }
557
558            //data = encodeURI(data); // Encode form data so that unicode characters work
559            data['originating_page'] = encodeURIComponent(window.location.pathname + window.location.search);
560
561            var url_prefix = '';
562            if (typeof window.archimedes.proxy_dir != 'undefined') {
563                url_prefix = window.archimedes.proxy_dir;
564            }
565
566            $.ajax({
567                url: url_prefix + "/contact/form/process/",
568                data: data,
569                cache: false,
570                type: 'POST',
571                dataType: 'json',
572                success: function(data) {
573                    $('.button', instance).removeClass('loading');
574                    $(instance).removeClass('submitting');
575                    if (data['success'] == 1) {
576                        window.galleries.contact_form_popup.after_submit_success();
577
578                        if ($('#contact_form_overlay').length > 0) {
579                            $('#contact_form_overlay_close a').trigger('click');
580                            if (typeof $('#contact_form_overlay').attr('data-confirmation-heading') != 'undefined' && typeof $('#contact_form_overlay').attr('data-confirmation-message') != 'undefined') {
581                                var confirmation_message = $('#contact_form_overlay').attr('data-confirmation-message');
582                                if ($('#form_type_name').length && typeof $('#form_type_name').val() != 'undefined') {
583                                    if (typeof $('#contact_form_overlay').attr('data-confirmation-message-' + $('#form_type_name').val()) != 'undefined') {
584                                        confirmation_message = $('#contact_form_overlay').attr('data-confirmation-message-' + $('#form_type_name').val());
585                                    }
586                                }
587                                h.alert('<h2>' + $('#contact_form_overlay').attr('data-confirmation-heading') + '</h2>' + confirmation_message);
588                            } else {
589                                h.alert('<h2>Thank you</h2> Your enquiry has been sent.')
590                            }
591                        } else {
592                            $.fancybox((url_prefix + '/contact/form/?modal=1&complete=1'), window.galleries.fancybox.ajax_defaults());
593                        }
594
595                        $('input[type="text"], select, textarea', instance).not('.campaign_tracking_autofilled').each(function() {
596                            $(this).val('');
597                        });
598
599                        if (window.fbq && typeof window.fbq != 'undefined') {
600                            // Track in Facebook Pixel
601                            fbq('track', 'Lead');
602                        }
603
604                        if (window.gtag) {
605                            gtag('event', 'contact_form_submit', {
606                                'success': true,
607                            });
608                        }
609
610                        if (window.ga) {
611                            // Track in Analytics
612                            ga('send', {
613                                'hitType': 'event',
614                                'eventCategory': 'Contact form submit success',
615                                'eventAction': window.location.pathname,
616                                'eventLabel': $(document).attr('title')
617                            });
618                            // Track in second Analytics account
619                            ga('tracker2.send', {
620                                'hitType': 'event',
621                                'eventCategory': 'Contact form submit success',
622                                'eventAction': window.location.pathname,
623                                'eventLabel': $(document).attr('title')
624                            });
625                            ga('artlogic_tracker.send', {
626                                'hitType': 'event',
627                                'eventCategory': 'Contact form submit success',
628                                'eventAction': window.location.pathname,
629                                'eventLabel': $(document).attr('title')
630                            });
631                        }
632
633                        if ($('.contact_form_captcha_enabled').length > 0) {
634                            if (typeof grecaptcha != 'undefined') {
635                                $.getScript('https://www.recaptcha.net/recaptcha/api.js?onload=google_captcha_onload', function(){
636                                    grecaptcha.reset();
637                                });
638                            }
639                        }
640
641                        window.galleries.contact_form_popup.after_submit();
642                    } else {
643                        var error_message = '';
644                        if (data['error_message'] && typeof data['error_message'] != 'undefined') {
645                            var error_message = data['error_message'];
646                        }
647                        if (error_message) {
648                            h.alert(error_message);
649                        } else {
650                            h.alert('<h2>Sorry</h2>An error occurred. Please try again.');
651                        }
652
653                        if (data['error_type'] && data['error_type'] == 'email_validation') {
654                            $('input#f_email', instance).attr('aria-invalid', "true");
655                            $('input#f_email', instance).attr('aria-errormessage', "error");
656                        } else if (data['error_type']) {
657                            // unknown error type, does not highlight any label
658                        }
659
660                        if (window.gtag) {
661                            gtag('event', 'contact_form_submit', {
662                                'success': false,
663                            });
664                        }
665
666                        if (window.ga) {
667                            // Track in Analytics
668                            ga('send', {
669                                'hitType': 'event',
670                                'eventCategory': 'Contact form submit error',
671                                'eventAction': window.location.pathname,
672                                'eventLabel': $(document).attr('title')
673                            });
674                            // Track in second Analytics account
675                            ga('tracker2.send', {
676                                'hitType': 'event',
677                                'eventCategory': 'Contact form submit error',
678                                'eventAction': window.location.pathname,
679                                'eventLabel': $(document).attr('title')
680                            });
681                            ga('artlogic_tracker.send', {
682                                'hitType': 'event',
683                                'eventCategory': 'Contact form submit error',
684                                'eventAction': window.location.pathname,
685                                'eventLabel': $(document).attr('title')
686                            });
687                        }
688
689                        if ($('.contact_form_captcha_enabled').length > 0) {
690                            if (typeof grecaptcha != 'undefined') {
691                                $.getScript('https://www.recaptcha.net/recaptcha/api.js?onload=google_captcha_onload', function(){
692                                    grecaptcha.reset();
693                                });
694                            }
695                        }
696
697                    }
698                }
699            });
700        }
701
702    },
703    
704    on_button_click: function() {
705
706    },
707
708    after_submit_success: function() {
709
710    },
711
712    after_submit: function() {
713
714    }
715
716}
717
718window.galleries = window.galleries || {};
719window.galleries.contact_form_popup = contact_form_popup
720export default contact_form_popup

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.