1jQuery(function ($) { 2 $('.smcf_link, .smcf-link').click(function (e) { // added .smcf_link for previous version 3 e.preventDefault(); 4 // display the contact form 5 $('#smcf-content').modal({ 6 closeHTML: "<a href='#' title='Close' class='modalCloseX simplemodal-close'>x</a>", 7 position: ["15%",], 8 overlayId: 'smcf-overlay', 9 containerId: 'smcf-container', 10 onOpen: contact.open, 11 onShow: contact.show, 12 onClose: contact.close, 13 zIndex: 10000 14 }); 15 }); 16 17 // preload images 18 var img = ['loading.gif']; 19 if ($('#smcf-content form').length > 0) { 20 var url = $('#smcf-content form').attr('action').replace(/smcf_data\.php/, 'img/'); 21 $(img).each(function () { 22 var i = new Image(); 23 i.src = url + this; 24 }); 25 } 26 27 var contact = { 28 message: null, 29 open: function (d) { 30 // dynamically determine height 31 var h = 300; 32 if ($('#smcf-subject').length) { 33 h += 26; 34 } 35 if ($('#smcf-cc').length) { 36 h += 22; 37 } 38 39 // resize the textarea for safari 40 if ($.browser.safari) { 41 $('#smcf-container .smcf-input').css({ 42 'font-size': '.9em' 43 }); 44 } 45 46 var title = $('#smcf-container .smcf-title').html(); 47 $('#smcf-container .smcf-title').html(smcf_messages.loading); 48 d.overlay.fadeIn(200, function () { 49 d.container.fadeIn(200, function () { 50 d.data.fadeIn(200, function () { 51 $('#smcf-container .smcf-content').animate({ 52 height: h 53 }, function () { 54 $('#smcf-container .smcf-title').html(title); 55 $('#smcf-container form').fadeIn(200, function () { 56 $('#smcf-container #smcf-name').focus(); 57 58 $('#smcf-container .smcf-cc').click(function () { 59 var cc = $('#smcf-container #smcf-cc'); 60 cc.is(':checked') ? cc.attr('checked', '') : cc.attr('checked', 'checked'); 61 });
62 }); 63 }); 64 }); 65 }); 66 }); 67 }, 68 show: function (d) { 69 $('#smcf-container .smcf-send').click(function (e) { 70 e.preventDefault(); 71 // validate form 72 if (contact.validate()) { 73 $('#smcf-container .smcf-message').fadeOut(function () { 74 $('#smcf-container .smcf-message').removeClass('smcf-error').empty(); 75 }); 76 $('#smcf-container .smcf-title').html(smcf_messages.sending); 77 $('#smcf-container form').fadeOut(200); 78 $('#smcf-container .smcf-content').animate({ 79 height: '90px' 80 }, function () { 81 $('#smcf-container .smcf-loading').fadeIn(200, function () { 82 $.ajax({ 83 url: $('#smcf-content form').attr('action'), 84 data: $('#smcf-container form').serialize() + '&action=send', 85 type: 'post', 86 cache: false, 87 dataType: 'html', 88 success: function (data) { 89 $('#smcf-container .smcf-loading').fadeOut(200, function () { 90 $('#smcf-container .smcf-title').html(smcf_messages.thankyou); 91 $('#smcf-container .smcf-message').html(data).fadeIn(200); 92 }); 93 }, 94 error: function (xhr) { 95 $('#smcf-container .smcf-loading').fadeOut(200, function () { 96 $('#smcf-container .smcf-title').html(smcf_messages.error); 97 $('#smcf-container .smcf-message').html(xhr.status + ': ' + xhr.statusText).fadeIn(200); 98 }); 99 } 100 }); 101 }); 102 }); 103 } 104 else { 105 if ($('#smcf-container .smcf-message:visible').length > 0) { 106 var msg = $('#smcf-container .smcf-message div'); 107 msg.fadeOut(200, function () { 108 msg.empty(); 109 contact.showError(); 110 msg.fadeIn(200); 111 }); 112 } 113 else { 114 $('#smcf-container .smcf-message').animate({ 115 height: '30px' 116 }, contact.showError); 117 } 118 } 119 }); 120 }, 121 close: function (d) { 122 $('#smcf-container .smcf-message').fadeOut(); 123 $('#smcf-container .smcf-title').html(smcf_messages.goodbye); 124 $('#smcf-container form').fadeOut(200); 125 $('#smcf-container .smcf-content').animate({ 126 height: '40px' 127 }, function () { 128 d.data.fadeOut(200, function () { 129 d.container.fadeOut(200, function () { 130 d.overlay.fadeOut(200, function () { 131 $.modal.close(); 132 }); 133 }); 134 }); 135 }); 136 }, 137 validate: function () { 138 contact.message = ''; 139 var req = [], 140 invalid = ""; 141 142 if (!$('#smcf-container #smcf-name').val()) { 143 req.push(smcf_messages.name); 144 } 145 146 var email = $('#smcf-container #smcf-email').val(); 147 if (!email) { 148 req.push(smcf_messages.email); 149 } 150 else { 151 if (!contact.validateEmail(email)) { 152 invalid = smcf_messages.emailinvalid; 153 } 154 } 155 156 if (!$('#smcf-container #smcf-message').val()) { 157 req.push(smcf_messages.message); 158 } 159 160 if (req.length > 0) { 161 var fields = req.join(', '); 162 contact.message += req.length > 1 ? 163 fields.replace(/(.*),/,'$1 ' + smcf_messages.and) + ' ' + smcf_messages.are : 164 fields + ' ' + smcf_messages.is; 165 contact.message += ' ' + smcf_messages.required; 166 } 167 168 if (invalid.length > 0) { 169 contact.message += (req.length > 0 ? ' ' : '') + smcf_messages.emailinvalid; 170 } 171 172 if (contact.message.length > 0) { 173 return false; 174 } 175 else { 176 return true; 177 } 178 }, 179 validateEmail: function (email) { 180 var at = email.lastIndexOf("@"); 181 182 // Make sure the at (@) sybmol exists and 183 // it is not the first or last character 184 if (at < 1 || (at + 1) === email.length) 185 return false; 186 187 // Make sure there aren't multiple periods together 188 if (/(\.{2,})/.test(email)) 189 return false; 190 191 // Break up the local and domain portions 192 var local = email.substring(0, at); 193 var domain = email.substring(at + 1); 194 195 // Check lengths 196 if (local.length < 1 || local.length > 64 || domain.length < 4 || domain.length > 255) 197 return false; 198 199 // Make sure local and domain don't start with or end with a period 200 if (/(^\.|\.$)/.test(local) || /(^\.|\.$)/.test(domain)) 201 return false; 202 203 // Check for quoted-string addresses 204 // Since almost anything is allowed in a quoted-string address, 205 // we're just going to let them go through 206 if (!/^"(.+)"$/.test(local)) { 207 // It's a dot-string address...check for valid characters 208 if (!/^[-a-zA-Z0-9!#$%*\/?|^{}`~&'+=_\.]*$/.test(local)) 209 return false; 210 } 211 212 // Make sure domain contains only valid characters and at least one period 213 if (!/^[-a-zA-Z0-9\.]*$/.test(domain) || domain.indexOf(".") === -1) 214 return false; 215 216 return true; 217 }, 218 showError: function () { 219 $('#smcf-container .smcf-message') 220 .html($('<div/>').addClass('smcf-error').append(contact.message)) 221 .fadeIn(200); 222 } 223 }; 224});
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.