1/* 2Name: View - Contact 3Written by: Okler Themes - (http://www.okler.net) 4Version: 3.1.0 5*/ 6 7(function() { 8 9 "use strict"; 10 11 var Contact = { 12 13 initialized: false, 14 15 initialize: function() { 16 17 if (this.initialized) return; 18 this.initialized = true; 19 20 this.build(); 21 this.events(); 22 23 }, 24 25 build: function() { 26 27 // Containers 28 var map = $("#googlemaps"), 29 contactForm = $("#contactformside"); 30 31 // Validations Form Type 32 if(contactForm.get(0)) { 33 34 if(contactForm.data("type") == "advanced") { 35 this.advancedValidations(); 36 } else { 37 this.basicValidations(); 38 } 39 40 } 41 42 43 }, 44 45 events: function() { 46 47 48 49 }, 50 51 52 53advancedValidations: function() { 54 55 var submitButton = $("#contactFormSubmit"), 56 contactFormside = $("#contactformside"); 57 58 submitButton.on("click", function() { 59 if(contactFormside.valid()) { 60 submitButton.button("loading"); 61 } 62 }); 63 64 contactFormside.validate({ 65 onkeyup: false, 66 onclick: false, 67 onfocusout: false, 68 rules: { 69 name: { 70 required: true 71 }, 72 email: { 73 required: true, 74 email: true 75 }, 76 phone: { 77 required: true 78 }, 79 message: { 80 required: true 81 }, 82 course: { 83 required: true 84 }, 85 captcha: { 86 required: true, 87 captcha: true 88 }, 89 //'checkboxes[]': { 90 // required: true 91 // } 92 }, 93 highlight: function (element) { 94 $(element) 95 .parent() 96 .removeClass("has-success") 97 .addClass("has-error"); 98 }, 99 success: function (element) { 100 $(element) 101 .parent() 102 .removeClass("has-error") 103 .addClass("has-success") 104 .find("label.error") 105 .remove(); 106 } 107 }); 108 109 $.validator.addMethod("captcha", function () { 110 var captchaValid = false; 111 var phpquery = $.ajax({ 112 url: "inc/php/contact-form-verify-captcha.php", 113 type: "POST", 114 async: false, 115 dataType: "json", 116 data: { 117 captcha: $.trim($("#contactformside #captcha").val()) 118 }, 119 success: function (data) { 120 if (data.response == "success") { 121 captchaValid = true; 122 } else { 123 124 } 125 } 126 }); 127 if (captchaValid) { 128 return true; 129 } 130 }, ""); 131 132 }, 133 134 135 basicValidations: function() { 136 137 var contactform = $("#contactForm"), 138 url = contactform.attr("action"); 139 140 contactform.validate({ 141 submitHandler: function(form) { 142 143 // Loading State 144 var submitButton = $(this.submitButton); 145 submitButton.button("loading"); 146 147 // Ajax Submit 148 $.ajax({ 149 type: "POST", 150 url: url, 151 data: { 152 "name": $("#contactForm #name").val(), 153 "email": $("#contactForm #email").val(), 154 "subject": $("#contactForm #subject").val(), 155 "phone": $("#contactForm #phone").val(), 156 "course": $("#contactForm #course").val(), 157 "message": $("#contactForm #message").val() 158 }, 159 dataType: "json", 160 success: function (data) { 161 if (data.response == "success") { 162 163 $("#contactSuccess").removeClass("hidden"); 164 $("#contactError").addClass("hidden"); 165 166 // Reset Form 167 $("#contactForm .form-control") 168 .val("") 169 .blur() 170 .parent() 171 .removeClass("has-success") 172 .removeClass("has-error") 173 .find("label.error") 174 .remove(); 175 176 if(($("#contactSuccess").position().top - 80) < $(window).scrollTop()){ 177 $("html, body").animate({ 178 scrollTop: $("#contactSuccess").offset().top - 80 179 }, 300); 180 } 181 182 } else { 183 184 $("#contactError").removeClass("hidden"); 185 $("#contactSuccess").addClass("hidden"); 186 187 if(($("#contactError").position().top - 80) < $(window).scrollTop()){ 188 $("html, body").animate({ 189 scrollTop: $("#contactError").offset().top - 80 190 }, 300); 191 } 192 193 } 194 }, 195 complete: function () { 196 submitButton.button("reset"); 197 } 198 }); 199 }, 200 rules: { 201 name: { 202 required: true 203 }, 204 email: { 205 required: true, 206 email: true 207 }, 208 subject: { 209 required: true 210 }, 211 phone: { 212 required: true 213 }, 214 message: { 215 required: true 216 } 217 }, 218 highlight: function (element) { 219 $(element) 220 .parent() 221 .removeClass("has-success") 222 .addClass("has-error"); 223 }, 224 success: function (element) { 225 $(element) 226 .parent() 227 .removeClass("has-error") 228 .addClass("has-success") 229 .find("label.error") 230 .remove(); 231 } 232 }); 233 234 } 235 236 237 238 239 240 }; 241
242 Contact.initialize(); 243 244})();
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.