1jQuery(function($) { 2 3 $('form[id^=rm-subscriptionform-]').on('submit', function() { 4 5 var self = $(this), 6 data = self.serialize(); 7 8 self.find('input[type="submit"]').hide(); 9 self.find('input').prop('disabled', true); 10 self.find('.spinner').show(); 11 12 $ 13 .post({ 14 url: self.attr('action'), 15 data: data, 16 dataType: 'json', 17 beforeSend: function(xhr) { 18 xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); 19 } 20 }) 21 .always(function() { 22 23 self.find('.rm-error').hide(); 24 25 self.find('input[type="submit"]').show(); 26 self.find('input').prop('disabled', false); 27 self.find('.spinner').hide(); 28 29 }) 30 .then(function(xhr) { 31 32 self 33 .removeClass('rm-subscribe-error') 34 .addClass('rm-subscribe-success'); 35 36 self.find('.rm-success-container').remove(); 37 38 var el = $('<li class="rm-success-container"><span class="rm-success"></span></li>'); 39 el.find('.rm-success').html(rmwidget.msg_subscribe_success); 40 el.prependTo(self.find('ul'));
41 42 self[0].reset(); 43 44 }) 45 .fail(function(xhr) { 46 47 self 48 .addClass('rm-subscribe-error') 49 .removeClass('rm-subscribe-success'); 50 51 var hasGlobalError = false, 52 hasLocalError = false; 53 54 if (xhr.status === 422) { 55 56 $.each(xhr.responseJSON.validation_messages, function(fieldName, message) { 57 58 var cls = 'rm-error-' + fieldName, 59 el = self.find('.' + cls), 60 target = []; 61 62 if (el.length) { 63 el.html(message).show(); 64 hasLocalError = true; 65 } else { 66 67 target = self.find('.rm-' + fieldName + '-error-after,[name="' + fieldName + '"]').first(); 68 69 if (target.length) { 70 71 $('<span class="rm-error"></span>') 72 .html(message) 73 .addClass(cls) 74 .insertAfter(target); 75 76 hasLocalError = true; 77 78 } else { 79 hasGlobalError = true; 80 } 81 82 } 83 84 }); 85 86 } else { 87 hasGlobalError = true; 88 } 89 90 if (hasGlobalError && !hasLocalError) { 91 92 var el = $('<li class="rm-global-errors-container"><span class="rm-error"></span></li>'); 93 el.find('.rm-error').html(rmwidget.msg_an_error_occurred); 94 el.prependTo(self.find('ul'));
95 96 } 97 98 }); 99 100 return false; 101 102 }); 103 104});
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.