1/* 2 * author: Awedoo Studio 3 * template: Bicolor - Creative Coming Soon Template 4 * version: v1.1 5 * url: http://themeforest.net/user/awedoo 6 */ 7 8(function ($) { 9 "use strict"; 10 11 function awdMenu() { 12 $(".menu-toggle").on('click', function (e) { 13 $(this).toggleClass('opened'); 14 $("#awd-site-nav").toggleClass('active'); 15 }); 16 } 17 18 ///** Background Animation **/ 19 20 var canvas = document.getElementById("awd-site-canvas"); 21 var ctx = canvas.getContext("2d"); 22 window.requestAnimFrame = (function () { 23 return window.requestAnimationFrame || 24 window.webkitRequestAnimationFrame || 25 window.mozRequestAnimationFrame || 26 function (callback) { 27 window.setTimeout(callback, 1000 / 60); 28 }; 29 })(); 30 31 var curves_array = []; 32 var curve = function (abc1x, abc1y, abc2x, abc2y, x, y, abc1xvx, abc1xvy, abc1yvx, abc1yvy, abc2xvx, abc2xvy, abc2yvx, abc2yvy) { 33 this.abc1x = abc1x; 34 this.abc1y = abc1y; 35 this.abc2x = abc2x; 36 this.abc2y = abc2y; 37 this.x = x; 38 this.y = y; 39 40 this.abc1xvx = abc1xvx; 41 this.abc1xvy = abc1xvy; 42 this.abc1yvx = abc1yvx; 43 this.abc1yvy = abc1yvy; 44 45 this.abc2xvx = abc2xvx; 46 this.abc2xvy = abc2xvy; 47 this.abc2yvx = abc2yvx; 48 this.abc2yvy = abc2yvy; 49 }; 50 51 52 function awdCanvasResize() { 53 canvas.width = window.innerWidth; 54 canvas.height = window.innerHeight; 55 } 56 57 58 function awdCanvasInit() { 59 for (var i = 0; i < awd_bg_number_of_curves; i++) { 60 var abc1x = Math.random() * canvas.width; 61 var abc1y = Math.random() * canvas.height; 62 var abc2x = Math.random() * canvas.width; 63 var abc2y = Math.random() * canvas.height; 64 var x = 0; 65 var y = 0; 66 67 var abc1xvx = Math.random() * 2 - 1; 68 var abc1xvy = Math.random() * 2 - 1; 69 70 var abc1yvx = Math.random() * 2 - 1; 71 var abc1yvy = Math.random() * 2 - 1; 72 73 var abc2xvx = Math.random() * 2 - 1; 74 var abc2xvy = Math.random() * 2 - 1; 75 76 var abc2yvx = Math.random() * 2 - 1; 77 var abc2yvy = Math.random() * 2 - 1; 78 79 80 curves_array.push( 81 new curve( 82 abc1x, abc1y, abc2x, abc2y, 83 x, y, 84 abc1xvx, abc1xvy, abc1yvx, abc1yvy, 85 abc2xvx, abc2xvy, abc2yvx, abc2yvy 86 ) 87 ); 88 } 89 } 90 91 92 function awdCanvasDraw() { 93 ctx.clearRect(0, 0, canvas.width, canvas.height); 94 95 ctx.lineWidth = 1; 96 ctx.strokeStyle = $("#awd-site-wrap").css('color'); 97 98 for (var i = 0; i < curves_array.length; i++) { 99 100 ctx.beginPath(); 101 ctx.moveTo(-100, canvas.height + 100); 102 ctx.bezierCurveTo( 103 curves_array[i].abc1x, curves_array[i].abc1y, 104 curves_array[i].abc2x, curves_array[i].abc2y, 105 canvas.width + 100, curves_array[i].y - 100 106 ); 107 ctx.stroke(); 108 109 if (curves_array[i].abc1x < 0 || curves_array[i].abc1x > canvas.width) { 110 curves_array[i].abc1x -= curves_array[i].abc1xvx; 111 curves_array[i].abc1xvx *= -1; 112 } 113 if (curves_array[i].abc1y < 0 || curves_array[i].abc1y > canvas.height) { 114 curves_array[i].abc1y -= curves_array[i].abc1yvy; 115 curves_array[i].abc1yvy *= -1; 116 } 117 118 if (curves_array[i].abc2x < 0 || curves_array[i].abc2x > canvas.width) { 119 curves_array[i].abc2x -= curves_array[i].abc2xvx; 120 curves_array[i].abc2xvx *= -1; 121 } 122 if (curves_array[i].abc2y < 0 || curves_array[i].abc2y > canvas.height) { 123 curves_array[i].abc2y -= curves_array[i].abc2yvy; 124 curves_array[i].abc2yvy *= -1; 125 } 126 127 curves_array[i].abc1y += curves_array[i].abc1yvy; 128 curves_array[i].abc1x += curves_array[i].abc1xvx; 129 curves_array[i].abc2x += curves_array[i].abc2xvx; 130 }
131 requestAnimFrame(awdCanvasDraw); 132 } 133 134 function awdCanvas() { 135 awdCanvasResize(); 136 awdCanvasInit(); 137 awdCanvasDraw(); 138 } 139 140 ///** ANIMATE ELEMENTS **/ 141 142 function awdAnimate(state) { 143 if (!$('body').hasClass('mobile')) { 144 145 var elements; 146 147 if (state == "active") { 148 elements = $('.start .active .animated'); 149 } else { 150 elements = $('.start .animated'); 151 } 152 153 elements.each(function () { 154 var that = $(this); 155 if (!that.hasClass('visible')) { 156 if (that.data('animation-delay')) { 157 setTimeout(function () { 158 that.addClass(that.data('animation') + " visible"); 159 }, that.data('animation-delay')); 160 } else { 161 that.addClass(that.data('animation') + " visible"); 162 } 163 } 164 }); 165 166 } 167 } 168 169 ///** CONTENT SLIDER **/ 170 171 function awdContentSlider() { 172 $('.slide-item').first().addClass('active'); 173 174 var bg = $('#bg'); 175 var menu = $('#awd-site-nav'); 176 var menu_link = menu.find('a'); 177 178 menu_link.on('click', function (e) { 179 e.preventDefault(); 180 181 var active_slide = $(this).data('slide'); 182 var active_bg = bg.find('.bg-' + active_slide); 183 184 bg.find('.awd-site-bg').removeClass('active'); 185 $('#awd-site-wrap').removeClass('bg-' + menu.find('a.active').data('slide')).addClass("bg-" + active_slide); 186 active_bg.css({ 187 "left": $(this).offset().left + ($(this).outerWidth() / 2) - 50, 188 "top": $(this).offset().top + ($(this).outerHeight() / 2) - 50 189 }); 190 active_bg.addClass('active'); 191 192 if ($(window).width() < 769) { 193 menu.removeClass('active'); 194 $(".menu-toggle").removeClass('opened'); 195 } 196 197 if (!$(this).hasClass('active')) { 198 199 menu_link.removeClass('active'); 200 $(this).addClass('active'); 201 202 var active_slide_content = $('.slide-item[data-slide-id=' + active_slide + ']'); 203 if (active_slide_content) { 204 $('.slide-item').removeClass('active'); 205 active_slide_content.addClass('active'); 206 207 if (active_slide_content.hasClass('active')) { 208 awdAnimate('active'); 209 } 210 211 } 212 } 213 214 }); 215 216 //* go to current slide */ 217 218 $('a.go-slide').on('click', function (e) { 219 e.preventDefault(); 220 var active_slide = $(this).data('slide'); 221 222 menu.find('a[data-slide=' + active_slide + ']').trigger("click"); 223 224 }); 225 226 } 227 228 ///** COUNTDOWN **/ 229 230 function awdCountdown() { 231 232 $('#clock').countdown(awd_countdown_date).on('update.countdown', function (event) { 233 var $this = $(this).html(event.strftime('' 234 + '<div class="counter-container"><div class="counter-date"><div class="counter-box first"><span>day%!d</span><div class="number">%-D</div></div></div>' 235 + '<div class="counter-time"><div class="counter-box"><div class="number">%H:%M</div></div>' 236 + '<div class="counter-box last"><div class="number">%S</div><span>seconds</span></div></div></div>' 237 )); 238 }); 239 } 240 241 ///** EMAIL VALIDATION **/ 242 243 function awdFormValidation(email_address) { 244 var pattern = new RegExp(/^(([^<>()\[\]\.,;:\s@\"]+(\.[^<>()\[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i); 245 return pattern.test(email_address); 246 } 247 248 249 ///** SUBSCRIBE FORM **/ 250 251 function awdSubscribe() { 252 if (awd_subscribe == 1 || awd_subscribe == 2) { 253 awdSubscribeForm(); 254 } else if (awd_subscribe == 3) { 255 awdMailchimp(); 256 } 257 } 258 259 //* mailchimp */ 260 261 function awdMailchimp() { 262 263 var subscribe_form = $('#subscribe-form'); 264 var subscribe_email = $('#subscribe-email'); 265 266 function awdMailchimpStatus(resp) { 267 268 if (resp.result === 'error') { 269 subscribe_email.focus(); 270 $('.subscribe-notice').addClass('visible'); 271 } 272 else if (resp.result === 'success') { 273 subscribe_form[0].reset(); 274 subscribe_email.blur(); 275 $('.subscribe-notice').addClass('visible'); 276 } 277 } 278 279 subscribe_form.ajaxChimp({ 280 callback: awdMailchimpStatus, 281 language: 'eng', 282 type: 'POST', 283 url: awd_mailchimp_url 284 }); 285 } 286 287 //* php */ 288 289 function awdSubscribeForm() { 290 291 var subscribe_form = $('#subscribe-form'); 292 var subscribe_email = $('#subscribe-email'); 293 var subscribe_url; 294 if (awd_subscribe == 1) { 295 subscribe_url = 'assets/php/to-mail.php'; 296 } else if (awd_subscribe == 2) { 297 subscribe_url = 'assets/php/to-file.php'; 298 } 299 300 subscribe_email.prop('type', 'text'); 301 302 subscribe_form.on('submit', function (e) { 303 304 var subscribe_email_val = subscribe_email.val(); 305 var subscribe_notice = $('.subscribe-notice'); 306 var subscribe_button = subscribe_form.find('button[type="submit"]'); 307 308 e.preventDefault(); 309 310 subscribe_button.prop('disabled', true); 311 312 if (!awdFormValidation(subscribe_email_val)) { 313 subscribe_notice.stop(true).hide().addClass('visible').html(awd_subscribe_error).fadeIn(); 314 subscribe_button.prop('disabled', false); 315 subscribe_email.focus(); 316 } 317 else { 318 $.ajax({ 319 type: 'POST', 320 url: subscribe_url, 321 data: { 322 email: subscribe_email_val, 323 emailAddress: awd_subscribe_email 324 }, 325 success: function () { 326 subscribe_notice.stop(true).hide().addClass('visible').html(awd_subscribe_success).fadeIn(); 327 328 subscribe_button.prop('disabled', false); 329 subscribe_form[0].reset(); 330 subscribe_email.blur(); 331 332 } 333 }); 334 } 335 return false;
336 337 }); 338 339 } 340 341 342 ///** CONTACT FORM **/ 343 344 function awdContactForm() { 345 346 var contact_form = $('#contact-form'); 347 348 contact_form.on('submit', function (e) { 349 350 var input = $(this).find('input, textarea'); 351 var required_fields = $(this).find('.required'); 352 var email_field = $('.contact-form-email'); 353 var contact_name_val = $('.contact-form-name').val(); 354 var contact_subject_val = $('.contact-form-subject').val(); 355 var contact_email_val = email_field.val(); 356 var contact_message_val = $('.contact-form-message').val(); 357 var contact_notice = $('.contact-notice'); 358 359 e.preventDefault(); 360 361 if (contact_name_val == '' || contact_email_val == '' || contact_message_val == '' || contact_subject_val == '') { 362 contact_notice.stop(true).hide().html(awd_contact_input_error).fadeIn(); 363 required_fields.each(function () { 364 $(this).addClass("input-error"); 365 }); 366 367 } else if (!awdFormValidation(contact_email_val)) { 368 contact_notice.stop(true).hide().html(awd_contact_email_error).fadeIn(); 369 email_field.addClass("input-error"); 370 $('#contact-email').focus(); 371 } 372 else { 373 $.ajax({ 374 type: 'POST', 375 url: 'assets/php/contact.php', 376 data: { 377 name: contact_name_val, 378 email: contact_email_val, 379 message: contact_message_val, 380 subject: contact_subject_val, 381 emailAddress: awd_contact_email 382 }, 383 success: function () { 384 contact_notice.stop(true).hide().html(awd_contact_success).fadeIn(); 385 contact_form[0].reset(); 386 input.blur(); 387 } 388 }); 389 } 390 return false; 391 392 }); 393 394 } 395 396 ///** CUSTOM SCROLL **/ 397 398 function awdScrollbar() { 399 400 $('.sections-block').perfectScrollbar({ 401 suppressScrollX: true 402 }); 403 404 } 405 406 407 ///** DOCUMENT READY **/ 408 409 $(document).on('ready', function () { 410 411 if (awd_bordered === true) { 412 $('body').addClass('bordered'); 413 } 414 415 awdMenu(); 416 awdContentSlider(); 417 418 if (awd_countdown === true) { 419 awdCountdown(); 420 } 421 422 if (awd_animated === true) { 423 $('body').addClass('start'); 424 awdAnimate(); 425 } 426 awdSubscribe(); 427 awdContactForm(); 428 awdScrollbar(); 429 430 if (awd_bg_animated === true) { 431 awdCanvas(); 432 $(window).resize(function () { 433 awdCanvasResize(); 434 }); 435 } 436 437 438 }); 439 440 441})(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.