1// Description: Alterna, Retina Responsive Theme V7.0 2"use strict"; 3 4jQuery(document).ready(function($) { 5 6/* ---------------------------------------------------- 7 Functions 8---------------------------------------------------- */ 9 10// --------------------------------------- 11// init menu 12// --------------------------------------- 13function menuInit(){ 14 //add arrow 15 $('ul.alterna-nav-menu > li > ul').each(function() { 16 $(this).parent().children('a').append('<i class="fa fa-angle-down"></i>'); 17 $(this).find('ul').each(function() { 18 $(this).parent().children('a').append('<i class="fa fa-angle-right"></i>'); 19 }); 20 }); 21 22 //mobile menu 23 $('#alterna-drop-nav ul.navbar-nav li ul').each(function() { 24 $(this).parent().children('a').append('<span class="child-btn"><i class="fa fa-caret-down"></i></span>'); 25 }); 26 27 $('#alterna-drop-nav ul.navbar-nav .child-btn').click(function() { 28 if ($(this).parent().parent().children('ul').hasClass('is-show')) { 29 $(this).parent().parent().children('ul').removeClass('is-show'); 30 $(this).parent().parent().children('ul').slideUp(); 31 }else{ 32 $(this).parent().parent().children('ul').addClass('is-show'); 33 $(this).parent().parent().children('ul').slideDown(); 34 } 35 36 return false; 37 }); 38 39 //header style 4 40 if($('.header-style-4 .alterna-nav-form-icon').length > 0){ 41 $('.header-style-4 .alterna-nav-form-icon').click(function() { 42 if($(this).find('i').hasClass('fa fa-search')){ 43 $(this).find('i').removeClass('fa fa-search'); 44 $(this).find('i').addClass('fa fa-times'); 45 $('.header-style-4 .menu').addClass('opacity'); 46 $('.alterna-nav-form-content').addClass('show'); 47 }else{ 48 $(this).find('i').removeClass('fa fa-times'); 49 $(this).find('i').addClass('fa fa-search'); 50 $('.alterna-nav-form-content').removeClass('show'); 51 $('.header-style-4 .menu').removeClass('opacity'); 52 } 53 }); 54 } 55 56 //header style 6 57 if($('.header-style-6 .alterna-nav-form-icon').length > 0){ 58 $('.header-style-6 .alterna-nav-form-icon').click(function() { 59 if($(this).find('i').hasClass('fa fa-search')){ 60 $(this).find('i').removeClass('fa fa-search'); 61 $(this).find('i').addClass('fa fa-times'); 62 $('.header-style-6 .menu').addClass('opacity'); 63 $('.header-style-6 .right-content').addClass('opacity'); 64 $('.alterna-nav-form-content').addClass('show'); 65 }else{ 66 $(this).find('i').removeClass('fa fa-times'); 67 $(this).find('i').addClass('fa fa-search'); 68 $('.alterna-nav-form-content').removeClass('show'); 69 $('.header-style-6 .menu').removeClass('opacity'); 70 $('.header-style-6 .right-content').removeClass('opacity'); 71 } 72 }); 73 } 74} 75 76// --------------------------------------- 77// title line menu 78// --------------------------------------- 79function titleLineInit(){ 80 $('.line').each(function() { 81 if( $(this).children('.left-line').length === 0 ) { 82 $(this).append('<span class="left-line"></span>'); 83 } 84 if( $(this).children('.right-line').length === 0 ) { 85 $(this).append('<span class="right-line"></span>'); 86 } 87 }); 88} 89 90// --------------------------------------- 91// custom title 92// --------------------------------------- 93function alternaAlertTitleInit() { 94 $('.widget_tag_cloud a').tooltip(); 95 $('.widget_product_tag_cloud a').tooltip(); 96 $('.header-social a').tooltip(); 97 $('.show-tooltip').tooltip(); 98} 99 100// --------------------------------------- 101// run animation elements 102// --------------------------------------- 103function animationRun(){ 104 var current_width = $(window).width(); 105 // check all single animate element 106 $('.animate').each(function(){ 107 if($(this).hasClass('animated')){ 108 return false; 109 } 110 if (checkPosition(this)) { 111 $(this).removeClass('animate'); 112 exAnimate(this); 113 } 114 }); 115 116 // check all animate list element 117 $('.animate-list').each(function() { 118 var items = $(this).find('.animate-item'); 119 var count = 0; 120 for(var i=0;i<items.length;i++){ 121 if($(items[i]).hasClass('animating') || $(items[i]).hasClass('animated')){ 122 if(!$(items[i]).hasClass('animated')){ 123 count++; 124 }else{ 125 $(items[i]).removeClass('animating'); 126 $(items[i]).removeClass('animate-item'); 127 } 128 continue; 129 } 130 if (checkPosition(items[i])) { 131 listItemDelayEx(items[i],count); 132 count++; 133 } 134 } 135 }); 136 137 // list item delay time and execute 138 function listItemDelayEx(element,count){ 139 $(element).addClass('animating').delay(300*count).queue(function(){exAnimate(this);}); 140 } 141 142 // check element position 143 function checkPosition(element){ 144 if(current_width <= 768){ 145 return true; 146 } 147 var imagePos = $(element).offset().top; 148 var topOfWindow = $(window).scrollTop(); 149 var heightOfWindow = $(window).height(); 150 if (imagePos < topOfWindow+heightOfWindow - 50) { 151 return true; 152 } 153 return false;
154 } 155 156 // add class for element run animation 157 function exAnimate(element){ 158 var effect = 'fadeIn'; 159 if($(element).attr('data-effect') && $(element).attr('data-effect') !== ""){ 160 effect = $(element).attr('data-effect'); 161 } 162 $(element).addClass('animated '+effect); 163 } 164} 165 166// --------------------------------------- 167// single post comment placeholder 168// --------------------------------------- 169function postCommentPlaceholderInit(){ 170 //all input files 171 $('.placeholding-input input').each(function() { 172 $(this).keydown(function() { 173 refreshText(this,$(this).attr('value')); 174 }); 175 $(this).focusout(function() { 176 refreshText(this,$(this).attr('value')); 177 }); 178 }); 179 180 $('.placeholding-input textarea').each(function() { 181 $(this).keydown(function() { 182 refreshText(this,$(this).attr('value')); 183 }); 184 $(this).focusout(function() { 185 refreshText(this,$(this).attr('value')); 186 }); 187 }); 188 189 function refreshText(item,text){ 190 if(text.length > 0){ 191 $(item).parent().addClass('have-some'); 192 }else{ 193 $(item).parent().removeClass('have-some'); 194 } 195 } 196} 197// --------------------------------------- 198// one page Navigation 199// --------------------------------------- 200function onepageNavInit(){ 201 checkElement(".alterna-pagenav", pageNavCheck); 202 203 function pageNavCheck(params){ 204 var items = $(params).find('a'); 205 if( $(params).hasClass('right')){ 206 $(params).find('a').tooltip({placement:'left'}); 207 $(params).css({ 'margin-top': -($(params).outerHeight()/2) }); 208 }else if( $(params).hasClass('left')){ 209 $(params).find('a').tooltip({placement:'right'}); 210 $(params).css({ 'margin-top': -($(params).outerHeight()/2) }); 211 }else{ 212 $(params).find('a').tooltip({placement:'top'}); 213 $(params).css({ 'margin-right': -($(params).outerWidth()/2) }); 214 } 215 216 $(items).click(function() { 217 if($(this).hasClass('current')){ return false; } 218 219 if($(this).attr('href') == '#home'){ 220 221 $('body,html').animate({ 222 scrollTop: 0 223 }, 800 , '', refreshPageNav); 224 }else if($($(this).attr('href')).length > 0){ 225 var pos = $($(this).attr('href')).offset().top; 226 var target_position = pos -100; 227 $('body,html').animate({ 228 scrollTop: target_position 229 }, 800 , '', refreshPageNav); 230 } 231 return false; 232 }); 233 } 234 235 //add one page scroll 236 $('.alterna-nav-menu > li > a').each(function() { 237 menuItemClick(this); 238 }); 239 240 $('#alterna-nav-menu-select nav > li > a').each(function() { 241 menuItemClick(this); 242 }); 243 244 function menuItemClick(element){ 245 var str = $(element).attr('href'); 246 if(str !== "" && String(str).substring(0,1) == "#" && ($(element).attr('href') == "#home" || $($(element).attr('href')).length > 0)){ 247 $(element).click(function() { 248 if($(element).attr('href') == "#home"){ 249 $('body,html').animate({ 250 scrollTop: 0 251 }, 800 , '', refreshPageNav); 252 }else{ 253 var pos = $($(element).attr('href')).offset().top; 254 var target_position = pos -100; 255 $('body,html').animate({ 256 scrollTop: target_position 257 }, 800 , '', refreshPageNav); 258 } 259 return false; 260 }); 261 } 262 } 263 264 refreshPageNav(); 265} 266function refreshPageNav(){ 267 var navitems = $('.alterna-pagenav'); 268 var topOfWindow = $(window).scrollTop(); 269 for(var i=0; i<navitems.length; i++){ 270 var index = 0; 271 var items = $(navitems[i]).find('a'); 272 for(var j=0;j<items.length;j++){ 273 if($($(items[j]).attr('href')).length > 0 && $($(items[j]).attr('href')).offset().top -100 <= topOfWindow){ 274 index = j; 275 } 276 } 277 $(items).removeClass('current'); 278 $(items[index]).addClass('current'); 279 } 280} 281// --------------------------------------- 282// Tabs & SideTabs 283// --------------------------------------- 284function tabsInit(){ 285 286 /* tabs */ 287 checkElement(".tabs",tabsBack); 288 289 /* side tabs */ 290 checkElement(".sidetabs",sideTabsBack); 291 292 /* back fun */ 293 function tabsBack(params){ 294 openTabs(params,".tabs-nav li",".tabs-content"); 295 } 296 297 function sideTabsBack(params){ 298 openTabs(params,".sidetabs-nav li",".sidetabs-content"); 299 } 300 301 function openTabs(params,pname1,pname2){ 302 var ot_items = $(params).find(pname1); 303 var citems = $(params).find(pname2); 304 var ot_s1 = 0; 305 var ot_sm = ot_items.length; 306 var ot_new; 307 308 $(ot_items).click(function() { 309 if(ot_s1 === $(this).index()) { 310 return false;
311 } 312 313 $(citems[ot_s1]).stop(true,true); 314 $(citems[ot_s1]).css("opacity",1); 315 316 ot_new = $(this).index(); 317 318 $(ot_items[ot_s1]).removeClass("current"); 319 $(ot_items[ot_new]).addClass("current"); 320 321 if($(citems[ot_s1]) !== null) { 322 $(citems[ot_s1]).fadeOut("fast","",runNewTabs); 323 } 324 }); 325 326 function runNewTabs(){ 327 ot_s1 = ot_new; 328 showElement(ot_s1,citems); 329 } 330 331 for(var k=0; k<ot_sm;k++) { 332 if(ot_s1 === k){ 333 if($(ot_items[k]).hasClass("current") === false) { 334 $(ot_items[k]).addClass("current"); 335 } 336 showElement(k,citems); 337 }else{ 338 if($(ot_items[k]).hasClass("current") === true) { 339 $(ot_items[k]).removeClass("current"); 340 } 341 hideElement(k,citems); 342 } 343 } 344 } 345 346 function showElement(k,citems){ 347 if($(citems[k]) !== null) { 348 $(citems[k]).fadeIn("fast"); 349 } 350 } 351 352 function hideElement(k,citems){ 353 if($(citems[k]) !== null) { 354 $(citems[k]).fadeOut("fast"); 355 } 356 } 357}/* end tabs */ 358 359// --------------------------------------- 360// client 361// --------------------------------------- 362function clientsInit(){ 363 $('.clients').each(function() { 364 var client = $(this); 365 var max_screen_width = $(this).width(); 366 var items = $(this).find('.client-element'); 367 var item_width; 368 var count = 5; 369 var index = 0; 370 371 if($(window).width() > 900){ 372 count = 5; 373 }else if($(window).width() > 700){ 374 count = 4; 375 }else if($(window).width() > 400){ 376 count = 2; 377 }else{ 378 count = 1; 379 } 380 381 item_width = max_screen_width/count; 382 refreshItem(client, items, item_width); 383 refreshArrowEvent(client, index, count, items.length); 384 385 $(this).find('.client-arrow-left').click(function() { 386 index--; 387 moveClientItems(client, index, item_width); 388 refreshArrowEvent(client, index, count, items.length); 389 }); 390 391 $(this).find('.client-arrow-right').click(function() { 392 index++; 393 moveClientItems(client, index, item_width); 394 refreshArrowEvent(client, index, count, items.length); 395 }); 396 397 $(window).resize(function() { 398 refreshClients(client, items); 399 }); 400 401 $(client).find('img').load(function() { 402 refreshClients(client, items); 403 }); 404 405 }); 406 407 function refreshClients(client, items){ 408 var count = 5; 409 if($(window).width() > 900){ 410 count = 5; 411 }else if($(window).width() > 700){ 412 count = 4; 413 }else if($(window).width() > 400){ 414 count = 2; 415 }else{ 416 count = 1; 417 } 418 var item_width = $(client).width()/count; 419 refreshItem(client, items, item_width); 420 moveClientItems(client, 0, item_width); 421 refreshArrowEvent(client, 0, count, items.length); 422 } 423 424 //refresh item width, height 425 function refreshItem(element,items, width){ 426 var max_height = 10; 427 $(items).css('width',width); 428 $(element).find('.clients-elements').css('width',width * items.length + 40); 429 for(var i=0;i<items.length;i++){ 430 if($(items[i]).height() > max_height){ 431 max_height = $(items[i]).height(); 432 } 433 } 434 $(element).css('height',max_height); 435 } 436 437 //refresh items 438 function moveClientItems(element, index, width){ 439 $(element).find('.clients-elements').animate({'margin-left':-index*width}); 440 } 441 442 // change arrow 443 function refreshArrowEvent(element, index,count, length){ 444 if(index <= 0){ 445 $(element).find('.client-arrow-left').hide(); 446 }else{ 447 $(element).find('.client-arrow-left').show(); 448 } 449 if(index+count > length-1){ 450 $(element).find('.client-arrow-right').hide(); 451 }else if(index + length > count){ 452 $(element).find('.client-arrow-right').show(); 453 } 454 } 455 456} 457 458// --------------------------------------- 459// client testimonials 460// --------------------------------------- 461function testimonialsInit(){ 462 463 checkElement(".testimonials",openFeedback); 464 465 function openFeedback(params){ 466 467 var cfb_items = $(params).find(".testimonials-item"); 468 var cfb_id = 0; 469 var cfb_max = cfb_items.length; 470 var run = false; 471 var intervalObj = null; 472 var auto = false; 473 var delay = 5000; 474 475 $(cfb_items).each(function(index, element) { 476 $(element).css("display","none"); 477 }); 478 479 function showPrevElement(){ 480 if(run) { 481 return false; 482 } 483 run = true; 484 closeInterval(); 485 486 hideElement($(cfb_items[cfb_id]),prevElement); 487 } 488 489 function showNextElement(){ 490 if(run) { 491 return false;
492 } 493 run = true; 494 closeInterval(); 495 496 hideElement($(cfb_items[cfb_id]),nextElement); 497 } 498 499 function prevElement(){ 500 cfb_id--; 501 if(cfb_id < 0) { 502 cfb_id = cfb_max-1; 503 } 504 showElement($(cfb_items[cfb_id])); 505 } 506 507 function nextElement(){ 508 cfb_id++; 509 if(cfb_id >= cfb_max) { 510 cfb_id = 0; 511 } 512 showElement($(cfb_items[cfb_id])); 513 } 514 515 if(cfb_max <= 1){ 516 $(params).find(".testimonials-prev").css('display','none'); 517 $(params).find(".testimonials-next").css('display','none'); 518 }else{ 519 $(params).find(".testimonials-prev").click(function() { 520 showPrevElement(); 521 }); 522 $(params).find(".testimonials-next").click(function() { 523 showNextElement(); 524 }); 525 // auto play 526 if( $(params).hasClass('testimonials-auto') ){ 527 auto = true; 528 delay = parseInt($(params).attr('data-delay'),0); 529 if(delay === 0){ delay = 5000;} 530 } 531 } 532 533 showElement($(cfb_items[cfb_id])); 534 535 function showElement(params){ 536 if($(params).css("display") !== "block"){ 537 $(params).fadeIn("fast"); 538 } 539 run = false; 540 if(auto) { startInterval(); } 541 } 542 543 //hide text slider elements effect 544 function hideElement(params,nextElement){ 545 if($(params).css("display") === "block"){ 546 $(params).fadeOut("fast","",nextElement); 547 } 548 } 549 550 function startInterval(){ 551 intervalObj = setInterval(showNextElement , delay); 552 } 553 554 function closeInterval(){ 555 if(intervalObj !== null) { clearInterval(intervalObj); } 556 intervalObj = null; 557 } 558 } 559 560} 561 562// --------------------------------------- 563// accordion 564// --------------------------------------- 565function accordionInit(){ 566 $('.alterna-accordion .accordion-toggle').click(function() { 567 if($(this).hasClass('collapsed')){ 568 $(this).parent().parent().prevAll().find('.accordion-toggle').addClass('collapsed'); 569 $(this).parent().parent().nextAll().find('.accordion-toggle').addClass('collapsed'); 570 } 571 }); 572} 573// --------------------------------------- 574// Scroll & Resize Window ----------- 575// --------------------------------------- 576function scrollResizeInit(){ 577 $("body").append("<a id='back-top' href='#top' ></a>"); 578 579 $(window).resize(function() { 580 if($('.header-fixed-enabled').length > 0) { 581 fixedHeader(); 582 } 583 serviceResize(); 584 animationRun(); 585 }); 586 587 $(window).scroll(function() { 588 if($('.header-fixed-enabled').length > 0) {fixedHeader();} 589 if($(window).scrollTop() > 200){ 590 $("#back-top").fadeIn("slow"); 591 }else{ 592 $("#back-top").fadeOut("slow"); 593 } 594 if($('.alterna-pagenav').length > 0){ 595 refreshPageNav(); 596 } 597 animationRun(); 598 skillsAnimationRun(); 599 }); 600 601 // scroll body to 0px on click 602 $('#back-top').click(function () { 603 $('body,html').animate({ 604 scrollTop: 0 605 }, 800); 606 return false; 607 }); 608 609 function fixedHeader(){ 610 //fixed header 611 if($(window).width() > 979 && $(window).scrollTop() > ($('.header-wrap').outerHeight())) { 612 if($('#alterna-nav').length > 0) { 613 if(!$('#alterna-nav').hasClass('header-fixed')) { 614 $('#alterna-nav').addClass('header-fixed'); 615 if($('#wpadminbar').length > 0){ 616 $('#alterna-nav').stop().animate({'top':$('#wpadminbar').height()},500); 617 }else{ 618 $('#alterna-nav').stop().css('top','-100px').animate({'top':'0px'},500); 619 } 620 } 621 }else{ 622 if(!$('.header-wrap header').hasClass('header-fixed')) { 623 $('.header-wrap header').addClass('header-fixed'); 624 if($('#wpadminbar').length > 0){ 625 $('.header-wrap header').stop().css('top','-100px').animate({'top':$('#wpadminbar').height()},500); 626 }else{ 627 $('.header-wrap header').stop().css('top','-100px').animate({'top':'0px'},500); 628 } 629 } 630 } 631 632 }else{ 633 if($('#alterna-nav').length > 0) { 634 if($('#alterna-nav').hasClass('header-fixed')) { 635 $('#alterna-nav').removeClass('header-fixed'); 636 $('#alterna-nav').stop().css('top','0px'); 637 } 638 }else{ 639 if($('.header-wrap header').hasClass('header-fixed')) { 640 $('.header-wrap header').removeClass('header-fixed'); 641 $('.header-wrap header').stop().css('top','0px'); 642 } 643 } 644 645 } 646 } 647} 648// --------------------------------------- 649// Touch Hover Effect ----------- 650// --------------------------------------- 651function touchHoverSolve(){ 652 if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))) { 653 $(".portfolio-element").each(function() { 654 if( $(this).find('.post-tip').length > 0 ){ 655 if($(this).find('.post-tip .left-link').length >0 ){ 656 657 var portfolio_link = $($(this).find('.post-tip .left-link').parent()).attr('href'); 658 if(!portfolio_link) { portfolio_link = $(this).find('.post-tip .left-link a').attr('href'); } 659 660 $(this).find('.portfolio-img').wrap('<a style="float:left;" href="'+ portfolio_link +'"></a>'); 661 } 662 $(this).find('.post-tip').remove(); 663 } 664 }); 665 666 $(".post-img").each(function() { 667 if( $(this).find('.post-tip').length > 0 && $(this).find('.no-bg').length === 0 ){ 668 if($(this).find('.post-tip .left-link').length > 0 ){ 669 $(this).wrap('<a style="float:left;" href="'+ $($(this).find('.post-tip .left-link').parent()).attr('href') +'"></a>'); 670 } else if($(this).find('.post-tip .center-link').length > 0 ){ 671 $(this).wrap('<a style="float:left;" href="'+ $($(this).find('.post-tip .center-link').parent()).attr('href') +'"></a>'); 672 } 673 $(this).find('.post-tip').remove(); 674 }else if( $(this).find('.post-cover').length >0 ){ 675 $(this).find('.post-cover').remove(); 676 $(this).find('h5').remove(); 677 } 678 }); 679 680 $('.alterna-fl').addClass('touch'); 681 682 $('#header-topbar-right-content .wpml').click(function() { 683 if($(this).hasClass('touch')){ 684 $(this).removeClass('touch'); 685 }else{ 686 $(this).addClass('touch'); 687 } 688 }); 689 } 690} 691 692// --------------------------------------- 693// Service Resize 694// --------------------------------------- 695function serviceResize(){ 696 $('.alterna-service.left').each(function() { 697 if($(this).width() <= 220){ 698 $(this).removeClass('left'); 699 $(this).addClass('center backleft'); 700 } 701 }); 702 $('.alterna-service.backleft').each(function() { 703 if($(this).width() > 220){ 704 $(this).removeClass('backleft'); 705 $(this).removeClass('center'); 706 $(this).addClass('left'); 707 } 708 }); 709} 710// --------------------------------------- 711// Header Banner v4.0 712// --------------------------------------- 713function headerBannerInit(){ 714 if(navigator.cookieEnabled){ 715 if($('#header-banner').length > 0){ 716 var cookie = getCookie("alterna-header-banner"); 717 //show header banner 718 if(cookie === null || cookie !== $('#header-banner').attr('data-id') ){ 719 $('#header-banner').css({marginTop:-($('#header-banner').height() + 1), display:'block'}); 720 $('#header-banner').animate({marginTop:0},600); 721 $('#header-banner .close-btn').click(function() { 722 $('#header-banner').animate({marginTop:-($('#header-banner').height() + 1)},600,'',function(){ $('#header-banner').remove(); }); 723 addCookie("alterna-header-banner", $('#header-banner').attr('data-id') , 24); 724 return false;
725 }); 726 }else{ 727 $('#header-banner').remove(); 728 } 729 } 730 } 731} 732// --------------------------------------- 733// Footer Banner v5.2 734// --------------------------------------- 735function footerBannerInit(){ 736 if(navigator.cookieEnabled){ 737 if($('#footer-banner').length > 0){ 738 var cookie = getCookie("alterna-footer-banner"); 739 //show header banner 740 if(cookie === null || cookie !== $('#footer-banner').attr('data-id') ){ 741 $('#footer-banner').css({marginBottom:-($('#footer-banner').height() + 1), display:'block'}); 742 $('#footer-banner').animate({marginBottom:0},600); 743 $('#footer-banner .close-btn').click(function() { 744 $('#footer-banner').animate({marginBottom:-($('#footer-banner').height() + 1)},600,'',function(){ $('#footer-banner').remove(); }); 745 addCookie("alterna-footer-banner", $('#footer-banner').attr('data-id') , 24); 746 return false; 747 }); 748 }else{ 749 $('#footer-banner').remove(); 750 } 751 } 752 } 753} 754// --------------------------------------- 755// skills animation 756// --------------------------------------- 757function skillsAnimationRun(){ 758 $(".skills").each(function() { 759 if($(this).hasClass('skill-animation-complete')){ 760 return; 761 } 762 if($(this).find('.skill-element').length == $(this).find('.skill-animation-run').length){ 763 $(this).addClass('skill-animation-complete'); 764 $(this).find('.skill-animation-run').removeClass('skill-animation-run'); 765 return; 766 } 767 768 var items = $(this).find('.skill-element'); 769 var count = 0; 770 for(var i=0;i<items.length;i++){ 771 if($(items[i]).find('.skill-bg').hasClass('.skill-animation-run')){ 772 continue; 773 } 774 var pos = $(this).offset().top; 775 var topOfWindow = $(window).scrollTop(); 776 var heightOfWindow = $(window).height(); 777 if (pos < topOfWindow+heightOfWindow - 60) { 778 $(items[i]).find('.skill-bg').addClass('skill-animation-run').animate({width:$(items[i]).find('.skill-bg').attr('data-percent')},{duration:(400*count + 500)}); 779 } 780 count++; 781 } 782 }); 783} 784// --------------------------------------- 785// POST COMMENT CHECK 786// --------------------------------------- 787function postCommentCheck(){ 788 checkElement("#comments", postCommentFieldCheck); 789 790 function postCommentFieldCheck(params){ 791 if($(params).find('#comment-alert-error').length > 0){ 792 $(params).find('#submit').click(function() { 793 $(params).find('#comment-alert-error').removeClass('show'); 794 $(params).find('#comment-alert-error span').removeClass('show'); 795 796 if($(params).find('.comment-alert-error-name').length > 0){ 797 if($(params).find('#author').attr('value').length === 0){ 798 $(params).find('#comment-alert-error').addClass('show'); 799 $(params).find('.comment-alert-error-name').addClass('show'); 800 return false; 801 } 802 } 803 if($(params).find('.comment-alert-error-email').length > 0){ 804 if($(params).find('#email').attr('value').length === 0){ 805 $(params).find('#comment-alert-error').addClass('show'); 806 $(params).find('.comment-alert-error-email').addClass('show'); 807 return false; 808 } 809 var reg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/; 810 811 if(!reg.test($(params).find('#email').attr('value'))){ 812 $(params).find('#comment-alert-error').addClass('show'); 813 $(params).find('.comment-alert-error-email').addClass('show'); 814 return false; 815 } 816 } 817 if($(params).find('.comment-alert-error-message').length > 0){ 818 if($(params).find('#comment').attr('value').length === 0){ 819 $(params).find('#comment-alert-error').addClass('show'); 820 $(params).find('.comment-alert-error-message').addClass('show'); 821 return false; 822 } 823 } 824 return true; 825 }); 826 } 827 } 828} 829// --------------------------------------- 830// ajax get posts 831// --------------------------------------- 832function ajaxGetPostsInit(){ 833 // check all ajax module 834 $('.ajax-main-area').each(function() { 835 836 if($(this).children('.ajax-isotope').length === 0){ 837 return; 838 } 839 840 var layout_mode = "masonry"; 841 var iso = $(this).children('.ajax-isotope'); 842 843 if($(this).children('.portfolio-ajax-type').length > 0){ 844 var layoutMode = iso.attr('data-layoutmode'); 845 if(!layoutMode || layoutMode === ""){ 846 layout_mode = 'fitRows'; 847 }else{ 848 layout_mode = layoutMode; 849 } 850 } 851 852 iso.isotope({ 853 itemSelector: '.post-ajax-element', 854 layoutMode : layout_mode , 855 transitionDuration : '0.8s', 856 }); 857 858 iso.find('img').load(function() { 859 iso.isotope('layout'); 860 }); 861 862 // have no more posts 863 if($(this).find('.ajax-load-content').length === 0){ 864 return false;
865 } 866 867 var ajax_main = $(this); 868 var ajax_load_content = $(ajax_main).find('.ajax-load-content'); 869 var ajax_paged = parseInt(ajax_load_content.attr('data-page'),0); 870 var ajax_max_paged = parseInt(ajax_load_content.attr('data-max'),0); 871 var ajax_next_link = ajax_load_content.attr('data-link'); 872 var ajax_loading = false; 873 874 // auto load posts 875 if($(ajax_main).find('.post-ajax-load-btn').length === 0){ 876 $(window).scroll(function() { 877 if(ajax_loading || ajax_paged > ajax_max_paged) {return false;} 878 var imagePos = $(ajax_main).find('.ajax-load-btn-container').offset().top; 879 var topOfWindow = $(window).scrollTop(); 880 var heightOfWindow = $(window).height(); 881 if (imagePos < topOfWindow+heightOfWindow - 50) { 882 loadPostsContent(); 883 } 884 }); 885 } 886 887 // load post content 888 function loadPostsContent(){ 889 ajax_loading = true; 890 891 $(ajax_main).find('.post-ajax-load-btn').hide(); 892 $(ajax_main).find('.post-ajax-scroll-load').hide(); 893 $(ajax_main).find('.post-ajax-loading').show(); 894 895 ajax_load_content.load(ajax_next_link + ' .post-ajax-element' , function(responseText, textStatus, XMLHttpRequest){ 896 897 if ( textStatus == "error" ) { 898 $(ajax_main).find('.post-ajax-loading').hide(); 899 $(ajax_main).find('.post-ajax-load-btn').show(); 900 $(ajax_main).find('.post-ajax-scroll-load').show(); 901 902 ajax_loading = false; 903 return false; 904 } 905 906 var new_elements = $($(ajax_load_content).html()); 907 908 ajax_load_content.html(''); 909 910 new_elements.find('.alterna-fl').flexslider({slideshow:false, 911 start: function(){ 912 iso.isotope( 'layout' ); 913 } 914 }); 915 916 new_elements.find('img').load(function() { iso.isotope('layout'); }); 917 918 iso.append(new_elements).isotope( 'appended',new_elements); 919 920 ajax_paged++; 921 922 if(ajax_paged <= ajax_max_paged) { 923 ajax_next_link = ajax_next_link.replace(/\/page\/[0-9]*/, '/page/'+ ajax_paged); 924 ajax_next_link = ajax_next_link.replace(/paged=[0-9]*/, 'paged='+ ajax_paged); 925 $(ajax_main).find('.post-ajax-loading').hide(); 926 $(ajax_main).find('.post-ajax-load-btn').show(); 927 $(ajax_main).find('.post-ajax-scroll-load').show(); 928 ajax_loading = false; 929 }else{ 930 $(ajax_main).find('.ajax-load-btn-container').remove(); 931 } 932 933 }); 934 } 935 936 // button click load posts 937 $(ajax_main).find('.post-ajax-load-btn').click(function() { 938 if(ajax_loading || ajax_paged > ajax_max_paged) {return false;} 939 loadPostsContent(); 940 }); 941 }); 942} 943 944// --------------------------------------- 945// COMMON ----------- check element and ex fun 946// --------------------------------------- 947function checkElement(params,fun){ 948 var list = $(params); 949 950 if(list.length <= 0) {return false;} 951 952 for (var w=0; w<list.length; w++) { 953 fun(list[w]); 954 } 955} 956 957// --------------------------------------- 958// Cookie ----------- save ,delete ,get cookie 959// --------------------------------------- 960function addCookie(name,value,hours){ 961 var str = name + "=" + value; 962 if(hours > 0){ 963 var date = new Date(); 964 var ms = hours*3600*1000; 965 date.setTime(date.getTime() + ms); 966 str += "; expires=" + date.toGMTString(); 967 } 968 document.cookie = str; 969} 970function getCookie(name){ 971 var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)")); 972 if(arr !== null) { 973 return arr[2]; 974 } 975 return null; 976} 977 978 979/* ---------------------------------------------------- 980 Execute 981---------------------------------------------------- */ 982 983 menuInit(); 984 titleLineInit(); 985 alternaAlertTitleInit(); 986 postCommentPlaceholderInit(); 987 tabsInit(); 988 clientsInit(); 989 testimonialsInit(); 990 accordionInit(); 991 scrollResizeInit(); 992 touchHoverSolve(); 993 serviceResize(); 994 headerBannerInit(); 995 footerBannerInit(); 996 postCommentCheck(); 997 ajaxGetPostsInit(); 998 animationRun(); 999 onepageNavInit(); 1000 skillsAnimationRun(); 1001 1002 // flexslide 1003 $('.alterna-fl').each(function() { 1004 if($(this).attr('data-delay')){ 1005 $(this).flexslider({slideshow: true , slideshowSpeed:$(this).attr('data-delay') }); 1006 }else{ 1007 $(this).flexslider({slideshow: false }); 1008 } 1009 }); 1010
1011 //carousel auto play v2.5 1012 $('.carousel-autoplay').each(function() { 1013 $(this).carousel({interval: $(this).attr('data-delay')}); 1014 }); 1015 1016 //woocommerce 1017 $('.widget_product_search #searchsubmit').attr('value',''); 1018 1019 //fancybox 1020 if($.fn.fancybox !== null) { 1021 $("a[class^='fancyBox']").fancybox(); 1022 $("a[class^='fancybox-thumb']").fancybox({helpers: {title: {type: 'outside'},thumbs: {width: 50,height : 50}}}); 1023 } 1024 1025 // isotope filters 1026 $('.portfolio-main-area').each(function() { 1027 var portfolio = $(this); 1028 if($(this).find('.portfolio-isotope').length > 0){ 1029 $(portfolio).find('.portfolio-filters-cate a').click(function() { 1030 if($(this).hasClass('active')) {return false;} 1031 $(this).addClass('active'); 1032 $(this).parent().prevAll().find('a').removeClass('active'); 1033 $(this).parent().nextAll().find('a').removeClass('active'); 1034 var filters = $(this).attr('data-filters'); 1035 $(portfolio).find('.portfolio-isotope').isotope({ filter: filters }); 1036 }); 1037 }else if($(this).find('.ajax-isotope').length > 0){ 1038 $(portfolio).find('.portfolio-filters-cate a').click(function() { 1039 if($(this).hasClass('active')) {return false;} 1040 $(this).addClass('active'); 1041 $(this).parent().prevAll().find('a').removeClass('active'); 1042 $(this).parent().nextAll().find('a').removeClass('active'); 1043 var filters = $(this).attr('data-filters'); 1044 $(portfolio).find('.ajax-isotope').isotope({ filter: filters }); 1045 }); 1046 } 1047 }); 1048 1049 $('.portfolio-isotope').each(function() { 1050 var layoutMode = $(this).attr('data-layoutmode'); 1051 if(!layoutMode || layoutMode === ""){ 1052 layoutMode = 'fitRows'; 1053 } 1054 $(this).isotope({ 1055 itemSelector: '.portfolio-element', 1056 layoutMode : layoutMode, 1057 transitionDuration : '0.8s' 1058 }); 1059 }); 1060 1061 $('.portfolio-isotope').find('img').load(function() { 1062 refreshIsotope(); 1063 }); 1064 1065 //service link 1066 $('.alterna-service-link').click(function() { 1067 if($(this).attr('data-link') && $(this).attr('data-link') != ''){ 1068 window.location = $(this).attr('data-link'); 1069 } 1070 1071 return false; 1072 }); 1073 1074}); 1075 1076jQuery(window).on("load", function() { 1077 refreshIsotope(); 1078}); 1079 1080function refreshIsotope(){ 1081 jQuery('.portfolio-isotope').isotope( 'layout' ); 1082 jQuery('.ajax-isotope').isotope( 'layout' ); 1083}
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.