1(function($){ 2 var hgMailchimp = {}; 3 4 hgMailchimp.cachedDom = function(){ 5 this.doc = $(document); 6 }; 7 8 hgMailchimp.init = function(){ 9 10 this.cachedDom(); 11 12 this.refresh_events( this.doc ); 13 // Refresh events on new content 14 this.doc.on('ZnNewContent',function(e){ 15 this.refresh_events( e.content ); 16 }.bind(this)); 17 }; 18 19 hgMailchimp.refresh_events = function(scope){ 20 this.mailchimp_subscribe( scope ); 21 }; 22 23 hgMailchimp.mailchimp_subscribe = function( scope ){ 24 25 var element = scope.find('.js-mcForm'); 26 27 if(element && element.length){ 28 element.each(function(index, el) { 29 30 $(el).on('submit', function(e) { 31 32 e.preventDefault(); 33 34 var self = $(this), 35 ajax_url = self.attr('data-url'), 36 email_field = self.find('.js-mcForm-email').val(), 37 result_placeholder = self.parent().find('.js-mcForm-result'); 38 39 self.addClass('is-submitting'); 40 41 if(email_field === ''){ 42 self.addClass('has-error'); 43 self.removeClass('is-submitting'); 44 return; 45 } 46 else if ( !email_field.match(/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/) ) { 47 self.addClass('has-error'); //see #1902 48 self.removeClass('is-submitting'); 49 return; 50 } 51 52 self.removeClass('has-error'); 53 result_placeholder.html(''); 54 55 formData = self.serialize(); 56 57 $.post( hgMailchimpConfig.ajaxurl, formData).success(function( data ){ 58 self.removeClass('is-submitting'); 59 if( data.success ){ 60 result_placeholder.html('<div class="dn-alert alert alert-success">' + data.data.message + '</div>'); 61 } 62 else{ 63 result_placeholder.html('<div style="color:#ff0000;"><b>'+ hgMailchimpConfig.l10n.error +'</b> ' + data.data.message + '</div>'); 64 } 65 }).error(function() { 66 self.removeClass('is-submitting'); 67 result_placeholder.html('ERROR.').css('color', 'red'); 68 }); 69 70 }); 71 }); 72 } 73 }; 74 75 // Init the script 76 hgMailchimp.init(); 77 78})(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.