1// START REGISTER VIEW 2var RegisterNewsletterView = { 3 tpl:_tpl_, 4 form:"form#newsletterForm", 5 ajaxUrl:_base_lang+"/na_ajax.php?action=register_newsletter_popup", 6 7 init: function() { 8 var self = this; 9 10 self.initPopup(); 11 self.initSubmitButton(self.form); 12// self.initClearButton(self.form); 13 14 self.initActions(self.form); 15 }, 16 17 initActions: function(form) { 18 var self = this; 19 20 /* 21 $(form).find("a.reload_captcha").bind("click",function(){ 22 reloadCaptcha('captcha_image_r'); 23 }); 24 */ 25 26// $('#social_email').bind('click', function(e) { 27 $('.social_email').bind('click', function(e) { 28 $('#newsletter_popup').bPopup(); 29// $(form).find("a.reload_captcha").trigger("click"); 30 e.preventDefault(); 31 }); 32 }, 33 34 initSubmitButton: function(form) { 35 var self = this; 36 37 $(form).find("#submitForm_n").click(function(event){ 38 var checked = self.initValidateForm(form); 39 if( checked == true ) { 40 self.submitForm(form); 41 } 42 event.preventDefault(); 43 }); 44 }, 45 46 initClearButton: function(form) { 47 var self = this; 48 49 $(form).find("#resetForm_n").click(function(event){ 50 if( confirm(self.tpl['approveClearForm']) ) { 51 self.clearForm(form); 52 } 53 event.preventDefault(); 54 }); 55 }, 56 57 submitForm: function(form) { 58 var self = this; 59 60 var url = self.ajaxUrl; 61 var params = $(form).serialize(); 62 63 var send = runJqueryAjax(url,params); 64 65 if( send == "success" ) { 66 Set_Cookie( 'pu', "1", 365 ); 67 alert(self.tpl['registerSuccessConf']); 68 self.clearForm(form); 69 $("#newsletter_popup a.bClose").trigger("click"); 70 } 71 else { 72 alert(self.tpl[send]); 73 } 74 }, 75 76 clearForm: function(form) { 77 var self = this; 78 resetForm(form); 79 }, 80 81 initValidateForm: function(form) { 82 var self = this; 83 84 var inputArray = ["fullName","email","phone"]; 85 86 for( var i in inputArray ) { 87 var inputName = inputArray[i]; 88 var input = $(form).find("input[name="+inputName+"]"); 89 var inputVal = $(input).val(); 90 91 if( inputVal == "" ) { 92 var inputDesc = self.tpl['pleaseEnter'] + " " + $(input).parent().prev().text(); 93 alert(inputDesc); 94 $(input).focus(); 95 return false; 96 } 97 98 if( ( inputName == "email" ) && !checkEmail(inputVal) ) { 99 var inputDesc = self.tpl['invalidEmail']; 100 alert(inputDesc); 101 $(input).focus(); 102 return false; 103 } 104 105 if( ( inputName == "phone" ) && !checkPhone(inputVal) ) { 106 var inputDesc = self.tpl['invalidPhone']; 107 alert(inputDesc); 108 $(input).focus(); 109 return false; 110 } 111 } 112 113 var captchValid = self.validCaptcha(form); 114 if( captchValid !== true ) { 115 return false; 116 } 117 118 /* 119 var confirmTemrs = $(form).find("input[name=confirmTerms]").is(":checked"); 120 if( !confirmTemrs ) { 121 alert(self.tpl['confirmTerms']); 122 $(form).find("input[name=confirmTerms]").focus(); 123 return false; 124 } 125 */ 126 127 return true; 128 }, 129 130 validCaptcha: function(form) { 131 var self = this; 132 133 if( $(form).find("input[name=security_code]").length > 0 ) 134 { 135 var input_security = $(form).find("input[name=security_code]"); 136 var input_security_val = trim( $(input_security).val() ); 137 138 if (trim( input_security_val ) == "") 139 { 140 alert(self.tpl['pleaseEnter'] + " " + self.tpl['captchCode']); 141 $(input_security).focus(); 142 return false; 143 } 144 145 var c_url = _base+"/na_ajax.php?action=get_session&session_name=security_code"; 146 var c_params = "action=get_session&session_name=security_code"; 147 var security_code = runJqueryAjax(c_url,c_params); 148 149 if ( input_security_val != security_code ) 150 { 151 alert(self.tpl['errorCaptchCode']); 152 $(input_security).focus(); 153 return false; 154 } 155 } 156 return true; 157 }, 158 159 initPopup : function () { 160 var self = this; 161
162 var popupWasShowed = localStorage.getItem('popupWasShowed') || ''; 163 if (popupWasShowed != 'yes') { 164 $('#newsletter_popup').bPopup(); 165 localStorage.setItem('popupWasShowed','yes'); 166 } 167 } 168} 169// END REGISTER VIEW
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.