1/* Composer Custom Scripts */ 2 3/* 4 * Get Viewport Dimensions 5 * returns object with viewport dimensions to match css in width and height properties 6 * ( source: http://andylangton.co.uk/blog/development/get-viewport-size-width-and-height-javascript ) 7*/ 8function updateViewportDimensions() { 9 var w=window,d=document,e=d.documentElement,g=d.getElementsByTagName('body')[0],x=w.innerWidth||e.clientWidth||g.clientWidth,y=w.innerHeight||e.clientHeight||g.clientHeight; 10 return { width:x,height:y } 11} 12// setting the viewport width 13var viewport = updateViewportDimensions(); 14 15function loadGravatars() { 16 // set the viewport using the function above 17 viewport = updateViewportDimensions(); 18 // if the viewport is tablet or larger, we load in the gravatars 19 if (viewport.width >= 768) { 20 jQuery('.comment img[data-gravatar]').each(function(){ 21 jQuery(this).attr('src',jQuery(this).attr('data-gravatar')); 22 }); 23 } 24} // end function 25 26if( jQuery('body').hasClass('pix-ajaxify') ) { 27 28 window.vc_js = function () { 29 if( typeof('vc_toggleBehaviour') != 'undefined'){ // todo remove on next release 30 vc_toggleBehaviour(); 31 } 32 33 if( typeof('vc_tabsBehaviour') != 'undefined'){ 34 vc_tabsBehaviour(); 35 } 36 37 if( typeof('vc_accordionBehaviour') != 'undefined'){ 38 vc_accordionBehaviour(); 39 } 40 41 if( typeof('vc_teaserGrid') != 'undefined'){ 42 vc_teaserGrid(); 43 } 44 45 if( typeof('vc_prettyPhoto') != 'undefined'){ 46 vc_prettyPhoto(); 47 } 48 49 if( typeof('vc_pinterest') != 'undefined'){ 50 vc_pinterest(); 51 } 52 53 if( typeof('vc_progress_bar') != 'undefined'){ 54 vc_progress_bar(); 55 } 56 57 if( typeof('vc_carouselBehaviour') != 'undefined'){ 58 vc_carouselBehaviour(); 59 } 60 61 if( typeof('vc_slidersBehaviour') != 'undefined'){ 62 vc_slidersBehaviour(); 63 } 64 65 if( typeof('vc_plugin_flexslider') != 'undefined'){ 66 vc_plugin_flexslider(); 67 } 68 69 if( typeof('vc_gridBehaviour') != 'undefined'){ 70 vc_gridBehaviour(); 71 } 72 73 if( typeof('vc_rowBehaviour') != 'undefined'){ 74 vc_rowBehaviour(); 75 } 76 77 jQuery( document ).trigger( 'vc_js' ); 78 window.setTimeout( vc_waypoints, 1500 ); 79 80 if( typeof('vc_waypoints') != 'undefined'){ 81 window.setTimeout(vc_waypoints, 1500); 82 } 83 84 }; 85 86} 87 88/* Theme Scripts */ 89(function($){ 90 'use strict'; 91 92 $(window).on( "unload", function() {}); 93 94 String.prototype.decodeHTML = function() { 95 return $("<div>", {html: "" + this}).html(); 96 }; 97 98 //WOO DROP DOWN 99 var $main = $("#wrapper"), 100 $mainCon = $("#main-wrapper"), 101 responsive_viewport = $(window).width(), 102 contentNode = $main.get(0), 103 104 updateQueryStringParameter = function ( uri, key, value ) { 105 var re = new RegExp("([?&])" + key + "=.*?(&|#|$)", "i"); 106 if( value === undefined ) { 107 if (uri.match(re)) { 108 return uri.replace(re, '$1$2'); 109 } else { 110 return uri; 111 } 112 } else { 113 if ( uri && uri.match(re) ) { 114 return uri.replace(re, '$1' + key + "=" + value + '$2'); 115 } else { 116 var separator = uri && uri.indexOf('?') !== -1 ? "&" : "?"; 117 return uri + separator + key + "=" + value; 118 } 119 } 120 }, 121 122 woo_drop_down = function (){ 123 /* WOO COMMERCE Cart */ 124 var $cartBtn = $('.cart-trigger'), 125 $cartDropdown = $('.cart-trigger').find('.woo-cart-dropdown'); 126 127 if($cartBtn.length > 0 && $cartDropdown.length > 0){ 128 129 $cartBtn.mouseover(function(){ 130 $(this).find('.woo-cart-dropdown').stop().fadeIn(); 131 }).mouseout(function(){ 132 $(this).find('.woo-cart-dropdown').stop().fadeOut(); 133 }); 134 135 } 136 }, 137 138 // Blocks Load more 139 blockLoadMore = function ( self ) { 140 141 // Assign div as variables 142 var $loadMoreBtn = self.parents('.block-load-more-btn'), 143 $loadContainer = self.parents('.loadmore-wrap').find('.load-container'); 144 145 // Assign useful values 146 var ajaxurl = pix_composer.ajaxurl, 147 values = self.data('values'), 148 args = self.data('args'); 149 150 var page_number = self.data('paged'); 151 if( undefined != page_number ) { 152 var page_number = page_number+1; 153 } 154 155 var max = values.max; 156 157 $.ajax({ 158 type: 'post', 159 url: ajaxurl, 160 data: { 161 action : values.action, 162 values : values, 163 args : args, 164 paged : page_number 165 }, 166 beforeSend: function(){ 167 $loadMoreBtn.find('.spinner').fadeIn(); 168 $loadMoreBtn.find('a').hide(); 169 $loadMoreBtn.addClass('disabled'); 170 },
171 complete: function() { 172 //Magnific Popup 173 $('.popup-gallery').magnificPopup({ 174 type: 'image', 175 tLoading: 'Loading image...', 176 mainClass: 'mfp-img-mobile', 177 gallery: { 178 enabled: true, 179 navigateByImgClick: true, 180 //preload: [0,1] // Will preload 0 - before current, and 1 after the current image 181 }, 182 image: { 183 verticalFit: true, 184 tError: '<a href="%url%">The image #%curr%</a> could not be loaded.', 185 titleSrc: function(item) { 186 return item.el.data('title'); 187 } 188 }, 189 zoom: { 190 enabled: true, 191 duration: 300, // don't foget to change the duration also in CSS 192 opener: function(element) { 193 return element; 194 } 195 } 196 }); 197 }, 198 }).done(function(data) { 199 200 var $data = $(data), 201 $posts = $data.find('.load-element'), 202 paged = $data.find('.ajax-posts').data('paged'), 203 categories = $data.find('.ajax-posts').data('categories'); 204 205 self.data('paged', paged ); 206 207 if( max == paged ) { 208 209 $loadMoreBtn.find('.loaded-msg').removeClass('hide'); 210 $loadMoreBtn.find('.loaded-msg').show(0); 211 } 212 else { 213 $loadMoreBtn.find('a').show(); 214 } 215 216 var $loadContainer = self.parents('.loadmore-wrap').find('.load-container'); 217 218 // Append Elements 219 if( $loadContainer.hasClass('portfolio-contents') || $loadContainer.hasClass('grid-blog-contents') || $loadContainer.hasClass('shop-contents') ) { 220 $loadContainer.isotope() 221 .append( $posts ) 222 .isotope( 'appended', $posts ); 223 $loadContainer.imagesLoaded().progress( function() { 224 $loadContainer.isotope('layout'); 225 }); 226 227 // For portfolio filter 228 if( $loadContainer.hasClass('portfolio-contents') ) { 229 var $filter = $loadContainer.parents( '.loadmore-wrap' ).find( '#filters' ), 230 oldCategories = $filter.data('categories'); 231 // Merge oldCategories into categories 232 $.extend( categories, oldCategories ); 233 234 $filter.data('categories', categories); 235 236 $.each( categories, function(index, val) { 237 if( ! ( index in oldCategories ) ) { 238 $filter.append('<li><a href="#" data-filter=".'+ index +'">'+ val +'</a></li>'); 239 } 240 }); 241 if( $filter.length > 0 ) { 242 $filter.find('li').eq(0).find('a').trigger('click'); 243 } 244 } 245 246 } 247 else { 248 $loadContainer.find('.load-element').last().after( $posts ); 249 } 250 251 }).always(function(){ 252 253 $loadMoreBtn.find('.spinner').fadeOut(); 254 $loadMoreBtn.removeClass('disabled'); 255 256 }); 257 }, 258 259 /* Make pie Responsive */ 260 pieChartResponsive = function (options, $self, $border, size){ 261 if($self.hasClass('style2') && $self.hasClass('style4')){ 262 263 $border.css({ 264 'line-height': (size + options.style4) +'px', 265 'height': (size + options.style4) +'px', 266 'width': (size + (options.style4)) +'px' 267 }); 268 269 }else if($self.hasClass('style2') && $self.hasClass('style5')){ 270 271 $border.css({ 272 'line-height': (size - options.style5) +'px', 273 'height': (size - options.style5) +'px', 274 'width': (size - (options.style5)) +'px' 275 }); 276 277 } 278 else if($self.hasClass('style2') && $self.hasClass('style6')){ 279 280 $border.css({ 281 'line-height': (size + options.style6) +'px', 282 'height': (size + options.style6) +'px', 283 'width': (size + options.style6) +'px' 284 }); 285 286 } 287 else if($self.hasClass('style2')){ 288 289 $border.css({ 290 'line-height': (size + options.style2) +'px', 291 'height': (size + options.style2) +'px', 292 'width': (size + options.style2) +'px' 293 }); 294 295 } 296 }, 297 298 afterContentLoad = function() { 299 300 301 }, 302 303 loadMore = function( self ) { 304 305 // Assign variables 306 var $loadMoreBtn = self.parents('.load-more-btn'), 307 $loadContainer = self.parents('.loadmore-wrap').find('.load-container'), 308 ajaxurl = pix_composer.ajaxurl, 309 values = self.data('values'), 310 args = self.data('args'), 311 page_number = self.data('paged'), 312 max = values.max, 313 url = self.data('link'), 314 change_url = self.data('change-url'), 315 search = $loadMoreBtn.data('search'), 316 searchPaged = $loadMoreBtn.data('search-paged'), 317 searchMax = $loadMoreBtn.data('search-max'); 318 319 if( $loadMoreBtn.hasClass('disabled') ) return; 320 321 if( '' != search && 'undefined' != typeof( search ) ) { 322 page_number = searchPaged; 323 max = searchMax; 324 } 325 326 if( 'undefined' != typeof( page_number ) ) { 327 page_number = page_number+1; 328 } 329 330 if( page_number > max ) return; 331 332 $.ajax({ 333 type: 'post', 334 url: ajaxurl, 335 data: { 336 action : values.action, 337 values : values, 338 args : args, 339 paged : page_number 340 }, 341 beforeSend: function(){ 342 $loadMoreBtn.find('.spinner').fadeIn(); 343 $loadMoreBtn.find('a').hide(); 344 $loadMoreBtn.addClass('disabled'); 345 },
346 complete: function() { 347 //Magnific Popup 348 $('.popup-gallery').magnificPopup({ 349 type: 'image', 350 tLoading: 'Loading image...', 351 mainClass: 'mfp-img-mobile', 352 gallery: { 353 enabled: true, 354 navigateByImgClick: true, 355 //preload: [0,1] // Will preload 0 - before current, and 1 after the current image 356 }, 357 image: { 358 verticalFit: true, 359 tError: '<a href="%url%">The image #%curr%</a> could not be loaded.', 360 titleSrc: function(item) { 361 return item.el.data('title'); 362 } 363 }, 364 zoom: { 365 enabled: true, 366 duration: 300, // don't foget to change the duration also in CSS 367 opener: function(element) { 368 return element; 369 } 370 } 371 }); 372 }, 373 }).done(function(data) { 374 375 var $data = $(data), 376 $posts = $data.find('.load-element'), 377 paged = $data.find('.ajax-posts').data('paged'), 378 categories = $data.find('.ajax-posts').data('categories'); 379 380 self.data('paged', paged ); 381 382 if( 'yes' == change_url ) { 383 var newUrl = updateQueryStringParameter(url, 'page', paged); 384 history.pushState( '', '', newUrl ); 385 } 386 387 388 if( max == paged ) { 389 390 $loadMoreBtn.find('.loaded-msg').removeClass('hide'); 391 $loadMoreBtn.find('.loaded-msg').show(0); 392 } 393 else { 394 $loadMoreBtn.find('a').show(); 395 } 396 397 var $loadContainer = self.parents('.loadmore-wrap').find('.load-container'); 398 399 // Append Elements 400 if( $loadContainer.hasClass('portfolio-contents') || $loadContainer.hasClass('blog-isotope') || $loadContainer.hasClass('shop-contents') || $loadContainer.hasClass('recent-blog-posts-contents') ) { 401 $loadContainer.isotope() 402 .append( $posts ) 403 .isotope( 'appended', $posts ); 404 $loadContainer.imagesLoaded().progress( function() { 405 $loadContainer.isotope('layout'); 406 }); 407 408 // For portfolio filter 409 if( $loadContainer.hasClass('portfolio-contents') ) { 410 var $filter = $loadContainer.parents( '.loadmore-wrap' ).find( '#filters' ), 411 oldCategories = $filter.data('categories'); 412 413 if( $filter.length > 0 ) { 414 415 // Merge oldCategories into categories 416 $.extend( categories, oldCategories ); 417 418 $filter.data('categories', categories); 419 420 $.each( categories, function(index, val) { 421 if( ! ( index in oldCategories ) ) { 422 $filter.append('<li><a href="#" data-filter=".'+ index +'">'+ val +'</a></li>'); 423 } 424 }); 425 426 $filter.find('li').eq(0).find('a').trigger('click'); 427 428 } 429 } 430 431 } 432 else { 433 $loadContainer.find('.load-element').last().after( $posts ); 434 } 435 436 var $elem = $('.pix-animate-cre'); 437 438 $elem.each(function(){ 439 var $singleElement = $(this); 440 441 // Get data-attr from element 442 var animateTrans = $singleElement.data('trans') ? $singleElement.data('trans') : 'fadeIn'; 443 var animateDelay = $singleElement.data('delay') ? $singleElement.data('delay') : ''; 444 var animateDuration = $singleElement.data('duration') ? $singleElement.data('duration') : ''; 445 446 if(animateDelay != ''){ 447 $singleElement.css('animation-delay', animateDelay); 448 } 449 450 if(animateDuration != ''){ 451 $singleElement.css('animation-duration', animateDuration); 452 } 453 454 $singleElement.waypoint(function() { 455 if ($singleElement.hasClass('animated ' + animateTrans)) return; 456 $singleElement.css('opacity','1').addClass('animated '+ animateTrans); 457 458 }, 459 { 460 offset: '80%', 461 triggerOnce: true 462 }); 463 }); 464 465 }).always(function(){ 466 467 $loadMoreBtn.find('.spinner').fadeOut(); 468 $loadMoreBtn.removeClass('disabled'); 469 470 }); 471 }, 472 473 portfolioSearch = function( $self, search ) { 474 475 // Assign div as variables 476 var $con = $self.parents('.loadmore-wrap'), 477 $loadMoreBtn = $con.find('.load-more-btn'), 478 $loadContainer = $con.find('.load-container'), 479 ajaxurl = pix_composer.ajaxurl, 480 $wrap = $self.parent(), 481 values = $wrap.data('values'), 482 args = $wrap.data('args'), 483 max = $wrap.data('max'); 484 485 if( $loadMoreBtn.hasClass('disabled') ) return; 486 487 // Set loadmore btn for search query 488 $loadMoreBtn.data( 'search', search ); 489 490 // Remove the All post loaded btn before ajax starts 491 $loadMoreBtn.find('.loaded-msg').addClass('hide'); 492 $loadMoreBtn.find('.loaded-msg').hide(0); 493 494 $.ajax({ 495 type: 'post', 496 url: ajaxurl, 497 data: { 498 action : values.action, 499 values : values, 500 args : args, 501 paged : 1, 502 search : search 503 }, 504 beforeSend: function(){ 505 $loadContainer.addClass('port-search-loading'); 506 $loadMoreBtn.find('.spinner').fadeIn(); 507 $loadMoreBtn.find('a').hide(); 508 $loadMoreBtn.addClass('disabled'); 509 },
510 complete: function() { 511 $loadContainer.removeClass('port-search-loading'); 512 //afterContentLoad(); 513 }, 514 }).done(function(data) { 515 516 var $data = $(data), 517 $posts = $data.find('.load-element'), 518 $ajaxPosts = $data.find('.ajax-posts'), 519 postFound = $ajaxPosts.data('post-found'), 520 postNotFoundText, 521 paged = $ajaxPosts.data('paged'), 522 max = $ajaxPosts.data('max'); 523 524 $loadContainer.find('.load-element').remove(); 525 $con.find('.not-found').remove(); 526 527 if( '' != search && 'undefined' != typeof( search ) ) { 528 $con.find('.clear-search').fadeIn(); 529 } 530 else { 531 $con.find('.clear-search').fadeOut(); 532 } 533 534 if( !postFound ) { 535 postNotFoundText = $ajaxPosts.text(); 536 $loadContainer.before('<div class="not-found">'+ postNotFoundText +'</div>'); 537 } 538 else { 539 540 $loadMoreBtn.data('search-paged', paged ); 541 $loadMoreBtn.data('search-max', max ); 542 543 if( max == paged ) { 544 545 $loadMoreBtn.find('.loaded-msg').removeClass('hide'); 546 $loadMoreBtn.find('.loaded-msg').show(0); 547 } 548 else { 549 $loadMoreBtn.find('a').show(); 550 } 551 552 // Append Elements 553 $loadContainer.isotope() 554 .append( $posts ) 555 .isotope( 'appended', $posts ); 556 $loadContainer.imagesLoaded().progress( function() { 557 $loadContainer.isotope('layout'); 558 }); 559 560 var $elem = $('.pix-animate-cre'); 561 562 $elem.each(function(){ 563 var $singleElement = $(this); 564 565 // Get data-attr from element 566 var animateTrans = $singleElement.data('trans') ? $singleElement.data('trans') : 'fadeIn'; 567 var animateDelay = $singleElement.data('delay') ? $singleElement.data('delay') : ''; 568 var animateDuration = $singleElement.data('duration') ? $singleElement.data('duration') : ''; 569 570 if(animateDelay != ''){ 571 $singleElement.css('animation-delay', animateDelay); 572 } 573 574 if(animateDuration != ''){ 575 $singleElement.css('animation-duration', animateDuration); 576 } 577 578 $singleElement.waypoint(function() { 579 if ($singleElement.hasClass('animated ' + animateTrans)) return; 580 $singleElement.css('opacity','1').addClass('animated '+ animateTrans); 581 582 }, 583 { 584 offset: '80%', 585 triggerOnce: true 586 }); 587 }); 588 } 589 590 }).always(function(){ 591 592 $loadMoreBtn.find('.spinner').fadeOut(); 593 $loadMoreBtn.removeClass('disabled'); 594 595 }); 596 }, 597 598 // Ajaxify Remove item in flyin cart 599 AjaxifyRemoveIteminCart = function(e){ 600 601 e.preventDefault(); 602 603 var $wooCart = $('.woo-cart-dropdown'), 604 $cartContent = $wooCart.find('.woo-cart-content'), 605 $cartLoader = $wooCart.find('.spinner'); 606 607 $.ajax({ 608 type: "POST", 609 url: pixLike.ajaxurl, 610 data: { 611 'action' : 'composer_cart_remove_item', 612 'item_key': $(this).data('item_key'), 613 }, 614 cache: false, 615 headers: {'cache-control': 'no-cache'}, 616 beforeSend: function() { 617 // Show flyin cart loader & hide content 618 $cartLoader.show(); 619 $(this).parent('li').addClass('removing'); 620 } 621 }).done(function(data){ 622 var $data = $(data), 623 status = $data.find('#status').html(), 624 cartCount = $data.find('#amz-cart-count').html(), 625 wcNotice = $data.find('#amz-wc-notice').html(), 626 wccart = $data.find('#amz-mini-cart').html(); 627 628 $(this).parent('li').removeClass('removing'); 629 630 if ( status != 1 ) { 631 $cartLoader.hide(); 632 return; 633 } 634 635 // Update cart count in menu. 636 $('body').find('.pix-item-icon').html( cartCount ); 637 638 // Update flyin cart if no error notice found 639 if( ! $data.find('.woocommerce-error').length ) { 640 $cartContent.html( wccart ); 641 } 642 643 $cartLoader.hide(); 644 }); 645 646 }, 647 648 modernPosts = function( $self, count ){ 649 650 var $con = $self.closest('.modern-posts'), 651 $imageListWrap = $con.find('.image-list-wrap'), 652 $titleListWrap = $con.find('.title-list-wrap'), 653 $imageList = $imageListWrap.find('.image-list'), 654 $titleList = $titleListWrap.find('.title-list'); 655 656 $imageList.eq(count).addClass('current').siblings().removeClass('current'); 657 $titleList.eq(count).addClass('current').siblings().removeClass('current'); 658 }, 659 660 init = function() { 661 662 // to top right away 663 if ( window.location.hash ){ 664 scroll(0,0);
665 // void some browsers issue 666 setTimeout( function() { scroll(0,0); }, 1); 667 } 668 669 /* getting viewport width */ 670 var responsive_viewport = $(window).width(); 671 672 loadGravatars(); 673 674 675 /* WPML Language Menu */ 676 var $langBtn = $('#lang-list.lang-dropdown.translated'); 677 678 if($langBtn.length > 0){ 679 680 $langBtn.mouseover(function(){ 681 var $langDropdown = $(this).find('.lang-dropdown-inner'); 682 $langDropdown.stop().slideDown(); 683 }).mouseout(function(){ 684 var $langDropdown = $(this).find('.lang-dropdown-inner'); 685 $langDropdown.stop().slideUp(); 686 }); 687 688 } 689 690 //Mobile Menu 691 var mMenuStatus = 0, 692 $mMenu = $('.mobile-menu-nav'), 693 $pixOverlay = $('<div />', {class: 'pix-overlay'}); 694 695 $('.pix-menu .pix-menu-trigger').on('click', function(e) { 696 var $this = $(this); 697 if(mMenuStatus == 0){ 698 $this.parent().addClass('pix-menu-open').removeClass('pix-menu-close'); 699 $('#content-pusher').addClass('content-pushed'); 700 //Add Overlay 701 $pixOverlay.hide().appendTo('body').fadeIn(300); 702 703 //Show Menu 704 $mMenu.addClass('mobile-nav').addClass('moved'); 705 $('.left-main-menu').addClass('moved'); 706 707 mMenuStatus = 1; 708 709 //Add Click event to overlay 710 $pixOverlay.off().on('click', function(e) { 711 e.preventDefault(); 712 if(mMenuStatus == 1){ 713 $this.parent().removeClass('pix-menu-open').addClass('pix-menu-close'); 714 $('#content-pusher').removeClass('content-pushed'); 715 $mMenu.removeClass('mobile-nav').removeClass('moved'); 716 $('.left-main-menu').removeClass('moved'); 717 $pixOverlay.fadeOut(300, function() { 718 $(this).remove(); 719 }); 720 mMenuStatus = 0; 721 } 722 }); 723 724 725 726 }else{ 727 $mMenu.removeClass('mobile-nav').removeClass('moved'); 728 $('.left-main-menu').removeClass('moved'); 729 $pixOverlay.fadeOut(300, function() { 730 $(this).remove(); 731 }); 732 mMenuStatus = 0; 733 $this.parent().removeClass('pix-menu-open').addClass('pix-menu-close'); 734 $('#content-pusher').removeClass('content-pushed'); 735 } 736 737 e.preventDefault(); 738 }); 739 740 //Flyin Sidebar 741 var fsStatus = 0, 742 $fs = $('.pix-flyin-content'); 743 744 $('.pix-flyin-sidebar .pix-flyin-trigger').on('click', function(e) { 745 var $this = $(this); 746 if(fsStatus == 0){ 747 $this.parent().addClass('pix-flyin-open').removeClass('pix-flyin-close'); 748 $('#content-pusher').addClass('flyin-pushed'); 749 750 //Show Menu 751 $fs.addClass('moved'); 752 753 fsStatus = 1; 754 755 756 }else{ 757 $fs.removeClass('moved'); 758 fsStatus = 0; 759 $this.parent().removeClass('pix-flyin-open').addClass('pix-flyin-close'); 760 $('#content-pusher').removeClass('flyin-pushed'); 761 } 762 763 e.preventDefault(); 764 }); 765 766 // Modern Post 767 $('.modern-posts .title-list-wrap').on('mouseover', '.title', function(e) { 768 e.preventDefault(); 769 770 var $self = $(this), 771 $con = $self.closest('.modern-posts'), 772 $ul = $con.find('.next-prev ul'), 773 count = $self.data('count'); 774 775 $ul.data('count', count); 776 777 modernPosts( $self, count ); 778 779 }); 780 781 $('.modern-posts .next-prev').on( 'click', 'li', function(e) { 782 e.preventDefault(); 783 784 var $self = $(this), 785 count = $self.closest('ul').data('count'), 786 $ul = $self.closest('ul'), 787 maxCount = $ul.data('max-count'); 788 789 if( $self.hasClass( 'prev' ) ) { 790 count = ( 0 != count ) ? count - 1 : 0; 791 } 792 else { // next 793 count = ( maxCount != count ) ? count + 1 : count; 794 } 795 796 $ul.data( 'count', count ); 797 798 modernPosts( $self, count ); 799 800 }); 801 802 //Counter 803 $('.counter-value').counterUp({ 804 delay: 10, 805 time: 1000 806 }); 807 808 /* Responsive video */ 809 $(".container, .posts, .pix-blog-video,.wp-video, .pix-post-video").fitVids(); 810 811 /* open share in popup window */ 812 $('.port-share-btn a, .share-social a').on('click', function(e){ 813 e.preventDefault(); 814 var newwindow = window.open($(this).attr('href'),'','height=450,width=700'); 815 if (window.focus) {newwindow.focus()} 816 return false; 817 }); 818 819 //Magnific Popup 820 $('.popup-gallery').magnificPopup({ 821 type: 'image', 822 tLoading: 'Loading image...', 823 mainClass: 'mfp-img-mobile', 824 gallery: { 825 enabled: true, 826 navigateByImgClick: true, 827 //preload: [0,1] // Will preload 0 - before current, and 1 after the current image 828 }, 829 image: { 830 verticalFit: true, 831 tError: '<a href="%url%">The image #%curr%</a> could not be loaded.', 832 titleSrc: function(item) { 833 return item.el.data('title'); 834 } 835 }, 836 zoom: { 837 enabled: true, 838 duration: 300, // don't foget to change the duration also in CSS 839 opener: function(element) { 840 return element; 841 } 842 } 843 }); 844 845 /* Pie Chart Used in Skills */ 846 $('.pix-chart').each(function(index, el) { 847 848 var $self = $(this); 849 $self.width($self.data('size')).height($self.data('size')).css('line-height', $self.data('size') +'px'); 850 851 $self.waypoint(function() { 852 853 $(this).easyPieChart({ 854 onStart: function(from, to){ 855 var canvas = $(this.el).find('canvas'),
856 size = canvas.width(), 857 $border = $(this.el).find('.border-bg'), 858 $bg = $(this.el).find('.bg'), 859 $self = $(this.el); 860 861 $self.css({ 862 'line-height': (size) +'px', 863 'height': (size) +'px', 864 'width': (size) +'px' 865 }); 866 867 }, 868 onStep: function(from, to, percent) { 869 $(this.el).find('.percent-text').text(Math.round(percent)); 870 } 871 }); 872 873 }, 874 { 875 offset: '90%', 876 triggerOnce: true 877 }); 878 879 }); 880 881 /* Menu open and close( header-11 ) */ 882 var $navDash = $('.nav-dash'); 883 884 if($navDash.length > 0){ 885 886 $navDash.on('click', function(e) { 887 e.preventDefault(); 888 $navDash.closest('.main-nav').toggleClass('menu-open'); 889 }); 890 891 } 892 893 // Login Form 894 var loginForm = function( self ){ 895 896 var ajaxurl = pix_composer.ajaxurl, 897 $form = self.parents('.login-form'), 898 username = $form.find('.username').val(), 899 password = $form.find('.password').val(), 900 remember = $form.find('.remember_me').prop('checked'); 901 902 $.ajax({ 903 type: 'post', 904 url: ajaxurl, 905 data: { 906 action : 'composer_ajax_login_form', 907 username : username, 908 password : password, 909 remember : remember 910 }, 911 beforeSend: function(){ 912 self.addClass('btn-loading'); 913 }, 914 complete: function() { 915 afterContentLoad(); 916 }, 917 }).done( function( data ) { 918 self.removeClass('btn-loading'); 919 920 var data = $.parseJSON(data), 921 error = data.error; 922 923 if( 1 == error ) { 924 var username = data.username, 925 password = data.password; 926 927 // Insert error content 928 $form.find('.username-notice').text(username); 929 $form.find('.password-notice').text(password); 930 931 } 932 else { 933 934 var success = data.success, 935 redirect = data.redirect; 936 937 $form.find('.success').text(success).delay(400).fadeOut(400); 938 939 // Redirect 940 $(location).attr('href',redirect); 941 } 942 943 }).always( function(){ 944 }); 945 }; 946 947 $('.login-form').on('click', '.submit-login-form', function(e) { 948 949 e.preventDefault(); 950 e.stopPropagation(); 951 952 var self = $(this); 953 954 // Call login ajax function 955 loginForm( self ); 956 }); 957 958 959 // Forgot Form 960 var forgotForm = function( self ){ 961 962 var ajaxurl = pix_composer.ajaxurl, 963 $form = self.parents('.forgot-form'), 964 user_login = $form.find('.user_login').val(); 965 966 $.ajax({ 967 type: 'post', 968 url: ajaxurl, 969 data: { 970 action : 'composer_ajax_forgot_form', 971 user_login : user_login 972 }, 973 beforeSend: function(){ 974 self.addClass('btn-loading'); 975 }, 976 complete: function() { 977 afterContentLoad(); 978 }, 979 }).done( function( data ) { 980 self.removeClass('btn-loading'); 981 982 var data = $.parseJSON(data), 983 error = data.error, 984 notice = data.notice; 985 986 if( 1 == error ) { 987 var forgot_login = data.forgot_login; 988 989 // Insert error content 990 $form.find('.user-login-notice').text(notice); 991 992 } 993 else { 994 var success = data.success, 995 redirect = data.redirect; 996 997 $form.find('.success').text(success).delay(400).fadeOut(400); 998 } 999 1000 }).always( function(){ 1001 }); 1002 }; 1003 1004 $('.forgot-form').on('click', '.submit-forgot-form', function(e) { 1005 1006 e.preventDefault(); 1007 e.stopPropagation(); 1008 1009 var self = $(this); 1010 1011 // Call login ajax function 1012 forgotForm( self ); 1013 }); 1014 1015 1016 // Forgot Form 1017 var resetForm = function( self ){ 1018 1019 var ajaxurl = pix_composer.ajaxurl, 1020 $form = self.parents('.reset-form'), 1021 login = self.data('login'), 1022 password = $form.find('.password').val(), 1023 key = $form.data('key'); 1024 1025 $.ajax({ 1026 type: 'post', 1027 url: ajaxurl, 1028 data: { 1029 action : 'composer_ajax_reset_form', 1030 login : login, 1031 password : password, 1032 key : key 1033 }, 1034 beforeSend: function(){ 1035 self.addClass('btn-loading'); 1036 }, 1037 complete: function() { 1038 afterContentLoad(); 1039 }, 1040 }).done( function( data ) { 1041 self.removeClass('btn-loading'); 1042 1043 var data = $.parseJSON(data), 1044 error = data.error, 1045 notice = data.notice; 1046 1047 if( 1 == error ) { 1048 var forgot_login = data.forgot_login; 1049 1050 // Insert error content 1051 $form.find('.user-login-notice').text(notice); 1052 1053 } 1054 else { 1055 var redirect = data.redirect; 1056 1057 // Redirect 1058 $(location).attr('href',redirect); 1059 1060 // Insert error content 1061 $form.parent().next('.login-form-con').find('.reset-notice').text(notice); 1062 } 1063 1064 }).always( function(){ 1065 }); 1066 }; 1067 1068 $('.reset-form').on('click', '.submit-reset-form', function(e) { 1069 1070 e.preventDefault(); 1071 e.stopPropagation(); 1072 1073 var self = $(this); 1074 1075 // Call login ajax function 1076 resetForm( self ); 1077 }); 1078 1079 // Update Profile 1080 var updateProfile = function( self ){ 1081 1082 var ajaxurl = pix_composer.ajaxurl, 1083 $form = self.parents('.update-form'), 1084 firstName = $form.find('.first_name').val(), 1085 lastName = $form.find('.last_name').val(), 1086 email = $form.find('.email').val(), 1087 website = $form.find('.website').val(), 1088 oldPassword = $form.find('.old_password').val(), 1089 newPassword = $form.find('.new_password').val(); 1090 1091 $.ajax({ 1092 type: 'post', 1093 url: ajaxurl, 1094 data: { 1095 action : 'composer_ajax_update_form', 1096 first_name : firstName, 1097 last_name : lastName, 1098 email : email, 1099 website : website, 1100 old_password : oldPassword, 1101 new_password : newPassword, 1102 }, 1103 beforeSend: function(){ 1104 self.addClass('btn-loading'); 1105 }, 1106 complete: function() { 1107 afterContentLoad(); 1108 }, 1109 }).done( function( data ) { 1110 1111 self.removeClass('btn-loading'); 1112 1113 var data = $.parseJSON(data), 1114 error = data.error; 1115 1116 if( true == error ) { 1117 var username_notice = data.username_notice, 1118 password_notice = data.password_notice; 1119 1120 // Insert error content 1121 $form.find('.username-notice').text(username_notice); 1122 $form.find('.password-notice').text(password_notice); 1123 1124 } 1125 else { 1126 var success = data.succcess_notice, 1127 redirect = data.redirect; 1128 1129 $form.find('.success').text(success); 1130 } 1131 1132 }).always( function(){ 1133 }); 1134 }; 1135 1136 $('.my-account-con').on('click', '.submit-update-form', function(e) { 1137 1138 e.preventDefault(); 1139 e.stopPropagation(); 1140 1141 var self = $(this); 1142 1143 // Call register ajax function 1144 updateProfile( self ); 1145 }); 1146 1147 1148 // Register Form 1149 var registerForm = function( self ){ 1150 1151 var ajaxurl = pix_composer.ajaxurl, 1152 $form = self.parents('.register-form'), 1153 username = $form.find('.username').val(), 1154 email = $form.find('.email').val(); 1155 1156 $.ajax({ 1157 type: 'post', 1158 url: ajaxurl, 1159 data: { 1160 action : 'composer_ajax_register_form', 1161 username : username, 1162 email : email 1163 }, 1164 beforeSend: function(){ 1165 self.addClass('btn-loading'); 1166 }, 1167 complete: function() { 1168 afterContentLoad(); 1169 }, 1170 }).done( function( data ) { 1171 self.removeClass('btn-loading'); 1172 1173 var data = $.parseJSON(data), 1174 error = data.error; 1175 1176 if( 1 == error ) { 1177 var username_notice = data.username_notice, 1178 email_notice = data.email_notice, 1179 general_notice = data.general_notice; 1180 1181 // Insert error content 1182 $form.find('.general-notice').addClass('error').removeClass('success').text(general_notice); 1183 $form.find('.username-notice').text(username_notice); 1184 $form.find('.email-notice').text(email_notice); 1185 1186 } 1187 else { 1188 var success = data.succcess_notice, 1189 redirect = data.redirect; 1190 1191 $form.find('.general-notice').addClass('success').removeClass('error').text(success).delay(400).fadeOut(400); 1192 1193 // Redirect 1194 $(location).attr('href',redirect); 1195 } 1196 1197 }).always( function(){ 1198 }); 1199 }; 1200 1201 $('.register-form').on('click', '.submit-register-form', function(e) { 1202 1203 e.preventDefault(); 1204 e.stopPropagation(); 1205 1206 var self = $(this); 1207 1208 // Call register ajax function 1209 registerForm( self ); 1210 }); 1211 1212 $('.login-form').on('click', '.forgot-password', function(e) { 1213 1214 e.preventDefault(); 1215 e.stopPropagation(); 1216 1217 var self = $(this); 1218 1219 // Switch form 1220 self.parents('.login-form-con').fadeOut(400); 1221 self.parents('.login-form-con').next('.forgot-password-con').fadeIn(400); 1222 }); 1223 1224 $('.login-form').on('click', '.change-password', function(e) { 1225 1226 e.preventDefault(); 1227 e.stopPropagation(); 1228 1229 var self = $(this); 1230 1231 // Switch form 1232 self.parents('.login-form-con').fadeOut(400); 1233 self.parents('.login-form-con').next().next('.change-password-con').fadeIn(400); 1234 }); 1235 1236 // Checkbox 1237 $('.login-form').on('click', '.form-checkbox label', function( e ) { 1238 1239 e.preventDefault(); 1240 e.stopPropagation(); 1241 1242 var self = $(this); 1243 1244 // Trigger checkbox 1245 self.next('.remember-me').trigger('click'); 1246 1247 }); 1248 1249 // Trigger checkbox 1250 $('.login-form').on('click', '.remember-me', function( e ) { 1251 1252 e.preventDefault(); 1253 e.stopPropagation(); 1254 1255 var self = $(this), 1256 $form = self.parents('.login-form'), 1257 $checkbox = self.parent().find('.remember_me'), 1258 val = $checkbox.prop('checked'); 1259 1260 if( false == val ) { 1261 $checkbox.prop('checked',true); 1262 } 1263 else{
1264 $checkbox.prop('checked',false); 1265 } 1266 1267 self.toggleClass('active'); 1268 1269 }); 1270 1271 $('.show-login-form').on('click', function(e) { 1272 1273 e.preventDefault(); 1274 e.stopPropagation(); 1275 1276 var self = $(this), 1277 $forgotPasswordCon = self.parents('.forgot-password-con'), 1278 $changePasswordCon = self.parents('.change-password-con'); 1279 1280 // Switch form 1281 $forgotPasswordCon.fadeOut(0); 1282 $changePasswordCon.fadeOut(0); 1283 $('.login-form-con').fadeIn(0); 1284 }); 1285 1286 $('.main-nav .menu-item-has-children .pix-dropdown-arrow').on('click',function(e) { 1287 e.preventDefault(); 1288 $(this).next('ul').stop().slideToggle(); 1289 }); 1290 1291 $('.pix-recent-blog-posts.blog-slide').on('mouseenter', '.post-container', function() { 1292 $(this).addClass('slide-open').siblings().removeClass('slide-open'); 1293 }).on('mouseleave', function() { 1294 1295 var $parent = $(this).closest('.pix-recent-blog-posts'), 1296 count = $parent.data('blog-slide-count'); 1297 1298 $parent.find('.post-container').eq(count - 1).addClass('slide-open').siblings().removeClass('slide-open'); 1299 }); 1300 1301 $(window).resize(function(event) { 1302 1303 var responsive_viewport = $(window).width(), 1304 $sideHeader = $('.left-main-menu'),$container = $('.portfolio-contents'), 1305 $portfolioInnerText = $container.find('.portfolio-inner-text'); 1306 1307 // initialize isotope 1308 1309 if($portfolioInnerText.length > 0 ){ 1310 $portfolioInnerText.css('height', $container.find('.element').first().height()); 1311 }; 1312 1313 // Single portfolio affix 1314 var $affix = $('.single-portfolio-affix'), 1315 $singlePortAffixWrap = $('.single-portfolio-affix-wrap'), 1316 $footer = $('#footer'); 1317 1318 if( $affix.length > 0 ) { 1319 1320 if (responsive_viewport >= 991) { 1321 1322 $('.single-portfolio-affix-container').height( $('.single-portfolio-item').height() - 50 ); 1323 1324 $singlePortAffixWrap.waypoint('destroy'); 1325 $footer.waypoint('destroy'); 1326 1327 $singlePortAffixWrap.waypoint({ 1328 handler: function(direction) { 1329 $('.single-portfolio-affix').toggleClass('sticky-top'); //change position to fixed by adding 'sticky-top' class 1330 } 1331 }); 1332 1333 $footer.waypoint({ 1334 offset: $('.single-portfolio-affix').height() + 180, //calculate menu's height and margin before footer 1335 handler: function(direction) { 1336 if( direction === 'down' ) { 1337 $('.single-portfolio-affix').removeClass('sticky-top'); //remove 'sticky-top' class 1338 $singlePortAffixWrap.addClass('sticky-bottom'); //change position to absolute for the wrapper 1339 } else if ( direction === 'up' ) { 1340 $('.single-portfolio-affix').addClass('sticky-top'); //remove 'sticky-top' class 1341 $singlePortAffixWrap.removeClass('sticky-bottom'); //change position to absolute for the wrapper 1342 } 1343 } 1344 }); 1345 1346 } else { 1347 /* Single portfolio affix */ 1348 $('.single-portfolio-affix-container').height( 'auto' ); 1349 $singlePortAffixWrap.waypoint('destroy'); 1350 $footer.waypoint('destroy'); 1351 } 1352 1353 } 1354 1355 if (responsive_viewport >= 991) { 1356 $mainCon.css('padding-bottom',$('.footer-fixed').height()+'px'); 1357 1358 }else{ 1359 $mainCon.css('padding-bottom','0px'); 1360 } 1361 1362 /* PIE CHART */ 1363 $('.pix-chart').each(function(index, el) { 1364 1365 var $self = $(this), 1366 canvas = $self.find('canvas'), 1367 size = canvas.width(), 1368 $border = $self.find('.border-bg'), 1369 $bg = $self.find('.bg'); 1370 1371 $self.css({ 1372 'line-height': (size) +'px', 1373 'height': (size) +'px' 1374 }); 1375 1376 }); 1377 1378 if(responsive_viewport <= 991){ 1379 $mMenu.addClass('mobile-nav'); 1380 1381 }else{ 1382 $mMenu.removeClass('mobile-nav'); 1383 } 1384 1385 }); 1386 1387 }, 1388 1389 portfolioImageOnScroll = function( $portElem ) { 1390 var portTotal = $portElem.length, 1391 showed = 0; 1392 1393 $portElem.each(function(index){ 1394 var $singleElement = $(this); 1395 1396 // Get data-attr from element 1397 var animateTrans = $singleElement.data('trans') ? $singleElement.data('trans') : 'fadeIn'; 1398 var animateDelay = $singleElement.data('delay') ? $singleElement.data('delay') : 200; 1399 var animateDuration = $singleElement.data('duration') ? $singleElement.data('duration') : ''; 1400 1401 if(animateDelay != ''){ 1402 // $singleElement.css('animation-delay', animateDelay); 1403 } 1404 1405 if(animateDuration != ''){ 1406 $singleElement.css('animation-duration', animateDuration); 1407 } 1408 1409 $singleElement.waypoint(function() { 1410 if ($singleElement.hasClass('animated ' + animateTrans)) return; 1411
1412 var delay = index, parentIndex = $(this).closest('.load-element').index(); 1413 1414 delay -= showed; 1415 1416 setTimeout(function() { 1417 $singleElement.css('opacity','1').addClass('animated '+ animateTrans); 1418 showed = parentIndex; 1419 }, delay * parseInt( animateDelay ) ); 1420 1421 // destroy waypoint after applied 1422 1423 }, 1424 { 1425 offset: '100%', 1426 triggerOnce: true 1427 }); 1428 1429 }); 1430 1431 }, 1432 1433 initHoverbox = function( $el ) { 1434 var $elem = ''; 1435 1436 $('[data-hover-animate]').addClass('loaded'); 1437 1438 /* HoverBox */ 1439 $el.hover( 1440 function() { 1441 var $elems = $(this).find('[data-hover-animate]'); 1442 1443 $elems.each(function() { 1444 1445 var animateTransIn = $(this).data('trans-in') ? $(this).data('trans-in') : 'fadeIn'; 1446 var animateTransOut = $(this).data('trans-out') ? $(this).data('trans-out') : 'fadeOut'; 1447 var animateDelay = $(this).data('delay-in') ? $(this).data('delay-in') : ''; 1448 var animateDuration = $(this).data('duration-in') ? $(this).data('duration-in') : ''; 1449 1450 if( animateDelay != '' ){ 1451 $(this).css('animation-delay', animateDelay); 1452 } 1453 1454 if( animateDuration != '' ){ 1455 $(this).css('animation-duration', animateDuration); 1456 } 1457 1458 $(this).removeClass(animateTransOut).addClass(animateTransIn); 1459 1460 }); 1461 1462 }, 1463 function(){ 1464 1465 var $elems = $(this).find('[data-hover-animate]'); 1466 1467 $elems.each(function() { 1468 1469 1470 var animateTransIn = $(this).data('trans-in') ? $(this).data('trans-in') : 'fadeIn'; 1471 var animateTransOut = $(this).data('trans-out') ? $(this).data('trans-out') : 'fadeOut'; 1472 var animateDelay = $(this).data('delay-out') ? $(this).data('delay-out') : ''; 1473 var animateDuration = $(this).data('duration-out') ? $(this).data('duration-out') : ''; 1474 1475 if( animateDelay != '' ){ 1476 $(this).css('animation-delay', animateDelay); 1477 } 1478 1479 if( animateDuration != '' ){ 1480 $(this).css('animation-duration', animateDuration); 1481 } 1482 1483 $(this).removeClass(animateTransIn).addClass(animateTransOut); 1484 1485 }); 1486 1487 $elems = ''; 1488 } 1489 ); 1490 }, 1491 1492 afterPageLoad = function() { 1493 1494 $('.popup-lightbox a').magnificPopup({ 1495 type: 'image', 1496 closeOnContentClick: true, 1497 mainClass: 'mfp-img-mobile', 1498 image: { 1499 verticalFit: true 1500 } 1501 }); 1502 1503 var $shopContainer = $('.shop-contents'); 1504 $shopContainer.isotope({ 1505 itemSelector : '.shop-item', 1506 percentPosition: true, 1507 masonry : { 1508 columnWidth : '.shop-grid-sizer' 1509 } 1510 }); 1511 1512 var $galleryContainer = $('.gallery-contents'); 1513 $galleryContainer.isotope({ 1514 itemSelector : '.gallery-item', 1515 percentPosition: true, 1516 masonry : { 1517 columnWidth : '.gallery-grid-sizer' 1518 } 1519 }); 1520 1521 var $portfolioContainer = $('.portfolio-contents'); 1522 $portfolioContainer.isotope({ 1523 itemSelector : '.pix-portfolio-item', 1524 percentPosition: true, 1525 masonry : { 1526 columnWidth : '.portfolio-grid-sizer' 1527 } 1528 }); 1529 1530 var $gridBlogContainer = $( '.grid-blog-contents' ); 1531 $gridBlogContainer.isotope({ 1532 itemSelector : '.grid-blog-item', 1533 percentPosition: true, 1534 masonry : { 1535 columnWidth : '.grid-blog-grid-sizer' 1536 } 1537 }); 1538 1539 var $recentBlogContainer = $( '.recent-blog-posts-contents' ); 1540 $recentBlogContainer.isotope({ 1541 itemSelector : '.load-element', 1542 percentPosition: true, 1543 masonry : { 1544 columnWidth : '.recent-blog-grid-sizer' 1545 } 1546 }); 1547 1548 // Load More 1549 var $loadMoreBtn = $( '.block-load-more-btn' ); 1550 1551 if ( $loadMoreBtn.length ) { 1552 1553 if ( $loadMoreBtn.hasClass( 'amz-autoload') ) { 1554 1555 $( window ).on('scroll', function() { 1556 1557 if( $( window ).scrollTop() >= $( '.load-container' ).offset().top + $( '.load-container' ).outerHeight() - window.innerHeight ) { 1558 1559 if( $loadMoreBtn.hasClass('done-loading') || $loadMoreBtn.hasClass( 'disabled' ) ) { 1560 return; 1561 } 1562 1563 $loadMoreBtn.find('a').trigger('click'); 1564 1565 } 1566 1567 }); 1568 } 1569 1570 $( '.block-load-more-btn' ).on( 'click', 'a', function(e) { 1571 e.preventDefault(); 1572 1573 blockLoadMore( $(this) ); 1574 1575 }); 1576 } 1577 1578 /* HoverBox */ 1579 initHoverbox( $(".hover-box") ); 1580 1581 /* Contact form move label */ 1582 $('.move-label').on('focus', function () { 1583 $(this).parents('p').find('label').addClass('is_focus'); 1584 }); 1585 1586 $('.move-label').on('blur', function () { 1587 if( ! $(this).val() ) { 1588 $(this).parents('p').find('label').removeClass('is_focus'); 1589 } 1590 }); 1591 1592 // Ajax remove cart 1593 var $wooCartDropdown = $('.woo-cart-dropdown'), 1594 $cartContent = $wooCartDropdown.find('.woo-cart-content'), 1595 $cartLoader = $wooCartDropdown.find('.spinner'); 1596 $wooCartDropdown.on('click', '.remove', AjaxifyRemoveIteminCart); 1597 1598 //WooCommerce update minicart 1599 $( document.body ).on( 'added_to_cart', function(){ 1600 1601 $.ajax({ 1602 url: woocommerce_params.ajax_url, 1603 type: 'post', 1604 data: { 1605 'action': 'composer_update_mini_cart' 1606 }, 1607 beforeSend: function(){ 1608 //$cartContent.html(''); 1609 $cartLoader.show(); 1610 1611 }, 1612 }).done(function(data) { 1613 $cartContent.html(data); 1614 }).always(function(){ 1615 $cartLoader.hide(); 1616 }); 1617 }); 1618 1619 $('.parallax').parallax('50%', -0.3, true); 1620 1621 if (responsive_viewport >= 991) { 1622 $mainCon.css('padding-bottom',$('.footer-fixed').height()+'px'); 1623 }else{ 1624 $mainCon.css('padding-bottom','0px'); 1625 } 1626
1627 /* Skrollr */ 1628 var s = skrollr.init({ 1629 easing: { 1630 quintic: function(p) { 1631 return 1*(p*p*p*p*p) - 5*(p*p*p*p) + 10*(p*p*p) - 10*(p*p) + 5*p; 1632 } 1633 },forceHeight: false 1634 }); 1635 1636 if (s.isMobile()) { 1637 s.destroy(); 1638 } 1639 1640 /* Search button */ 1641 1642 1643 var $searchHeader = $('.search-btn'), 1644 $search = $searchHeader.find('.topSearchForm'); 1645 1646 //if search is present in header then add events 1647 if($search.length > 0){ 1648 1649 $searchHeader.off().on('click', function(e) { 1650 var self = $(this); 1651 1652 self.toggleClass('color'); 1653 $search.toggleClass('show'); 1654 1655 setTimeout( function() { $search.find('input').focus(); }, 300 ); 1656 1657 1658 e.preventDefault(); 1659 e.stopPropagation(); 1660 }); 1661 1662 $search.off().on('click', function(e) { 1663 e.stopPropagation(); 1664 }); 1665 1666 $(document).on('click', function(e) { 1667 $search.removeClass('show'); 1668 $searchHeader.removeClass('color'); 1669 }); 1670 } 1671 1672 $('#dot-nav').css({marginTop:-($('#dot-nav').height()/2)}); 1673 var changeHashInURL = ($('body').hasClass('pix-ajaxify')) ? false : true; 1674 1675 $('#dot-nav').amzOnePageNav({ 1676 currentClass: 'current', 1677 changeHash: changeHashInURL 1678 }); 1679 1680 $('.main-nav').amzOnePageNav({ 1681 currentClass: 'current-menu-item', 1682 changeHash: changeHashInURL, 1683 filter: ':not(.external)', 1684 begin: function() { 1685 //Hack so you can click other menu items after the initial click 1686 $('body').append('<div id="device-dummy" style="height: 1px;"></div>'); 1687 $('button.overlay-close').trigger('click'); 1688 1689 var $mainnav = $('.main-nav'); 1690 if( $mainnav.length == 2 ) { 1691 $('.main-nav').find('li').removeClass('current-menu-item'); 1692 } 1693 }, 1694 end: function() { 1695 $('#device-dummy').remove(); 1696 } 1697 }); 1698 1699 $('.popup-video').magnificPopup({ 1700 disableOn: 700, 1701 type: 'iframe', 1702 mainClass: 'mfp-fade', 1703 removalDelay: 160, 1704 preloader: false, 1705 fixedContentPos: true 1706 }); 1707 1708 //Woo DropDown 1709 woo_drop_down(); 1710 1711 var $simplemenu = $( '#dl-menu' ); 1712 1713 /* Sticky Header */ 1714 var $headerCon = $('.header-con.pix-sticky-header'); 1715 if($headerCon.length > 0){ 1716 1717 $headerCon.waypoint('sticky', { 1718 offset: -($('.header-wrap').height()+30) 1719 }); 1720 1721 } 1722 1723 /* Single portfolio affix */ 1724 var $affix = $('.single-portfolio-affix'), 1725 $singlePortAffixWrap = $('.single-portfolio-affix-wrap'), 1726 $footer = $('#footer'); 1727 1728 if ( responsive_viewport >= 991 ) { 1729 1730 if ( $affix.length > 0 ) { 1731 1732 $('.single-portfolio-affix-container').height( $('.single-portfolio-item').height() - 50 ); 1733 1734 $singlePortAffixWrap.waypoint('destroy'); 1735 $footer.waypoint('destroy'); 1736 1737 $singlePortAffixWrap.waypoint({ 1738 handler: function(direction) { 1739 $('.single-portfolio-affix').toggleClass('sticky-top'); //change position to fixed by adding 'sticky-top' class 1740 } 1741 }); 1742 1743 $footer.waypoint({ 1744 offset: $('.single-portfolio-affix').height() + 180, //calculate menu's height and margin before footer 1745 handler: function(direction) { 1746 if( direction === 'down' ) { 1747 $('.single-portfolio-affix').removeClass('sticky-top'); //remove 'sticky-top' class 1748 $singlePortAffixWrap.addClass('sticky-bottom'); //change position to absolute for the wrapper 1749 } else if ( direction === 'up' ) { 1750 $('.single-portfolio-affix').addClass('sticky-top'); 1751 $singlePortAffixWrap.removeClass('sticky-bottom'); 1752 } 1753 } 1754 }); 1755 1756 } 1757 1758 } else { 1759 /* Single portfolio affix */ 1760 if( $affix.length > 0 ) { 1761 $('.single-portfolio-affix-container').height( 'auto' ); 1762 $singlePortAffixWrap.waypoint('destroy'); 1763 $footer.waypoint('destroy'); 1764 } 1765 } 1766 1767 var $elem = $('.pix-animate-cre'); 1768 1769 $elem.each(function(){ 1770 var $singleElement = $(this); 1771 1772 // Get data-attr from element 1773 var animateTrans = $singleElement.data('trans') ? $singleElement.data('trans') : 'fadeIn'; 1774 var animateDelay = $singleElement.data('delay') ? $singleElement.data('delay') : ''; 1775 var animateDuration = $singleElement.data('duration') ? $singleElement.data('duration') : ''; 1776 1777 if(animateDelay != ''){ 1778 $singleElement.css('animation-delay', animateDelay); 1779 } 1780 1781 if(animateDuration != ''){ 1782 $singleElement.css('animation-duration', animateDuration); 1783 } 1784 1785 if($singleElement.parent('.portfolio-container')){ 1786 1787 $singleElement.waypoint(function() { 1788 if ($singleElement.hasClass('animated ' + animateTrans)) return; 1789 1790 $singleElement.css('opacity','1').addClass('animated '+ animateTrans); 1791 1792 }, 1793 { 1794 offset: '80%', 1795 triggerOnce: true 1796 }); 1797 1798 } else { 1799 1800 $singleElement.waypoint(function() { 1801 if ($singleElement.hasClass('animated ' + animateTrans)) return; 1802 $singleElement.css('opacity','1').addClass('animated '+ animateTrans); 1803 1804 }, 1805 { 1806 offset: '90%', 1807 triggerOnce: true 1808 }); 1809 1810 } 1811 1812 1813 }); 1814 1815 var $portElem = $('.pix-animate-portfolio'); 1816 portfolioImageOnScroll( $portElem ); 1817 1818 // Owl Carousel
1819 if ( ! $('body').hasClass('compose-mode') ) { 1820 1821 $(".composer-primary-slider").each( function( index, el ) { 1822 var $self = $(this); 1823 $self.owlCarousel({ 1824 navText: ['',''], 1825 items: 1, 1826 nav: ( typeof ( $(this).data( 'nav' ) ) == 'undefined' ) ? false : $(this).data( 'nav' ), 1827 dots: ( typeof ( $(this).data( 'dots' ) ) == 'undefined' ) ? true : $(this).data( 'dots' ), 1828 autoplay : ( typeof ( $(this).data( 'autoplay' ) ) == 'undefined' ) ? false : $(this).data( 'autoplay' ), 1829 autoplayTimeout: ( typeof ( $(this).data( 'autoplay-timeout' ) ) == 'undefined' ) ? 5000 : $(this).data( 'autoplay-timeout' ), 1830 autoplayHoverPause : ( typeof ( $(this).data( 'autoplay-hover-pause' ) ) == 'undefined' ) ? true : $(this).data( 'autoplay-hover-pause' ), 1831 loop: ( typeof ( $(this).data( 'loop' ) ) == 'undefined' ) ? true : $(this).data( 'loop' ), 1832 animateOut : ( typeof ( $(this).data( 'animate-out' ) ) == 'undefined' ) ? false : $(this).data( 'animate-out' ), 1833 animateIn : ( typeof ( $(this).data( 'animate-in' ) ) == 'undefined' ) ? false : $(this).data( 'animate-in' ), 1834 mouseDrag : ( typeof ( $(this).data( 'mouse-drag' ) ) == 'undefined' ) ? true : $(this).data( 'mouse-drag' ), 1835 touchDrag : ( typeof ( $(this).data( 'touch-drag' ) ) == 'undefined' ) ? true : $(this).data( 'touch-drag' ), 1836 rtl: ( pix_composer.rtl === 'true' ) ? true : false, 1837 onInitialized: function(){ 1838 $self.find('.slide-title, .slide-content, .pix_button').removeClass('animated fadeInUp'); 1839 $self.find('.active .slide-title, .active .slide-content, .active .pix_button').addClass('animated fadeInUp'); 1840 1841 var header = $self.find('.active .slider-content').data('header'); 1842 1843 if( header == 'white' ) { 1844 $('.header-wrap').addClass('dark'); 1845 $('.pageTopCon').addClass('top-sec-dark'); 1846 } else if( header == 'black' ) { 1847 $('.header-wrap').removeClass('dark'); 1848 $('.pageTopCon').removeClass('top-sec-dark'); 1849 } 1850 1851 }, 1852 onTranslated: function(){ 1853 $self.find('.slide-title, .slide-content, .pix_button').removeClass('animated fadeInUp'); 1854 $self.find('.active .slide-title, .active .slide-content, .active .pix_button').addClass('animated fadeInUp'); 1855 1856 var header = $self.find('.active .slider-content').data('header'); 1857 1858 if( header == 'white' ) { 1859 $('.header-wrap').addClass('dark'); 1860 $('.pageTopCon').addClass('top-sec-dark'); 1861 } else if( header == 'black' ) { 1862 $('.header-wrap').removeClass('dark'); 1863 $('.pageTopCon').removeClass('top-sec-dark'); 1864 } 1865 1866 } 1867 }); 1868 }); 1869 1870 var $owlCarousel = $(".owl-carousel"); 1871 1872 if ( $owlCarousel.length ) { 1873 1874 $owlCarousel.each( function( index, el ) { 1875 1876 var elem = {}; 1877 elem.Items = ( typeof ( $(this).data( 'items' ) ) == 'undefined' ) ? 3 : $(this).data( 'items' ), 1878 elem.Margin = ( typeof ( $(this).data( 'margin' ) ) == 'undefined' ) ? 30 : $(this).data( 'margin' ), 1879 elem.Loop = ( typeof ( $(this).data( 'loop' ) ) == 'undefined' ) ? true : $(this).data( 'loop' ), 1880 elem.Center = ( typeof ( $(this).data( 'center' ) ) == 'undefined' ) ? false : $(this).data( 'center' ), 1881 elem.MouseDrag = ( typeof ( $(this).data( 'mouse-drag' ) ) == 'undefined' ) ? true : $(this).data( 'mouse-drag' ), 1882 elem.TouchDrag = ( typeof ( $(this).data( 'touch-drag' ) ) == 'undefined' ) ? true : $(this).data( 'touch-drag' ), 1883 elem.StagePadding = ( typeof ( $(this).data( 'stage-padding' ) ) == 'undefined' ) ? 0 : $(this).data( 'stage-padding' ), 1884 elem.StartPosition = ( typeof ( $(this).data( 'start-position' ) ) == 'undefined' ) ? 0 : $(this).data( 'start-position' ), 1885 elem.Nav = ( typeof ( $(this).data( 'nav' ) ) == 'undefined' ) ? false : $(this).data( 'nav' ), 1886 elem.Dots = ( typeof ( $(this).data( 'dots' ) ) == 'undefined' ) ? true : $(this).data( 'dots' ), 1887 elem.Autoplay = ( typeof ( $(this).data( 'autoplay' ) ) == 'undefined' ) ? false : $(this).data( 'autoplay' ), 1888 elem.AutoHeight = ( typeof ( $(this).data( 'autoHeight' ) ) == 'undefined' ) ? false : $(this).data( 'autoHeight' ), 1889 elem.AutoplayTimeout = ( typeof ( $(this).data( 'autoplay-timeout' ) ) == 'undefined' ) ? 5000 : $(this).data( 'autoplay-timeout' ), 1890 elem.AutoplayHoverPause = ( typeof ( $(this).data( 'autoplay-hover-pause' ) ) == 'undefined' ) ? true : $(this).data( 'autoplay-hover-pause' ), 1891 elem.AnimateOut = ( typeof ( $(this).data( 'animate-out' ) ) == 'undefined' ) ? false : $(this).data( 'animate-out' ), 1892 elem.AnimateIn = ( typeof ( $(this).data( 'animate-in' ) ) == 'undefined' ) ? false : $(this).data( 'animate-in' ), 1893 elem.Video = ( typeof ( $(this).data( 'video' ) ) == 'undefined' ) ? false : $(this).data( 'video' ); 1894 1895 if ( elem.Items >= 2 ) { 1896 elem.TabItems = 2; 1897 } else { 1898 elem.TabItems = 1; 1899 } 1900 1901 var $owl = $(this); 1902 1903 $(this).owlCarousel({ 1904 navText: ['',''], 1905 items: elem.Items, 1906 margin: elem.Margin, 1907 loop: elem.Loop, 1908 center: elem.Center, 1909 mouseDrag: elem.MouseDrag, 1910 touchDrag: elem.TouchDrag, 1911 stagePadding: elem.StagePadding, 1912 startPosition: elem.StartPosition, 1913 nav: elem.Nav, 1914 dots: elem.Dots, 1915 rtl: ( pix_composer.rtl === 'true' ) ? true : false, 1916 autoplay: elem.Autoplay, 1917 autoplayTimeout: elem.AutoplayTimeout, 1918 autoplayHoverPause: elem.AutoplayHoverPause, 1919 autoHeight: elem.AutoHeight, 1920 responsive: {0:{'items':1},768:{'items':elem.TabItems},991:{'items': elem.Items },1199:{'items': elem.Items }}, 1921 animateOut: elem.AnimateOut, 1922 animateIn: elem.AnimateIn, 1923 video: elem.Video, 1924 onInitialized: function () { 1925 1926 var id = window.location.hash.replace('#', ''); 1927 if(id) { 1928 var $id = $('#' + id ); 1929 if($id) { 1930 $('html,body').animate({ 1931 scrollTop: $id.offset().top 1932 }, 1000); 1933 } 1934 } 1935 1936 var $self = $(this.$element[0]), 1937 $item = $self.find('.owl-item'); 1938 1939 if( ! $item.length ) { 1940 return; 1941 } 1942 1943 if( true == elem.Loop ) { 1944 var $hoverBox = $item.find('.hover-box'); 1945 if( $hoverBox.length ) { 1946 initHoverbox( $hoverBox ); 1947 } 1948 } 1949 1950 if( elem.Center ) { 1951 1952 $item.on('click', function() { 1953 1954 if( $(this).hasClass('center') && $(this).hasClass('active') ) { 1955 return; 1956 } 1957 1958 var curIndex = $(this).index(), 1959 activeIndex = $self.find('.center').index(); 1960 1961 if( curIndex < activeIndex ) { 1962 $owl.trigger('prev.owl.carousel'); 1963 } else { 1964 $owl.trigger('next.owl.carousel'); 1965 } 1966 1967 }); 1968 1969 } 1970 1971 }, 1972 onChanged: function() { 1973 if ( elem.Items > 1 && elem.AnimateIn ) { 1974 var $item = $(this.$element[0]).find('.owl-item'), 1975 $curItem = $(this.$element[0]).find('.owl-item.active'), 1976 $prevItem = $curItem.first().prev(), 1977 $nextItem = $curItem.last().next(); 1978 1979 $(this.$element[0]).find('.owl-item').removeClass('animated '+ elem.AnimateIn); 1980 $prevItem.addClass('animated '+ elem.AnimateIn); 1981 $nextItem.addClass('animated '+ elem.AnimateIn); 1982 } 1983 }, 1984 }); 1985 1986 }); 1987 1988 } else { 1989 1990 var id = window.location.hash.replace('#', ''); 1991 if(id) { 1992 var $id = $('#' + id ); 1993 if($id) { 1994 $('html,body').animate({ 1995 scrollTop: $id.offset().top 1996 }, 1000); 1997 } 1998 } 1999 2000 } 2001 } 2002 2003 /* Isotope js */
2004 // cache container 2005 var $container = $('.portfolio-contents'), 2006 $portfolioInnerText = $container.find('.portfolio-inner-text'); 2007 // initialize isotope 2008 2009 if($portfolioInnerText.length > 0 ){ 2010 $portfolioInnerText.css('height', $container.find('.element').first().height()); 2011 } 2012 2013 $container.isotope({ 2014 itemSelector : '.pix-portfolio-item', 2015 percentPosition: true, 2016 masonry : { 2017 columnWidth : '.portfolio-grid-sizer' 2018 } 2019 }); 2020 2021 2022 2023 var $masonryContainer = $('.blog-isotope'), $filterCon = $("#filters"); 2024 $masonryContainer.isotope({ 2025 itemSelector : '.element', 2026 masonry : { 2027 columnWidth : 1 2028 } 2029 }); 2030 2031 if($filterCon.hasClass('dropdown')){ 2032 $filterCon.find('.selected').parent('li').css('display', 'none'); 2033 } 2034 2035 /* Portfolio Filter - Dropdown Style */ 2036 $('.top-active').on('click', function(e) { 2037 e.preventDefault(); 2038 2039 $(this).next('#filters').slideToggle('400'); 2040 2041 }); 2042 2043 // filter items when filter link is clicked 2044 $('#filters').on( 'click', 'a', function(e){ 2045 var $this = $(this), 2046 $filter = $this.parents('#filters'); 2047 2048 $portElem.waypoint('destroy'); 2049 2050 2051 if($filter.hasClass('dropdown')){ 2052 $filter.slideUp(400, function(){ 2053 $this.parent('li').css('display', 'none'); 2054 $this.parent('li').siblings().css('display', 'block'); 2055 }); 2056 $filter.prev('.top-active').find('.txt').text($this.text()); 2057 } 2058 2059 // don't proceed if already selected 2060 if ( $this.hasClass('selected') ) { 2061 return false; 2062 } 2063 2064 2065 var $optionSet = $this.parents('.option-set'); 2066 $optionSet.find('.selected').removeClass('selected'); 2067 $this.addClass('selected'); 2068 2069 2070 2071 var selector = $(this).attr('data-filter'); 2072 2073 $portElem = $(selector).find('.pix-animate-portfolio'); 2074 // var $portElem = $('.pix-animate-portfolio'); 2075 2076 $container.isotope({ filter: selector }); 2077 $container.isotope( 'on', 'layoutComplete', function() { 2078 2079 portfolioImageOnScroll( $portElem ); 2080 } ); 2081 //var $demo = $('.demo-filter'); 2082 //$demo.isotope({ filter: selector }); 2083 2084 $masonryContainer.isotope({ filter: selector }); 2085 $masonryContainer.isotope( 'on', 'layoutComplete', function() { 2086 portfolioImageOnScroll( $portElem ); 2087 }); 2088 2089 return false; 2090 }); 2091 2092 }; 2093 2094 $(window).load(function() { 2095 2096 afterPageLoad(); 2097 if( $('body').hasClass('pix-preload-enabled') ){ 2098 2099 var $preLoaderCon = $('#preloader-con'); 2100 $preLoaderCon.fadeOut(function(){ 2101 //$mainCon.fadeIn(500); 2102 var trans = $main.data('preloadtrans'); 2103 $main.removeClass().addClass('animated ' + trans); 2104 $('body').delay(750).removeClass('pix-preloader-enabled'); 2105 }); 2106 2107 $(document).on("click", 'a:not(.noajax, .woocommerce a, .btn, .button, [data-month], .popup-gallery, .popup-video, [href$=".png"], [href$=".jpg"], [href$=".jpeg"], [href$=".svg"], [href$=".mp4"], [href$=".webm"], [href$=".ogg"], [href$=".mp3"], [href^="#"], [href^="mailto:"], [href=""], [href*="wp-login"], [href^="tel:"], [href*="wp-admin"], .dot-nav-noajax, .pix-dropdown-arrow)', function(e) { 2108 2109 var attr = $(this).attr('href'); 2110 2111 if ( e.shiftKey || e.ctrlKey || e.metaKey || '_blank' == $.trim( $(this).attr('target') ) || typeof attr === typeof undefined || attr === false || window.location.href.split('#')[0] == attr.split('#')[0] ) { 2112 return; 2113 } 2114 2115 $('body').addClass('pix-preloader-enabled'); 2116 $preLoaderCon.fadeIn(); 2117 2118 }); 2119 2120 } 2121 2122 if( $('body').hasClass('like-count-on-ajax') ){ 2123 2124 if( $( '.pix-like-me' ).length ) { 2125 2126 $( '.pix-like-me' ).each(function(){ 2127 2128 var $self = $(this), 2129 id = $self.data('id'), 2130 getURL = pix_composer.ajaxurl+'?action=ajax_get_like_count&id='+id; 2131 2132 $.get( getURL, function( data ) { 2133 $self.find('.like-count').html(data); 2134 }); 2135 2136 }); 2137 } 2138 2139 } 2140 2141 $('.tool-tip').tooltip(); 2142 2143 $('.mobile-menu-nav li.menu-item-has-children').on('click', '.pix-dropdown-arrow, a[href="#"], a[href=""]', function (e) { 2144 e.preventDefault(); 2145 e.stopPropagation(); 2146 var $li = $(this).parent('li'); 2147 2148 $li.find('.sub-menu').first().stop().slideToggle(); 2149 2150 if( $(this).hasClass('pix-dropdown-arrow') ){ 2151 $(this).toggleClass('pix-bottom-arrow'); 2152 } else { 2153 $li.find('.pix-dropdown-arrow').toggleClass('pix-bottom-arrow'); 2154 } 2155 2156 }); 2157 2158 var changeHashInURL = ($('body').hasClass('pix-ajaxify')) ? false : true; 2159 $('.mobile-menu-inner').amzOnePageNav({ 2160 currentClass: 'current-menu-item', 2161 changeHash: changeHashInURL, 2162 filter: ':not(.external)', 2163 begin: function() { 2164 if($('.mobile-menu-nav').hasClass('mobile-nav')){ 2165 $('.pix-menu-trigger').trigger('click'); 2166 } 2167 }, 2168 }); 2169 2170 2171 // Load More 2172 var $loadMoreBtn = $( '.load-more-btn' ); 2173 2174 if ( $loadMoreBtn.length ) { 2175 2176 if ( $loadMoreBtn.hasClass( 'amz-autoload') ) { 2177 2178 $( window ).on('scroll', function() { 2179 2180 if( $( window ).scrollTop() >= $( '.load-container' ).offset().top + $( '.load-container' ).outerHeight() - window.innerHeight ) { 2181 2182 if( $loadMoreBtn.hasClass('done-loading') || $loadMoreBtn.hasClass( 'disabled' ) ) { 2183 return; 2184 } 2185 2186 $loadMoreBtn.find('a').trigger('click'); 2187 2188 } 2189 2190 }); 2191 } 2192 2193 $( '.load-more-btn' ).on( 'click', 'a', function(e) { 2194 e.preventDefault(); 2195
2196 loadMore( $(this) ); 2197 2198 }); 2199 } 2200 2201 }); 2202 2203 //Back To Top 2204 $("#back-top").hide(); 2205 2206 var lastScrollTop = 0; 2207 $(window).scroll(function(){ 2208 2209 var scrollTopVal = $(this).scrollTop(); 2210 2211 if( $(this).scrollTop() > 100 ){ 2212 $("#back-top").fadeIn(); 2213 }else{ 2214 $("#back-top").fadeOut(); 2215 } 2216 2217 var $headerConScrollUp = $('.header-con.pix-sticky-header.pix-sticky-header-scroll-up'); 2218 2219 if($headerConScrollUp.length > 0){ 2220 2221 if ( scrollTopVal > lastScrollTop ){ 2222 $headerConScrollUp.addClass('hide-sticky-header'); 2223 } else { 2224 $headerConScrollUp.removeClass('hide-sticky-header'); 2225 } 2226 2227 lastScrollTop = scrollTopVal; 2228 2229 } 2230 2231 }); 2232 2233 $("#back-top a").click(function(){ 2234 $("body,html").animate({ 2235 scrollTop:0},800); 2236 return false; 2237 }); 2238 2239 2240 // Header Widget 2241 var $headerWidgetCon = $("#headerWidgetCon"), 2242 $toggleBtn = $headerWidgetCon.find('.toggleBtn'), 2243 headerWidgetStatus = 0; 2244 2245 if($headerWidgetCon.length > 0 ){ 2246 2247 $toggleBtn.on('click', function(e) { 2248 e.preventDefault(); 2249 2250 if(headerWidgetStatus == 0){ 2251 $headerWidgetCon.animate({bottom: -$headerWidgetCon.outerHeight()}); 2252 $toggleBtn.addClass('close').removeClass('open'); 2253 headerWidgetStatus = 1; 2254 }else{ 2255 $headerWidgetCon.animate({bottom: -2}); 2256 $toggleBtn.addClass('open').removeClass('close'); 2257 headerWidgetStatus = 0; 2258 } 2259 2260 }); 2261 } 2262 2263 /* End of Header Scripts */ 2264 2265 init(); 2266 2267 $('#pix-header-search-form').on('submit', 2268 function(e){ 2269 e.preventDefault(); 2270 var host = pix_composer.rootUrl + "?s=", searchUrl; 2271 searchUrl = host + $(this).find('.pix-search').val(); 2272 2273 if($(window).scrollTop() > 10){ 2274 $("body,html").animate({ scrollTop:0 },300,function(){ 2275 history.pushState({}, '', searchUrl); 2276 loadPage(searchUrl); 2277 }); 2278 }else{ 2279 history.pushState({}, '', searchUrl); 2280 loadPage(searchUrl); 2281 } 2282 } 2283 ); 2284 2285 /* Ajaxify Navigation */ 2286 var ajaxLoad = function(html) { 2287 document.title = html 2288 .match(/<title>(.*?)<\/title>/)[1] 2289 .trim() 2290 .decodeHTML(); 2291 }, 2292 2293 documentHtml = function(html){ 2294 // Prepare 2295 var result = String(html).replace(/<\!DOCTYPE[^>]*>/i, '') 2296 .replace(/<(html|head|body|title|script|style)([\s\>])/gi,'<div id="document-$1"$2') 2297 .replace(/<\/(html|head|body|title|script|style)\>/gi,'</div>'); 2298 // Return 2299 return result; 2300 }, 2301 2302 loadPage = function(href) { 2303 2304 $.ajax({ 2305 url: href, 2306 dataType: "html", 2307 beforeSend: function(){ 2308 2309 $mainCon.height(($(window).height()) + 200); 2310 2311 2312 var trans = $main.data('ajaxtransout'); 2313 $main.removeClass().addClass('animated ' + trans); 2314 2315 if ($("#pix-loadingbar").length > 0) { 2316 $('#pix-loadingbar').delay(750).show(function(){ 2317 $main.html(''); 2318 }); 2319 } 2320 2321 2322 } 2323 2324 }).done(function(data) { 2325 var $data = $(documentHtml(data)), 2326 $dataHead = $data.find('#document-head:first'), 2327 $dataBody = $data.find('#document-body:first #wrapper'), 2328 bodyClasses = $data.find('#document-body:first').attr('class'), 2329 htmlFiltered = $('#wrapper', data).html(), 2330 2331 rootUrl = pix_composer.rootUrl, 2332 relativeUrl = href.replace(rootUrl,''), 2333 url = href, 2334 $menu_list, $scripts, $embeddedStyle, $wpadminbar; 2335 2336 $menu_list = $data.find('.main-nav'); 2337 2338 //Add classes to body 2339 $('body').attr('class', bodyClasses); 2340 2341 //Embeded Style 2342 $embeddedStyle = $dataHead.find('#document-style'); 2343 2344 var $pixAllStyle = $('head').find('#pix-all-styles'); 2345 if($pixAllStyle.length){ 2346 $pixAllStyle.html(''); 2347 }else{ 2348 $('head').append('<style media="screen" id="pix-all-styles"></style>'); 2349 $pixAllStyle = $('head').find('#pix-all-styles'); 2350 } 2351 var newStyles = ''; 2352 $embeddedStyle.each(function(){ 2353 var media = ($(this).attr('media')) ? $(this).attr('media') : 'screen'; 2354 2355 if(media == 'screen'){ 2356 newStyles += $(this).html(); 2357 } 2358 2359 }); 2360 2361 $pixAllStyle.html(newStyles); 2362 2363 // Fetch the scripts 2364 $scripts = $dataBody.find('#document-script'); 2365 if ( $scripts.length ) $scripts.detach(); 2366 2367 if(!htmlFiltered){ 2368 document.location.href = href; 2369 return false; 2370 } 2371 2372 $main.html(htmlFiltered).fadeIn(); 2373 $mainCon.height('auto'); 2374 ajaxLoad(data); 2375 2376 //Append new menu HTML to provided classs 2377 $('.main-nav').html($menu_list.html()); 2378 2379 //Change wpadminbar edit link id. 2380 var $currwpadminbar = $('#wpadminbar'); 2381 if($currwpadminbar.length > 0 ){ 2382 $wpadminbar = $data.find('#wpadminbar'); 2383 2384 if( $wpadminbar.length > 0 ){ 2385 $('#wpadminbar').html($wpadminbar.html()); 2386 }else{ 2387 $currwpadminbar.remove(); 2388 } 2389 } 2390 2391 // Add the scripts 2392 $scripts.each(function(){ 2393 var scriptText = $(this).html(); 2394
2395 if ( '' != scriptText ) { 2396 var scriptNode = document.createElement('script'); 2397 scriptNode.appendChild(document.createTextNode(scriptText)); 2398 contentNode.appendChild(scriptNode); 2399 } else { 2400 $.getScript( $(this).attr('src') ); 2401 } 2402 }); 2403 2404 init(); 2405 $(window).trigger('load'); 2406 2407 if (typeof window['vc_js'] == 'function') { 2408 window.vc_js(); 2409 } 2410 2411 if ($("#pix-loadingbar").length > 0) { 2412 $('#pix-loadingbar').hide(function(){ 2413 var trans = $main.data('ajaxtransin'); 2414 $main.removeClass().addClass('animated ' + trans); 2415 }); 2416 } 2417 2418 // Inform Google Analytics of the change 2419 if ( typeof window.pageTracker !== 'undefined' ) window.pageTracker._trackPageview(relativeUrl); 2420 2421 // Inform ReInvigorate of a state change 2422 if ( typeof window.reinvigorate !== 'undefined' && typeof window.reinvigorate.ajax_track !== 'undefined' ) 2423 reinvigorate.ajax_track(url); 2424 2425 2426 2427 }).error(function(){ 2428 2429 document.location.href = href; 2430 return false; 2431 2432 }); 2433 }; 2434 2435 // Used to detect initial (useless) popstate. 2436 // If history.state exists, assume browser isn't going to fire initial popstate. 2437 var popped = ('state' in window.history && window.history.state !== null), initialURL = location.href; 2438 2439 if($('body').hasClass('pix-ajaxify')){ 2440 2441 $(window).on("popstate", function(e) { 2442 var initialPop = !popped && location.href == initialURL 2443 popped = true 2444 2445 if (initialPop) return; 2446 2447 loadPage(location.href); 2448 }); 2449 2450 $(document).on("click", 'a:not(.noajax, [href^="#"], [href^=""], [href=""], [href*="wp-login"], [href*="wp-admin"], .dot-nav-noajax, .pix-dropdown-arrow)', function(e) { 2451 var self = $(this), 2452 href = self.attr("href"); 2453 2454 // Continue as normal for cmd clicks etc 2455 if ( e.which == 2 || e.metaKey ) return true; 2456 2457 if($('.mobile-menu-nav').hasClass('mobile-nav')){ 2458 $('.pix-menu-trigger').trigger('click'); 2459 } 2460 2461 if (href.indexOf(document.domain) > -1 || href.indexOf(':') === -1){ 2462 if($(window).scrollTop() > 10){ 2463 2464 $("body,html").animate({ scrollTop:0 },300,function(){ 2465 history.pushState({}, '', href); 2466 loadPage(href); 2467 2468 }); 2469 }else{ 2470 history.pushState({}, '', href); 2471 loadPage(href); 2472 } 2473 2474 return false; 2475 } 2476 2477 }); 2478 2479 } 2480 2481 2482 /*---------------------------------------------------- 2483 /* Make all anchor links smooth scrolling 2484 /*--------------------------------------------------*/ 2485 jQuery(document).ready(function($) { 2486 2487 if ( ! $('body').hasClass('seperate-mobile-nav') ) { 2488 2489 $('.main-nav').each(function(){ 2490 var navHtml = $(this).html(); 2491 $('.mobile-menu-inner').append(navHtml); 2492 2493 var $titleStyle = $('.mobile-menu-inner').find('.pix-title-style'); 2494 2495 $titleStyle.each(function(index, el) { 2496 2497 var $this = $(this); 2498 2499 $this.nextUntil('.pix-title-style').wrapAll('<ul class="sub-menu">'); 2500 2501 $this.addClass('menu-item-has-children moved-pix-title-style'); 2502 2503 // move ul inside li.pix-title-style 2504 $this.append( $this.next('.sub-menu') ); 2505 $this.next('.sub-menu').remove(); 2506 2507 // then move li.pix-title-style next to parent li 2508 var $parentLi = $this.parents('li'), 2509 $parentLiNext = $parentLi.next('.moved-pix-title-style'); 2510 2511 if( $parentLiNext.length ) { 2512 var $moveItems = $parentLi.parent().find('.moved-pix-title-style'), 2513 elem = $this.prop('outerHTML'); 2514 $( elem ).insertAfter( $moveItems.eq( $moveItems.length - 1 ) ); 2515 2516 } else { 2517 $this.insertAfter( $this.parents('li') ); 2518 2519 } 2520 2521 $this.remove(); 2522 2523 }); 2524 2525 }); 2526 2527 } 2528 2529 2530 2531 // scroll handler 2532 var scrollToAnchor = function( id, event ) { 2533 // grab the element to scroll to based on the name 2534 var elem = $("a[name='"+ id +"']"); 2535 // if that didn't work, look for an element with our ID 2536 if ( typeof( elem.offset() ) === "undefined" ) { 2537 elem = $("#"+id); 2538 } 2539 // if the destination element exists 2540 if ( typeof( elem.offset() ) !== "undefined" ) { 2541 // cancel default event propagation 2542 event.preventDefault(); 2543 var scroll_to = elem.offset().top; 2544 // do the scroll 2545 $('html, body').animate({ 2546 scrollTop: scroll_to 2547 }, 600, 'swing', function() { if (scroll_to > 46) window.location.hash = id; } ); 2548 } 2549 }; 2550 // bind to click event 2551 $("a.scroll-to, .scroll-to a").click(function( event ) { 2552 // only do this if it's an anchor link 2553 var href = $(this).attr("href"); 2554 if ( href.match("#") && href !== '#' && $(this).parents(".tabs").length !== 1 ) { 2555 // scroll to the location 2556 var parts = href.split('#'), 2557 url = parts[0], 2558 target = parts[1]; 2559 if ((!url || url == window.location.href.split('#')[0]) && target) 2560 scrollToAnchor( target, event ); 2561 } 2562 }); 2563 2564 $('.portfolio-search').on('keypress', '.search-field', function(e) { 2565 2566 var $self = $(this), 2567 search = $self.val(); 2568 2569 if( e.keyCode === 13 ) { 2570 // Call portfolio search ajax 2571 portfolioSearch( $self, search ); 2572 } 2573 2574 }); 2575 2576 $('.portfolio-search').on('click', '.clear-search', function(e) { 2577 2578 var $self = $(this), 2579 search = $self.val(); 2580 2581 portfolioSearch( $self, '' ); 2582 2583 }); 2584 2585 }); 2586 2587 $('.blog-modern').on('click', '.show-content-arrow', function(e) { 2588 e.preventDefault(); 2589 $(this).parents('.post-container').toggleClass('show-content'); 2590 }); 2591 2592})(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.