1;(function ( $, window, document, undefined ) { 2 3 4 $(document).ready(function($) { 5 var $signups = $('.sendpress-signup'); 6 7 $signups.each(function(){ 8 $form = $(this), 9 $error = $form.find('#error'), 10 $thanks = $form.find('#thanks'), 11 $exists = $form.find('#exists'); 12 13 //$error.hide(); 14 //$thanks.hide(); 15 }); 16 17 $signups.submit(function(e){ 18 e.preventDefault(); 19 20 var signup = {}, 21 $form = $(this), 22 $error = $form.find('#error'), 23 $thanks = $form.find('#thanks'), 24 $formwrap = $form.find('#form-wrap'), 25 $submit = $form.find('#submit'), 26 $ajaxInd = $form.find('.ajaxloader'), 27 submit_ok = true, 28 emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/; 29 30 $error.hide(); 31 $ajaxInd.show(); 32 33 signup['first'] = $form.find('.sp_firstname').val(); 34 signup['last'] = $form.find('.sp_lastname').val(); 35 signup['email'] = $form.find('.sp_email').val(); 36 signup['phonenumber'] = $form.find('.sp_phonenumber').val(); 37 signup['salutation'] = $form.find('.sp_salutation').val(); 38 signup['listid'] = "";//$form.find('.sp_list').val(); 39 signup['formid'] = $form.data('form-id'); 40 signup['sp_contact_me_by_fax_only'] = $form.find('.sp_contact_me_by_fax_only:checked').val(); 41 $form.find("input:checkbox.sp_list:checked").each(function(){ 42 signup['listid'] += $(this).val() +","; 43 }); 44 if(signup['listid'] === ""){ 45 signup['listid'] = $form.find('.sp_list').val(); 46 } 47 48 $form.find('.sp_custom_field').each(function(){ 49 var $obj = $(this); 50 signup[$obj.attr('id')] = $obj.val(); 51 }); 52 53 //adding this back in for post notifications 54 $form.find('.custom-field').each(function(){ 55 var $obj = $(this); 56 signup[$obj.attr('id')] = $obj.val(); 57 }); 58 59 signup['action'] = 'sendpress_subscribe_to_list'; 60 61 if( signup.email.length === 0 ){ 62 $error.show(); 63 $error.html('<div class="item">*'+sendpress.missingemail+'.</div>'); 64 submit_ok = false; 65 }else if(!emailReg.test(signup.email)) { 66 $error.show(); 67 $error.html('<div class="item">'+sendpress.invalidemail+'.</div>'); 68 submit_ok = false; 69 } 70 71 $.each($form.find('.required'), function(index, value){ 72 if($(value).val().length === 0 && submit_ok){ 73 $error.show(); 74 $error.html('<div class="item">'+sendpress.required+'</div>'); 75 submit_ok = false; 76 } 77 }); 78 79 $form.find("input:checkbox#signup_approval").each(function(){ 80 var $obj = $(this); 81 82 if($obj.is(':checked')){ 83 signup['signup_approval'] = "yes"; 84 }else{ 85 $error.show(); 86 $error.html('<div class="item">'+sendpress.required+'</div>'); 87 submit_ok = false; 88 } 89 90 91 }); 92 93 if(submit_ok){ 94 $submit.attr("disabled", "disabled"); 95 96 97 98 jQuery.post(sendpress.ajaxurl, signup, function(response){ 99 100 try { 101 response = JSON.parse(response); 102 } catch (err) { 103 // Invalid JSON. 104 $submit.removeAttr("disabled"); 105 if(!jQuery.trim(response).length) { 106 response = { error: 'Server returned empty response during add attempt'}; 107 } else { 108 response = {error: 'Server returned invalid response:<br /><br />' + response}; 109 } 110 } 111 112 if(response.success){ 113 $error.hide(); 114 $formwrap.hide(); 115 if(response.exists){ 116 $exists.show(); 117 }else{ 118 $thanks.show(); 119 } 120 121 }else{ 122 //possibly display an error here 123 124 } 125 }); 126 127 }else{ 128 $ajaxInd.hide(); 129 } 130 131 return false;
132 133 }); 134 /* 135 $('.sendpress-signup input').bind('focus blur',function(e){ 136 var $obj = $(this), 137 $value = $obj.val(), 138 $orig = $obj.attr('orig'); 139 140 if(e.type === "focus"){ 141 if($value === $orig){ 142 $obj.val(''); 143 } 144 }else{ 145 if($value === ''){ 146 $obj.val($orig); 147 } 148 } 149 150 }); 151 */ 152 $('.sendpress-signup .post-notifications-list').on('click', function(e){ 153 var $obj = $(this), 154 $form = $obj.closest('form.sendpress-signup'), 155 type = $obj.data('type'), 156 hidden = "<input class='post-notifications custom-field' type='hidden' value='"+type+"' name='post_notifications' id='post_notifications'/>"; 157 158 if($obj.is(':checked')){ 159 $form.append(hidden); 160 }else{ 161 $form.find('.post-notifications').remove(); 162 } 163 }); 164 165 }); 166 167}).call( window.sendpress=window.sendpress || {}, jQuery, window, document ); 168 169 170 171 172 173 174
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.