1jQuery(function($) { 2 $.fn.inPageStatus = function (action, value) { 3 if (!this[0]) return; 4 var el = this; 5 var jThis = $(this); 6 jThis.addClass('in-page-status'); 7 if (typeof action == 'object') { 8 value = action; 9 action = false; 10 } 11 if (!action) { 12 var settings = $.extend(true, { 13 messages: { 14 wait: '<i class="fa fa-spin fa-spinner"></i>', 15 success: this.data('success_message'), 16 error: this.data('failure_message') 17 }, 18 clickToClose: { 19 error: true 20 } 21 }, value); 22 jThis.data('messages', settings.messages); 23 $.each(settings.messages, function (id, val) { 24 var t = '<div aria-live="alert" role="dialog" aria-hidden="true" class="nv-message ' + id + '-holder"><div class="' + id + '-message">' + val + '</div></div>'; 25 jThis.append(t); 26 }); 27 $.each(settings.clickToClose, function (k, v) { 28 if (!v) return; 29 jThis.find('.' + k + '-holder').click(function (ev) { 30 ev.preventDefault(); 31 $(this).attr('aria-hidden', 'true'); 32 $.each(settings.messages, function (id) { 33 jThis.removeClass(id); 34 }); 35 }); 36 }); 37 } else { 38 var msgs = jThis.data('messages'); 39 if (!msgs[action]) { 40 msgs[action] = value; 41 } 42 $.each(msgs, function (id) { 43 jThis.removeClass(id); 44 }); 45 if (value) { 46 jThis.attr('aria-hidden', 'false'); 47 jThis.find('.' + action + '-message').html(value); 48 } 49 jThis.addClass(action); 50 } 51 return this; 52 }; 53 54 var frm = $('.active-form'); 55 frm.inPageStatus({ 56 messages: { 57 success: frm.data('success_message'), 58 failure: frm.data('failure_message') 59 }, 60 clickToClose: {success: 1, failure: 1} 61 }); 62 63 frm.submit(function (ev) { 64 ev.preventDefault(); 65 afterSubmit(frm); 66 }); 67 function afterSubmit(form) { 68 var errors = { 69 'MISC': form.data('failure_message') 70 }; 71 //var form = $('.active-form'); 72 var action = form[0].action; 73 var data = form.serializeArray().reduce(function (m, o) { 74 m[o.name] = o.value; 75 return m; 76 }, {}); 77 data['action'] = form.find('input[name=_action]').val(); 78 if (window._paq) { 79 _paq.push(['trackEvent', 'Register', 'Submit', 'Attempt']); 80 } 81 form.inPageStatus('wait'); 82 //atc.inPageStatus('success'); return; 83 $.ajax({ 84 type: "POST", 85 url: action, 86 data: data, 87 success: function (response) { 88 if (response.success) { 89 if(window._paq) { 90 _paq.push(['trackEvent', 'Register', 'Submit', 'Success']); 91 } 92 form.inPageStatus('success', form.data('success_message')); 93 } else { 94 if(window._paq) { 95 _paq.push(['trackEvent', 'Register', 'Submit', 'Fail']); 96 } 97 if (response.data) { 98 form.inPageStatus('error', errors[response.data.error]); 99 } else { 100 form.inPageStatus('error', errors['MISC']); 101 } 102 } 103 }, 104 error: function () { 105 form.inPageStatus('error', errors['MISC']); 106 }, 107 dataType: 'json' 108 }); 109 } 110}); 111
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.