PageSourceSearch

https://www.crisis.org.uk/Scripts/crisis.js?s=ARKQGZQTKQ

js crisis.org.uk collected 2026-09-24 08:39:32 UTC 108,865 bytes, 2,437 lines download raw bytes

1var Crisis = window.Crisis || {};
2
3Crisis.util = {
4    debounce: function (func, wait, immediate) {
5        var timeout;
6        return function () {
7            var context = this, args = arguments;
8            var later = function () {
9                timeout = null;
10                if (!immediate) func.apply(context, args);
11            };
12            var callNow = immediate && !timeout;
13            clearTimeout(timeout);
14            timeout = setTimeout(later, wait);
15            if (callNow) func.apply(context, args);
16        };
17    },
18    _doc: null,
19    checkDocSet: function () {
20        if (Crisis.util._doc == null) {
21            Crisis.util._doc = window.document.documentElement;
22        }
23        return Crisis.util._doc;
24    },
25    getViewportH: function () {
26        var self = this,
27            client = self.checkDocSet()['clientHeight'],
28            inner = window['innerHeight'];
29
30        if (client < inner)
31            return inner;
32        else
33            return client;
34    },
35    scrollY: function () {
36        var self = this;
37        return window.pageYOffset || self.checkDocSet().scrollTop;
38    },
39    clientInfo: {
40        browserName: '',
41        browserVersion: '',
42        ipAddress: ''
43    },
44    getOffset: function (el) {
45        var self = this, offsetTop = 0, offsetLeft = 0;
46        do {
47            if (!isNaN(el.offsetTop)) {
48                offsetTop += el.offsetTop;
49            }
50            if (!isNaN(el.offsetLeft)) {
51                offsetLeft += el.offsetLeft;
52            }
53        } while (el = el.offsetParent)
54
55        return {
56            top: offsetTop,
57            left: offsetLeft
58        }
59
60    },
61    inViewport: function (el, h) {
62        var self = this,
63            elH = el.offsetHeight,
64            scrolled = self.scrollY(),
65            viewed = scrolled + self.getViewportH(),
66            elTop = self.getOffset(el).top,
67            elBottom = elTop + elH,
68            // if 0, the element is considered in the viewport as soon as it enters.
69            // if 1, the element is considered in the viewport only when it's fully inside
70            // value in percentage (1 >= h >= 0)
71            h = h || 0;
72
73        return (elTop + elH * h) <= viewed && (elBottom - elH * h) >= scrolled;
74    },
75    getCurrentFilterObject: function () {
76        var allFilters = $('input[type="checkbox"][data-name="flt-tag"]:checked');
77        var dtFrom = $('#fltDateFrom').val();
78        var dtTo = $('#fltDateTo').val();
79
80        var selectedFilters = [];
81
82        allFilters.map(function (idx, flt) {
83            var $el = $(flt),
84                pvGrp = $el.attr('data-pvgroup');
85
86            if (!selectedFilters[pvGrp]) {
87                selectedFilters[pvGrp] = [];
88            }
89            selectedFilters[pvGrp].push('\'' + $el.attr('data-pv') + '\'');
90        });
91
92        var postData = {
93            fromDate: dtFrom,
94            toDate: dtTo
95        };
96
97        for (var grp in selectedFilters) {
98            postData[grp] = selectedFilters[grp];
99        }
100
101        return postData;
102    },
103    initialiseMap: function (ele) {
104        var lat = $(ele).attr('data-lat'),
105            lng = $(ele).attr('data-lng'),
106            pos = { lat: parseFloat(lat), lng: parseFloat(lng) },
107            map = new google.maps.Map(ele, {
108                center: pos,
109                scrollwheel: false,
110                zoom: 17
111            });
112
113        var marker = new google.maps.Marker({
114            map: map,
115            position: pos,
116            icon: '/content/images/map-marker.png'
117        });
118    },
119    gmapsReady: function () {
120        if ($('.gmap').length) {
121            $('.gmap').each(function () {
122                var id = $(this).attr('id');
123                Crisis.util.initialiseMap(document.getElementById(id));
124            });
125        }
126    },
127    setupContactForm: function () {
128        $('#cntSubject').on('change', function () {
129            var grp = $(this).find('option:selected').attr('data-related-group');
130            $('div.form-group[data-related-group]').hide().find('select').prop('disabled', true);
131            if (grp !== '') {
132                $('div.form-group[data-related-group="' + grp + '"]').show().find('select').prop('disabled', false);
133            }
134        });
135        $('#cntSubject').trigger('change');
136    },
137    skmapReady: function () {
138        if ($('#skmap').length) {
139            if (skmap_locations) {
140                Crisis.util.initialiseSkylightMap(document.getElementById('skmap'));
141            }
142        }
143    },
144    initialiseSkylightMap: function (ele) {
145        var map = new google.maps.Map(ele, {
146                zoom: 15,
147                center: { lat: skmap_locations[0].lat, lng: skmap_locations[0].lng }
148            }),
149            bounds = new google.maps.LatLngBounds();
150
151        for (var idx = 0; idx < skmap_locations.length; idx++) {
152            (function (loc) {
153                var mrk = new google.maps.Marker({
154                    map: map,
155                    position: { lat: skmap_locations[idx].lat, lng: skmap_locations[idx].lng },
156                    icon: '/content/images/map-marker.png'
157                });
158                bounds.extend(mrk.getPosition());
159            })(skmap_locations[idx]);
160        }
161
162        google.maps.event.addListenerOnce(map, 'bounds_changed', function (event) {
163            this.setZoom(map.getZoom() - 1);
164
165            if (this.getZoom() > 15) {
166                this.setZoom(15);
167            }
168        });
169
170        map.fitBounds(bounds);
171    },
172    bankDetailsFields: null,
173    onAccountVerificationResponse: function (response) {
174
175        var parentForm = Crisis.util.bankDetailsFields.parentForm,
176            sc1 = Crisis.util.bankDetailsFields.sc1,
177            sc2 = Crisis.util.bankDetailsFields.sc2,
178            sc3 = Crisis.util.bankDetailsFields.sc3,
179            accNumber = Crisis.util.bankDetailsFields.accNumber,
180            bankName = Crisis.util.bankDetailsFields.bankName,
181            branchName = Crisis.util.bankDetailsFields.branchName,
182            accFields = $([sc1[0], sc2[0], sc3[0], accNumber[0]]).removeClass('invalid'),
183            scFields = $([sc1[0], sc2[0], sc3[0]]),
184            btnComplete = parentForm.find('button.regular-complete'),
185            isLocal = location.host.indexOf('localhost') != (-1),
186            genericWarning = parentForm.find('.msg-error-urgent.bank-details'),
187            sortCodeWarning = parentForm.find('.sort-code-fields .bank-details-error-inline'),
188            accNumberWarning = parentForm.find('.account-number-field .bank-detail
188s-error-inline'),
189            warningElements = $([genericWarning[0], sortCodeWarning[0], accNumberWarning[0]]),
190            //warningElements = parentForm.find('.bank-details-error-inline'),
191            passLocal = isLocal &&
192                (response[0].Error) &&
193                (sc1.val() == '00' && sc2.val() == '00' && sc3.val() == '99' && accNumber.val() == '12345678'),
194            forceError = location.host.indexOf('crisis.org.uk') != (-1) &&
195                (response[0].CorrectedSortCode == '000099' || response[0].CorrectedSortCode == '000098' || response[0].CorrectedSortCode == '000097'),
196            showError = function (errorType = '') {
197                warningElements.addClass('hidden');
198                switch (errorType) {
199                    case 'sc':
200                        sortCodeWarning.removeClass('hidden');
201                        scFields.addClass('invalid');
202                        break;
203                    case 'an':
204                        accNumberWarning.removeClass('hidden');
205                        accNumber.addClass('invalid');
206                        break;
207                    default:
208                        genericWarning.removeClass('hidden');
209                        accFields.addClass('invalid');
210                }
211                btnComplete.prop('disabled', true).addClass("ui-state-disabled");
212            };
213
214        console.log(response);
215
216        if (!passLocal && (response.length == 1 && typeof (response[0].Error) != 'undefined')) {
217            showError();
218        }
219        else {
220            // Check if there were any items found
221            if (response.length == 0 || forceError) {
222                showError();
223            } else {
224                if (passLocal || response[0].IsCorrect.toLowerCase() != "false") {
225
226                    var bankNameVal = passLocal ? 'TEST BANK PLC PLC' : response[0].Bank;
227                    var branchNameVal = passLocal ? 'Worcester' : response[0].Branch;
228
229                    bankName.val(bankNameVal).trigger('change');
230                    branchName.val(branchNameVal);
231                    warningElements.addClass('hidden');
232                    btnComplete.prop('disabled', false).removeClass("ui-state-disabled");
233                } else {
234                    if (response[0].StatusInformation && response[0].StatusInformation.toLowerCase() == 'unknownsortcode')
235                        showError('sc');
236                    else if (response[0].StatusInformation && response[0].StatusInformation.toLowerCase() == 'invalidaccountnumber')
237                        showError('an');
238                    else
239                        showError();
240
241                    accNumber.attr("pattern", "(?=a)b");
242
243                }
244            }
245        }
246    },
247    updateDirectDebitDetails: function (form) {
248
249        var form = $(form);
250        var confDetails = form.find('.conf-details');
251
252        if (!confDetails.length)
253            return;
254
255        var ddDetails = {
256            accountName: form.find('[name="accountName"]').val(),
257            sc1: form.find('[name="sc1"]').val(),
258            sc2: form.find('[name="sc2"]').val(),
259            sc3: form.find('[name="sc3"]').val(),
260            accountNumber: form.find('[name="accountNumber"]').val(),
261            bankName: form.find('[name="bankName"]').val(),
262            branchName: form.find('[name="branchName"]').val(),
263            amount: form.find('[name="amount"]').val()
264        }
265        var paymentDate, addressDetails;
266
267        var checkValid = function () {
268            var returnVal = true;
269            for (key in ddDetails) {
270                if (ddDetails.hasOwnProperty(key)) {
271                    if (key != 'branchName' && !ddDetails[key]) {
272                        returnVal = false;
273                        break;
274                    }
275                }
276                else {
277                    returnVal = false;
278                    break;
279                }
280            }
281            return returnVal;
282        };
283
284
285        if (checkValid()) {
286            paymentDate = {
287                paymentFrequency: form.find('[name="paymentFrequency"]').val(),
288                firstPaymentDay: form.find('[name="firstPaymentDay"]').val(),
289                firstPaymentMonth: form.find('[name="firstPaymentMonth"]').val(),
290                firstPaymentYear: form.find('[name="firstPaymentYear"]').val()
291            }
292            addressDetails = {
293                addressLine1: form.find('[name="addressLine1"]').val(),
294                addressLine2: form.find('[name="addressLine2"]').val(),
295                addressLine3: form.find('[name="addressLine3"]').val(),
296                city: form.find('[name="city"]').val(),
297                postalCode: form.find('[name="postalCode"]').val()
298            }
299
300            confDetails.find('.accountName dd').html(ddDetails.accountName);
301            confDetails.find('.address dd').html(
302                addressDetails.addressLine1 +
303                (addressDetails.addressLine2 ? ',' + addressDetails.addressLine2 : '') +
304                (addressDetails.addressLine3 ? ',' + addressDetails.addressLine3 : '') +
305                '<br />' + addressDetails.city + ' ' + addressDetails.postalCode);
306            confDetails.find('.bankName dd').html(ddDetails.bankName);
307            confDetails.find('.sortCode dd').html(ddDetails.sc1 + '-' + ddDetails.sc2 + '-' + ddDetails.sc3);
308            confDetails.find('.accountNumber dd').html(ddDetails.accountNumber);
309            confDetails.find('.amount dd').html('&pound;' + ddDetails.amount);
310            confDetails.find('.frequency dd').html(
311                paymentDate.paymentFrequency == 'M' ? 'monthly' :
312                    paymentDate.paymentFrequency == 'A' ? 'annually' :
313                        paymentDate.paymentFrequency == 'Q' ? 'quarterly' : '');
314            try {
315                confDetails.find('.firstPaymentDate dd').html(paymentDate.firstPaymentDay.padStart(2, 0) + '/' + paymentDate.firstPaymentMonth.padStart(2, 0) + '/' + paymentDate.firstPaymentYear);
316            }
317            catch (e) {
318                confDetails.find('.firstPaymentDate dd').html(paymentDate.firstPaymentDay + '/' + paymentDate.firstPaymentMonth + '/' + paymentDate.firstPaymentYear);
319            }
320
321            confDetails.removeClass('hidden');
322        }
323        else {
324            confDetails.addClass('hidden');
325        }
326    },
327    fnShowAccWarning: function () {
328
329        var fields = $('#sc1,#sc2,#sc3,#accountNumber');
330        fields.addClass('bank-validation-error');
331
332        if (!Crisis.util.showAccWarningStopPopUp) {
333
334            Crisis.UI.modalAlert('error validating bank account');
335            //alert('error validating bank account');
336        }
337        Crisis.util.showAccWarningStopPopUp = true;
338        //setTimeout(function () {
339        //    stopPop = false;
340        //}, 2000)
341    },
342    showAccWarningStopPopUp: false,
343    getAbsoluteUrl: (function () {
344        var a;
345
346        return function (url) {
347            if (!a) a = document.createElement('a');
348            a.href = url;
349
350            return a.href;
351        };
352    })(),
353    truncateString: function (str, length, addEllipsis) {
354
355        if (str.length <= length) return str;
356
357        var newStr = str.substr(0, str.lastIndexOf(' ', length));
358        newStr = newStr.replace(/[\:-\;\,\.]$/, '');
359
360        return newStr + (addEllipsis ? '...' : '');
361    },
362    // added by A Lafene 14/05/2018
363    throttle: function (func, wait, options) {
364        var context, args, result;
365        var timeout = null;
366        var previous = 0;
367
368        if (!options)
369            options = {};
370
371        var later = function () {
372            previous = options.leading === false ? 0 : (Date.now || function () { return new Date().getTime(); })();
373            timeout = null;
374            result = func.apply(context, args);
375            if (!timeout)
376                context = args = null;
377        };
378        return function () {
379            var now = (Date.now || function () { return new Date().getTime(); })();
380            if (!previous && options.leading === false)
381                previous = now;
382            var remaining = wait - (now - previous);
383            context = this;
384            args = arguments;
385
386            if (remaining <= 0 || remaining > wait) {
387                if (timeout) {
388                    clearTimeout(timeout);
389                    timeout = null;
390                }
391                previous = now;
392                result = func.apply(context, args);
393
394                if (!timeout)
395                    context = args = null;
396
397            } else if (!timeout && options.trailing !== false) {
398                timeout = setTimeout(later, remaining);
399            }
400            return result;
401        };
402    },
403    storageAvailable: function (type) {
404        try {
405            var storage = window[type],
406                x = '__storage_test__';
407            storage.setItem(x, x);
408            storage.removeItem(x);
409            return true;
410        }
411        catch (e) {
412            return false;
413        }
414    },
415    countryCodes: [
416        { key: 'GB', val: 'United Kingdom' }, { key: 'AF', val: 'Afghanistan' }, { key: 'AX', val: 'Åland Islands' }, { key: 'AL', val: 'Albania' }, { key: 'DZ', val: 'Algeria' }, { key: 'AS', val: 'American Samoa' }, { key: 'AD', val: 'Andorra' }, { key: 'AO', val: 'Angola' }, { key: 'AI', val: 'Anguilla' }, { key: 'AQ', val: 'Antarctica' }, { key: 'AG', val: 'Antigua and Barbuda' }, { key: 'AR', val: 'Argentina' }, { key: 'AM', val: 'Armenia' }, { key: 'AW', val: 'Aruba' }, { key: 'AU', val: 'Australia' }, { key: 'AT', val: 'Austria' }, { key: 'AZ', val: 'Azerbaijan' }, { key: 'BS', val: 'Bahamas' }, { key: 'BH', val: 'Bahrain' }, { key: 'BD', val: 'Bangladesh' }, { key: 'BB', val: 'Barbados' }, { key: 'BY', val: 'Belarus' }, { key: 'BE', val: 'Belgium' }, { key: 'BZ', val: 'Belize' }, { key: 'BJ', val: 'Benin' }, { key: 'BM', val: 'Bermuda' }, { key: 'BT', val: 'Bhutan' }, { key: 'BO', val: 'Bolivia, Plurinational State of' }, { key: 'BQ', val: 'Bonaire, Sint Eustatius and Saba' }, { key: 'BA', val: 'Bosnia and Herzegovina' }, { key: 'BW', val: 'Botswana' }, { key: 'BV', val: 'Bouvet Island' }, { key: 'BR', val: 'Brazil' }, { key: 'IO', val: 'British Indian Ocean Territory' }, { key: 'BN', val: 'Brunei Darussalam' }, { key: 'BG', val: 'Bulgaria' }, { key: 'BF', val: 'Burkina Faso' }, { key: 'BI', val: 'Burundi' }, { key: 'KH', val: 'Cambodia' }, { key: 'CM', val: 'Cameroon' }, { key: 'CA', val: 'Canada' }, { key: 'CV', val: 'Cape Verde' }, { key: 'KY', val: 'Cayman Islands' }, { key: 'CF', val: 'Central African Republic' }, { key: 'TD', val: 'Chad' }, { key: 'CL', val: 'Chile' }, { key: 'CN', val: 'China' }, { key: 'CX', val: 'Christmas Island' }, { key: 'CC', val: 'Cocos (Keeling) Islands' }, { key: 'CO', val: 'Colombia' }, { key: 'KM', val: 'Comoros' }, { key: 'CG', val: 'Congo' }, { key: 'CD', val: 'Congo, the Democratic Republic of the' }, { key: 'CK', val: 'Cook Islands' }, { key: 'CR', val: 'Costa Rica' }, { key: 'CI', val: 'Côte d\'Ivoire' }, { key: 'HR', val: 'Croatia' }, { key: 'CU', val: 'Cuba' }, { key: 'CW', val: 'Curaçao' }, { key: 'CY', val: 'Cyprus' }, { key: 'CZ', val: 'Czech Republic' }, { key: 'DK', val: 'Denmark' }, { key: 'DJ', val: 'Djibouti' }, { key: 'DM', val: 'Dominica' }, { key: 'DO', val: 'Dominican Republic' }, { key: 'EC', val: 'Ecuador' }, { key: 'EG', val: 'Egypt' }, { key: 'SV', val: 'El Salvador' }, { key: 'GQ', val: 'Equatorial Guinea' }, { key: 'ER', val: 'Eritrea' }, { key: 'EE', val: 'Estonia' }, { key: 'ET', val: 'Ethiopia' }, { key: 'FK', val: 'Falkland Islands (Malvinas)' }, { key: 'FO', val: 'Faroe Islands' }, { key: 'FJ', val: 'Fiji' }, { key: 'FI', val: 'Finland' }, { key: 'FR', val: 'France' }, { key: 'GF', val: 'French Guiana' }, { key: 'PF', val: 'French Polynesia' }, { key: 'TF', val: 'French Southern Territories' }, { key: 'GA', val: 'Gabon' }, { key: 'GM', val: 'Gambia' }, { key: 'GE', val: 'Georgia' }, { key: 'DE', val: 'Germany' }, { key: 'GH', val: 'Ghana' }, { key: 'GI', val: 'Gibraltar' }, { key: 'GR', val: 'Greece' }, { key: 'GL', val: 'Greenland' }, { key: 'GD', val: 'Grenada' }, { key: 'GP', val: 'Guadeloupe' }, { key: 'GU', val: 'Guam' }, { key: 'GT', val: 'Guatemala' }, { key: 'GG', val: 'Guernsey' }, { key: 'GN', val: 'Guinea' }, { key: 'GW', val: 'Guinea-Bissau' }, { key: 'GY', val: 'Guyana' }, { key: 'HT', val: 'Haiti' }, { key: 'HM', val: 'Heard Island and McDonald Islands' }, { key: 'VA', val: 'Holy See (Vatican City State)' }, { key: 'HN', val: 'Honduras' }, { key: 'HK', val: 'Hong Kong' }, { key: 'HU', val: 'Hungary' }, { key: 'IS', val: 'Iceland' }, { key: 'IN', val: 'India' }, { key: 'ID', val: 'Indonesia' }
416, { key: 'IR', val: 'Iran, Islamic Republic of' }, { key: 'IQ', val: 'Iraq' }, { key: 'IE', val: 'Ireland' }, { key: 'IM', val: 'Isle of Man' }, { key: 'IL', val: 'Israel' }, { key: 'IT', val: 'Italy' }, { key: 'JM', val: 'Jamaica' }, { key: 'JP', val: 'Japan' }, { key: 'JE', val: 'Jersey' }, { key: 'JO', val: 'Jordan' }, { key: 'KZ', val: 'Kazakhstan' }, { key: 'KE', val: 'Kenya' }, { key: 'KI', val: 'Kiribati' }, { key: 'KP', val: 'Korea, Democratic People\'s Republic of' }, { key: 'KR', val: 'Korea, Republic of' }, { key: 'KW', val: 'Kuwait' }, { key: 'KG', val: 'Kyrgyzstan' }, { key: 'LA', val: 'Lao People\'s Democratic Republic' }, { key: 'LV', val: 'Latvia' }, { key: 'LB', val: 'Lebanon' }, { key: 'LS', val: 'Lesotho' }, { key: 'LR', val: 'Liberia' }, { key: 'LY', val: 'Libya' }, { key: 'LI', val: 'Liechtenstein' }, { key: 'LT', val: 'Lithuania' }, { key: 'LU', val: 'Luxembourg' }, { key: 'MO', val: 'Macao' }, { key: 'MK', val: 'Macedonia, the former Yugoslav Republic of' }, { key: 'MG', val: 'Madagascar' }, { key: 'MW', val: 'Malawi' }, { key: 'MY', val: 'Malaysia' }, { key: 'MV', val: 'Maldives' }, { key: 'ML', val: 'Mali' }, { key: 'MT', val: 'Malta' }, { key: 'MH', val: 'Marshall Islands' }, { key: 'MQ', val: 'Martinique' }, { key: 'MR', val: 'Mauritania' }, { key: 'MU', val: 'Mauritius' }, { key: 'YT', val: 'Mayotte' }, { key: 'MX', val: 'Mexico' }, { key: 'FM', val: 'Micronesia, Federated States of' }, { key: 'MD', val: 'Moldova, Republic of' }, { key: 'MC', val: 'Monaco' }, { key: 'MN', val: 'Mongolia' }, { key: 'ME', val: 'Montenegro' }, { key: 'MS', val: 'Montserrat' }, { key: 'MA', val: 'Morocco' }, { key: 'MZ', val: 'Mozambique' }, { key: 'MM', val: 'Myanmar' }, { key: 'NA', val: 'Namibia' }, { key: 'NR', val: 'Nauru' }, { key: 'NP', val: 'Nepal' }, { key: 'NL', val: 'Netherlands' }, { key: 'NC', val: 'New Caledonia' }, { key: 'NZ', val: 'New Zealand' }, { key: 'NI', val: 'Nicaragua' }, { key: 'NE', val: 'Niger' }, { key: 'NG', val: 'Nigeria' }, { key: 'NU', val: 'Niue' }, { key: 'NF', val: 'Norfolk Island' }, { key: 'MP', val: 'Northern Mariana Islands' }, { key: 'NO', val: 'Norway' }, { key: 'OM', val: 'Oman' }, { key: 'PK', val: 'Pakistan' }, { key: 'PW', val: 'Palau' }, { key: 'PS', val: 'Palestinian Territory, Occupied' }, { key: 'PA', val: 'Panama' }, { key: 'PG', val: 'Papua New Guinea' }, { key: 'PY', val: 'Paraguay' }, { key: 'PE', val: 'Peru' }, { key: 'PH', val: 'Philippines' }, { key: 'PN', val: 'Pitcairn' }, { key: 'PL', val: 'Poland' }, { key: 'PT', val: 'Portugal' }, { key: 'PR', val: 'Puerto Rico' }, { key: 'QA', val: 'Qatar' }, { key: 'RE', val: 'Réunion' }, { key: 'RO', val: 'Romania' }, { key: 'RU', val: 'Russian Federation' }, { key: 'RW', val: 'Rwanda' }, { key: 'BL', val: 'Saint Barthélemy' }, { key: 'SH', val: 'Saint Helena, Ascension and Tristan da Cunha' }, { key: 'KN', val: 'Saint Kitts and Nevis' }, { key: 'LC', val: 'Saint Lucia' }, { key: 'MF', val: 'Saint Martin (French part)' }, { key: 'PM', val: 'Saint Pierre and Miquelon' }, { key: 'VC', val: 'Saint Vincent and the Grenadines' }, { key: 'WS', val: 'Samoa' }, { key: 'SM', val: 'San Marino' }, { key: 'ST', val: 'Sao Tome and Principe' }, { key: 'SA', val: 'Saudi Arabia' }, { key: 'SN', val: 'Senegal' }, { key: 'RS', val: 'Serbia' }, { key: 'SC', val: 'Seychelles' }, { key: 'SL', val: 'Sierra Leone' }, { key: 'SG', val: 'Singapore' }, { key: 'SX', val: 'Sint Maarten (Dutch part)' }, { key: 'SK', val: 'Slovakia' }, { key: 'SI', val: 'Slovenia' }, { key: 'SB', val: 'Solomon Islands' }, { key: 'SO', val: 'Somalia' }, { key: 'ZA', val: 'South Africa' }, { key: 'GS', val: 'South Georgia and the South Sandwich Islands' }, { key: 'SS', val: 'South Sudan' }, { key: 'ES', val: 'Spain' }, { key: 'LK', val: 'Sri Lanka' }, { key: 'SD', val: 'Sudan' }, { key: 'SR', val: 'Suriname' }, { key: 'SJ', val: 'Svalbard and Jan Mayen' }, { key: 'SZ', val: 'Swaziland' }, { key: 'SE', val: 'Sweden' }, { key: 'CH', val: 'Switzerland' }, { key: 'SY', val: 'Syrian Arab Republic' }, { key: 'TW', val: 'Taiwan, Province of China' }, { key: 'TJ', val: 'Tajikistan' }, { key: 'TZ', val: 'Tanzania, United Republic of' }, { key: 'TH', val: 'Thailand' }, { key: 'TL', val: 'Timor-Leste' }, { key: 'TG', val: 'Togo' }, { key: 'TK', val: 'Tokelau' }, { key: 'TO', val: 'Tonga' }, { key: 'TT', val: 'Trinidad and Tobago' }, { key: 'TN', val: 'Tunisia' }, { key: 'TR', val: 'Turkey' }, { key: 'TM', val: 'Turkmenistan' }, { key: 'TC', val: 'Turks and Caicos Islands' }, { key: 'TV', val: 'Tuvalu' }, { key: 'UG', val: 'Uganda' }, { key: 'UA', val: 'Ukraine' }, { key: 'AE', val: 'United Arab Emirates' }, { key: 'US', val: 'United States' }, { key: 'UM', val: 'United States Minor Outlying Islands' }, { key: 'UY', val: 'Uruguay' }, { key: 'UZ', val: 'Uzbekistan' }, { key: 'VU', val: 'Vanuatu' }, { key: 'VE', val: 'Venezuela, Bolivarian Republic of' }, { key: 'VN', val: 'Viet Nam' }, { key: 'VG', val: 'Virgin Islands, British' }, { key: 'VI', val: 'Virgin Islands, U.S.' }, { key: 'WF', val: 'Wallis and Futuna' }, { key: 'EH', val: 'Western Sahara' }, { key: 'YE', val: 'Yemen' }, { key: 'ZM', val: 'Zambia' }, { key: 'ZW', val: 'Zimbabwe' }
417    ],
418    getCountryCode : function (s) {
419        var countryName = s.toLowerCase();
420
421        if (!s || countryName == 'united kingdom')
422            return 'GB';
423
424        for (var i = 0; i <= Crisis.util.countryCodes.length; i++) {
425            if (Crisis.util.countryCodes[i].val.toLowerCase() == countryName) {
426                return Crisis.util.countryCodes[i].key;
427            }
428        }
429    },
430    cookies: {
431        set: function (cname, cvalue, exdays) {
432            var d = new Date();
433            d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
434            var expires = "expires=" + d.toUTCString();
435            document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
436        },
437        get: function (cname) {
438            var name = cname + "=";
439            var decodedCookie = decodeURIComponent(document.cookie);
440            var ca = decodedCookie.split(';');
441            for (var i = 0; i < ca.length; i++) {
442                var c = ca[i];
443                while (c.charAt(0) == ' ') {
444                    c = c.substring(1);
445                }
446                if (c.indexOf(name) == 0) {
447                    return c.substring(name.length, c.length);
448                }
449            }
450            return "";
451        },
452        getCookieConsentPrefs: function () {
453            var optAnonConsentStr = Crisis.util.cookies.get('OptanonConsent');
454            var returnVal = {};
455
456            // For local testing:
457            // optAnonConsentStr = 'consentId=d65fd170-4d1a-4c96-ade3-d2385c1fc4ef&datestamp=Thu+May+20+2021+10%3A40%3A10+GMT%2B0100+(British+Summer+Time)&version=6.8.0&interactionCount=4&isIABGlobal=false&hosts=&landingPath=NotLandingPage&groups=C0001%3A1%2CC0002%3A1%2CC0003%3A0%2CC0004%3A1%2CSTACK42%3A1&geolocation=%3B&AwaitingReconsent=false';
458
459            var optAnonParams = optAnonConsentStr.split('&');
460
461            for (var i = 0; i < optAnonParams.length; i++) {
462
463                var param = optAnonParams[i].split('=');
464
465                if (param[0].toLowerCase() == 'groups') {
466
467                    var groups = decodeURIComponent(param[1]).split(',');
468
469                    for (var ii = 0; ii < groups.length; ii++) {
470                        var group = groups[ii].split(':');
471                        returnVal[group[0]] = group[1] == '1' ? true : false;
472                    }
473
474                    break;
475                }
476            }
477
478            if (!Object.keys(returnVal).length)
479                returnVal = null;
480
481            return returnVal;
482
483        }
484    },
485    MD5: function (e) {
486        function n(g, h) { var l = g & 2147483648; var k = h & 2147483648; var p = g & 1073741824; var q = h & 1073741824; var m = (g & 1073741823) + (h & 1073741823); return p & q ? m ^ 2147483648 ^ l ^ k : p | q ? m & 1073741824 ? m ^ 3221225472 ^ l ^ k : m ^ 1073741824 ^ l ^ k : m ^ l ^ k } function r(g, h, l, k, p, q, m) { g = n(g, n(n(h & l | ~h & k, p), m)); return n(g << q | g >>> 32 - q, h) } function t(g, h, l, k, p, q, m) { g = n(g, n(n(h & k | l & ~k, p), m)); return n(g << q | g >>> 32 - q, h) } function u(g, h, l, k, p, q, m) { g = n(g, n(n(h ^ l ^ k, p), m)); return n(g << q | g >>> 32 - q, h) } function v(g, h, l, k, p, q, m) {
487            g = n(g, n(n(l ^
488                (h | ~k), p), m)); return n(g << q | g >>> 32 - q, h)
489        } function w(g) { var h = "", l; for (l = 0; 3 >= l; l++) { var k = g >>> 8 * l & 255; k = "0" + k.toString(16); h += k.substr(k.length - 2, 2) } return h } var f = []; e = function (g) { g = g.replace(/\r\n/g, "\n"); for (var h = "", l = 0; l < g.length; l++) { var k = g.charCodeAt(l); 128 > k ? h += String.fromCharCode(k) : (127 < k && 2048 > k ? h += String.fromCharCode(k >> 6 | 192) : (h += String.fromCharCode(k >> 12 | 224), h += String.fromCharCode(k >> 6 & 63 | 128)), h += String.fromCharCode(k & 63 | 128)) } return h }(e); f = function (g) {
490            var h = g.length; var l = h + 8; for (var k =
491                16 * ((l - l % 64) / 64 + 1), p = Array(k - 1), q, m = 0; m < h;)l = (m - m % 4) / 4, q = m % 4 * 8, p[l] |= g.charCodeAt(m) << q, m++; l = (m - m % 4) / 4; p[l] |= 128 << m % 4 * 8; p[k - 2] = h << 3; p[k - 1] = h >>> 29; return p
492        }(e); var a = 1732584193; var b = 4023233417; var c = 2562383102; var d = 271733878; for (e = 0; e < f.length; e += 16) {
493            var x = a; var y = b; var z = c; var A = d; a = r(a, b, c, d, f[e + 0], 7, 3614090360); d = r(d, a, b, c, f[e + 1], 12, 3905402710); c = r(c, d, a, b, f[e + 2], 17, 606105819); b = r(b, c, d, a, f[e + 3], 22, 3250441966); a = r(a, b, c, d, f[e + 4], 7, 4118548399); d = r(d, a, b, c, f[e + 5], 12, 1200080426); c = r(c, d, a, b, f[e +
494            6], 17, 2821735955); b = r(b, c, d, a, f[e + 7], 22, 4249261313); a = r(a, b, c, d, f[e + 8], 7, 1770035416); d = r(d, a, b, c, f[e + 9], 12, 2336552879); c = r(c, d, a, b, f[e + 10], 17, 4294925233); b = r(b, c, d, a, f[e + 11], 22, 2304563134); a = r(a, b, c, d, f[e + 12], 7, 1804603682); d = r(d, a, b, c, f[e + 13], 12, 4254626195); c = r(c, d, a, b, f[e + 14], 17, 2792965006);
494 b = r(b, c, d, a, f[e + 15], 22, 1236535329); a = t(a, b, c, d, f[e + 1], 5, 4129170786); d = t(d, a, b, c, f[e + 6], 9, 3225465664); c = t(c, d, a, b, f[e + 11], 14, 643717713); b = t(b, c, d, a, f[e + 0], 20, 3921069994); a = t(a, b, c, d, f[e + 5], 5, 3593408605); d = t(d,
495                a, b, c, f[e + 10], 9, 38016083); c = t(c, d, a, b, f[e + 15], 14, 3634488961); b = t(b, c, d, a, f[e + 4], 20, 3889429448); a = t(a, b, c, d, f[e + 9], 5, 568446438); d = t(d, a, b, c, f[e + 14], 9, 3275163606); c = t(c, d, a, b, f[e + 3], 14, 4107603335); b = t(b, c, d, a, f[e + 8], 20, 1163531501); a = t(a, b, c, d, f[e + 13], 5, 2850285829); d = t(d, a, b, c, f[e + 2], 9, 4243563512); c = t(c, d, a, b, f[e + 7], 14, 1735328473); b = t(b, c, d, a, f[e + 12], 20, 2368359562); a = u(a, b, c, d, f[e + 5], 4, 4294588738); d = u(d, a, b, c, f[e + 8], 11, 2272392833); c = u(c, d, a, b, f[e + 11], 16, 1839030562); b = u(b, c, d, a, f[e + 14], 23, 4259657740);
496            a = u(a, b, c, d, f[e + 1], 4, 2763975236); d = u(d, a, b, c, f[e + 4], 11, 1272893353); c = u(c, d, a, b, f[e + 7], 16, 4139469664); b = u(b, c, d, a, f[e + 10], 23, 3200236656); a = u(a, b, c, d, f[e + 13], 4, 681279174); d = u(d, a, b, c, f[e + 0], 11, 3936430074); c = u(c, d, a, b, f[e + 3], 16, 3572445317); b = u(b, c, d, a, f[e + 6], 23, 76029189); a = u(a, b, c, d, f[e + 9], 4, 3654602809); d = u(d, a, b, c, f[e + 12], 11, 3873151461); c = u(c, d, a, b, f[e + 15], 16, 530742520); b = u(b, c, d, a, f[e + 2], 23, 3299628645); a = v(a, b, c, d, f[e + 0], 6, 4096336452); d = v(d, a, b, c, f[e + 7], 10, 1126891415); c = v(c, d, a, b, f[e + 14], 15, 2878612391);
497            b = v(b, c, d, a, f[e + 5], 21, 4237533241); a = v(a, b, c, d, f[e + 12], 6, 1700485571); d = v(d, a, b, c, f[e + 3], 10, 2399980690); c = v(c, d, a, b, f[e + 10], 15, 4293915773); b = v(b, c, d, a, f[e + 1], 21, 2240044497); a = v(a, b, c, d, f[e + 8], 6, 1873313359); d = v(d, a, b, c, f[e + 15], 10, 4264355552); c = v(c, d, a, b, f[e + 6], 15, 2734768916); b = v(b, c, d, a, f[e + 13], 21, 1309151649); a = v(a, b, c, d, f[e + 4], 6, 4149444226); d = v(d, a, b, c, f[e + 11], 10, 3174756917); c = v(c, d, a, b, f[e + 2], 15, 718787259); b = v(b, c, d, a, f[e + 9], 21, 3951481745); a = n(a, x); b = n(b, y); c = n(c, z); d = n(d, A)
498        } return (w(a) + w(b) + w(c) +
499            w(d)).toLowerCase()
500    },
501    isDevHost: (window.location.hostname.indexOf('localhost') != -1 || window.location.hostname.indexOf('umbraco-dev') != -1),
502    isMobileDevice: /(iPad)|(iPhone)|(iPod)|(Android)|(PlayBook)|(BB10)|(BlackBerry)|(Opera Mini)|(IEMobile)|(webOS)|(MeeGo)/i.test(navigator.userAgent)
503}
504
505Crisis.UI = {
506    elements: {
507        scrollingBodyElement: $('html,body'),
508        offCanvas: $('body > div.off-canvas'),
509        document: $(document),
510        documentBody: $('body'),
511        documentHead: $('head'),
512        donationModal: $('.donation-form-modal-wrapper'),
513        window: $(window),
514        navHeight: 148,
515        navShrinkHeight: 107
516    },
517    touchEnabled: (document.addEventListener && 'ontouchstart' in document.documentElement) ? true : false,
518    scrollToElement: function (jqObj, offset) {
519        var _this = this;
520        var position = jqObj.offset().top;
521        var navOffset = _this.elements.offCanvas.is(':visible') ? 0 :
522            position < 200 ? 150 :
523                109;
524        var offset = navOffset + (offset || 0);
525
526        _this.elements.scrollingBodyElement.animate({ scrollTop: (jqObj.offset().top - offset) }, 'slow');
527    },
528    pageScrollAction: function () {
529        if (Crisis.UI.elements.document.scrollTop() > 100) {
530            $('nav').not('.force-shrink').addClass('shrink');
531            Crisis.UI.elements.documentBody.addClass('nav-shrink');
532        } else {
533            $('nav').not('.force-shrink').removeClass('shrink');
534            Crisis.UI.elements.documentBody.removeClass('nav-shrink');
535        }
536
537        if (Crisis.UI.elements.document.scrollTop() > 200) {
538            $('a.scroll').show('fade');
539        } else {
540            $('a.scroll').hide('fade');
541        }
542    },
543    modalHtml: function (options) {
544
545        var id = options.id;
546        var html = options.html;
547
548        if (id && html) {
549            $('<div class="modal fade" id="' + id + '" tabindex="-1" role="dialog" aria-hidden="true">' +
550                '<div class="modal-dialog" role="document">' +
551                '<div class="modal-content">' +
552                '<div class="modal-header">' +
553                '<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>' +
554                '</div>' +
555                '<div class="modal-body">' +
556                '<div class="inner">' +
557                html +
558                '</div>' +
559                '</div>' +
560                '</div>' +
561                '</div>' +
562                '</div>').modal();
563        }
564
565    },
566    modalAlert: function (msg) {
567        $('<div class="modal fade" id="modal-alert" tabindex="-1" role="dialog" aria-hidden="true">' +
568            '<div class="modal-dialog" role="document">' +
569            '<div class="modal-content">' +
570            '<div class="modal-header">' +
571            '<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>' +
572            '</div>' +
573            '<div class="modal-body">' +
574            '<div class="inner">' +
575            '<h5 class="mb-30 mt-10">' + msg + '</h5>' +
576            '<a class="mb-15 btn btn-red-s btn-wd" href="#" data-dismiss="modal" aria-label="Close">OK</a>' +
577            '</div>' +
578            '</div>' +
579            '</div>' +
580            '</div>' +
581            '</div>').modal();
582
583    },
584    infiniteScroll: {
585        container: null,
586        items: null,
587        showInterval: null,
588        scrollFunction: null,
589        resizeFunction: null,
590        moreLink: null,
591        moreLinkItemsLeft: null,
592        windowInnerWidth: window.innerWidth,
593        setItemHeights: function () {
594            var _this = this;
595
596            _this.items.each(function () {
597                var $this = $(this).addClass('get-height');
598                this.style.height = "";
599                $this.css('height', $this.innerHeight());
600                $this.removeClass('get-height');
601            });
602        },
603        init: function ($container, $items, show) {
604            var _this = this;
605            var contentItems;
606            var visibleHeadings = $items.filter(':lt(' + show + ')').filter('h2');
607            var usingKeyboard = false;
608
609            window.removeEventListener('scroll', _this.scrollfunction);
610
611            _this.scrollfunction = Crisis.util.debounce(function () {
612                _this.showItems();
613
614            }, 0);
615
616            _this.items = $items;
617            _this.setItemHeights();
618
619            _this.container = $container;
620
621            _this.items.removeClass('infinite-scroller-hidden hidden').filter(':gt(' + ((show + visibleHeadings.length) - 1) + ')').addClass('infinite-scroller-hidden hidden');
622
623            contentItems = _this.items.filter('div.infinite-scroller-hidden');
624
625            if (_this.moreLink) {
626                _this.moreLink.remove();
627                _this.moreLink = "";
628            }
629            if (_this.moreLinkScroller) {
630                _this.moreLinkScroller.remove();
631                _this.moreLinkScroller = "";
632            }
633
634            //if (contentItems.length <= show) {
635            //    _this.items.removeClass('infinite-scroller-hidden');
636            //    console.log('yes');
637            //    return;
638            //}
639
640            _this.moreLink = $('<p class="more-link"><a href="#" class="btn btn-red-s btn-wd">Load ' + contentItems.length + ' more</a></p>');
641            _this.moreLinkScroller = $('<p class="more-link hidden clearfix"><i class="fa fa-angle-double-down"></i><strong><span>' + contentItems.length + '</span></p>');
642
643            if (contentItems.length > 0) {
644                _this.container.append(_this.moreLinkScroller);
645                contentItems.first().before(_this.moreLink);
646
647                _this.moreLink.css('height', _this.moreLink.innerHeight()).on('click', 'a', function (e) {
648                    e.preventDefault();
649                    _this.moreLink.hide();
650
651                    if (usingKeyboard) {
652                        contentItems.removeClass('infinite-scroller-hidden hidden');
653                    }
654                    else {
655                        if (_this.moreLinkScroller.hasClass('scrolling'))
656                            return;
657
658                        _this.moreLinkScroller.addClass('scrolling').removeClass('hidden');
659                        _this.moreLinkItemsLeft = _this.moreLinkScroller.find('span');
660                        _this.showItems(3);
661                        window.addEventListener('scroll', _this.scrollfunction);
662                    }
663
664                }).on('keydown', 'a', function (e) { 
665                    var charCode = (e.which) ? e.which : e.keyCode;
666                    if (charCode == 13)
667                        usingKeyboard = true;
668                });
669            }
670
671            window.addEventListener('resize', Crisis.util.debounce(function () {
672                if (_this.windowInnerWidth != window.innerWidth) {
673                    _this.setItemHeights();
674                    _this.windowInnerWidth = window.innerWidth;
675                }
676
677            }, 500));
678
679        },
680        destroy: function ($items) {
681
682            var _this = this;
683
684            window.removeEventListener('scroll', _this.scrollfunction);
685
686            _this.items = $items;
687
688            _this.items.removeClass('infinite-scroller-hidden hidden');
689            _this.moreLink.remove();
690            _this.moreLink = "";
691            _this.moreLinkScroller.remove();
692            _this.moreLinkScroller = "";
693
694        },
695        showItems: function (num) {
696
697            var _this = this;
698            var i = 0;
699
700            if (_this.showInterval)
701                return;
702
703            _this.showInterval = setInterval(function () {
704
705                var bottom = _this.container.offset().top + _this.container.height();
706                var scrollBottom = $(document).scrollTop() + window.innerHeight;
707                var hiddenItems = _this.items.filter('.infinite-scroller-hidden').removeClass('hidden');
708                var contentItems = hiddenItems.filter('div');
709                var item;
710
711                _this.moreLinkItemsLeft.text(contentItems.length);
712
713                if (hiddenItems.length < 1) {
714                    window.removeEventListener('scroll', _this.scrollfunction);
715                }
716                else if (scrollBottom > bottom + 150 || (num && i < num)) {
717                    if (hiddenItems.length == 1 && _this.moreLinkScroller) {
718                        _this.moreLinkScroller.addClass('invisible');
719                    }
720
721                    item = hiddenItems.eq(0);
722                    setTimeout(function () {
723                        item.removeClass('infinite-scroller-hidden');
724                    }, 50);
725
726                    if (item.prop('tagName').toLowerCase() == 'div')
727                        i++
728
729                    return;
730                }
731
732                clearInterval(_this.showInterval);
733                _this.showInterval = "";
734
735            }, 150);
736        }
737    },
738    heroVideo: {
739
740        btnTogglePlay: null,
741        btnToggleMute: null,
742        btnVolumeUp: null,
743        btnVolumeDown: null,
744        hasTouchEvents: null,
745        controls: null,
746        videoElement: null,
747        videoJqElement: null,
748        volumeBar: null,
749        volumeTimeout: null,
750        volumeIvl: null,
751        subTrack: null,
752        subTrackDomContainer: null,
753
754        init: function (jqObj, vol) {
755
756            if (!jqObj || jqObj.length != 1) {
757                console.log('no video specified');
758                return false;
759            }
760            var _this = this;
761            var vol = vol || 1;
762
763            _this.videoJqElement = jqObj;
764            _this.videoElement = jqObj[0];
765
766            if (_this.videoElement.muted)
767                _this.videoElement.volume = 0;
768            else
769                _this.videoElement.volume = vol;
770
771            if (_this.videoElement.autoplay) {
772                var ivl = setInterval(function () {
773                    if (!_this.videoElement.paused) {
774                        _this.initControls();
775                        clearInterval(ivl);
776                    }
777                }, 100);
778            }
779            else {
780                setTimeout(function () {
781                    _this.initControls();
782                }, 1000);
783            }
784
785            // Subtitles
786            if (_this.videoElement.textTracks.length > 0) {
787                _this.subTrack = _this.videoElement.textTracks[0];
788
789                _this.subTrackDomContainer = $('<div class="subs"><span></span><span></span></div>');
790                _this.videoJqElement.after(_this.subTrackDomContainer);
791                _this.subTrack.mode = 'hidden';
792
793                (function () {
794                    var i = 0;
795                    var spans = _this.subTrackDomContainer.find('span');
796                    _this.subTrack.oncuechange = function () {
797
798                        var cue = this.activeCues[0];
799
800                        if (cue) {
801                            spans.eq(i).removeClass('out').addClass('in').html(cue.getCueAsHTML());
802
803                            i = ++i % 2;
804
805                            spans.eq(i).removeClass('in').addClass('out');
806                            //setTimeout(function () {
807                            //    spans[i].removeClass('out');
808                            //}, 500);
809                        }
810                        else {
811                            spans.removeClass('in out');
812                        }
813                    }
814                })();
815            }
816
817        },
818        initControls: function () {
819
820            var _this = this;
821            var volumeBarWrapper = $('<li class="volume-bar-wrapper" />');
822
823            _this.controls = $('<ul class="controls" />');
824
825            _this.btnTogglePlay = $('<li class="play-pause ' + (!_this.videoElement.paused ? 'playing' : 'paused') + '" />')
826                .html('<i class="fa fa-play"><span class="hidden-accessible">Play</span></i>' +
827                    '<i class="fa fa-pause"><span class="hidden-accessible">Pause</span></i>');
828
829            _this.btnToggleMute = $('<li class="sound ' + (!_this.videoElement.muted ? 'unmuted' : 'muted') + '" />')
830                .html('<i class="fa fa-volume-off"><span class="hidden-accessible">Mute</span></i>' +
831                    '<i class="fa fa-volume-up"><span class="hidden-accessible">Unmute</span></i>');
832
833            _this.btnVolumeUp = $('<li class="volume-control volume-up" />')
834                .html('<i class="fa fa-volume-up"><span class="hidden-accessible">Volume up</span></i>');
835
836            _this.btnVolumeDown = $('<li class="volume-control volume-down' + (_this.videoElement.muted ? ' muted' : '') + '" />')
837                .html('<i class="fa fa-volume-down"><span class="hidden-accessible">Volume down</span></i>' +
838                    '<i class="fa fa-volume-off"><span class="hidden-accessible">Volume down</span></i>');
839
840            _this.volumeBar = $('<div class="volume-bar" style="height: ' + _this.videoElement.volume * 100 + '%" />');
841
842            _this.videoJqElement
843                .after(_this.controls
844                    .append(_this.btnTogglePlay)
845                    .append(_this.btnVolumeUp)
846                    .append(volumeBarWrapper.append(_this.volumeBar))
847                    .append(_this.btnVolumeDown)
848                );
849
850            _this.controls
851                .on('click', 'li', function (e) {
852
853                    var $this = $(this);
854
855                    if ($this.hasClass('play-pause')) {
856                        if (_this.videoElement.paused) {
857                            _this.play();
858                        }
859                        else {
860                            _this.pause();
861                        }
862                    }
863                    else if ($this.hasClass('volume-bar-wrapper')) {
864                        var pos = Math.round(e.offsetY / ($this.outerHeight() / 100));
865                        if (!isNaN(pos)) {
866                            _this.setVolume(pos);
867                        }
868                    }
869                })
870                .on('mousedown touchstart', '.volume-control', function () {
871
872                    var $this = $(this);
873
874                    if ($this.hasClass('volume-up')) {
875                        _this.volumeUp();
876                        _this.volumeTimeout = setTimeout(function () {
877                            _this.volumeIvl = setInterval(function () {
878                                _this.volumeUp();
879                            }, 50);
880                        }, 500);
881                    }
882                    else if ($this.hasClass('volume-down')) {
883                        _this.volumeDown();
884                        _this.volumeTimeout = setTimeout(function () {
885                            _this.volumeIvl = setInterval(function () {
886                                _this.volumeDown();
887                            }, 50);
888                        }, 500);
889                    }
890                })
891                .on('mouseup touchend', '.volume-control', function () {
892                    clearInterval(_this.volumeIvl);
893                    clearTimeout(_this.volumeTimeout);
894                    _this.volumeIvl = null;
895                    _this.volumeTimeout = null;
896                });
897        },
898        play: function () {
899            var _this = this;
900            _this.videoJqElement.removeClass('paused');
901            _this.videoElement.play();
902            _this.btnTogglePlay.removeClass('paused').addClass('playing');
903        },
904        pause: function () {
905            var _this = this;
906            _this.videoJqElement.addClass('paused');
907            _this.videoElement.pause();
908            _this.btnTogglePlay.removeClass('playing').addClass('paused');
909        },
910        volumeUp: function () {
911            var _this = this;
912            var vol = _this.videoElement.volume;
913            if (vol < 1) {
914                _this.videoElement.muted = false;
915                _this.btnVolumeDown.removeClass('muted');
916                _this.videoElement.volume = (vol + 0.1).toFixed(1);
917                //if (_this.subTrackDomContainer.length)
918                //    _this.subTrackDomContainer.addClass('opacity-hide');
919            }
920            else {
921                return;
922            }
923            _this.volumeBar[0].style.height = _this.videoElement.volume * 100 + '%';
924        },
925        volumeDown: function () {
926            var _this = this;
927            var vol = _this.videoElement.volume;
928            if (vol > 0) {
929                _this.videoElement.volume = (vol - 0.1).toFixed(1);
930                if (vol === 0.1) {
931                    _this.videoElement.muted = true;
932                    _this.btnVolumeDown.addClass('muted');
933                    //if (_this.subTrackDomContainer.length)
934                    //    _this.subTrackDomContainer.removeClass('opacity-hide');
935                }
936            }
937            else {
938                return
939            }
940            _this.volumeBar[0].style.height = _this.videoElement.volume * 100 + '%';
941        },
942        setVolume: function (val) {
943            var _this = this;
944            if (!val)
945                return;
946            _this.videoElement.volume = (val / 100).toFixed(1);
947            _this.volumeBar[0].style.height = _this.videoElement.volume * 100 + '%';
948
949            if (_this.videoElement.volume > 0) {
950                _this.videoElement.muted = false;
951                _this.btnVolumeDown.removeClass('muted');
952                //if (_this.subTrackDomContainer.length)
953                //    _this.subTrackDomContainer.addClass('opacity-hide');
954            }
955            else {
956                _this.videoElement.muted = true;
957                _this.btnVolumeDown.addClass('muted');
958                //if (_this.subTrackDomContainer.length)
959                //    _this.subTrackDomContainer.removeClass('opacity-hide');
960
961            }
962        }
963    }
964}
965
966Crisis.UI.elements.document.ready(function () {
967
968    var shiftWindow = function () { scrollBy(0, -120); };
969    if (location.hash) shiftWindow();
970    window.addEventListener("hashchange", shiftWindow);
971
972    $('#btnApplyFilters').on('click', function (evt) {
973        evt.preventDefault();
974        $('#scrollLoadChecker').attr('data-pageidx', 0);
975        loadMoreArticles(0, true);
976    });
977
978    if ($('#cntSubject').length) {
979        Crisis.util.setupContactForm();
980    }
981
982    $('.btn-share-gp').on('click', function (evt) {
983        evt.preventDefault();
984        window.open(this.href, '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=600,width=600');
985    });
986
987    if ($('#lstSkylightPicker').length) {
988        $('#lstSkylightPicker').on('change', function (evt) {
989            //$('#btnSkylightSelected').on('click', function (evt) {
990            evt.preventDefault();
991            var v = $('#lstSkylightPicker option:selected').attr('data-url');
992            if (v) {
993                window.location.href = v;
994            }
995        });
996    }
997
998    var fnApplyTimetableFilters = function () {
999        var selectedFilters = $('.classtypefilter:checked').map(function (idx, e) {
1000            return $(e).attr('data-classtypeid');
1001        }).get();
1002
1003        var selectedAtFilters = $('.classattrfilter:checked').map(function (idx, e) {
1004            return $(e).attr('data-classatt');
1005        }).get();
1006
1007
1008        $('.tt-activity').hide();
1009
1010        var baseFilter = '.tt-activity[data-classtypeid="' + selectedFilters.join('"],[data-classtypeid="') + '"]';
1011        var $set = $(baseFilter);
1012
1013        if ($('#ttFltVenue').length || $('#ttFltArea').val() != '') {
1014            var selectedAreaFilter = $('#ttFltArea').val();
1015            var selectedVenueFilter = $('#ttFltVenueContainer').is(':visible') ? $('#ttFltVenue').val() : '';
1016
1017            if (selectedVenueFilter != '') {
1018                var newFilter = '[data-venueid="' + selectedVenueFilter + '"]';
1019                $set = $set.filter(newFilter);
1020            } else if (selectedAreaFilter != '' && typeof selectedAreaFilter !== 'undefined') {
1021                var combinedVenuFilters = $.map($('#ttFltVenue').find('option'), function (ele, idx) {
1022                    if ($(ele).attr('data-areaid') == selectedAreaFilter) {
1023                        return $(ele).val();
1024                    }
1025                });
1026                var newFilter = '[data-venueid="' + combinedVenuFilters.join('"],[data-venueid="') + '"]';
1027                $set = $set.filter(newFilter);
1028            }
1029        }
1030
1031        if (selectedAtFilters.length) {
1032            var f = '[data-att-' + selectedAtFilters.join('],[data-att-') + ']';
1033            $set = $set.filter(f);
1034        }
1035
1036        $set.show();
1037
1038        //update download link
1039        var dlLink = $('a[data-rooturl]').eq(0);
1040        var fullUrl = dlLink.attr('data-rooturl');
1041
1042        if (selectedFilters.length) {
1043            fullUrl = fullUrl + '&classTypeFilter=' + selectedFilters.join(',');
1044        }
1045
1046        if (selectedAtFilters.length) {
1047            fullUrl = fullUrl + '&classAttributeFilter=' + selectedAtFilters.join(',');
1048        }
1049
1050        dlLink.attr('href', fullUrl);
1051    };
1052
1053    if ($('.classtypefilter').length) {
1054        $('.classtypefilter').on('change', function (evt) {
1055            var srcElement = $(evt.target);
1056            var altElement = $('.classtypefilter[data-classtypeid="' + srcElement.attr('data-classtypeid') + '"]').not(srcElement);
1057
1058            console.log(altElement);
1059
1060            if (srcElement.is(':checked')) {
1061                altElement.prop('checked', true);
1062            } else {
1063                altElement.prop('checked', false);
1064            }
1065
1066            fnApplyTimetableFilters();
1067        });
1068
1069        $('#ttCtrlChangeWeek').on('change', function (evt) {
1070            window.location.href = $('#ttCtrlChangeWeek').attr('data-baseurl') + '?tdd=' + $('#ttCtrlChangeWeek').val();
1071        });
1072    }
1073
1074    if ($('.classattrfilter').length) {
1075        $('.classattrfilter').on('change', function (evt) {
1076
1077            var srcElement = $(evt.target);
1078            var altElement = $('.classattrfilter[data-classatt="' + srcElement.attr('data-classatt') + '"]').not(srcElement);
1079
1080            console.log(altElement);
1081
1082            if (srcElement.is(':checked')) {
1083                altElement.prop('checked', true);
1084            } else {
1085                altElement.prop('checked', false);
1086            }
1087
1088            fnApplyTimetableFilters();
1089        });
1090    }
1091
1092    if ($('.tt-activity').length) {
1093        $('.tt-activity').on('click', function (evt) {
1094            var id = $(this).attr('data-classid'),
1095                displayDate = $(this).attr('data-classdate');
1096
1097            if (displayDate) {
1098                $('#activityModal-' + id).find('.phClassDate').text(displayDate);
1099            }
1100
1101            $('#activityModal-' + id).modal('show');
1102        });
1103    }
1104
1105    if ($('#ttFltArea').length) {
1106        $('#ttFltArea').on('change', function (evt) {
1107            var v = $('#ttFltArea').val();
1108            if (v == '') {
1109                //deselect all options and hide dropdown
1110                $('#ttFltVenueContainer').hide();
1111
1112            } else {
1113                //filter options & display dropdown
1114                $('#ttFltVenueContainer').show();
1115                $('#ttFltVenue option:hidden').show();
1116                $('#ttFltVenue option').not('[data-areaid="' + v + '"]').hide();
1117                $('#ttFltVenue option[value=""]').show();
1118            }
1119            fnApplyTimetableFilters();
1120        });
1121    }
1122
1123    if ($('#ttFltVenue').length) {
1124        $('#ttFltVenue').on('change', function (evt) {
1125            fnApplyTimetableFilters();
1126        });
1127    }
1128
1129    if ($('#tt-filters-mobile').length) {
1130        $('#tt-filters-mobile').on('show.bs.collapse', function (evt) {
1131            $('#btnMobileFilterToggle span').removeClass('fa-chevron-down').addClass('fa-chevron-up');
1132        }).on('hide.bs.collapse', function (evt) {
1133            $('#btnMobileFilterToggle span').removeClass('fa-chevron-up').addClass('fa-chevron-down');
1134        });
1135    }
1136
1137    var fnCheckTimetableDayHeights = Crisis.util.debounce(function () {
1138        var rows = $('.timetable-wrapper');
1139        rows.each(function (idx, ele) {
1140            var days = $(ele).find('.day'),
1141                heights = days.map(function (idx, day) {
1142                    return $(day).height();
1143                }).get();
1144
1145            var allSame = !!heights.reduce(function (a, b) { return (a === b) ? a : NaN; });
1146            if (!allSame) {
1147                var tallest = Math.max.apply(Math, heights);
1148                $(days).css('min-height', (tallest + 10) + 'px');
1149            }
1150        });
1151    }, 100);
1152
1153    if ($('.timetable').length) {
1154        //check and adjust day heights
1155        fnCheckTimetableDayHeights();
1156
1157        $(window).on('resize', function () {
1158            fnCheckTimetableDayHeights();
1159        });
1160    }
1161
1162    /////////////////////////////////////////////
1163    // Dropdown behaviours
1164    $('li.dropdown-linkto :first-child').on('click', function () {
1165        var $el = $(this).parent();
1166        if ($el.hasClass('open')) {
1167            var $a = $el.children('a.dropdown-toggle');
1168            if ($a.length && $a.attr('href')) {
1169                location.href = $a.attr('href');
1170            }
1171        }
1172    });
1173
1174    // Add tabbing for nav dropdowns for accessibility AL 04/24
1175    var selectedNavDropdown = '';
1176    Crisis.UI.elements.documentBody.on('keyup', function (e) {
1177
1178        // User has tabbed
1179        if (e.keyCode == 9) {
1180            var activeElement = $(document.activeElement);
1181            var dropdownContainer = activeElement.closest('nav li.dropdown');
1182
1183            if (dropdownContainer.length && !dropdownContainer.hasClass('open')) {
1184                if (!activeElement.hasClass('dropdown-toggle')) 
1185                    selectedNavDropdown = dropdownContainer.find('.dropdown-toggle')
1186                else
1187                    selectedNavDropdown = activeElement;
1188
1189                selectedNavDropdown.dropdown('toggle');
1190            }
1191            else if (selectedNavDropdown && !dropdownContainer.length) {
1192                selectedNavDropdown.dropdown('toggle');
1193                selectedNavDropdown = '';
1194            }
1195        }
1196    });
1197
1198    // DONATION FORM BEHAVIOURS
1199    Crisis.UI.elements.donationModal.find('form').each(function (e) {
1200        var $this = $(this);
1201
1202        if ($this.hasClass('is-regular')) {
1203            $this.on('change', '.dd-details input, .dd-details select', function () {
1204               Crisis.util.updateDirectDebitDetails($this)
1205            })
1206        }
1207    });
1208
1209    // Regular sort code - jump to next field functionality
1210    Crisis.UI.elements.donationModal.find('.sort-code-fields .input-wrapper').each(function (e) {
1211        var $this = $(this);
1212        var nextInput = $this.next('.input-wrapper');
1213        var regexpField = /^[0-9][0-9]$/;
1214        var regexpKey = /^[0-9]$/;
1215        var isMobile = Crisis.util.isMobileDevice;
1216
1217        if (nextInput.length) {
1218            $this.on('keyup', 'input', function (e) {
1219                var val = $(this).val();
1220
1221                if (regexpField.test(val) &&
1222                    (regexpKey.test(e.key) || (e.key && e.key.toLowerCase() == 'unidentified' && isMobile)))
1223                    nextInput.find('input').focus();
1224            });
1225        }
1226    });
1227
1228    ///////////////////////////////////////////////
1229
1230    //Video Overlay switch
1231    $(".overlay-play").on("click", function () {
1232        $(this).hide();
1233        var iframe = $(this).parent().find(".jVideoHandler iframe");
1234        $(this).parent().find(".jVideoHandler").show();
1235        iframe.attr('src', iframe.attr('src') + "&autoplay=1");
1236    });
1237
1238    if ($('#wpCardDetails').length) {
1239        var fnInitWorldpay = function () {
1240            if (Worldpay) {
1241                //much pain!!! having to override the WP modal position due to miscalculations
1242                //var fnOrig = Worldpay.template.formLoaded;
1243                //Worldpay.template.formLoaded = function () {
1244                //    var closeTop = (parseInt($('#wpCardDetails').position().top) - 166) + 'px';
1245                //    $('#_iframe_close').css('top', closeTop);
1246                //    fnOrig();
1247                //}
1248
1249                //var btnTop = (parseInt($('#wpCardDetails').position().top) - 166) + 'px';
1250                //$('#_iframe_close').css('top', btnTop);
1251                Worldpay.useTemplateForm({
1252                    'clientKey': 'T_C_75d759c7-b167-4d7c-9112-1dbbee0d8fb0',
1253                    'saveButton': false,
1254                    'form': 'donationForm',
1255                    'paymentSection': 'wpCardDetails',
1256                    'display': 'inline',
1257                    'reusable': true,
1258                    'type': 'card',
1259                    //'templateOptions': {
1260                    //    iframeHolderModal: "position: absolute;top: " + btnTop + ";left: -350px;background-color: #fff;width: 220px;height: 220px;margin-left: 50%;border:none;",
1261                    //    iframeClose: 'position: relative;top: 10px;height: 20px;
1261width: 20px;right: -350px;text-decoration: none;margin-right: 50%;cursor: pointer;z-index: 999;color: #000;font-size: 16px;font-weight: bold;text-align: center;',
1262                    //},
1263                    'callback': function (obj) {
1264                        if (obj && obj.token) {
1265                            $('input[name="token"]').val(obj.token);
1266                            $('#displayToken').text(obj.paymentMethod.maskedCardNumber);
1267                        }
1268
1269                        $('#frmDonation').submit();
1270
1271                        //Worldpay.closeTemplateModal();
1272                    }
1273                });
1274            }
1275        }
1276
1277        fnInitWorldpay();
1278    }
1279
1280    var fnDiffDays = function (a, b) {
1281        var _MS_PER_DAY = 1000 * 60 * 60 * 24;
1282
1283        var utc1 = Date.UTC(a.getFullYear(), a.getMonth(), a.getDate());
1284        var utc2 = Date.UTC(b.getFullYear(), b.getMonth(), b.getDate());
1285
1286        return Math.floor((utc2 - utc1) / _MS_PER_DAY);
1287    }
1288
1289    var fnDiffWorkDays = function (start, end) {
1290        var first = start.clone().endOf('week'); // end of first week
1291        var last = end.clone().startOf('week'); // start of last week
1292        var days = last.diff(first, 'days') * 5 / 7; // this will always multiply of 7
1293        var wfirst = first.day() - start.day(); // check first week
1294        if (start.day() == 0)--wfirst; // -1 if start with sunday
1295        var wlast = end.day() - last.day(); // check last week
1296        if (end.day() == 6)--wlast; // -1 if end with saturday
1297        return Math.floor(wfirst + days + wlast); // get the total
1298    }
1299
1300    if ($('a[data-presetDonation="1"]').length) {
1301        $('a[data-presetDonation="1"]').on('click', function (evt) {
1302            evt.preventDefault();
1303            var src = $(this);
1304            $(src.attr('data-target')).val(src.attr('data-value'));
1305        });
1306    }
1307
1308    if ($('a[data-presetRaffle="1"]').length) {
1309        $('a[data-presetRaffle="1"]').on('click', function (evt) {
1310            evt.preventDefault();
1311            var src = $(this);
1312            $(src.attr('data-target')).val(src.attr('data-value'));
1313        });
1314    }
1315
1316    var paymentDateDetails = $('.payment-date-details');
1317
1318    if (paymentDateDetails.length) {
1319
1320        paymentDateDetails.each(function () {
1321            var $this = $(this);
1322            var paymentDayOfMonth = $this.find('[name="paymentDayOfMonth"]');
1323            var firstPaymentDay = $this.find('[name="firstPaymentDay"]');
1324            var firstPaymentMonth = $this.find('[name="firstPaymentMonth"]');
1325            var firstPaymentYear = $this.find('[name="firstPaymentYear"]');
1326            var firstPaymentDateDisplay = $this.find('.firstPaymentDateDisplay');
1327
1328            var populatePaymentDateFields = function () {
1329                var selectedDay = paymentDayOfMonth.val();
1330                var todayPlusX = new Date();
1331                var x = 21;
1332                var d, m, y;
1333
1334                // Add 21 days (3 weeks) to current date
1335                todayPlusX.setDate(todayPlusX.getDate() + x);
1336                d = todayPlusX.getDate();
1337                m = todayPlusX.getMonth() + 1;
1338                y = todayPlusX.getFullYear();
1339
1340                if (d > selectedDay) {
1341                    if (m == 12) {
1342                        m = 1;
1343                        y++;
1344                    }
1345                    else {
1346                        m++;
1347                    }
1348                }
1349                firstPaymentDay.val(selectedDay);
1350                firstPaymentMonth.val(m);
1351                firstPaymentYear.val(y);
1352
1353                firstPaymentDateDisplay.text(selectedDay.toString().padStart(2, '0') + '/' + m.toString().padStart(2, '0') + '/' + y);
1354            }
1355
1356            paymentDayOfMonth.on('change', function () {
1357                populatePaymentDateFields();
1358            });
1359            populatePaymentDateFields();
1360        });
1361    }
1362    else if ($('#firstPaymentDay').length) {
1363        $('#firstPaymentDay,#firstPaymentMonth,#firstPaymentYear').on('change', function (evt) {
1364            var today = new Date(),
1365                selectedDate = new Date($('#firstPaymentYear').val(), $('#firstPaymentMonth').val() - 1, $('#firstPaymentDay').val());
1366
1367            var diffDays = fnDiffWorkDays(moment(today), moment(selectedDate));
1368
1369            if (diffDays < 15) {
1370                //alert('start date must be at least 15 working days in the future');
1371                Crisis.UI.modalAlert('start date must be at least 15 working days in the future');
1372                $('#txtDdDateError').show();
1373                $('#complete').attr('disabled', 'disabled').addClass("ui-state-disabled");
1374            } else {
1375                $('#txtDdDateError').hide();
1376                $('#complete').removeAttr('disabled', 'disabled').removeClass("ui-state-disabled");
1377                $('span#confFirstDay').html($('#firstPaymentDay').val());
1378                $('span#confFirstMonth').html($('#firstPaymentMonth>option:selected').html());
1379                $('span#confFirstYear').html($('#firstPaymentYear>option:selected').html());
1380            }
1381        });
1382    }
1383
1384    //modal close stop video
1385    $('.modal-video').on('hidden.bs.modal', function (e) {
1386        if ($(this).find('.ytmodalplayer').length) {
1387            var playerElement = $(this).find('.ytmodalplayer').eq(0);
1388            playerElement.attr('data-src', playerElement.attr('src'));
1389            playerElement.attr('src', ' ');
1390        } else {
1391            $(this).find("video").get(0).pause();
1392        }
1393    });
1394
1395    $('.modal').on('hidden.bs.modal', function (e) {
1396        var iframe = $(this).find('iframe')[0]
1397
1398        if (iframe) {
1399            var src = iframe.src;
1400
1401            iframe.src = src;
1402        }
1403    });
1404
1405    $('.modal').on('shown.bs.modal', function (e) {
1406        if ($(this).find('.history-img').length) {
1407            var modalH = $(this).find('.modal-content').outerHeight();
1408            $(this).find('.history-img').height(modalH);
1409        }
1410
1411        if ($(this).find('.ytmodalplayer').length) {
1412            var playerElement = $(this).find('.ytmodalplayer').eq(0);
1413            if (playerElement.attr('data-src')) {
1414                playerElement.attr('src', playerElement.attr('data-src'));
1415            }
1416
1417            playerElement.attr('data-src', ' ');
1418        }
1419    })
1420
1421    // 
1422
1423    $('form.acc-donation-form.is-regular').each(function () { 
1424        var $this = $(this).on('blur', '[name="sc1"], [name="sc2"], [name="sc3"], [name="accountNumber"]', function () {
1425            Crisis.util.bankDetailsFields = {
1426                parentForm: $this,
1427                sc1: $this.find('[name="sc1"]'),
1428                sc2: $this.find('[name="sc2"]'),
1429                sc3: $this.find('[name="sc3"]'),
1430                accNumber: $this.find('[name="accountNumber"]'),
1431                bankName: $this.find('[name="bankName"]'),
1432                branchName: $this.find('[name="branchName"]')
1433            };
1434
1435            var sc1 = Crisis.util.bankDetailsFields.sc1,
1436                sc2 = Crisis.util.bankDetailsFields.sc2,
1437                sc3 = Crisis.util.bankDetailsFields.sc3,
1438                accNumber = Crisis.util.bankDetailsFields.accNumber,
1439                pcaKey = (window.location.hostname === 'localhost') ? 'WZ55-AR48-ZA96-CD33' : 'pr99-xw29-pu92-fx57',
1440                pcaUrl = 'https://services.postcodeanywhere.co.uk/BankAccountValidation/Interactive/Validate/v2.00/json.ws?',
1441                scriptTag = document.getElementById("pcascript"),
1442                headTag = document.getElementsByTagName("head").item(0);
1443
1444            if (sc1.val() && sc2.val() && sc3.val() && accNumber.val()) {
1445                var url = pcaUrl + 'Key=' + pcaKey,
1446                    sortCode = sc1.val() + '-' + sc2.val() + '-' + sc3.val();
1447
1448                url += '&SortCode=' + encodeURIComponent(sortCode);
1449                url += '&AccountNumber=' + encodeURIComponent(accNumber.val());
1450                url += '&CallbackFunction=Crisis.util.onAccountVerificationResponse';
1451
1452                if (scriptTag)
1453                    try { headTag.removeChild(scriptTag); } catch (e) { }
1454
1455                scriptTag = document.createElement("script");
1456                scriptTag.src = url;
1457                scriptTag.type = "text/javascript";
1458                scriptTag.id = "pcascript";
1459                headTag.appendChild(scriptTag);
1460
1461            }
1462        });
1463    });
1464
1465    //specific to the payment forms (for now)
1466    if ($('.donation-form .jDonate').length) {
1467        $('.jDonate a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
1468            if ($(e.target).attr('data-presetdonation') == '2') {
1469                $('#grpDonationAmount').show();
1470            } else {
1471                $('#grpDonationAmount').hide();
1472            }
1473        });
1474    }
1475
1476    //donation amount tab
1477    $(".jDonate li a").on("touch click", function () {
1478
1479        var $this = $(this);
1480        console.log('change')
1481        var parentPane = $this.parents('.tab-pane');
1482        var queryTag = $("input[name='urlQuerytag']").val() != null ? $("input[name='urlQuerytag']").val() : "";
1483        var url = parentPane.find(".jDonate").attr("data-url") + $this.attr("data-query") + (queryTag != "" ? "&" + queryTag : "");
1484        var amount = $this.data('amount') ? '&pound;' + $this.data('amount') : $this.html();
1485        parentPane.find(".jAmount a").attr('href', url);
1486        parentPane.find(".jAmount span").html(amount);
1487    });
1488    $(".input select").on("change", function () {
1489        console.log('input')
1490        var $this = $(this);
1491        var parentPane = $this.parents('.tab-pane');
1492
1493        var url = $this.val() + $this.closest(".donation-content").find(".jDonate .active a").attr("data-query");
1494        var amount = $(".input input[type='text']").val();
1495        parentPane.find(".input").attr("data-url", $this.val());
1496        parentPane.find(".jDonate").attr("data-url", $this.val());
1497        parentPane.find(".jAmount a").attr("href", url);
1498        if (amount != null && amount != "") {
1499            parentPane.find(".jDonateLinkReplace").attr("href", $this.val() + "?amount=" + amount);
1500        }
1501        else {
1502            parentPane.find(".jDonateLinkReplace").attr("href", $this.val());
1503        }
1504    });
1505    $(".input input[type='text']").on("change paste keyup", function () {
1506
1507        var $this = $(this);
1508        var jDonateLink = $(".jDonateLinkReplace");
1509
1510        if (!jDonateLink.length)
1511            return;
1512
1513        var queryTag = $("input[name='urlQuerytag']").val() != null ? $("input[name='urlQuerytag']").val() : "";
1514
1515        if (jDonateLink.attr("href").indexOf("#") == 0)
1516            return;
1517
1518        var amount = $this.val();
1519        var url = $this.parent(".input").attr("data-url") + "?amount=" + amount + (queryTag != "" ? "&" + queryTag : "");
1520        jDonateLink.attr("href", url);
1521    });
1522
1523    $('a.scroll').on('click', function (evt) {
1524        evt.preventDefault();
1525        scrollToAnchor($(this).attr('data-target'));
1526    });
1527
1528    //Image replace Tab control
1529    $(".jTImageReplace").each(function () {
1530        var $this = $(this)
1531        var tabImg = $this.closest(".tab-pane").find(".jImageReplace");
1532        var imgUrl = $this.attr("data-img");
1533
1534        $this.on('click touch', function (e) {
1535            e.preventDefault();
1536            tabImg.attr("src", imgUrl);
1537        });
1538    });
1539
1540    $('.tab-pane').each(function () {
1541        var $thisPane = $(this);
1542        var tabImages = $thisPane.find('img.jImageToggle');
1543        var toggles = $thisPane.find('.jTImageToggle');
1544        if (tabImages.length == toggles.length) {
1545            toggles.each(function (i) {
1546                $(this).on('click touch', function () {
1547                    var selectedImage = tabImages.eq(i);
1548
1549                    if (selectedImage.length) {
1550                        tabImages.addClass('hidden');
1551                        selectedImage.removeClass('hidden');
1552                    }
1553                });
1554            });
1555        }
1556    });
1557
1558    function scrollToAnchor(aid) {
1559        var aTag = $("a[name='" + aid + "']");
1560        $('html,body').animate({ scrollTop: (aTag.offset().top - 100) }, 'slow');
1561    }
1562
1563    //  volunteer application form
1564    if ($('#applicationApplyNow, #applicationApplyNowSideBar').length && $('#applicationForm').length) {
1565        $('#applicationApplyNow, #applicationApplyNowSideBar').click(function () {
1566            $('#applicationApplyNow').hide();
1567            $("#applicationForm").show();
1568        })
1569    }
1570
1571    //  Masonry Load more
1572    if ($('#loadMoreMasonry').length) {
1573        var $this = $('#loadMoreMasonry');
1574        var masonryGrid = $('#grid.masonry-grid');
1575        var masonryGridItem = $('#grid.masonry-grid .item');
1576
1577        imagesLoaded(masonryGrid, function () {
1578
1579            // number of initial elements to load
1580            var x = Number($this.attr('data-loadstart'));
1581            var hideGridItems = $('#grid.masonry-grid .item:nth-child(n' + (x + 1) + ')');
1582
1583            // Put this in a timeOut as there were intermittent DOMException masonry errors in this function
1584            setTimeout(function() {
1585                // initialize masonry
1586                masonryGrid.masonry({
1587                    itemSelector: masonryGridItem,
1588                    transitionDuration: 0,
1589                    isFitWidth: true
1590                });
1591
1592                $this.text('Load ' + ((hideGridItems.length < x) ? hideGridItems.length : x) + ' more');
1593                hideGridItems.hide();
1594                masonryGrid.masonry('layout');
1595            },200);
1596
1597            $this.click(function (e) {
1598
1599                e.preventDefault();
1600                var hiddenEl = masonryGridItem.filter(':hidden');
1601                var hiddenElCount = hiddenEl.length;
1602                var loadNext = hiddenEl.filter(':lt(' + x + ')');
1603
1604                x = (hiddenElCount <= x) ? hiddenElCount : x;
1605                loadNext.show().addClass('animate');
1606                masonryGrid.masonry('layout');
1607                hiddenElCount = masonryGridItem.filter(':hidden').size();
1608                x = (hiddenElCount <= x) ? hiddenElCount : x;
1609
1610                if (x <= 0)
1611                    $this.hide();
1612                else
1613                    $this.text('Load ' + x + ' more');
1614
1615            });
1616        })
1617    }
1618
1619    //load more kanban cols
1620
1621    if (('#kanban').length) {
1622        $('.kanban-col').each(function () {
1623            var $this = $(this);
1624            //load inital items
1625            var x = Number($this.attr('data-loadstart'));
1626            var items = $this.find('.kanban-outer');
1627            var showItems = items.filter(':lt(' + x + ')');
1628            showItems.removeClass('hidden');
1629        })
1630
1631        $('#loadMoreKanban').click(function (e) {
1632            var kanbanClick = $(this);
1633            e.preventDefault();
1634            var y = 0;
1635            var colCount = $('.kanban-col').length;
1636            $('.kanban-col').each(function () {
1637                var $this = $(this);
1638                var x = Number($this.attr('data-loadstart'));
1639                var items = $this.find('.kanban-outer');
1640                var hiddenEl = items.filter(':hidden');
1641                var hiddenElCount = hiddenEl.length;
1642                var loadNext = hiddenEl.filter(':lt(' + x + ')');
1643                x = (hiddenElCount <= x) ? hiddenElCount : x;
1644                loadNext.removeClass('hidden').addClass('animate');
1645
1646                hiddenElCount = items.filter(':hidden').length;
1647                x = (hiddenElCount <= x) ? hiddenElCount : x;
1648
1649                if (x <= 0) {
1650                    y++
1651                }
1652
1653            })
1654            if (y == colCount) {
1655                kanbanClick.hide();
1656            }
1657            else {
1658                kanbanClick.text('Load more');
1659            }
1660
1661        })
1662
1663
1664    };
1665
1666    // populate consentTarget fields
1667    $('form').on('change', 'input.consent', function () {
1668        this.value = this.checked ? "True" : "False";
1669        console.log(this.checked, 'consent')
1670        $(this).prev('input.consentTarget').prop('value', this.value);
1671        if ($('input[name="isRecurringPayment"]')) {
1672            console.log('exists')
1673            $('input[name="isRecurringPayment"]').val(this.value);
1674            console.log($('input[name="isRecurringPayment"]').val(), 'val')
1675        }
1676
1677
1678    });
1679
1680    // responsive video wrap
1681    $('iframe').each(function () {
1682        var $this = $(this);
1683
1684        if ($this.attr('src') && $this.attr('src').indexOf('.youtu') != (-1)) {
1685            if (!$this.closest('.embed-responsive, .liquid-video-wrapper').length)
1686                $this.wrap('<span class="embedded-video"/>');
1687        }
1688
1689    })
1690
1691    // Cookies disabled warning
1692
1693    if (!navigator.cookieEnabled)
1694        Crisis.UI.modalAlert('Cookies are disabled in your browser. This means you will get a reduced experience on our website and may not be able to access certain pages. Please enable cookies for a full user experience.');
1695
1696
1697    // Tweet counter
1698
1699    if ($('.tweet-counter').length) {
1700        $('.tweet-counter').each(function () {
1701            var $that = $(this),
1702                url = $that.parents('.boot-item').find('.see-more');
1703
1704            if (!$that.parents('.item').length) {
1705                url = $that.parents('.boot-item').find('.see-more');
1706            }
1707
1708            if ($that.parents('.article-date').length) {
1709                //article heading (on page)
1710                url = $('<a>');
1711                url.attr('href', document.location.href);
1712            }
1713
1714            if (url.length) {
1715                var absUrl = Crisis.util.getAbsoluteUrl(url.attr('href'));
1716
1717                $.get('https://graph.facebook.com/?fields=og_object{likes.limit(0).summary(true)},share&ids=' + encodeURIComponent(absUrl), function (result) {
1718                    if (result[absUrl].share && typeof (result[absUrl].share) !== undefined) {
1719                        $that.html(result[absUrl].share.share_count);
1720                    } else {
1721                        $that.html('0');
1722                    }
1723                });
1724            }
1725        });
1726    }
1727
1728    // Stop propagation on dropdown toggle
1729    $('.dropdown-toggle .fa-open-close').on('click touch', function () {
1730        event.stopImmediatePropagation();
1731        event.preventDefault();
1732        $(this).parent().dropdown("toggle");
1733    });
1734
1735    // scrollto functionality, added by AL 30/10/17:
1736    (function ($) {
1737        var offCanvas = $('body > div.off-canvas');
1738        var stickyNav = $('.secondary-sticky-nav');
1739        var offset;
1740
1741        Crisis.UI.elements.documentBody.on('click', 'a[data-scrollto]', function (e) {
1742
1743            e.preventDefault();
1744            offset = offCanvas.is(':visible') ? 0 : 100;
1745            offset += stickyNav.length ? 76 : 0;
1746
1747            var scrollToId = $(this).data('scrollto');
1748
1749            var scrolltoElement = $('#' + scrollToId);
1750            //console.log(scrolltoElement);
1751
1752            // Removed scrolling animation and made the scrolling instant for accessibility purposes
1753            // AL 03/24
1754
1755            //$('html,body').animate({ scrollTop: scrolltoElement.offset().top - offset }, 'slow');
1756
1757            window.scrollTo({
1758                top: scrolltoElement.offset().top - offset,
1759                left: 0,
1760                behaviour: 'instant'
1761            });
1762
1763        })
1764        .on('click', '.scrollTo', function (e) {
1765
1766            e.preventDefault();
1767            offset = offCanvas.is(':visible') ? 0 : 100;
1768            offset += stickyNav.length ? 76 : 0;
1769
1770            var scrollToId = $(this).attr('href').split('#')[1];
1771            var scrolltoElement = $('#' + scrollToId);
1772
1773            // Removed scrolling animation and made the scrolling instant for accessibility purposes
1774            // AL 03/24
1775
1776            //$('html,body').animate({ scrollTop: scrolltoElement.offset().top - offset }, 'slow');
1777
1778            window.scrollTo({
1779                top: scrolltoElement.offset().top - offset,
1780                left: 0,
1781                behaviour: 'instant'
1782            });
1783        });
1784    })(jQuery)
1785
1786    $('input#donationAmount').each(function () {
1787        var $this = $(this);
1788        var min = $this.attr('min');
1789        var msgMin = $this.data('msg-min');
1790        var max = $this.attr('max');
1791        var msgMax = $this.data('msg-max');
1792        var span = $('<span class="field-invalid-msg" />');
1793
1794        $this.after(span)
1795
1796        $this.on('input change', function () {
1797
1798            var val = $this.val();
1799            var msg;
1800
1801            if (min && msgMin && parseFloat(val) < min) {
1802                msg = msgMin;
1803            }
1804            else if (max && msgMax && parseFloat(val) > max) {
1805                msg = msgMax;
1806            }
1807
1808            if (msg)
1809                span.html('<span>' + msg + '</span>');
1810            else
1811                span.html('');
1812
1813        })
1814            // for values passed in via query on page load
1815            .trigger('change');
1816    });
1817
1818    // wait-on-submit functionality for conventional form submit buttons
1819    $('form').on('click', '.wait-on-submit', function (e) {
1820        if ($(e.delegateTarget).valid()) {
1821            var $this = $(this);
1822            var submitMsg = $this.data('alert-waiting-msg');
1823
1824            if ($this.hasClass('wait')) {
1825                e.preventDefault();
1826            }
1827            else {
1828                $this.addClass('wait');
1829                if (submitMsg) {
1830                    $('<div class="modal fade alert-waiting" id="modal-alert" tabindex="-1" role="dialog" aria-hidden="true">' +
1831                        '<div class="modal-dialog" role="document">' +
1832                        '<div class="modal-content">' +
1833                        '<div class="modal-body">' +
1834                        '<div class="inner">' +
1835                        '<h5 class="mb-60 mt-10">' + submitMsg + '</h5>' +
1836                        '<span class="css-loader blue default"><span></span><span></span><span></span></span>' +
1837                        '</div>' +
1838                        '</div>' +
1839                        '</div>' +
1840                        '</div>' +
1841                        '</div>').modal();
1842                }
1843            }
1844        }
1845    });
1846
1847    // ajax-modal
1848    Crisis.UI.elements.documentBody.on('click', '[data-ajaxmodal]', function (e) {
1849        e.preventDefault();
1850        var $this = $(this);
1851        var selector = $this.data('ajaxmodal');
1852        var url = $this.attr('href');
1853        var msgError = $this.data('ajaxmodal-error') || 'Sorry, content is not found.';
1854
1855        $('#ajaxModal').remove();
1856
1857        var modal = $('<div class="modal fade" id="ajaxModal" tabindex="-1" role="dialog" aria-hidden="true">' +
1858            '<div class="modal-dialog" role="document">' +
1859            '<div class="modal-content">' +
1860            '<div class="modal-header">' +
1861            '<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>' +
1862            '</div>' +
1863            '<div class="modal-body">' +
1864            '<div class="inner wait">' +
1865            '<span class="css-loader default"><span></span><span></span><span></span></span>' +
1866            '<p class="msg-error hidden">' + msgError + '</p>' +
1867            '</div>' +
1868            '</div>' +
1869            '</div>' +
1870            '</div>' +
1871            '</div>');
1872        var inner = modal.find('div.inner')
1873
1874        Crisis.UI.elements.documentBody.append(modal);
1875        modal.on('shown.bs.modal', function () {
1876
1877            $.ajax({
1878                url: url,
1879                dataType: 'html',
1880                complete: function (r) {
1881
1882                    var page, element;
1883                    inner.removeClass('wait');
1884
1885                    if (r.status == 200 && r.responseText) {
1886                        page = $(r.responseText);
1887                        element = page.find(selector).length ? page.find(selector) : page.filter(selector);
1888
1889                        if (element.length == 1) {
1890                            inner.html(element);
1891                            return;
1892                        }
1893                    }
1894
1895                    inner.find('.msg-error').removeClass('hidden');
1896
1897                }
1898            });
1899        })
1900            .modal();
1901
1902    });
1903
1904    //Custom "Other" field
1905
1906    $('[data-other-field-target]').each(function () {
1907        var $this = $(this);
1908        var select = $this.find('select');
1909        var radios = $this.find('input[type="radio"]');
1910
1911        var textField = $('[data-other-field-control="' + $this.data('other-field-target') +'"]');
1912
1913        if (select.length) {
1914            select.on('change', function () {
1915                if (select.val().toLowerCase() == 'other')
1916                    textField.removeClass('hidden');
1917                else
1918                    textField.addClass('hidden');
1919            });
1920        }
1921        else if (radios.length) {
1922            radios.on('change', function () {
1923                if (radios.filter(':checked').val() == 'true')
1924                    textField.removeClass('hidden');
1925                else
1926                    textField.addClass('hidden');
1927            });
1928        }
1929    });
1930
1931    // Embedded video
1932    $('div.mceNonEditable.embeditem').each(function () {
1933        var $this = $(this);
1934
1935        $this.css({
1936            'max-width': $this.data('embed-width') || 'none'
1937        })
1938        .children('iframe').wrap('<div class="liquid-video-wrapper" />');
1939
1940    }); 
1941
1942});
1943
1944/////////////////////////////////////////////
1945// window onload handler events here
1946Crisis.UI.elements.window.on('load', function () {
1947
1948    // Accordion anchoring functionality
1949    var accordionItems = $('.accordion.accordion-item');
1950
1951    if (accordionItems.length) {
1952        var goToAccordion = function (isHashChange) {
1953            var urlHash = location.hash;
1954
1955            if (urlHash) {
1956
1957                accordionItems.each(function () {
1958
1959                    var $this = $(this);
1960                    var id = $this.attr('id');
1961                    var hash = urlHash.replace('#', '');
1962
1963                    if (hash == id) {
1964
1965                        var accordionContent = $this.find('.collapse');
1966
1967                        Crisis.UI.scrollToElement($this);
1968                        accordionContent.collapse('show');
1969                        return false;
1970                    }
1971                });
1972            }
1973        }
1974        Crisis.UI.elements.window.on('hashchange', function () {
1975            goToAccordion();
1976        });
1977        goToAccordion();
1978    }
1979});
1980
1981// Handle modal scrolling bug when multiple modals are engaged
1982Crisis.UI.elements.document.on('hidden.bs.modal', '.modal', function () {
1983    if ($('.modal:visible').length)
1984        Crisis.UI.elements.documentBody.addClass('modal-open');
1985});
1986
1987//== Off canvas menu button
1988//
1989//* Toggle active class on menu button
1990$('#off-canvas-open, #off-canvas-close, #off-canvas-close-after, .toggleNav').on('click touchstart', function (e) {
1991    if (e.type == 'touchstart') {
1992        e.stopImmediatePropagation();
1993        e.preventDefault();
1994    }
1995
1996    Crisis.UI.elements.documentBody.toggleClass('off-canvas-active');
1997});
1998
1999$('header a.expant-btn').click(function (e) {
2000    var $this = $(this);
2001    e.preventDefault();
2002    var section = $this.closest('header')
2003    var nextSection = section.next('section');
2004    smoothScroll(nextSection)
2005})
2006
2007
2008function smoothScroll(target) {
2009    $('body,html').animate(
2010        { scrollTop: target.offset().top - 165 },
2011        600);
2012}
2013
2014
2015//RED STICKY NAV
2016if ($('.secondary-sticky-nav').length) {
2017    Crisis.UI.elements.document.ready(function () {
2018        var y = 0;
2019        var navHeight = Crisis.UI.elements.navHeight;
2020        var navShrinkHeight = Crisis.UI.elements.navShrinkHeight;
2021        var stickyNavContainer = $('.secondary-sticky-nav');
2022        var stickyNav = stickyNavContainer.find('ul');
2023        var heroHeight = $('.header-content').length ? $('.header-content').height() : 0;
2024        var totalHeight = heroHeight + navHeight;
2025        var currSelected = null;
2026        var leftPos, $magicLine, stickyNavContainerHeight, navList;
2027
2028        //Add nav list items to red sticky secondary nav 
2029        $('section[data-nav-title], .featured-list .featured-list__item').each(function (i) {
2030            var $this = $(this);
2031
2032            var id = $this.attr('id');
2033            var stickyTitle = $this.attr('data-nav-title');
2034            console.log(y);
2035
2036            if (id != null && stickyTitle != null) {
2037                y++;
2038                stickyNav.append('<li data-menu-index="' + i + '"><a role="tab" data-toggle="tab" data-id="' + y + '" data-scrollto="' + id + '" href="#' + id + '"><span>' + stickyTitle + '</span></a></li>');
2039            }
2040        });
2041        navList = stickyNav.find('li');
2042        stickyNavContainer.parent('.height-wrapper').height(stickyNavContainer.outerHeight());
2043
2044        //append indicator
2045        $magicLine = $('#magic-line');
2046        $magicLine.width(navList.first().width());
2047
2048        //check if section is in window view
2049        function isElementInViewport(el) {
2050            var rect;
2051            var returnVal = false;
2052
2053
2054            if (rect = el[0].getBoundingClientRect()) {
2055                var boundaryTop = stickyNavContainerHeight + navShrinkHeight;
2056
2057                returnVal = (rect.top <= boundaryTop && rect.bottom >
2057 boundaryTop)
2058            }
2059            return returnVal;
2060        }
2061
2062        //update sticky nav on scroll
2063        function updateNavigation() {
2064            currSelected = null;
2065            $('section[data-nav-title]').each(function (i) {
2066                var $this = $(this);
2067                var navItem;
2068
2069                if (isElementInViewport($this)) {
2070                    currSelected = i;
2071                    navItem = navList.filter('[data-menu-index="' + i + '"]');
2072
2073                    $magicLine.css({
2074                        'left': navItem.position().left,
2075                        'width': navItem.width()
2076                    });
2077
2078                    return false;
2079                }
2080            });
2081        }
2082
2083        //Sticky Scroll
2084        var scrollAction = function () {
2085
2086            if ($(document).scrollTop() + navShrinkHeight >= totalHeight) {
2087
2088                stickyNavContainerHeight = stickyNavContainer.outerHeight();
2089
2090                stickyNavContainer.addClass('sticky');
2091                Crisis.UI.elements.documentBody.addClass('show-zine-sticky-nav');
2092                updateNavigation();
2093            } else {
2094                stickyNavContainer.removeClass('sticky has-selected');
2095                Crisis.UI.elements.documentBody.removeClass('show-zine-sticky-nav');
2096            }
2097
2098            if (currSelected != null)
2099                stickyNavContainer.addClass('has-selected');
2100            else
2101                stickyNavContainer.removeClass('has-selected');
2102        };
2103
2104        //$(window).scroll(scrollAction);
2105
2106        document.addEventListener('scroll', Crisis.util.throttle(scrollAction, 50));
2107        window.addEventListener('resize', Crisis.util.debounce(scrollAction, 100));
2108        scrollAction();
2109    });
2110}
2111
2112// Richtext carousel
2113
2114Crisis.UI.elements.document.ready(function () {
2115
2116    $('.richtext-carousel').each(function () {
2117        var $this = $(this);
2118        var sliderObj = $this.find('ul.slider');
2119
2120        $this.css('width', $this.outerWidth())
2121
2122        var slider = sliderObj.lightSlider({
2123            item: 1,
2124            loop: sliderObj.data('looped') ? sliderObj.data('looped') : false,
2125            slideMove: 1,
2126            easing: 'cubic-bezier(0.25, 0, 0.25, 1)',
2127            speed: 600,
2128            pager: false,
2129            slideMargin: 1200
2130        });
2131
2132        window.addEventListener('resize', Crisis.util.debounce(function () {
2133            $this.addClass('resetWidth');
2134            $this.css('width', $this.outerWidth()).removeClass('resetWidth');
2135            slider.refresh();
2136        }, 32));
2137
2138    });
2139    $('a[rel="richTextCarousel"]').swipebox({
2140        removeBarsOnMobile: false,
2141        afterOpen: function () {
2142            $('#swipebox-slider .slide').append('<div class="css-loader"><span></span><span></span><span></span></div>');
2143        }
2144    });
2145});
2146
2147
2148$('#micro-menu-icon').click(function () {
2149    $(this).toggleClass('open');
2150    $('.openNav').toggleClass('page-open');
2151    $('body').toggleClass('hide-overflow')
2152
2153});
2154
2155/* aCsrfToken stuff */
2156
2157$('form').submit(function (e) {
2158    var $this = $(this);
2159    var $token = aCsrfToken ? $(aCsrfToken) : '';
2160    var method = $this.attr('method');
2161
2162    if ($token.length &&
2163        method &&
2164        method.toLowerCase() == 'post' &&
2165        !$this.find('[name=' + $token.attr('name') + ']').length) {
2166        $this.append($token);
2167    }
2168
2169    // AL 03/26:
2170    let snurl = $this.data('snurl');
2171    let snurlRx = /^([\/\w-]+)(\?[\w\=\&\#~-]+)*$/;
2172    if (snurl) {
2173        snurl = (snurl && snurlRx.test(snurl)) ? snurl :
2174            document.location.pathname;
2175
2176        $this.find('input[name="SourceNodeUrl"]').remove();
2177        $('<input/>', { name: 'SourceNodeUrl', value: snurl, type: 'hidden' }).appendTo($this);
2178    }
2179});
2180
2181//shrink/expand nav bar
2182Crisis.UI.elements.window.scroll(Crisis.UI.pageScrollAction);
2183Crisis.UI.pageScrollAction();
2184
2185///////////////////////////////////
2186// PLUGINS
2187///////////////////////////////////
2188
2189/*
2190* CSS animations plugin 1.01
2191* Copyright (c) 2019 Adam Lafene
2192* https://github.com/EdamL/css-animation
2193*
2194* Licensed under the terms of the MIT and GPL licenses:
2195*   http://www.opensource.org/licenses/mit-license.php
2196*   http://www.gnu.org/licenses/gpl.html
2197*/
2198
2199(function (n) {
2200    function q(a, b) { var c = document.body.appendChild(document.createElement(a.nodeName)), d = n.getComputedStyle(c).getPropertyValue(b); c.parentNode.removeChild(c); return d } var p = !!document.querySelector, f = n.jQuery, m = function (a, b, c) { if ("[object Object]" === Object.prototype.toString.call(a)) for (var d in a) Object.prototype.hasOwnProperty.call(a, d) && b.call(c, a[d], d, a); else { d = 0; for (var g = a.length; d < g; d++)b.call(c, a[d], d, a) } }, g = function (a, b) {
2201        if (a.length) m(a, function (a) { for (var c in b) a.style[c] = b[c] });
2202        else for (var c in b) a.style[c] = b[c]; return a
2203    }; if (!f) { var l = function (a) { if (!(this instanceof l)) return new l(a); this.domObj = document.querySelectorAll(a) }; l.fn = l.prototype = {}; n.CssAni = l; f = n.CssAni } f.fn.cssSlideToggle = function (a, b, c) {
2204        var d = this.domObj || this; if (1 > d.length || !p) return !1; var r = a && "function" === typeof a ? a : b && "function" === typeof b ? b : c && "function" === typeof c ? c : "", h = a && "function" !== typeof a ? parseInt(a) : 500, e = b && "function" !== typeof b ? b : "ease"; m(d, function (a, b) {
2205            if (1 === a.nodeType && !isNaN(b)) {
2206                var c =
2207                    n.getComputedStyle(a), k = c.getPropertyValue("display"), u = "border-box" == c.getPropertyValue("box-sizing") ? !0 : !1, f, l, m; if ("none" === k) { g(a, { "margin-top": 0, "margin-bottom": 0, overflow: "hidden", display: "", opacity: 0, position: "absolute" }); "none" === c.getPropertyValue("display") && (a.style.display = q(a, "display")); k = a.offsetHeight; g(a, { "padding-top": 0, "padding-bottom": 0, "max-height": 0, opacity: "", position: "" }); var p = k; var t = m = l = f = "" } else {
2208                    var v = !0; k = a.offsetHeight; u || (k -= parseInt(c.getPropertyValue("padding-top")) -
2209                        parseInt(c.getPropertyValue("padding-bottom"))); g(a, { "max-height": k + "px" }); t = m = l = f = p = 0
2210                } setTimeout(function () {
2211                    g(a, { transition: "all " + h + "ms " + e, "-webkit-transition": "all " + h + "ms " + e, "-moz-transition": "all " + h + "ms " + e, "-ms-transition": "all " + h + "ms " + e, "-o-transition": "all " + h + "ms " + e }); setTimeout(function () {
2212                        g(a, { "max-height": p + "px", "padding-top": f, "padding-bottom": l, "margin-top": m, "margin-bottom": t, overflow: "hidden" }); setTimeout(function () {
2213                            g(a, {
2214                                transition: "", "-webkit-transition": "", "-moz-transition": "",
2215                                "-ms-transition": "", "-o-transition": ""
2216                            }); v && (a.style.display = "none"); g(a, { "max-height": "", "padding-top": "", "padding-bottom": "", "margin-top": "", "margin-bottom": "", overflow: "" }); r && 0 == b && r.call(d)
2217                        }, h + 50)
2218                    }, 50)
2219                }, 50)
2220            }
2221        })
2222    }; f.fn.cssFadeToggle = function (a, b, c) {
2223        var d = this.domObj || this; if (1 > d.length || !p) return !1; var f = a && "function" === typeof a ? a : b && "function" === typeof b ? b : c && "function" === typeof c ? c : "", h = a && "function" !== typeof a ? parseInt(a) : 500, e = b && "function" !== typeof b ? b : "ease"; m(d, function (a, b) {
2224            if (1 === a.nodeType &&
2225                !isNaN(b)) {
2226                var c = n.getComputedStyle(a); if ("none" === c.getPropertyValue("display")) g(a, { opacity: 0, display: "" }
2226), "none" === c.getPropertyValue("display") && (a.style.display = q(a, "display")); else var k = !0; g(a, { transition: "all " + h + "ms " + e, "-webkit-transition": "all " + h + "ms " + e, "-moz-transition": "all " + h + "ms " + e, "-ms-transition": "all " + h + "ms " + e, "-o-transition": "all " + h + "ms " + e }); setTimeout(function () {
2227                    g(a, { opacity: k ? 0 : 1 }); setTimeout(function () {
2228                        k && (a.style.display = "none"); g(a, {
2229                            transition: "", "-webkit-transition": "",
2230                            "-moz-transition": "", "-ms-transition": "", "-o-transition": "", opacity: ""
2231                        }); f && 0 == b && f.call(d)
2232                    }, h + 50)
2233                }, 50)
2234            }
2235        })
2236    }; f.fn.cssAnimate = function (a, b, c, d) {
2237        var f = this.domObj || this; if (1 > f.length || !p) return !1; if (a && "object" === typeof a) {
2238            var h = b && "function" === typeof b ? b : c && "function" === typeof c ? c : d && "function" === typeof d ? d : "", e = b && "function" !== typeof b ? parseInt(b) : 500, k = c && "function" !== typeof c ? c : "ease"; m(f, function (b, c) {
2239                1 !== b.nodeType || isNaN(c) || (g(b, {
2240                    transition: "all " + e + "ms " + k, "-webkit-transition": "all " + e + "ms " +
2241                        k, "-moz-transition": "all " + e + "ms " + k, "-ms-transition": "all " + e + "ms " + k, "-o-transition": "all " + e + "ms " + k
2242                }), setTimeout(function () { g(b, a); setTimeout(function () { g(b, { transition: "", "-webkit-transition": "", "-moz-transition": "", "-ms-transition": "", "-o-transition": "" }); h && 0 == c && h.call(f) }, e + 50) }, 50))
2243            })
2244        }
2245    }
2246})(window);
2247
2248//https://services.postcodeanywhere.co.uk/BankAccountValidation/Interactive/Validate/v2.00/json.ws?Key=AA11-AA11-AA11-AA11&AccountNumber=12345678&SortCode=00-00-99
2249
2250//http://services.postcodeanywhere.co.uk/Capture/Interactive/Find/v1.00/json3ex.ws?Key=AA11-AA11-AA11-AA11&Text=wr2 6nj&Method=Predict&Container=&Origin=&Filter=&Limit=&Language=&Countries=
2251
2252///////////////////////////////////
2253// POLYFILLS
2254///////////////////////////////////
2255
2256/* URLSearchParams */
2257(function (w) {
2258    w.URLSearchParams = w.URLSearchParams || function (searchString) {
2259        var self = this;
2260        self.searchString = searchString;
2261        self.get = function (name) {
2262            var results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(self.searchString);
2263            if (results == null) {
2264                return null;
2265            }
2266            else {
2267                return decodeURI(results[1]) || 0;
2268            }
2269        };
2270    }
2271})(window);
2272
2273$(document).ready(function () {
2274
2275    //Set the amount input
2276    const amountInput = $('#amount')
2277
2278    //Set the old input value
2279    old_value = amountInput.val()
2280
2281    //Set if the amount has been interacted with
2282    interaction = false
2283
2284//  ========================================================
2285//  Donate Kit Navigation
2286//  ========================================================
2287    function goToKit(section, kit_index, donation, anim_time, button)
2288    {
2289        //Set the donation in the input
2290        amountInput.val(donation).css("width", donation.toString().length + "ch")
2291        updateButtonAmounts(donation)
2292        validateDonation(donation)
2293
2294        //Show kit body on wide and small screens
2295        if($(window).width() > 700)
2296        {
2297            if(!button.hasClass("kits_nav_button-selected"))
2298            {
2299                //Remove selected service and clear stage
2300                section.find(".kits_nav_button-selected").removeClass("kits_nav_button-selected")
2301
2302                //Set the kit button to selected
2303                section.find(".kits_tray").eq(kit_index).find(".kits_nav_button").addClass("kits_nav_button-selected")
2304
2305                section.find("#content_cover").fadeIn(250, function (){
2306
2307                    //Get new content and add it to stage
2308                    var new_content = section.find(".kits_body_spacer").eq(kit_index).html()
2309                    section.find("#insert_content").html(new_content)
2310
2311                    //Fade in new content
2312                    section.find("#content_cover").fadeOut(250)
2313                })
2314            }
2315        }else{
2316            //Small screen
2317            var kit = section.find(".kits_tray").eq(kit_index)
2318            if(kit.hasClass("kits_tray-selected"))
2319            {
2320                kit.removeClass("kits_tray-selected")
2321                kit.find(".kits_tray_body").slideUp(anim_time, function(){
2322                })
2323            }else{
2324                section.find(".kits_tray-selected").removeClass("kits_tray-selected")
2325                section.find(".kits_tray_body").slideUp(400)
2326                kit.addClass("kits_tray-selected")
2327                kit.find(".kits_tray_body").slideDown(anim_time, function(){
2328                })
2329            }
2330        }
2331    }
2332
2333    //Kit button clicked
2334    $(".kits_nav_button").click(function () {
2335        const section = $(".donate")
2336        let donation = $(this).find(".kits_nav_button_cost").text()
2337        donation = parseInt(donation.substring(1))
2338        $(this).blur()
2339        goToKit(section, ($(this).parent().index() - 1), donation, 200, $(this))
2340    })
2341
2342//  ========================================================
2343//  Handle donation amount input
2344//  ========================================================
2345    const validateInput = (amount) => {
2346        const is_number = $.isNumeric(amount)
2347        if(is_number || amount === ''){
2348            if(parseInt(amount) > 0 || amount === '') {
2349                return true
2350            }
2351        }
2352        return false
2353    }
2354
2355    const validateDonation = (amount) => {
2356        if(parseInt(amount) > 1) {
2357            $('.donate_button').removeAttr("disabled")
2358        }else{
2359            $(".donate_button").attr('disabled', 'disabled')
2360        }
2361    }
2362
2363    //Input focus
2364    amountInput.focus(function (){
2365        const section = $(this).closest("#donate_interaction")
2366        section.find(".sticky_donate_container_input_wrapper").addClass("sticky_donate_container_input_wrapper-selected")
2367        section.find(".sticky_donate_container_label_wrapper").addClass("sticky_donate_container_label_wrapper-selected")
2368        if(!interaction){
2369            $(this).val("")
2370            old_value = ''
2371            $(this).css("width", "3ch")
2372        }
2373    })
2374
2375    //Input Blur
2376    $("#amount").blur(function (){
2377        let value = $(this).val()
2378        $(".sticky_donate_container_input_wrapper-selected").removeClass("sticky_donate_container_input_wrapper-selected")
2379        $(".sticky_donate_container_label_wrapper-selected").removeClass("sticky_donate_container_label_wrapper-selected")
2380
2381        //Validate donation
2382        validateDonation(value)
2383    })
2384
2385    //Input Change
2386    amountInput.on('input', function() {
2387        let value = $(this).val()
2388
2389        //Validate input
2390        let checkInput = validateInput(value)
2391        if(checkInput !== false){
2392            $(this).val(value)
2393            old_value = value
2394            interaction = true
2395            $(this).css("width", value.length + "ch")
2396            updateButtonAmounts(value)
2397        }else{
2398            $(this).val(old_value)
2399        }
2400
2401        //Validate donation
2402        validateDonation(value)
2403    })
2404
2405    //Blur on return press
2406    $('body').on('keydown', '#amount', function(e){
2407        if (e.which === 13) {
2408            $("#amount").blur()
2409        }
2410    })
2411
2412//  ========================================================
2413//  Update amount on buttons
2414//  ========================================================
2415    const updateButtonAmounts = (donation) => {
2416        let safevalue = encodeURIComponent(donation).replace(/\./g, '%2E')
2417
2418        if(safevalue === ''){
2419            safevalue = 0
2420        }
2421        if(donation === ''){
2422            donation = 0
2423        }
2424        $("#initial_amount").html("£" + donation)
2425        $("#amountModalValue").attr("value", donation)
2426        $(".donate_button").attr("value", safevalue).attr("data-gift-amount", safevalue)
2427    }
2428
2429//  ========================================================
2430//  Timeline buttons
2431//  ========================================================
2432    $(".time-line_year_event_title_hidden_button").click(function () {
2433        var event = $(this).closest(".time-line_year_event");
2434        event.toggleClass("time-line_year_event--open");
2435        event.find(".time-line_year_event_tray").slideToggle(400);
2436    })
2437})

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.