PageSourceSearch

https://www.renewableenergyzones.tas.gov.au/application/js/hive-login-signup.js?_v=2.70.24.0

js renewableenergyzones.tas.gov.au collected 2026-09-25 04:10:17 UTC 39,857 bytes, 915 lines download raw bytes

1(function($) {
2    if (typeof $ !== 'function') {
3        console.warn('hive-login-signup.js: jQuery not loaded');
4        return;
5    }
6
7$(function(){
8
9    i18next
10        .loadNamespaces('core')
11        .then(function() {
12            var $t = function (key, options) {
13                var defaults = {
14                    ns: 'core'
15                };
16                var opts = $.extend(true, {}, defaults, options)
17                return i18next.t(key, opts);
18            };
19
20            var uniqueNames = {
21                list: [],
22                message: $t('validation.nameTaken')
23            };
24            var uniqueEmails = {
25                list: [],
26                message: $t('validation.emailTaken')
27            };
28
29            // add validation methods
30            $.validator.addMethod("noSpace", function (value, element) {
31                return value.indexOf(" ") < 0 && value != "";
32            }, function (params, element) {
33                var label = $('label[for="' + element.id + '"]').text().replace(' *', '') || false;
34                if (!!label.length) {
35                    return $t('validation.noSpacesInField', {field: label});
36                }
37                return $t('validation.noSpaces');
38            });
39            $.validator.addMethod("dontStartWith", function (value, element, params) {
40                var pattern = new RegExp('^(?![' + params.join('|') + ']).*$', 'i');
41                return (this.optional(element) || pattern.test(value));
42            }, function (params, element) {
43                var label = $('label[for="' + element.id + '"]').text().replace(' *', '') || false;
44                if (!!label.length) {
45                    return $t('validation.dontStartInField', {field: label, chars: params.join(' ')});
46                }
47                return $t('validation.dontStart', {field: label, chars: params.join(' ')});
48            });
49            $.validator.addMethod("regexMatchesAny", function (value, element, params) {
50                var pattern = new RegExp('^([' + params.join('|') + ']+)$');
51                return (this.optional(element) || pattern.test(value));
52            }, function (params, element) {
53                var label = $('label[for="' + element.id + '"]').text().replace(' *', '') || false;
54                if (!!label.length) {
55                    return $t('validation.noSpecialInField', {field: label});
56                }
57                return $t('validation.noSpecial');
58            });
59            $.validator.addMethod("uniqueField", function (value, element, params) {
60                var list = [];
61
62                if (element.name.toLowerCase() === 'uname') {
63                    list = uniqueNames.list;
64                } else if (element.name.toLowerCase() === 'uemail') {
65                    list = uniqueEmails.list;
66                }
67
68                if (list.indexOf(value.toLowerCase()) !== -1) {
69                    return false;
70                }
71
72                return true;
73            }, function (params, element) {
74                if (element.name.toLowerCase() == 'uname') {
75                    return uniqueNames.message;
76                } else if (element.name.toLowerCase() == 'uemail') {
77                    return uniqueEmails.message;
78                }
79            });
80
81            // this is the custom strong password validation method
82            $.validator.addMethod('strongPassword', function (value, element) {
83
84                var $element = $(element);
85                // collect these values from the element attributes
86                // the attributes are created from the concrete 5 concrete.php file
87                var numOf = Number.parseInt($element.attr('number_of') || 0);
88                var isUpper = $element.attr('char_upper');
89                var isLower = $element.attr('char_lower');
90                var isNumber = $element.attr('char_number');
91                var isSpecial = $element.attr('char_special');
92
93                // define the object that will hold all the active filters
94                var groups = [];
95
96                // test each attribute to see if it is in this validation
97                if (isUpper) {
98                    groups.push({
99                        type: 'uppercase',
100                        regex: /^\S*(?=\S*[A-Z])\S*$/
101                    });
102                }
103
104                if (isLower) {
105                    groups.push({
106                        type: 'lowercase',
107                        regex: /^\S*(?=\S*[a-z])\S*$/
108                    });
109                }
110
111                if (isNumber) {
112                    groups.push({
113                        type: 'numeric',
114                        regex: /^\S*(?=\S*[\d])\S*$/
115                    });
116                }
117
118                if (isSpecial) {
119                    groups.push({
120                        type: 'special',
121                        regex: /^\S*(?=\S*[\W])\S*$/
122                    });
123                }
124
125                // this is a counter to check the total types set
126                var typeSet = groups.length;
127
128                // if there has been a config set incorrectly correct it here
129                if (typeSet < numOf) {
130                    numOf = typeSet;
131                }
132
133                // loop through each active character type and count success's
134                var counter = 0;
135                groups.forEach(function (group) {
136                    var reg = new RegExp(group.regex);
137
138                    if (reg.exec(value)) {
139                        counter++
140                    }
141                });
142
143                // build our base error message
144                var formatReadableGroups = function (groups, joinWith, count) {
145                    var types = groups.map(function (group) {
146                        return group.type;
147                    });
148                    var g1 = [types.slice(0, -1).map(function (type) {
149                        return $t('validation.groups.' + type + '.description', {count: count})
150                    }).join(', ')];
151                    var g2 = types.slice(-1).map(function (type) {
152                        return $t('validation.groups.' + type + '.description', {count: count});
153                    })
154                    return g1.concat(g2).join(' ' + joinWith + ' ');
155                };
156                var errorMessage = '';
157                if (numOf > 0) {
158                    errorMessage = $t('validation.passwordMustContain') + ' ';
159                    if (numOf === typeSet) {
160                        errorMessage += $t('validation.atLeast') + ' ' + formatReadableGroups(groups, $t('validation.and'), 1);
161                    } else {
162                        if (numOf !== 1) {
163                            errorMessage += $t('validation.mixOf') + ' ';
164                        }
165                        errorMessage += $t('validation.atLeastFollowing', {num: numOf}) + ' ' + formatReadableGroups(groups, $t('validation.or'), 0);
166                    }
167                }
168
169                // pass the error message to the validation handler
170                $.validator.messages["strongPassword"] = errorMessage;
171
172                // see if we have enough types to pass
173                if (counter >= numOf)
174                    return true;
175                else
176                    return false;
177
178            }, '');
179
180            // check if element has Other option and make sure that error class is being deligated correctly
181            var checkOther = function (element, action) {
182                var el = $(element);
183                const formGroup = el.parents('.form-group');
184
185                //select with other
186                if (el.is('select') && formGroup.find('input[id$=_other]').length
187                    && !formGroup.find('input[id$=_other]').is(':hidden')) {
188                    return (formGroup.find('input[id$=_other]').val() == '' && action == 'unhighlight');
189                }
190
191                //checkbox with other
192                else if (el.is('input[type="checkbox"]') && formGroup.find('input[id$=_other]').length
193                    && !formGroup.find('input[id$=_other]').is(':hidden')) {
194                    return (formGroup.find('input[id$=_other]').val() == '' && action == 'unhighlight');
195                }
196
197                return false;
198            }
199
200            // override jquery validate plugin defaults to match Bootstrap
201            $.validator.setDefaults({
202                highlight: function (element) {
203                    if (checkOther(element, 'highlight')) {
204                        return;
205                    }
206                    $(element).closest('.form-group').addClass('has-error');
207                },
208                unhighlight: function (element) {
209                    if (checkOther(element, 'unhighlight')) {
210                        return;
211                    }
212                    $(element).closest('.form-group').removeClass('has-error');
213                },
214                errorElement: 'span',
215                errorClass: 'help-block help-validation',
216                errorPlacement: function (error, element) {
217                    if (element.closest('.radioList, .checkboxList').length) {
218                        error.appendTo(element.closest('.radioList, .checkboxList'));
219                    } else if (element.parent('.input-group, label, .checkbox').length) {
220                        error.insertAfter(element.parent());
221                    } else {
222                        error.insertAfter(element);
223                    }
224                }
225            });
226
227            function IsJsonString(str) {
228                try {
229                    JSON.parse(str);
230                } catch (e) {
231                    return false;
232                }
233                return true;
234            }
235
236            $('#logInForm').validate({
237                rules: {
238                    uName: {required: true, email: true},
239                    uPassword: {required: true}
240                },
241                messages: {
242                    uName: {required: $t('validation.emailRequired')},
243                    uPassword: {required: $t('validation.passwordRequired')}
244                },
245                submitHandler: function(form) {
246                    var $form = $(form);
247                    $.ajax({
248                        type: $form.attr('method'),
249                        url: $form.attr('action'),
250                        data: $form.serialize(),
251                        dataType: 'json',
252                        headers: {
253                            'X-Locale': (window.CCM_ACTIVE_LOCALE || 'en-US')
254                        },
255                        beforeSend: function(xhr, opts) {
256                            $form.find('.error-message').attr('aria-hidden', true).removeClass().addClass('error-message').children().remove();
257                            $form.find('[type="submit"]').prop('disabled', true).addClass('is-loading');
258                        },
259                        success: function(data) {
260                            if (data.success == 1){
261                                //redirect
262                                if($('body').attr('id') == 'login') {
263                                    window.location.href = '/';
264                                    return;
265                                }
266
267                                // refresh the page if the user can view the toolbar
268                                if (data.canViewToolbar && !$('#ccm-toolbar').length) {
269                                    window.location.reload();
270                                    return;
271                                }
272
273                                $form.closest('.modal').modal('hide');
274                                _paq.push(['setUserId', data.uID]);
275                                _paq.push(['trackEvent', 'user', 'login', 'email']);
276
277                                CCM_LOGGED_IN = 'true';
278                                $(window).trigger($.Event("signedin.hive", { uID: data.uID, userName: data.userName, logout_token: data.logout_token, add_conversation_message_token: data.add_conversation_message_token, add_conversations_file_token: data.add_conversations_file_token, attributes: data.attributes, profile: data.profile, canViewToolbar: data.canViewToolbar }));
279                            } else {
280                                var $alert = $form.find('.error-message');
281
282                                if(IsJsonString(data.msg)){
283                                    var msg = JSON.parse(data.msg);
284                                    if(msg.error_type=="user_previous_platform"){
285                                        $alert.addClass('alert alert-info').attr('aria-hidden', false);
286                                        $alert.append('<p>' + msg.error_msg + '</p>');
287                                        $form.find('.form-group').hide();
288                                    }
289                                } else {
290                                    $alert.addClass('alert alert-danger').attr('aria-hidden', false);
291                                    $.each(data.msg, function(i, val) {
292                                        $alert.append('<p>' + val + '</p>');
293                                    });
294                                }
295                                $alert.fadeIn();
296                                $alert.focus();
297                            }
298                        },
299                        complete: function() {
300                            $form.find('[type="submit"]').prop('disabled', false).removeClass('is-loading');
301                        }
302                    });
303                }
304            });
305
306            $('.js-login-form').validate({
307                rules: {
308                    uName: {required: true, email: true},
309                    uPassword: {required: true}
310                },
311                messages: {
312                    uName: {required: $t('validation.emailRequired')},
313                    uPassword: {required: $t('validation.passwordRequired')}
314                },
315                submitHandler: function(form) {
316                    form.submit();
317                }
318            });
319
320            $('#signUpForm').on('grecaptcha.callback', function(e) {
321                $('#signUpForm').submit();
322            });
323
324            $('#signUpForm').validate({
325                rules: {
326                    uName: {
327                        required: true,
328                        minlength: $('[name=uName][minlength]').attr('minlength') || 3,
329                        maxlength: $('[name=uName][maxlength]').attr('maxlength') || 64,
330                        noSpace:true,
331                        dontStartWith: ['.', '_'],
332                        regexMatchesAny: ['A-Z', 'a-z', '0-9', '_', '.'],
333                        uniqueField: true,
334                    },
335                    uEmail: {
336                        required: true,
337                        email: true,
338                        uniqueField: true,
339                    },
340                    uPassword: {
341                        required: true,
342                        minlength: $('[name=uPassword][minlength]').attr('minlength') || 5,
343                        maxlength: $('[name=uPassword][maxlength]').attr('maxlength') || 128,
344                        strongPassword: true
345                    },
346                    uPasswordConfirm: {
347                        equalTo : '#signupFormPassword'
348                    },
349                    'sweeter-email': {
350                        maxlength: 0
351                    },
352                    'sweeter-input': {
353                        maxlength: 0
354                    },
355                    'sweeter-text-area': {
356                        maxlength: 0
357                    }
358                },
359                messages: {
360                    uName: {
361                        required: $t('validation.provideUsername')
362                    },
363                    uEmail: {
364                        required: $t('validation.provideEmail')
365                    },
366                    uPassword: {
367                        required: $t('validation.providePassword'),
368                        minlength: $t('validation.passwordMinLength', { length: ($('[name=uPassword][minlength]').attr('minlength') || 5) }),
369                        strong: "strong fail"
370                    },
371                    uPasswordConfirm: {
372                        equalTo: $t('validation.passwordMismatch'),
373                    }
374                },
375                submitHandler: function(form) {
376                    var $form = $(form);
377
378                    if(typeof HiveAntiSpam !== 'undefined'
379                        && !HiveAntiSpam.evaluateRequest($form))
380                    {
381                        return false;
382                    }
383
384                    $.ajax({
385                        type: $form.attr('method'),
386                        url: $form.attr('action'),
387                        data: $form.serialize(),
388                        dataType: 'json',
389                        headers: {
390                            'X-Locale': (window.CCM_ACTIVE_LOCALE || 'en-US')
391                        },
392                        beforeSend: function(xhr, opts) {
393                            $form.find('.error-message').attr('aria-hidden', true).removeClass().addClass('error-message hidden').text('');
394                            $form.find('[type="submit"]').prop('disabled', true).addClass('is-loading');
395                        },
396                        success: function(data) {
397                            if (data.success == 1) {
398                                $(window).trigger($.Event("signedup.hive", { userName: data.userName }));
399                                var nextModal = '#userDetailsModal';
400                                if (!!$form.attr('data-next-modal')) {
401                                    nextModal = $form.attr('data-next-modal');
402                                }
403
404                                if (typeof data.msg !== 'undefined' && data.msg !== '') {
405                                    var $msgContainer = $('#signUpConfirmModal').find('.js-success-msg-container');
406                                    $msgContainer.empty();
407                                    if (Array.isArray(data.msg)) {
408                                        data.msg.forEach(function(m) {
409                                            $('<p/>').text(m).appendTo($msgContainer);
410                                        });
411                                    } else {
412                                        $('<p>').text(data.msg).appendTo($msgContainer);
413                                    }
414                                }
415
416                                switchModals(nextModal);
417                                if (typeof data.isLoggedIn !== 'undefined' && data.isLoggedIn === true) {
418                                    _paq.push(['setUserId', data.uID]);
419                                    CCM_LOGGED_IN = 'true';
420                                    $(window).trigger($.Event("signedin.hive", {
421                                        uID: data.uID,
422                                        userName: data.userName,
423                                        logout_token: data.logout_token,
424                                        add_conversation_message_token: data.add_conversation_message_token,
425                                        add_conversations_file_token: data.add_conversations_file_token,
426                                        attributes: data.attributes,
427                                        profile: data.profile
428                                    }));
429                                }
430                                _paq.push(['trackEvent', 'user', 'signup', 'email']);
431                            } else {
432                                _paq.push(['trackEvent', 'user', 'signup_attempt', 'email']);
433                                var validator = $form.validate();
434                                var $alert = $form.find('.error-message');
435                                $alert.removeClass('hidden');
436                                $alert.addClass('alert alert-danger');
437
438                                $.each(data.errors, function(i, msg) {
439                                    var uEmail = $form.find('[name="uEmail"]').val().toLowerCase();
440                                    var uName = $form.find('[name="uName"]').val().toLowerCase();
441
442                                    if (msg == "The email address " + uEmail + " is already in use. Please choose another.") {
443                                        validator.showErrors({
444                                            "uEmail": uniqueEmails.message
445                                        });
446
447                                        if (uniqueEmails.list.indexOf(uEmail) === -1) {
448                                            uniqueEmails.list.push(uEmail);
449                                        }
450                                    } else if (msg == "The username " + uName + " already exists. Please choose another") {
451                                        validator.showErrors({
452                                            "uName": uniqueNames.message
453                                        });
454
455                                        if (uniqueNames.list.indexOf(uName) === -1) {
456                                            uniqueNames.list.push(uName);
457                                        }
458                                    } else if (msg == "A username may only contain letters, numbers and spaces.") {
459                                        validator.showErrors({
460                                            "uName": msg
461                                        });
462                                    } else if (msg == "A username may only contain letters or numbers.") {
463                                        validator.showErrors({
464                                            "uName": msg
465                                        });
466                                    } else {
467                                        $alert.append(msg + '<br />');
468                                    }
469                                });
470
471                                if ($alert.children().length) {
472                                    $alert.show().attr('aria-hidden', false);
473                                } else {
474                                    $alert.hide().attr('aria-hidden', true);
475                                }
476
477                                if (validator.errorList.length > 0) {
478                                    validator.errorList[0].element.focus();
479                                }
480                            }
481                        },
482                        complete: function () {
483                            $form.find('[type="submit"]').prop('disabled', false).removeClass('is-loading');
484
485                            if(typeof HiveAntiSpam !== 'undefined') {
486                                HiveAntiSpam.reset($form);
487                            }
488                        },
489                    });
490                }
491            });
492
493            $('.js-register-form').on('grecaptcha.callback', function() {
494                $('.js-register-form').submit();
495            });
496
497            $('.js-register-form').validate({
498                rules: {
499                    uName: {
500                        required: true,
501                        minlength: $('[name=uName][minlength]').attr('minlength') || 3,
502                        maxlength: $('[name=uName][maxlength]').attr('maxlength') || 64,
503                        noSpace:true,
504                        dontStartWith: ['.', '_'],
505                        regexMatchesAny: ['A-Z', 'a-z', '0-9', '_', '.'],
506                    },
507                    uEmail: {required: true, email: true},
508                    uPassword: {
509                        required: true,
510                        minlength: $('[name=uPassword][minlength]').attr('minlength') || 5,
511                        maxlength: $('[name=uPassword][maxlength]').attr('maxlength') || 128,
512                        strongPassword: true
513                    },
514                    uPasswordConfirm: {
515                        equalTo : '#uPassword'
516                    },
517                    'sweeter-email': {
518                        maxlength: 0
519                    },
520                    'sweeter-input': {
521                        maxlength: 0
522                    },
523                    'sweeter-text-area': {
524                        maxlength: 0
525                    }
526                },
527                messages: {
528                    uName: {
529                        required: $t('validation.provideUsername')
530                    },
531                    uEmail: {
532                        required: $t('validation.provideEmail')
533                    },
534                    uPassword: {
535                        required: $t('validation.providePassword'),
536                        minlength: $t('validation.passwordMinLength', { length: ($('[name=uPassword][minlength]').attr('minlength') || 5) }),
537                        strong: "strong fail"
538                    },
539                    uPasswordConfirm: {
540                        equalTo: $t('validation.passwordMismatch'),
541                    }
542                },
543                submitHandler: function(form) {
544                    var $form = $(form);
545
546                    if(typeof HiveAntiSpam !== 'undefined'
547                        && !HiveAntiSpam.evaluateRequest($form))
548                    {
549                        return false;
550                    }
551
552                    form.submit();
553                }
554            });
555
556            $('#userDetailsForm').validate({
557                submitHandler: function(form) {
558                    var $form = $(form);
559                    $.ajax({
560                        type: $form.attr('method'),
561                        url: $form.attr('action'),
562                        data: $form.serialize(),
563                        dataType: 'json',
564                        headers: {
565                            'X-Locale': (window.CCM_ACTIVE_LOCALE || 'en-US')
566                        },
567                        beforeSend: function() {
568                            $form.find('.error-message').attr('aria-hidden', true).removeClass().addClass('error-message').text('');
569                            $form.find('[type="submit"]').prop('disabled', true).addClass('is-loading');
570                        },
571                        success: function(data) {
572                            $form.find('[type="submit"]').prop('disabled', false).removeClass('is-loading');
573
574                            if (data.success == 1) {
575                                switchModals('#signUpConfirmModal');
576                            } else {
577                                var $alert = $form.find('.error-message');
578                                $alert.addClass('alert alert-danger');
579
580                                $.each(data.errors, function(i, msg) {
581                                    $alert.append(msg + '<br/>');
582                                });
583
584                                if ($alert.children().length) {
585                                    $alert.show().attr('aria-hidden', false);
586                                } else {
587                                    $alert.hide().attr('aria-hidden', true);
588                                }
589                            }
590                        }
591                    });
592                }
593            });
594
595            $('#resetPasswordForm').on('grecaptcha.callback', function(e) {
596                $('#resetPasswordForm').submit();
597            });
598
599            $('#resetPasswordForm').validate({
600                rules: {
601                    uEmail: {required: true, email: true}
602                },
603                submitHandler: function(form) {
604                    var $form = $(form);
605
606                    if(typeof HiveAntiSpam !== 'undefined'
607                        && !HiveAntiSpam.evaluateRequest($form))
608                    {
609                        return false;
610                    }
611
612                    $.ajax({
613                        type: $form.attr('method'),
614                        url: $form.attr('action'),
615                        data: $form.serialize(),
616                        dataType : 'json',
617                        headers: {
618                            'X-Locale': (window.CCM_ACTIVE_LOCALE || 'en-US')
619                        },
620                        beforeSend: function() {
621                            $form.find('.error-message').fadeOut().attr('aria-hidden', true).removeClass().addClass('error-message').children().remove();
622                            $form.find('[type="submit"]').prop('disabled', true).addClass('is-loading');
623                        },
624                        success: function(data) {
625                            $form.find('[type="submit"]').prop('disabled', false).removeClass('is-loading');
626
627                            var $alert = $form.find('.error-message');
628
629                            if (data.success == 1) {
630                                $form.find('.form-group').hide();
631                                $alert.addClass('alert alert-success');
632                                $alert.html(data.msg);
633                            }
634                            else {
635                                $alert.html('');
636                                $alert.addClass('alert alert-danger');
637                                $.each(data.msg, function(i, m) {
638                                    $alert.append(m + '<br/>');
639                                });
640                            }
641
642                            $alert.fadeIn();
643                        },
644                        complete: function () {
645                            $form.find('[type="submit"]').prop('disabled', false).removeClass('is-loading');
646                            if(typeof HiveAntiSpam !== 'undefined') {
647                                HiveAntiSpam.reset($form);
648                            }
649                        }
650                    });
651                }
652            });
653
654            $('.js-forgot-password-form').on('grecaptcha.callback', function() {
655                $('.js-forgot-password-form').submit();
656            });
657
658            $('.js-forgot-password-form').validate({
659                rules: {
660                    uEmail: {required: true, email: true}
661                },
662                submitHandler: function(form) {
663                    var $form = $(form);
664
665                    if (typeof HiveAntiSpam !== 'undefined' && !HiveAntiSpam.evaluateRequest($form)) {
666                        return false;
667                    }
668
669                    $form.find('[type="submit"]').prop('disabled', true).addClass('is-loading');
670                    form.submit();
671                }
672            });
673
674            $('.js-change-password-form').validate({
675                rules: {
676                    uPassword: {
677                        required: true,
678                        minlength: $('#uPassword').attr('minlength') || 5,
679                        maxlength: $('#uPassword').attr('maxlength') || 128,
680                        strongPassword: true
681                    },
682                    uPasswordConfirm: {
683                        required: true,
684                        equalTo: "#uPassword"
685                    }
686                },
687                submitHandler: function(form) {
688                    var $form = $(form);
689                    $form.find('[type="submit"]').prop('disabled', true).addClass('is-loading');
690                    form.submit();
691                }
692            });
693
694            $('.input-group-password-toggle').on('click', '.js-btn-toggle-password', function() {
695                var $passwordField = $(this).closest('.input-group-password-toggle').find('input');
696                if ($passwordField.length < 1) return;
697
698                $(this).toggleClass('icon-hide-password');
699
700                if ($passwordField.attr('type') === 'password') {
701                    $passwordField.attr('type', 'text');
702                    $(this).attr('aria-pressed', 'true')
703                        .attr('style', 'background-image: url(' + $(this).attr('data-hide-img') + ')')
704                        .attr('title', $t('hidePassword'))
705                        .attr('aria-label', $t('hidePassword'));
706                } else {
707                    $passwordField.attr('type', 'password');
708                    $(this).attr('aria-pressed', 'false')
709                        .attr('style', 'background-image: url(' + $(this).attr('data-show-img') + ')')
710                        .attr('title', $t('showPassword'))
711                        .attr('aria-label', $t('showPassword'));
712                }
713            });
714        });
715
716    window.openModals = {
717        loginModal: false,
718        signUpModal: false,
719        userDetailsModal: false,
720        privacyPolicyModal: false,
721        termsOfUseModal: false,
722        signUpConfirmModal: false
723    };
724
725    window.switchModals = function (target, current) {
726        var $current, $target;
727        if (current === undefined || current === null) {
728            $current = $('.modal.in');
729        } else {
730            $current = $(current);
731        }
732        $target = $(target);
733
734        if ($current.length > 1) {
735            var $topMostModal = $current.first();
736            $current.each(function() {
737                var $this = $(this);
738                if (parseInt($this.css('z-index')) >= parseInt($topMostModal.css('z-index'))) {
739                    $topMostModal = $this;
740                }
741            });
742            $current = $topMostModal;
743        }
744
745        $current.one('hide.bs.modal', function () {
746            if (openModals[$target.attr('id')] !== undefined) {
747                openModals[$target.attr('id')] = true;
748            }
749        }).one('hidden.bs.modal', function () {
750            $target.modal('show');
751        }).modal('hide');
752    };
753
754    // set aria attributes for open and closed modals
755    $('.modal').on('show.bs.modal', function(e) {
756        $(e.target).attr({
757            'aria-hidden': false,
758            'tabindex': '0'
759        });
760    }).on('hide.bs.modal', function(e) {
761        $(e.target).attr({
762            'aria-hidden': true,
763            'tabindex': '-1'
764        });
765    });
766
767    $('#loginModal').on('hidden.bs.modal', function() {
768        $('#loginModal form .form-group').show();
769        $('#loginModal').find('.error-message').attr('aria-hidden', true).removeClass().addClass('error-message').children().remove();
770    });
771
772    $('#signUpModal').on('shown.bs.modal', function() {
773        setTimeout(function() {
774            if(typeof onLoadRecaptchaCallback !== 'undefined') { onLoadRecaptchaCallback(); }
775        }, 1000);
776    });
777
778    $('#resetPasswordModal').on('shown.bs.modal', function() {
779        setTimeout(function() {
780            if(typeof onLoadRecaptchaCallback !== 'undefined') { onLoadRecaptchaCallback(); }
781        }, 1000);
782    });
783
784    $('#signUpModal').on('hidden.bs.modal', function() {
785        openModals.signUpModal = false;
786        if (openModals.privacyPolicyModal || openModals.termsOfUseModal) {
787            openModals.signUpModal = true;
788        }
789    });
790
791    $('#userDetailsModal').on('hidden.bs.modal', function() {
792        if (openModals.ideaModal) {
793            openModals.ideaModal = false;
794            reopenIdeaModal();
795        }
796        openModals.userDetailsModal = false;
797
798        //redirect
799        if($('body').attr('id') == 'login'
800            && !openModals.userDetailsModal
801                && !openModals.signUpConfirmModal) {
802            window.location.reload();
803            return;
804        }
805    });
806
807    $('#privacyPolicyModal').on('hidden.bs.modal', function() {
808        if (openModals.signUpModal) {
809            openModals.signUpModal = false;
810            $('#signUpModal').modal('show');
811        }
812        openModals.privacyPolicyModal = false;
813    });
814
815    $('#termsOfUseModal').on('hidden.bs.modal', function() {
816        if (openModals.signUpModal) {
817            openModals.signUpModal = false;
818            $('#signUpModal').modal('show');
819        }
820        openModals.termsOfUseModal = false;
821    });
822
823    /** redirect to home page if main page is login or register */
824    $('#signUpConfirmModal').on('hidden.bs.modal', function() {
825        if(openModals.signUpConfirmModal) {
826            openModals.signUpConfirmModal = false;
827
828            //redirect
829            if($('body').attr('id') == 'login') {
830                window.location.reload();
831                return;
832            }
833        }
834    });
835
836    $(document).on('click', '.js-modal-switch', function(e) {
837        e.preventDefault();
838        if ($(this).data('target') && $('.modal.in').length) {
839            switchModals($(this).data('target'));
840        }
841    });
842
843    // Since select2 is older version, and doesn't support 'unselect' event
844    var selectVal, selectPrevVal = [];
845    $('#signupFormselect, .select2.select-multiple').on('change', function(e) {
846        selectPrevVal = (!!selectVal && selectVal.length > 0) ? selectVal : selectPrevVal;
847        optionAll = $(this).find('option[value=0]');
848        options = $(this).find('option');
849        selectVal = $(this).val();
850        if (!!selectVal && selectVal.indexOf('0') === 0) { // if is 'all'
851            $(this).find('option:not([value=0])').prop('selected', true);
852        } else if (!!selectPrevVal && selectPrevVal.indexOf('0') === 0) {
853            options.prop('selected', false);
854        } else if (!selectVal || selectVal.length <= 0) { // if no values selected
855            optionAll.prop('disabled', false);
856        } else { // anything other than null or all
857            optionAll.prop('disabled', true);
858        }
859    });
860
861
862    var initAuthTypeSwitch = function($container) {
863        var $auth0 = $container.find('[data-handle="auth0_hdp"]');
864        if (!$auth0.length) {
865            return;
866        }
867        var $concrete = $container.find('[data-handle="concrete"]');
868        var $authTypes = $container.find('div[data-handle]');
869        $concrete.find('[name="uName"]').on('input', function(e) {
870            if (e.target.value && /@(harvestdp\.com|socialpinpoint\.com|mysite\.com\.au|consultationmanager\.com|openpoint\.com)$/.test(e.target.value)) {
871                $authTypes.hide();
872                $auth0.show();
873                $auth0.find('[name="uName"]').val(e.target.value);
874                $auth0.find('button[type="submit"]').focus();
875            }
876        });
877        $auth0.find('button[type="button"]').on('click', function() {
878            $authTypes.show();
879            $auth0.hide();
880            $concrete.find('[name="uName"]').focus();
881        });
882    }
883    initAuthTypeSwitch($('#loginModal'));
884    initAuthTypeSwitch($('.login-page'));
885
886    $('#fillUserAttributesForm').validate();
887
888    $(window).on('signedin.hive', function(e) {
889        if (e.uID !== '' && window.Sentry) {
890            window.Sentry.setUser({ id: String(e.uID) });
891            window.Sentry.setTag('isLoggedIn', true);
892        }
893    });
894
895    $(window).on('signedout.hive', function(e) {
896        if (typeof e.tokens !==  'undefined') {
897            if (typeof e.tokens.login_token !== 'undefined') {
898                $('#logInForm').find('[name="ccm_token"]').val(e.tokens.login_token);
899            }
900            if (typeof e.tokens.register_token !== 'undefined') {
901                $('#signUpForm').find('[name="ccm_token"]').val(e.tokens.register_token);
902            }
903        }
904        $('#ccm-page-controls-wrapper').remove();
905        $('#page').attr('style', 'padding-top:0!important');
906
907        if (window.Sentry) {
908            window.Sentry.setUser(null);
909            window.Sentry.setTag('isLoggedIn', false);
910        }
911    });
912
913});
914
915})(window.jQuery);

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.