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