1/** 2 * Copyright (C) 2015 freakedout (www.freakedout.de) 3 * This program is free software: you can redistribute it and/or modify 4 * it under the terms of the GNU General Public License as published by 5 * the Free Software Foundation, either version 3 of the License, or 6 * (at your option) any later version. 7 * This program is distributed in the hope that it will be useful, 8 * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * GNU General Public License for more details. 11 * You should have received a copy of the GNU General Public License 12 * along with this program. If not, see <http://www.gnu.org/licenses/>. 13**/ 14 15!function($){ 16 $(document).ready(function() { 17 $('div.mcSignupModule input.url').blur(function() { 18 if ( $(this).val() == 'http://') { 19 $(this).val(''); 20 } else if ($(this).val() && $(this).val().indexOf('http://') != 0) { 21 $(this).val('http://' + $(this).val()); 22 } 23 }); 24 25 $('div.mcSignupModule input.number').blur(function() { 26 if ($(this).val() != parseFloat($(this).val())) { 27 alert($(this).attr('title').replace(' *', '') + ' ' + mcSignupErrorNotANumber); 28 } 29 }); 30 31 $('.mcSignupSubmit').click(function() { 32 var moduleId = $(this).data('id'); 33 var module = $('#mcSignupModule_' + moduleId); 34 //var isMember = <?php echo $user->id;?>; 35 36 // Validate email address with regex 37 if (!mcSignupCheckEmail(module.find('input[name=fields\\[EMAIL\\]]').val())) { 38 alert(mcSignupErrorInvalidEmail); 39 return; 40 } 41 42 var checked = []; 43 var formValid = true; 44 45 rVal = true; 46 47 module.find('.mcSignupRequired').each(function() { 48 var title = $(this).attr('title'); 49 var name = $(this).attr('name'); 50 51 if ($.inArray(name, checked) > -1) { 52 return true; // continue 53 } 54 checked.push(name); 55 56 if ($.inArray($(this).attr('type'), Array('checkbox', 'radio')) > -1) { 57 name = name.replace(/\[/g, '\\[').replace(/\]/g, '\\]'); 58 if (module.find('input[name=' + name + ']:checked').length == 0) { 59 alert(title.replace(' \*', '') + ' ' + mcSignupErrorRequired); 60 formValid = false; 61 return false; 62 } 63 } else if ($(this).val() == '') { 64 alert(title.replace(' \*', '') + ' ' + mcSignupErrorRequired); 65 formValid = false; 66 return false; 67 } 68 }); 69 70 // Submit the form 71 if (formValid) { 72 mcSignupSubmit(module); 73 } 74 }); 75 76 $('.mcSignupTryAgain').click(function(e) { 77 e.preventDefault(); 78 79 $('#mcSignupModule_' + $(this).data('id') + ' .mcSignupTryAgainWrapper').css('display', 'none'); 80 $('#mcSignupModule_' + $(this).data('id') + ' .mcSignupResult').css('display', 'none'); 81 $('#mcSignupModule_' + $(this).data('id') + ' .intro').css('display', 'block'); 82 $('#mcSignupModule_' + $(this).data('id') + ' .mcSignupFormWrapper').css('display', 'block'); 83 }); 84 85 function mcSignupCheckEmail(email) { 86 var pattern = /^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; 87 return pattern.test(email); 88 } 89 90 function mcSignupSubmit(module) { 91 var moduleId = module.data('id'); 92 93 $.ajax({
94 url: mcSignupBaseUrl + 'index.php?option=com_joomailermailchimpintegration&task=signup&format=raw', 95 type: 'post', 96 dataType: 'json', 97 data: module.find('form').serialize(), 98 beforeSend: function() { 99 module.find('.intro').css('display', 'none'); 100 module.find('.mcSignupFormWrapper').css('display', 'none'); 101 module.find('.ajaxLoader').css('display', 'block'); 102 }, 103 success: function(response) { 104 module.find('.ajaxLoader').css('display', 'none'); 105 module.find('.mcSignupResult').html(response.html).css('display', 'block'); 106 if (response.error == true) { 107 module.find('.mcSignupTryAgainWrapper').css('display', 'block'); 108 } 109 } 110 }); 111 112 } 113 }); 114}(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.