PageSourceSearch

https://adoddle.org/wp-content/themes/adoddle/js/scripts.js?v245

js adoddle.org collected 2026-10-04 02:16:44 UTC 6,695 bytes, 227 lines download raw bytes

1// Load mobile navigation menu
2document.addEventListener(
3    "DOMContentLoaded", () => {
4        new Mmenu( "#mobile-nav", {
5            slidingSubmenus: true,
6            extensions: ['position-right', 'position-front']
7        });
8
9        document.querySelector( 'a[href="#mobile-nav"]' )
10            .addEventListener( 'click', ( evnt ) => {
11                evnt.preventDefault();
12                drawer.open();
13            });
14    }
15);
16
17$(document).ready(function() {
18
19    getAuthStatus();
20    calculateHeightBasedOnWidth();
21    footerMailingList();
22    //showRegion();
23
24    // Site banner
25    $('.site-banner').click(function(event) {
26        window.location.href = $(this).attr('data-href');
27    });
28
29    $('.site-banner').css('top', '-' + $('.site-banner').outerHeight(true) + 'px');
30
31    // Site header 'Search' form - chooses first address item when the search button is clicked
32    $('.simple-search-form button').click(function(event) {
33        event.preventDefault();
34
35        if($('.autocomplete').is(':visible')) {
36            console.log('test');
37            $('.autocomplete-address:nth-of-type(1)').click();
38        }
39    });
40
41
42    $(document).on('click', 'a[rel="ajax:modal"]', function(event) {
43        event.preventDefault();
44
45        $.modal.close();
46        $('.modal').remove();
47
48        $.ajax({
49            url: $(this).attr('href'),
50            complete: function(newHTML, textStatus, jqXHR) {
51                $('body').append('<div class="modal" style="display: none;"></div>')
52                $('.modal').append(newHTML.responseText).modal();
53            },
54        });
55
56        return false;
57    });
58
59});
60
61$(window).on('load', function() {
62
63    regionCirclePosition();
64
65});
66
67$(window).resize(function() {
68
69    calculateHeightBasedOnWidth();
70    regionCirclePosition();
71
72});
73
74$(window).scroll(function() {
75
76    // Move site banner based on scroll position
77    if($(window).scrollTop() > ($('header').offset().top + 200)) {
78        //$('body').css('margin-top', $('.site-banner').outerHeight(true) + 'px');
79        $('.site-banner').css('top','0');
80    } else {
81        $('.site-banner').css('top', '-' + $('.site-banner').outerHeight(true) + 'px');
82    }
83
84});
85
86
87function calculateHeightBasedOnWidth() {
88    // Calculate the height of the property
89    // 66% of the width
90    var elem = $('.calculate-height-bywidth');
91
92    elem.each(function() {
93        var width = $(this).outerWidth(true);
94        var height = Math.round((66.6 / 100) * width);
95
96        $(this).css('height', height + 'px');
97    });
98
99}
100
101// Show a region's HTML on click
102function showRegion()
103{
104    var regions = $('.regions-container');
105
106    $('.region').click(function(event) {
107        event.preventDefault();
108        var region = $(this);
109        var regionSlug = $(this).attr('data-region');
110
111        $.get('https://adoddle.org/wp-json/adoddle/v1/get-region-html?region=' + regionSlug, function(html) {
112            var index = region.index();
113            console.log(html);
114
115            $('body').prepend(html);
116            $('.region-content').fadeIn();
117        }, 'html');
118    });
119}
120
121function regionCirclePosition()
122{
123    var height = ($('.region-circles').height() / 2);
124    $('.region-circles').css('margin-top', '-' + height + 'px');
125}
126
127function getAuthStatus()
128{
129    if(currentApp == 'wp') {
130        $.ajax({
131            url: '/wp-content/themes/adoddle/check-auth.php',
132            type: 'GET',
133            global: false,
134            cache: false,
135            success: function(response) {
136                response = JSON.parse(response);
137
138                if(response.authenticated) {
139                    $('.auth').each(function() {
140                        $(this).addClass('has-sub-menu').find('.auth-text').replaceWith(response.text);
141
142                        if($(this).hasClass('mm-listitem')) {
143                            $(this).find('.auth-text').addClass('mm-listitem__text');
144                        }
145                    });
146                }
147            },
148
149        });
150    }
151}
152
153/**
154* Subscribe email address to mailing list on MailChimp
155*/
156function footerMailingList()
157{
158	var container = $('.mailing');
159	var text = container.find('.page-mailing-list-text');
160	var form = container.find('.page-mailing-list-form');
161
162	// User has clicked "Join" button
163	form.find('.btn').click(function(event) {
164		event.preventDefault();
165
166		grecaptcha.ready(function() {
167			grecaptcha.execute('6Lc9vnUaAAAAAKcDa0EI_ITPjwpoJ7R-OTv1103r', {action: 'submit'}).then(function(recaptcha_token) {
168				var email = form.find('input[name="email"]');
169				var fname = form.find('input[name="fname"]');
170
171				// First remove any existing messages
172				if(form.find('.page-mailing-list-message').length > 0) {
173					form.find('.page-mailing-list-message').fadeOut(function() {
174						$(this).remove();
175					});
176				}
177
178				// Check email address has been type and is valid format
179				if(email.val() == '' || !validateEmail(email.val())) {
180					form.prepend('<span class="page-mailing-list-message error" style="display: none;">Please enter a valid email address.</span>');
181
182					form.find('.page-mailing-list-message').fadeIn();
183					return false;
184				}
185
186				if(fname.val() == '' || !validateEmail(email.val())) {
187					form.prepend('<span class="page-mailing-list-message error" style="display: none;">Please enter your first name.</span>');
188
189					form.find('.page-mailing-list-message').fadeIn();
190					return false;
191				}
192
193				var data = {
194					email: email.val(),
195					fname: fname.val(),
196					list: 'aDoddle',
197					mailing_list_subscribe: true,
198					recaptcha_token: recaptcha_token
199				};
200
201				$.ajax({
202					type: 'POST',
203					url: (window.location.host == 'adoddle.development:2480' ? 'http://adoddle.development:2480' : 'https://adoddle.org') + '/app/api/mailing-lists/subscribe',
204					data: data,
205					complete: function(response) {
206						var responseText = JSON.parse(response.responseText);
207
208						if(responseText.success) {
209							var messageClass = 'success';
210						} else {
211							var messageClass = 'error';
212						}
213
214						form.prepend('<span class="page-mailing-list-message ' + messageClass + '" style="display: none;">' + responseText.message + '</span>');
215
216						form.find('.page-mailing-list-message').fadeIn();
217					}
218				});
219			});
220		});
221	});
222}
223
224function validateEmail(email) {
225	var re = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
226	return re.test(email);
227}

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.