1(function ($) { 2 3 4 $(document).ready(function () { 5 6 7 // Global Variables 8 window_w = $(window).width(); 9 window_h = $(window).height(); 10 window_s = $(window).scrollTop(); 11 12 $html = $('html'); 13 $body = $('body'); 14 15 if(history.pushState) 16 var ionic_current_path = location.pathname; 17 18 // Window Load and Resize 19 $(window).bind('resize load', function () { 20 21 window_w = $(window).width(); 22 window_h = $(window).height(); 23 window_s = $(window).scrollTop(); 24 25 }); 26 27 // Window Scroll 28 $(window).scroll(function () { 29 30 window_s = $(window).scrollTop(); 31 32 }); 33 34 35 // CSS3 transition support 36 function supportsTransitions() { 37 var b = document.body || document.documentElement, 38 s = b.style, 39 p = 'transition'; 40 41 if (typeof s[p] == 'string') { return true; } 42 43 // Tests for vendor specific prop 44 var v = ['Moz', 'webkit', 'Webkit', 'Khtml', 'O', 'ms']; 45 p = p.charAt(0).toUpperCase() + p.substr(1); 46 47 for (var i=0; i<v.length; i++) { 48 if (typeof s[v[i] + p] == 'string') { return true; } 49 } 50 51 return false; 52 } 53 54 55 /*************************************************/ 56 /* TEMPLATE FEATURES */ 57 /*************************************************/ 58 59 60 /* Element Features */ 61 62 enableStickyHeader(); // Sticky Header 63 64 enableHoverStickyHeader(); // Hover Sticky Header 65 66 enableMobileNav(); // Mobile Navigation 67 68 enableFlexSlider(); // Flexslider - Slider Plugin 69 70 enableAccordions(); // Accordions 71 72 enableTabs(); // Tabs 73 74 enableProgressbars(); // Progressbars 75 76 enableCircularProgressbars(); // Circular Progressbars 77 78 enableTooltips(); // Bootstrap Tooltips 79 80 enableAlertBox(); // Alert Boxes 81 82 enableFancyBox() // Fancy Box 83 84 enableCustomAudio(); // Custom Audio Player 85 86 enableSearchBox(); // Search Box 87 88 enableSearchPreBox(); // Search Box in Preheader 89 90 enableCustomInput(); // Custom Made Inputs 91 92 enableSliderAlternativeOverlay(); // Alternative Slider Overlay 93 94 enableGoogleMaps(); // Google Maps API 95 96 enableDatePicker(); // Form Datepicker 97 98 enableBackToTop(); // Back To Top Button 99 100 enableNavigationButton(); // Navigation Button 101 102 // enableStickyFooter(); // Sticky Footer 103 104 105 /* Layout Features */ 106 107 enableMasonryBlog(); // Masonry Blog 108 109 enableTimelineBlog(); // Timeline Blog 110 111 enableMixItUp(); // MixItUp - Filtering Plugin 112 113 enableFullWidth(); // Full Width 114 115 enableWOWAnimate(); // WOW Animate.css Plugin 116 117 118 /* Action Features */ 119 120 enableRecentProductRemove(); // Recent Product Remove 121 122 enableShopRefine(); // Shop Refine 123 124 enableOnePageScroll(); // One Page Menu Items 125 126 enablePrettyPhoto(); // PrettyPhoto - Lightbox Plugin 127 128 enableFitVids(); // FitVids Plugin 129 130 131 132 /* AJAX Features */ 133 134 enableLoadMoreButton(); // Portfolio, Masonry AJAX Load More 135 136 enableTimelineLoadMore(); // Timeline AJAX Load More 137 138 enableWooCommerceAddToCart(); // WooCommerce Add To Cart 139 140 enableWooCommerceLoadMore(); // WooCommerce Load More 141 142 enableAjaxContactForm(); // Contact Form AJAX 143 144 enablePostLike(); // Post Like Options 145 146 enableAjaxPageLoad(); // AJAX page Loading 147 148 149 150 151 /*************************************************/ 152 /* FUNCTIONS */ 153 /*************************************************/ 154 155 156 157 // Reinitilize All Features Function 158 function reinitializeAllFeatures(){ 159 160 /* Element Features */ 161 162 initMenuFeatures(); // Mobile Nav 163 164 enableFlexSlider(); // Flexslider - Slider Plugin 165 166 enableAccordions(); // Accordions 167 168 enableTabs(); // Tabs 169 170 animateProgressBars(); // Progressbars 171 172 initCircularProgressbars(); // Circular Progressbars 173 174 enableTooltips(); // Bootstrap Tooltips 175 176 enableAlertBox(); // Alert Boxes 177 178 enableFancyBox() // Fancy Box 179 180 initCustomAudio(); // Custom Audio Player 181 182 initSearchBox(); // Search Box 183 184 initMarineHeader(); // Marine Header 185 186 enableCustomInput(); // Custom Made Inputs 187 188 sliderAlternativeOverlay(); // Alternative Slider Overlay 189 190 setTimeout(function(){ 191 enableGoogleMaps(); // Google Maps API 192 }, 420); 193 194 enableDatePicker(); // Form Datepicker 195 196 // initStickyFooter() // Sticky Footer 197 198 199 /* Layout Features */ 200 201 initMasonryBlog(); // Masonry Blog 202 203 setTimelineBlog(); // Timeline Blog 204 205 reinitializeMixItUp(); // MixItUp - Filtering Plugin 206 207 setFullWidth(); // Set Fullwidth 208 209 setTimeout(function(){ 210 enableWOWAnimate(); // WOW Animate.css Plugin 211 }, 1200); 212 213 214 /* Action Features */ 215 216 enableRecentProductRemove(); // Recent Product Remove 217 218 enableShopRefine(); // Shop Refine 219 220 enableOnePageScroll(); // One Page Menu Items 221 222 enablePrettyPhoto(); // PrettyPhoto - Lightbox Plugin 223 224 enableFitVids(); // FitVids Plugin 225 226 227 /* AJAX Features */ 228 229 enableLoadMoreButton(); // Portfolio, Masonry AJAX Load More 230 231 enableTimelineLoadMore(); // Timeline AJAX Load More 232 233 enableWooCommerceAddToCart(); // WooCommerce Add To Cart 234 235 enableWooCommerceLoadMore(); // WooCommerce Load More 236 237 enableAjaxContactForm(); // Contact Form AJAX 238 239 enablePostLike(); // Post Like Options 240 241 initAjaxNav(); // AJAX page Loading 242 243 setFullWidth(); 244 245 setTimeout(function(){ 246 setFullWidth(); 247 }, 400); 248 249 } 250 251 252 253 /** 254 * Form Datepicker 255 */ 256 function enableDatePicker(){ 257 258 $('.datepicker-button .datepicker-el').datepicker({ 259 onSelect: function(){ 260 261 var datePicker = $(this); 262 var datePickerWrap = datePicker.parents('.date-picker'); 263 var currentDate = datePicker.datepicker( "getDate" ); 264 265 if(currentDate){ 266 var year = currentDate.getFullYear();
267 var month = currentDate.getMonth(); 268 var day = currentDate.getDate(); 269 270 datePickerWrap.find('.day').attr('value', day); 271 datePickerWrap.find('.month').attr('value', month); 272 datePickerWrap.find('.year').attr('value', year); 273 274 datePicker.fadeToggle(300); 275 } 276 277 } 278 }); 279 280 $('.datepicker-button .datepicker-icon').click(function(){ 281 $(this).parent().find('.datepicker-el').fadeToggle(300); 282 }); 283 284 } 285 286 287 288 289 /** 290 * Navigation Button 291 */ 292 293 function enableNavigationButton(){ 294 295 // Initialize Navigaiton Button 296 initNavigationButton(); 297 298 } 299 300 function initNavigationButton(){ 301 302 $('#nav-button').click(function(){ 303 $(this).parent().find('.navigation-style2').toggleClass('nav-active'); 304 }); 305 306 } 307 308 309 310 /** 311 * Back To Top button 312 */ 313 314 function enableBackToTop(){ 315 316 // Show/Hide Back To Top Button 317 $(window).scroll(function(){ 318 var offset = $(document).height() - window_h - 300; 319 if($('#footer').length) 320 offset = $('#footer').offset().top - window_h; 321 322 if(window_s > offset && window_w > 767){ 323 $('#back-to-top').fadeIn(400); 324 }else{ 325 $('#back-to-top').fadeOut(400); 326 } 327 }); 328 329 // Back To Top 330 $('#back-to-top a').click(function(e){ 331 e.preventDefault(); 332 333 // Duration 334 var duration = 1200; 335 if(window_s < 400) 336 duration = 600; 337 if(window_s = 0) 338 duration = 0; 339 340 $('html, body').animate( 341 { 342 scrollTop: 0+'px' 343 }, 344 { 345 duration: duration, 346 easing: 'easeInOutCubic' 347 } 348 ); 349 }); 350 351 } 352 353 354 355 356 /** 357 * Sticky Header 358 */ 359 function enableStickyHeader() { 360 361 $(window).scroll(function () { 362 363 window_s = $(this).scrollTop(); 364 window_w = $(this).width(); 365 366 if (window_s > 130 && window_w > 991) { 367 368 // Prevent Header Top Animation Flash Effect 369 if($('body').hasClass('headerstyle9') && !$('body').hasClass('sticky-header-on')){ 370 $('#header').hide(); 371 setTimeout(function(){ 372 $('#header').show(); 373 }, 300); 374 } 375 376 $('#header').addClass('sticky-header'); 377 $('body').addClass('sticky-header-on'); 378 379 } else { 380 381 $('#header').removeClass('sticky-header'); 382 $('body').removeClass('sticky-header-on'); 383 384 } 385 386 }); 387 388 // Initialize Body Padding for Header 389 initMarineHeader(); 390 $(window).bind('load resize', function(){ 391 initMarineHeader(); 392 }); 393 394 } 395 396 397 function initMarineHeader(){ 398 if(window_w > parseInt(mobilenav_screen_size) && !$body.hasClass('headerstyle7') && !$body.hasClass('headerstyle8')){ 399 400 var $header = $('#header'), 401 header_h; 402 403 if(!$header.hasClass('sticky-header')){ 404 header_h = $header.height(); 405 $body.css('padding-top', header_h); 406 }else{ 407 $header.removeClass('sticky-header'); 408 header_h = $header.height(); 409 $body.css('padding-top', header_h); 410 $header.addClass('sticky-header'); 411 } 412 413 }else{ 414 $body.css('padding-top', ''); 415 } 416 } 417 418 419 420 /** 421 * Hover Sticky Header 422 */ 423 function enableHoverStickyHeader(){ 424 425 var header_hover = false; 426 var button_hover = false; 427 428 $('#header').hover(function(){ 429 header_hover = true; 430 }, function(){ 431 header_hover = false; 432 setTimeout(function(){ 433 if(!button_hover && !header_hover) 434 $('#header').removeClass('sticky-header-visible'); 435 }, 600); 436 }); 437 438 $('#sticky-header-hover-button .button-content').hover(function(){ 439 button_hover = true; 440 $('#header').addClass('sticky-header-visible'); 441 setTimeout(function(){ 442 if(!header_hover){ 443 $('#header').removeClass('sticky-header-visible'); 444 } 445 }, 1200); 446 }, function(){ 447 button_hover = false; 448 }); 449 450 } 451 452 453 454 455 456 /* Sticky Footer */ 457 458 function enableStickyFooter(){ 459 460 // Initialize Sticky Footer 461 initStickyFooter(); 462 $(window).bind('load resize', function(){ 463 if($body.hasClass('sticky-footer-on')) 464 fixStickyFooter(); 465 }); 466 467 } 468 469 // Init Sticky Footer 470 function initStickyFooter(){ 471 $body.addClass('sticky-footer-on') 472 if($body.hasClass('sticky-footer-on')){ 473 fixStickyFooter(); 474 } 475 } 476 477 // Fix Sticky Footer 478 function fixStickyFooter(){ 479 var footer = $('#footer'); 480 if(footer.length){ 481 var footer_h = $('#footer').height(); 482 $body.css('padding-bottom', footer_h); 483 } 484 } 485 486 487 488 489 /* Search Box */ 490 function enableSearchBox() { 491 492 initSearchBox(); 493 494 $(document).click(function(e){
495 if (!$('#search-box, #search-box *').is(e.target)){ 496 $('#search-box').removeClass('search-box-opened'); 497 } 498 }); 499 500 }; 501 502 function initSearchBox(){ 503 $('#search-box>.icons').click(function () { 504 $(this).parent().toggleClass('search-box-opened'); 505 }); 506 } 507 508 /* Search Box Preheader */ 509 function enableSearchPreBox() { 510 511 initSearchBoxPre(); 512 513 $(document).click(function(e){ 514 if (!$('#search-box-pre, #search-box-pre *').is(e.target)){ 515 $('#search-box-pre').removeClass('search-box-opened'); 516 } 517 }); 518 519 }; 520 521 function initSearchBoxPre(){ 522 $('#search-box-pre>.icons').click(function () { 523 $(this).parent().toggleClass('search-box-opened'); 524 }); 525 } 526 527 528 // WOW Animate.css Plugin 529 function enableWOWAnimate(){ 530 531 var isMobileBrowser = navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i); 532 533 // WOW animate.css if transitions are supported 534 if(supportsTransitions() && !isMobileBrowser){ 535 var off = window_h/5; 536 537 var wow = new WOW({ 538 offset: off 539 }); 540 541 wow.init(); 542 } 543 544 } 545 546 547 548 549 550 551 552 /* Cookie Manipulations Functions */ 553 554 // Create Cookie 555 function createCookie(name,value,days) { 556 if (days) { 557 var date = new Date(); 558 date.setTime(date.getTime()+(days*24*60*60*1000)); 559 var expires = "; expires="+date.toGMTString(); 560 } 561 else var expires = ""; 562 document.cookie = name+"="+value+expires+"; path=/"; 563 } 564 565 // Erase Cookie 566 function eraseCookie(name) { 567 createCookie(name,"",-1); 568 } 569 570 571 572 573 574 575 /* Recent Product Remove */ 576 function enableRecentProductRemove() { 577 // Single Remove Button 578 $('.remove-product-button').click(function (e) { 579 580 e.preventDefault(); 581 582 // Load Recently Viewed Array 583 var name = 'woocommerce_recently_viewed' + "="; 584 var ca = document.cookie.split(';'); 585 recently_viewed = new Array(); 586 for(var i=0; i<ca.length; i++) { 587 var c = ca[i].trim(); 588 if (c.indexOf(name) == 0) { 589 recently_viewed = c.substring(name.length, c.length).split('%7C'); 590 } 591 } 592 593 // Erase Cookie 594 eraseCookie('woocommerce_recently_viewed'); 595 596 // Create New Recently Viewed Array 597 new_recently_viewed = new Array(); 598 if (recently_viewed instanceof Array) { 599 j = 0; 600 for (i=0; i<recently_viewed.length; i++) { 601 if (recently_viewed[i] == $(this).data('id')) { 602 continue; 603 } 604 new_recently_viewed[j] = recently_viewed[i]; 605 j++; 606 } 607 } 608 609 // Create New Cookie 610 createCookie('woocommerce_recently_viewed', new_recently_viewed.join('|')); 611 612 // Fade Out Elemenet 613 $(this).parents('.recently-viewed-product').fadeOut(300, function () { 614 $(this).remove(); 615 }); 616 617 }); 618 619 // Remove All Button 620 $('.clear-recent-products').click(function (e) { 621 622 e.preventDefault(); 623 624 $('.recently-viewed-product').each(function () { 625 $(this).fadeOut(300, function () { 626 $(this).remove(); 627 }); 628 }); 629 630 // Erase Cookie 631 eraseCookie('woocommerce_recently_viewed'); 632 633 }); 634 635 636 637 } 638 639 640 641 /* Custom Made Inputs */ 642 function enableCustomInput() { 643 /* Numeric Input */ 644 645 if ($('.shopping-cart').length > 0) { 646 647 $('input[type="number"]').each(function () { 648 $(this).wrap('<div class="numeric-input-holder"></div>'); 649 650 651 $(this).parent().prepend('<div class="decrease-button"></div>'); 652 $(this).parent().append('<div class="increase-button"></div>'); 653 // Decrease Button 654 $(this).parent().find('.decrease-button').click(function () { 655 var value = parseInt($(this).parent().find('input[type="number"]').val()); 656 value--; 657 $(this).parent().find('input[type="number"]').val(value); 658 });
659 // Increase Button 660 $(this).parent().find('.increase-button').click(function () { 661 var value = parseInt($(this).parent().find('input[type="number"]').val()); 662 value++; 663 $(this).parent().find('input[type="number"]').val(value); 664 }); 665 // Prevent Not A Number(NaN) Value 666 $(this).keypress(function (e) { 667 var value = parseInt(String.fromCharCode(e.which)); 668 if (isNaN(value)) { 669 e.preventDefault(); 670 } 671 }); 672 }) 673 } 674 } 675 676 677 678 679 /* Shop Refine */ 680 function enableShopRefine() { 681 682 if (typeof $.fn.perfectScrollbar == 'function') { 683 684 // Shop product perdectscrollbar 685 $('.shop-products-recommend').perfectScrollbar({ 686 wheelSpeed: 20, 687 wheelPropagation: true, minScrollbarLength: 20, 688 suppressScrollX: true 689 }); 690 691 $('#reviews').perfectScrollbar({ 692 wheelSpeed: 20, 693 wheelPropagation: true, minScrollbarLength: 20, 694 suppressScrollX: true 695 }); 696 } 697 698 if (typeof $.fn.noUiSlider == 'function' && $('.price_slider').length > 0) { 699 var noUi_slider = $('.price_slider'); 700 var noUi_slider_parent = noUi_slider.parent(); 701 702 var noUi_min = parseInt($('#min_price').data('min')); 703 var noUi_max = parseInt($('#max_price').data('max')); 704 var noUi_min_start = parseInt($('#min_price').data('min')); 705 var noUi_max_start = parseInt($('#max_price').data('max')); 706 707 if(woocommerce_price_slider_params.currency_symbol) 708 var currency = woocommerce_price_slider_params.currency_symbol; 709 else 710 var currency = '$'; 711 712 noUi_slider.noUiSlider({ 713 start: [ noUi_min_start, noUi_max_start ], range: { 714 'min': [ noUi_min ], 715 'max': [ noUi_max ] 716 }, serialization: { 717 lower: [ 718 $.Link({ 719 target: $('.price_slider_amount .price_label .from', noUi_slider_parent) 720 }) 721 ], 722 upper: [ 723 $.Link({ 724 target: $('.price_slider_amount .price_label .to', noUi_slider_parent) 725 }) 726 ], 727 format: { 728 decimals: 0, 729 mark: ',', 730 prefix: currency 731 } 732 } 733 }); 734 } 735 736 if (typeof $.fn.perfectScrollbar == 'function') { 737 738 $('.sidebar .shop-widget').each(function () { 739 // Perfect Scrollbar 740 741 $(this).not('.product-price-range').find('>ul') 742 .perfectScrollbar({ 743 wheelSpeed: 20, 744 wheelPropagation: true, 745 minScrollbarLength: 20, 746 suppressScrollX: true 747 }); 748 // noUI Slider 749 750 // Accordions 751 $(this).not('.opened').find('>ul,>form').hide(); 752 $(this).find('.arrow').click(function () { 753 if (!$(this).parents('.shop-widget').hasClass('opened')) { 754 $(this).parents('.shop-widget').addClass('opened') 755 .find('>ul,>form').slideDown(400, function () { 756 $(this).perfectScrollbar("update"); 757 });
758 } else { 759 $(this).parents('.shop-widget').removeClass('opened') 760 .find('>ul,>form').slideUp(400); 761 } 762 }); 763 }); 764 } 765 } 766 767 768 /* FlexSlider */ 769 770 function enableFlexSlider() { 771 772 if (typeof $.fn.flexslider != 'function') { 773 return; 774 } 775 776 /* FullScreen Slider */ 777 $('.main-flexslider').flexslider({ 778 animation: "slide", 779 controlNav: false, 780 prevText: "", 781 nextText: "" 782 }); 783 784 /* Shop Product Slider */ 785 $('.shop-product-slider').flexslider({ 786 animation: "slide", 787 controlNav: "thumbnails", 788 prevText: "", 789 nextText: "", 790 smoothHeight: true 791 }); 792 793 /* Portfolio Slider */ 794 $('.portfolio-flexslider').flexslider({ 795 animation: "slide", 796 controlNav: false, 797 prevText: "", 798 nextText: "" 799 }); 800 801 /* Post Gallery Slider */ 802 $('.post-image-gallery:not(".slider-enabled")').flexslider({ 803 animation: "slide", 804 controlNav: false, 805 prevText: "", 806 nextText: "" 807 }); 808 809 /* Chefs Slider */ 810 $('.chefs-slider').flexslider({ 811 animation: "fade", 812 animationSpeed: 0, 813 slideshow: false, 814 controlNav:false, 815 prevText: "", 816 nextText: "" 817 }); 818 819 /* Food Menu Slider */ 820 $('.food-menu-slider').flexslider({ 821 animation: "slide", 822 animationSpeed: 0, 823 smoothHeight: true, 824 controlNav:false, 825 slideshow: false, 826 prevText: "", 827 nextText: "" 828 }); 829 830 831 /* Food Menu Full Slider */ 832 $('.food-menu-full').each(function(){ 833 834 var slider = $(this).find('.food-menu-full-slider'), 835 nav = $(this).find('.food-menu-nav .food-menu-nav-item'); 836 837 slider.flexslider({ 838 animation: "slide", 839 animationSpeed: 0, 840 smoothHeight: true, 841 controlNav: true, 842 slideshow: false, 843 prevText: "", 844 nextText: "", 845 manualControls: nav 846 }); 847 848 }); 849 850 /* Tweets Slider */ 851 $('.tweets-flexslider').flexslider({ 852 animation: "slide", 853 controlNav: false, 854 directionNav: false, 855 touch: true, 856 slideshowSpeed: 3000, 857 animationSpeed: 400, 858 prevText: "", 859 nextText: "", 860 start: function (slider) { 861 862 slider.find('.arrow-left').click(function () { 863 slider.flexAnimate(slider.getTarget("prev")); 864 }); 865 866 slider.find('.arrow-right').click(function () { 867 slider.flexAnimate(slider.getTarget("next")); 868 }); 869 870 } 871 }); 872 873 874 /* Product Slider with Carousel Nav */ 875 $('.products-carousel').flexslider({ 876 animation: "slide", 877 controlNav: false, 878 directionNav: false, 879 animationLoop: false, 880 slideshow: false, 881 itemWidth: 70, 882 itemMargin: 6, 883 asNavFor: '.products-slider', 884 start: function (slider) { 885 886 slider.find('.arrow-left').click(function () { 887 slider.flexAnimate(slider.getTarget("prev")); 888 }); 889 890 slider.find('.arrow-right').click(function () { 891 slider.flexAnimate(slider.getTarget("next")); 892 }); 893 894 } 895 }); 896 897 $('.products-slider').flexslider({ 898 animation: "slide", 899 controlNav: false, 900 directionNav: false, 901 animationLoop: false, 902 slideshow: false, 903 sync: ".products-carousel" 904 }); 905 906 $('.flexslider-thumbnail-gallery').flexslider({ 907 animation: "fade", 908 animationSpeed: 300, 909 controlNav: "thumbnails", 910 directionNav: false, 911 start: function(slider){ 912 913 var $slider = slider; 914 915 $('.slides li', $slider).not('.clone').each(function(index, value){ 916 var tooltip = $(this).data('tooltip'); 917 $slider.find('.flex-control-nav li').eq(index) 918 .attr('title', tooltip) 919 .tooltip({ 920 placement: 'top', 921 animation: false 922 });; 923 });
924 925 $slider.find('.flex-control-nav li').hover(function(){ 926 $('img',this).trigger('click'); 927 }); 928 929 } 930 }); 931 932 933 $('.testimonial-slider').flexslider({ 934 animation: "slide", 935 animationSpeed: 0, 936 smoothHeight: true, 937 controlNav: "bullets", 938 slideshow: false, 939 directionNav: false 940 }); 941 942 $(window).load(function(){ 943 $(window).trigger('resize'); 944 }); 945 946 } 947 948 949 /* Accordions */ 950 951 function enableAccordions() { 952 953 $('.accordions').each(function () { 954 955 // Set First Accordion As Active 956 $(this).find('.accordion-content').hide(); 957 958 if ($(this).find('.accordion:first-child').hasClass('accordion-active')) { 959 $(this).find('.accordion:first-child .accordion-content').show(); 960 } 961 962 963 // Set Accordion Events 964 $(this).find('.accordion-header').click(function () { 965 966 if (!$(this).parent().hasClass('accordion-active')) { 967 968 // Close other accordions 969 $(this).parent().parent().find('.accordion-active').removeClass('accordion-active').find('.accordion-content').slideUp(300); 970 971 // Open Accordion 972 $(this).parent().addClass('accordion-active'); 973 $(this).parent().find('.accordion-content').slideDown(300); 974 975 } else { 976 977 // Close Accordion 978 $(this).parent().removeClass('accordion-active'); 979 $(this).parent().find('.accordion-content').slideUp(300); 980 981 } 982 983 }); 984 985 }); 986 987 } 988 989 990 /* Tabs */ 991 992 function enableTabs() { 993 994 $('.tabs').each(function () { 995 996 // Set Active Tab 997 $(this).find('.tab').hide(); 998 $(this).find('.tab:first-child').show(); 999 $(this).find('.tab-header ul li:first-child').addClass('active-tab'); 1000 1001 1002 // Prevent Default 1003 $(this).find('.tab-header li a').click(function (e) { 1004 e.preventDefault(); 1005 }); 1006 1007 1008 // Tab Navigation 1009 $(this).find('.tab-header li').click(function () { 1010 1011 var target = $(this).find('a').attr('href'); 1012 1013 $(this).parent().parent().parent().find('.tab').fadeOut(200); 1014 $(this).parent().parent().parent().find(target).delay(200).fadeIn(200); 1015 1016 $(this).parent().find('.active-tab').removeClass('active-tab'); 1017 $(this).addClass('active-tab'); 1018 1019 1020 }); 1021 1022 1023 }); 1024 1025 } 1026 1027 1028 /* Mobile Navigation */ 1029 1030 function enableMobileNav() { 1031 1032 // navigation 1033 if($('#sidemenu').length == 0){ 1034 var navigation = $('#main-nav'); 1035 if(!navigation.length){ 1036 navigation = $('#header div.menu>ul'); 1037 } 1038 }else{ 1039 var navigation = $('#side-nav>ul'); 1040 } 1041 1042 // Mobile Menu Button 1043 initMenuFeatures(); 1044 1045 // On Resize 1046 $(window).resize(function () { 1047 if (window_w > parseInt(mobilenav_screen_size)) { 1048 navigation.show().removeClass('nav-opened'); 1049 } 1050 }); 1051 1052 fixMegaMenu(); 1053 fixSidemenu(); 1054 1055 // Fix Sidemenu Overlaping, and Mega Menu 1056 $(window).bind('load resize', function(){ 1057 fixSidemenu(); 1058 fixMegaMenu(); 1059 }); 1060 1061 1062 1063 } 1064 1065 /* Mega Menu Position Fix */ 1066 function initMenuFeatures(){ 1067 1068 // navigation 1069 if($('#sidemenu').length == 0){ 1070 var navigation = $('#main-nav'); 1071 if(!navigation.length){ 1072 navigation = $('#header div.menu>ul'); 1073 } 1074 }else{ 1075 var navigation = $('#side-nav>ul'); 1076 } 1077 1078 var sidemenu = $('#sidemenu'); 1079 if(sidemenu.length){ 1080 1081 // Sidemenu Overlaping Elements 1082 var sidenav = sidemenu.find('#side-nav'); 1083 1084 // Sidemenu Dropdown 1085 sidenav.find('>ul li').hover(function(){ 1086 var li = $(this); 1087 if(!li.parents('.mega-menu').length && window_w > parseInt(mobilenav_screen_size)){ 1088 li.addClass('item-hovered'); 1089 li.find('>ul').slideDown(800, function(){ 1090 fixSidemenu('fade'); 1091 }); 1092 } 1093 }, function(){ 1094 var li = $(this); 1095 if(!li.parents('.mega-menu').length){ 1096 li.removeClass('item-hovered'); 1097 setTimeout(function(){ 1098 if(!li.hasClass('item-hovered') && window_w > parseInt(mobilenav_screen_size)){ 1099 li.find('>ul').slideUp(800, function(){ 1100 fixSidemenu('fade'); 1101 }); 1102 } 1103 }, 1200); 1104 } 1105 }); 1106 1107 } 1108 1109 1110 // Fix Mega Menu 1111 fixMegaMenu(); 1112 fixSidemenu(); 1113 1114 /* Dropdowns */ 1115 $('li', navigation).each(function(){ 1116 1117 if($(this).find('ul').length > 0){ 1118 $(this).append('<div class="dropdown-button"></div>'); 1119 } 1120 1121 }); 1122 1123 $('.dropdown-button', navigation).click(function(){ 1124 1125 $(this).parent().toggleClass('dropdown-opened').find('>ul').slideToggle(300); 1126 1127 }); 1128 1129 1130 1131 1132 // Menu Button 1133 $('#main-nav-button').click(function() { 1134 1135 if ($(navigation).hasClass('nav-opened')) { 1136 1137 $(navigation).slideUp(300).removeClass('nav-opened'); 1138 1139 } else { 1140 1141 $(navigation).slideDown(300).addClass('nav-opened'); 1142 1143 } 1144 1145 }); 1146 1147 1148 // Sidenav Init 1149 $('#sidemenu-button').click(function(){ 1150 var sidemenu = $('#sidemenu'); 1151 var wrapper = $('#sidemenu-wrapper'); 1152 1153 sidemenu.toggleClass('menu-opened'); 1154 wrapper.addClass('menu-mouse-out'); 1155 setTimeout(function(){ 1156 if(wrapper.hasClass('menu-mouse-out')){ 1157 sidemenu.removeClass('menu-opened'); 1158 } 1159 }, 1000); 1160 1161 }); 1162 1163 $('#sidemenu-wrapper').hover(function(){ 1164 var wrapper = $(this); 1165 wrapper.addClass('menu-mouse-hover'); 1166 wrapper.removeClass('menu-mouse-out'); 1167 }, function(){ 1168 var wrapper = $(this); 1169 wrapper.addClass('menu-mouse-out'); 1170 wrapper.removeClass('menu-mouse-hover'); 1171 if(wrapper.parent().hasClass('hidden-menu')){ 1172 setTimeout(function(){ 1173 if(wrapper.hasClass('menu-mouse-out')){ 1174 wrapper.parent().removeClass('menu-opened'); 1175 } 1176 }, 600); 1177 } 1178 }); 1179 } 1180 1181 // FixSidemenu 1182 function fixSidemenu($animate){ 1183 1184 var animation = 0; 1185 if($animate == 'fade') animation = 300; 1186 var sidemenu = $('#sidemenu'); 1187 if(sidemenu.length){ 1188 1189 // Sidemenu Overlaping Elements 1190 var sidenav = sidemenu.find('#side-nav'); 1191 var sidetweets = sidemenu.find('.sidemenu-tweets'); 1192 var sidefooter = sidemenu.find('.sidemenu-footer'); 1193 1194 var tweetsVisible = sidetweets.is(':visible'); 1195 var footerVisible = sidefooter.is(':visible'); 1196 1197 var tAnimation = animation; 1198 var fAnimation = animation; 1199 1200 if(!tweetsVisible) tAnimation = 0; 1201 if(!footerVisible) fAnimation = 0; 1202 1203 // Reset Styles 1204 sidetweets.show(); 1205 sidefooter.show(); 1206 1207 // Fix Overlaping 1208 if(sidetweets.length && sidefooter.length){ 1209 1210 if( (sidenav.position().top + sidenav.outerHeight()) > sidefooter.position().top ){ 1211 sidetweets.fadeOut(tAnimation); 1212 sidefooter.fadeOut(fAnimation); 1213 }else if( (sidetweets.position().top + sidetweets.outerHeight()) > sidefooter.position().top ){ 1214 sidetweets.fadeOut(tAnimation); 1215 if(!footerVisible) 1216 sidefooter.hide().fadeIn(300); 1217 } 1218 1219 }else if(sidetweets.length){ 1220 1221 if( (sidetweets.position().top + sidetweets.outerHeight()) > window_h ){
1222 sidetweets.fadeOut(tAnimation); 1223 if(!footerVisible) 1224 sidefooter.hide().fadeIn(300); 1225 } 1226 1227 }else if(sidefooter.length){ 1228 1229 if( (sidenav.position().top + sidenav.outerHeight()) > sidefooter.position().top ){ 1230 sidefooter.fadeOut(fAnimation); 1231 if(!tweetsVisible) 1232 sidetweets.hide().fadeIn(300); 1233 } 1234 1235 }else{ 1236 if(!tweetsVisible) 1237 sidetweets.hide().fadeIn(300); 1238 if(!footerVisible) 1239 sidefooter.hide().fadeIn(300); 1240 } 1241 } 1242 1243 } 1244 1245 function fixMegaMenu(){ 1246 // fix megamenu 1247 if($('#header .mega-menu').length != 0){ 1248 $('#header .mega-menu').each(function(){ 1249 1250 var el = $(this); 1251 1252 // Reset Styles 1253 el.removeClass('mega-menu-too-big'); 1254 el.css('display','block'); 1255 1256 // Calculate Width And Offset 1257 var el_w = el.width(); 1258 var el_x = el.offset().left; 1259 1260 var container = $('#header .container'); 1261 var container_w = container.width(); 1262 var container_x = container.offset().left; 1263 1264 // Reset Positioning 1265 el.css('left','').css('right','').css('margin-left','').css('display',''); 1266 1267 // Fix Mega Menu Position 1268 if(window_w > 768){ 1269 1270 if( (el_x + el_w) > (container_x + container_w) ) 1271 el.css('right',0).css('margin-left','0px'); 1272 else if( el_x < container_x ) 1273 el.css('left',0).css('margin-left','0px'); 1274 1275 if( el_w > container_w ) 1276 el.addClass('mega-menu-too-big'); 1277 1278 } 1279 1280 }); 1281 } 1282 } 1283 fixMegaMenu(); 1284 1285 1286 /* Progressbars */ 1287 1288 function enableProgressbars() { 1289 1290 $(window).bind('load resize scroll', function(){ 1291 animateProgressBars(); 1292 }); 1293 1294 } 1295 1296 /* Animate Progress Bars */ 1297 function animateProgressBars() { 1298 1299 $('.progressbar').each(function () { 1300 1301 var bar = $(this); 1302 var bar_y = $(bar).offset().top; 1303 1304 if ((bar_y < (window_s + window_h)) && !$(bar).hasClass('progressbar-animating')) { 1305 1306 barStartAnimation(bar); 1307 var other_bars = bar.parent().parent().find('.progressbar').not('.progressbar-animating'); 1308 other_bars.each(function(){ 1309 barStartAnimation($(this)); 1310 }); 1311 1312 } 1313 }); 1314 1315 1316 /* Bar FillIn Animation */ 1317 function barStartAnimation(el) { 1318 1319 var bar = el; 1320 var bar_progress = el.find('.progress-width'); 1321 var bar_percent = el.find('.progress-percent'); 1322 1323 bar.addClass('progressbar-animating').addClass('progessbar-start'); 1324 bar_percent.fadeIn(200); 1325 var percent = parseInt($(bar).attr('data-percent')); 1326 1327 bar_progress.animate( 1328 { 1329 width: percent+'%' 1330 }, 1331 { 1332 duration: 1000, 1333 easing: 'swing', 1334 step: function( now, fx ) { 1335 bar_percent.text(parseInt(now) + '%').css('left', parseInt(now) + '%'); 1336 } 1337 } 1338 ); 1339 1340 } 1341 1342 } 1343 1344 1345 1346 1347 /* Circular Progressbar */ 1348 1349 function enableCircularProgressbars() { 1350 1351 if (typeof $.fn.knob != 'function') { 1352 return; 1353 } 1354 1355 initCircularProgressbars(); 1356 1357
1358 // Check If Knob Is In Viewport 1359 $(window).bind('scroll load resize', function(){ 1360 1361 $('.circular-progressbar').each(function(){ 1362 1363 /* Knob Elements */ 1364 var knob = $(this); 1365 var knob_percent = knob.parent().find('.knob-percent .knob-number'); 1366 1367 /* Knob Variables */ 1368 var value = knob.data('value'); 1369 var knob_y = knob.offset().top; 1370 var knob_val = knob.data('value'); 1371 var knob_animated = knob.hasClass('knob-animated'); 1372 1373 /* Viewport Offset */ 1374 var viewport_offset = 0; 1375 1376 // Animate Knob If In Viewport 1377 if((window_s + window_h - viewport_offset) > knob_y && !knob_animated){ 1378 1379 knob.addClass('knob-animated'); 1380 $({startVal:0}).animate({startVal:knob_val}, 1381 { 1382 duration: 3000, 1383 easing:'linear', 1384 step: function() { 1385 knob.val(Math.ceil(this.startVal)).trigger('change'); 1386 //knob_percent.html(Math.ceil(this.startVal)); 1387 } 1388 } 1389 ); 1390 1391 var knob_percent_v = 0; 1392 var knob_inc = Math.round(knob_val / 30); 1393 knob_inc = (knob_inc > 1) ? knob_inc : 1; 1394 var knob_interval = setInterval(function(){ 1395 1396 knob_percent_v += knob_inc; 1397 if(knob_percent_v >= knob_val){ 1398 knob_percent_v = knob_val; 1399 clearInterval(knob_interval); 1400 } 1401 1402 knob_percent.html(knob_percent_v); 1403 1404 }, 100); 1405 1406 } 1407 1408 }); 1409 1410 }); 1411 1412 } 1413 1414 function initCircularProgressbars(){ 1415 1416 if (typeof $.fn.knob != 'function') { 1417 return; 1418 } 1419 1420 // Initialize Circular Progressbars 1421 $('.circular-progressbar').each(function() { 1422 1423 var knob = $(this); 1424 1425 // Set the value 1426 var value = knob.val(); 1427 var knob_title = $(this).attr('data-title'); 1428 knob.data('value', value); 1429 1430 1431 var text_color, 1432 text_color_style; 1433 1434 if (knob.attr('data-textcolor')) { 1435 text_color = knob.attr('data-textcolor'); 1436 text_color_style = 'style="color: ' + text_color + '"'; 1437 } 1438 1439 // Initialize Knob 1440 knob.knob({ 1441 "min": 0, 1442 "max": value 1443 }); 1444 knob.val(0).trigger('change'); 1445 knob.after('<p class="knob-percent" ' + text_color_style + '><span class="knob-number">0</span>' + knob_title + '</p>'); 1446 1447 }); 1448 } 1449 1450 1451 // Enable MixItUp Filtering Plugin 1452 function enableMixItUp() { 1453 1454 if (typeof $.fn.mixItUp != 'function') { 1455 return; 1456 } 1457 1458 $('#projects-container').mixItUp(); 1459 $('#sortable-shop-products').mixItUp(); 1460 $('.faq-accordions').mixItUp(); 1461 $('.projects-container').mixItUp({ 1462 controls: { 1463 enable: false 1464 } 1465 }); 1466 1467 $('.projects-container').parent().find('.filter[data-filter="all"]').addClass('active'); 1468 $('.projects-container').parent().find('.filter').click(function(e){
1469 e.preventDefault(); 1470 var cat = $(this).data('filter'); 1471 $(this).parent().find('.active').removeClass('active'); 1472 $(this).addClass('active'); 1473 $(this).parent().parent().parent().find('.projects-container').mixItUp('filter', cat); 1474 }); 1475 1476 } 1477 1478 function reinitializeMixItUp(){ 1479 1480 if (typeof $.fn.mixItUp != 'function') { 1481 return; 1482 } 1483 1484 if($('#projects-container').mixItUp('isLoaded')) 1485 $('#projects-container').mixItUp('destroy'); 1486 1487 if($('#sortable-shop-products').mixItUp('isLoaded')) 1488 $('#sortable-shop-products').mixItUp('destroy'); 1489 1490 if($('.faq-accordions').mixItUp('isLoaded')) 1491 $('.faq-accordions').mixItUp('destroy'); 1492 1493 if($('.projects-container').mixItUp('isLoaded')) 1494 $('.projects-container').mixItUp('destroy'); 1495 1496 $('#projects-container').mixItUp(); 1497 $('#sortable-shop-products').mixItUp(); 1498 $('.faq-accordions').mixItUp(); 1499 1500 $('.projects-container').mixItUp({ 1501 controls: { 1502 enable: false 1503 } 1504 }); 1505 1506 $('.projects-container').parent().find('.filter[data-filter="all"]').addClass('active'); 1507 $('.projects-container').parent().find('.filter').click(function(e){ 1508 e.preventDefault(); 1509 var cat = $(this).data('filter'); 1510 $(this).parent().find('.active').removeClass('active'); 1511 $(this).addClass('active'); 1512 $(this).parent().parent().parent().find('.projects-container').mixItUp('filter', cat); 1513 }); 1514 1515 } 1516 1517 1518 1519 /* Bootstrap Tooltips */ 1520 function enableTooltips() { 1521 1522 $('.hover-tooltip').tooltip(); 1523 1524 // Tooltip on TOP 1525 $('.tooltip-ontop').tooltip({ 1526 placement: 'top' 1527 }); 1528 1529 // Tooltip on BOTTOM 1530 $('.tooltip-onbottom').tooltip({ 1531 placement: 'bottom' 1532 }); 1533 1534 // Tooltip on LEFT 1535 $('.tooltip-onleft').tooltip({ 1536 placement: 'left' 1537 }); 1538 1539 // Tooltip on RIGHT 1540 $('.tooltip-onright').tooltip({ 1541 placement: 'right' 1542 }); 1543 1544 } 1545 1546 1547 // Alert Boxes 1548 function enableAlertBox() { 1549 1550 $('.alert-box .close-button').click(function () { 1551 1552 $(this).parent().slideUp(300); 1553 1554 }); 1555 1556 } 1557 1558 1559 // Fancy box 1560 function enableFancyBox() { 1561 1562 if ($('.fancybox').length > 0) { 1563 $(".fancybox").fancybox(); 1564 } 1565 1566 } 1567 1568 1569 // Masonry Blog 1570 function enableMasonryBlog() { 1571 1572 if (typeof $.fn.masonry != 'function') { 1573 return; 1574 } 1575 1576 var $container = $('.masonry-container'); 1577 1578 // Initialize 1579 initMasonryBlog(); 1580 1581 $(window).load(function(){ 1582 $container.masonry(); 1583 }); 1584 1585 } 1586 1587 function initMasonryBlog(){ 1588 1589 if (typeof $.fn.masonry != 'function') { 1590 return; 1591 } 1592 1593 var $container = $('.masonry-container'); 1594 1595 // initialize 1596 $container.masonry({ 1597 itemSelector: '.masonry-box' 1598 }); 1599 1600 } 1601 1602 1603 // Timeline Blog 1604 function enableTimelineBlog() { 1605 1606 1607 $(window).bind('load resize', function(){ 1608 setTimelineBlog(); 1609 }); 1610 1611 var timelineInterval = setInterval(function () { 1612 1613 $('.timeline-container .masonry-box').each(function () { 1614 var el_x = $(this).offset().left; 1615 1616 if (parseInt($(this).attr('data-left')) != el_x) { 1617 1618 $(this).attr('data-left', el_x); 1619 setTimelineItem($(this)); 1620 1621 } 1622 }); 1623 1624 }, 100); 1625 1626 } 1627 1628 // Initialize Timeline Blog 1629 function setTimelineBlog() { 1630 1631 $('.timeline-container').each(function () { 1632 1633 if ($(this).hasClass('timeline-activated')) { 1634 1635 $(this).find('.masonry-box').each(function () { 1636 setTimelineItem($(this)); 1637 }); 1638 1639 } else { 1640 1641 $(this).append('<div class="timeline-line"></div>'); 1642 $(this).addClass('timeline-activated'); 1643 $(this).find('.masonry-box').each(function () { 1644 setTimelineItem($(this)); 1645 }); 1646 1647 } 1648 1649 }); 1650 1651 } 1652 1653 1654 // Sets Timeline Items 1655 function setTimelineItem(element) { 1656 1657 var item = element; 1658 var item_x = $(item).offset().left; 1659 var timeline_line_x = window_w/2; 1660 1661 if (item_x < timeline_line_x) { 1662 1663 $(item).addClass('left-timeline-item'); 1664 $(item).removeClass('right-timeline-item'); 1665 1666 } else { 1667 1668 $(item).addClass('right-timeline-item'); 1669 $(item).removeClass('left-timeline-item'); 1670 1671 } 1672 1673 $('.left-timeline-item, .right-timeline-item').bind('moveend', function () { 1674 1675 setTimelineBlog(); 1676 1677 }); 1678 1679 } 1680 1681 1682 1683 // One Page Menu Item Scroll
1684 function enableOnePageScroll(){ 1685 1686 var navigation = $('#main-nav'); 1687 if(!navigation.length){ 1688 navigation = $('#header div.menu>ul'); 1689 if(!navigation.length){ 1690 navigation = $('#side-nav'); 1691 } 1692 } 1693 1694 $('a[href*="#"]', navigation).add('a[href*="#"]', '#slider').click(function(e) { 1695 e.preventDefault(); 1696 var target_hash = $(this).attr('href'); 1697 var target = $(target_hash); 1698 if(target.length){ 1699 var target_y = target.offset().top; 1700 $('html, body').animate( 1701 { 1702 scrollTop: target_y+'px' 1703 }, 1704 { 1705 duration: 1200, 1706 easing: 'easeInOutCubic', 1707 complete: function(){ 1708 1709 if(history.pushState) { 1710 history.pushState(null, null, target_hash); 1711 } 1712 else { 1713 location.hash = target_hash; 1714 } 1715 1716 } 1717 }); 1718 }else if(target == '#'){ 1719 $('html, body').animate( 1720 { 1721 scrollTop: 0+'px' 1722 }, 1723 { 1724 duration: 1200, 1725 easing: 'easeInOutCubic' 1726 } 1727 ); 1728 } 1729 }); 1730 1731 } 1732 1733 1734 1735 // Custom Audio Player 1736 function enableCustomAudio() { 1737 1738 $(document).mouseup(function () { 1739 1740 $('.audio-progress').attr('data-mousedown', ''); 1741 $('.audio-volume').attr('data-mousedown', ''); 1742 1743 }); 1744 1745 initCustomAudio(); 1746 1747 } 1748 1749 function initCustomAudio(){ 1750 1751 $('audio').each(function () { 1752 1753 var audio = $(this)[0]; 1754 audio.volume = 0.5; 1755 1756 /* Setup Audio Player */ 1757 $(this).wrap('<div class="audio-player"></div>'); 1758 $(this).parent().append('<div class="audio-play-button"></div>'); 1759 $(this).parent().append('<div class="audio-progress" data-mousedown=""><div class="audio-progress-bar"></div></div>'); 1760 1761 1762 /* Playe/Pause button */ 1763 $('.audio-play-button').click(function () { 1764 1765 if ($(this).hasClass('pause')) { 1766 $(this).parent().find('audio')[0].pause(); 1767 $(this).removeClass('pause'); 1768 } else { 1769 $(this).parent().find('audio')[0].play(); 1770 $(this).addClass('pause'); 1771 } 1772 1773 }); 1774 1775 1776 /* Progress update */ 1777 $(this).bind('timeupdate', function () { 1778 1779 var track_length = $(this)[0].duration; 1780 var secs = $(this)[0].currentTime; 1781 var progress = (secs / track_length) * 100; 1782 1783 $(this).parent().find('.audio-progress-bar').css('width', progress + '%'); 1784 1785 // Show play button again at the end 1786 if (track_length == secs) { 1787 $(this).parent().find('audio')[0].pause(); 1788 $(this).parent().find('.audio-play-button').removeClass('pause'); 1789 } 1790 1791 }); 1792 1793 1794 /* Progress click event */ 1795 $('.audio-progress').click(function (e) { 1796 1797 var audio_x = $(this).offset().left; 1798 var audio_w = $(this).width(); 1799 var mouse_x = e.pageX; 1800 1801 var progress = (mouse_x - audio_x) / audio_w * 100; 1802 1803 var track_length = $(this).parent().find('audio')[0].duration; 1804 var update_time = track_length / (100 / progress); 1805 1806 $(this).parent().find('audio')[0].currentTime = update_time; 1807 1808 }); 1809 1810 /* Progress drag event */ 1811 1812 $('.audio-progress').mousedown(function () { 1813 1814 $(this).attr('data-mousedown', 'true'); 1815 1816 }); 1817 1818 $('.audio-progress').mousemove(function (e) { 1819 1820 if ($(this).attr('data-mousedown') == 'true') { 1821 1822 var audio_x = $(this).offset().left; 1823 var audio_w = $(this).width(); 1824 var mouse_x = e.pageX; 1825 1826 var progress = (mouse_x - audio_x) / audio_w * 100; 1827 1828 var track_length = $(this).parent().find('audio')[0].duration; 1829 var update_time = track_length / (100 / progress); 1830 1831 $(this).parent().find('audio')[0].currentTime = update_time; 1832 1833 } 1834 1835 }); 1836 1837 1838 /* Volume */ 1839 if ($(this).hasClass('volume-on')) { 1840 1841 $(this).parent().addClass('volume-on'); 1842 $(this).parent().append('<div class="audio-volume"><div class="audio-volume-bar"></div></div>'); 1843 1844 /* Volume Click Event */ 1845 $('.audio-volume-bar').css('width', audio.volume * 100 + '%'); 1846 $('.audio-volume').click(function (e) { 1847 1848 var volume_x = $(this).offset().left; 1849 var volume_w = $(this).width(); 1850 var mouse_x = e.pageX; 1851 1852 var new_volume = (mouse_x - volume_x) / volume_w; 1853 1854 $(this).find('.audio-volume-bar').css('width', new_volume * 100 + '%'); 1855 $(this).parent().find('audio')[0].volume = new_volume; 1856 1857 }); 1858 1859 1860 /* Volume Drag Event */ 1861
1862 $('.audio-volume').mousedown(function () { 1863 1864 $(this).attr('data-mousedown', 'true'); 1865 1866 }); 1867 1868 $('.audio-volume').mousemove(function (e) { 1869 1870 if ($(this).attr('data-mousedown') == 'true') { 1871 1872 var volume_x = $(this).offset().left; 1873 var volume_w = $(this).width(); 1874 var mouse_x = e.pageX; 1875 1876 var new_volume = (mouse_x - volume_x) / volume_w; 1877 1878 if (new_volume >= 0 && new_volume <= 1) { 1879 1880 $(this).find('.audio-volume-bar').css('width', new_volume * 100 + '%'); 1881 $(this).parent().find('audio')[0].volume = new_volume; 1882 1883 } 1884 1885 } 1886 1887 }); 1888 1889 } 1890 1891 1892 }); 1893 1894 } 1895 1896 1897 1898 1899 1900 1901 /** 1902 * Slider Alternative Overlay 1903 */ 1904 1905 function enableSliderAlternativeOverlay(){ 1906 sliderAlternativeOverlay(); 1907 $(window).load(function(){ 1908 sliderAlternativeOverlay(); 1909 }); 1910 $(window).resize(function(){ 1911 sliderAlternativeOverlay(); 1912 }); 1913 } 1914 1915 function sliderAlternativeOverlay(){ 1916 $('.alternate-slider-bg').each(function(){ 1917 1918 if(window_w > 991){ 1919 var el_h = $(this).innerHeight(); 1920 $(this).css('margin-top', -el_h+'px'); 1921 }else{ 1922 $(this).css('margin-top', 0); 1923 } 1924 1925 }); 1926 } 1927 1928 1929 1930 1931 /** 1932 * Timeline Load More 1933 */ 1934 1935 function enableTimelineLoadMore(){ 1936 1937 if (typeof $.fn.masonry != 'function') { 1938 return; 1939 } 1940 1941 $.each($('.timeline-row .masonry-container'), function () { 1942 currentMonth = $(this).find('.col-md-6').attr('data-month'); 1943 currentYear = $(this).find('.col-md-6').attr('data-year'); 1944 1945 }); 1946 1947 $('#timeline-load-more').click(function (e) { 1948 1949 $this = $(this); 1950 $this.html(ts_lang.loading_posts); 1951 1952 $.ajax({
1953 url: templateUrl + '/ajax/timeline.php', 1954 type: 'GET', 1955 data: 'offset=' + timelineOffsetNext + '&posts_per_page=' + timelinePerPage + '&month=' + currentMonth + '&year=' + currentYear, 1956 success: function (data) { 1957 1958 if (data == 0) { 1959 $('#timeline-load-more').hide(); 1960 } else { 1961 $('.timeline-container-wrap').append(data); 1962 $('.masonry-container .timeline-line').remove(); 1963 1964 $('.masonry-container').append('<div class="timeline-line"></div>'); 1965 1966 enableTimelineBlog(); 1967 1968 $this.html(ts_lang.load_more); 1969 1970 timelineOffsetNext += timelinePerPage; 1971 } 1972 1973 var new_post_items = $(data).find('.masonry-container .masonry-box'); 1974 1975 // Append new posts 1976 var $container = $('.masonry-container'); 1977 1978 $('.timeline-container-wrap').find('.timeline-date-tooltip:not(:first-child)').addClass('timeline-date-tooltip-top'); 1979 1980 // Masonry Reload Fix (Animation Delay) 1981 masonryFix = setTimeout(function(){ 1982 $container.masonry({ 1983 itemSelector: '.masonry-box' 1984 }); 1985 }, 500); 1986 1987 $container.on('layoutComplete', function () { 1988 return true; 1989 }); 1990 } 1991 }) 1992 e.preventDefault(); 1993 }); 1994 1995 } 1996 1997 1998 /** 1999 * Woocommerce load More Button 2000 */ 2001 2002 function enableWooCommerceLoadMore(){ 2003 2004 var newWCElements = {}; 2005 var $new_wc_items = ''; 2006 newWCElements.loadElem = function($url) { 2007 2008 $.ajax({
2009 type: 'GET', 2010 async: false, 2011 url: $url, 2012 success: function(data, textStatus, XMLHttpRequest){ 2013 $new_wc_items = $(data).find('#sortable-shop-products').html(); 2014 $next = $(data).find('#wc-load-more').attr('href'); 2015 if ($next) { 2016 $('#wc-load-more').attr('href',$next); 2017 } else { 2018 $('#wc-load-more').slideUp(); 2019 } 2020 }, 2021 error: function(MLHttpRequest, textStatus, errorThrown){ 2022 alert(errorThrown); 2023 } 2024 }); 2025 return $new_wc_items; 2026 }; 2027 2028 $('#wc-load-more').click(function(){ 2029 2030 var $newEls = $( newWCElements.loadElem($(this).attr('href')) ).hide(); 2031 $('#sortable-shop-products').append( $newEls ); 2032 $('#sortable-shop-products').find('.product').slideDown(); 2033 return false; 2034 }); 2035 2036 $('#checkout-submit').click( function(e) { 2037 e.preventDefault(); 2038 $('#cart-form').submit(); 2039 }); 2040 2041 $('.sc-open-video').click( function(e) { 2042 e.preventDefault(); 2043 $popup = $(this).closest('.sc-videp-popup-wrapper').find('.sc-video-popup'); 2044 2045 var $autoplay = ''; 2046 2047 if ($popup.data('autoplay') && $popup.data('autoplay') == 'yes') { 2048 2049 if ($popup.data('url').indexOf('?') == -1) { 2050 $autoplay += '?'; 2051 } else if ($popup.data('url').indexOf('&') == -1) { 2052 $autoplay += '&'; 2053 } else { 2054 $autoplay += '&'; 2055 } 2056 $autoplay += 'autoplay=1'; 2057 } 2058 2059 $popup.prepend('<iframe src="' + $popup.data('url') + $autoplay + '"></iframe>'); 2060 $popup.fadeIn(400); 2061 }); 2062 2063 $('.sc-close-video').click( function(e) { 2064 e.preventDefault(); 2065 $(this).closest('.sc-video-popup').find('iframe').remove(); 2066 $(this).closest('.sc-video-popup').fadeOut(400); 2067 }); 2068 2069 } 2070 2071 2072 2073 /** 2074 * Woocommerce add to cart notification 2075 */ 2076 2077 function enableWooCommerceAddToCart(){ 2078 2079 var addi = {}; 2080 2081 if(!$('#added_items').length) 2082 $('body').append('<div id="added_items"></div>') 2083 2084 function if_added(item) { 2085 if (item.hasClass('added')) { 2086 var product_id = item.attr('data-product_id'); 2087 clearInterval(addi[product_id]); 2088 item.find('.loader-container').remove(); 2089 $('#added_items').prepend('<div id="'+product_id+'" class="added_item"><img src="'+ item.parents('.product').find('.attachment-shop_catalog').attr('src') +'" alt=""/><p><b>"'+ item.parents('.product').find('.product-title').html() +'"</b> was added to the cart. </p><div class="clear"></div></div>'); 2090 $('#'+product_id).animate({opacity:1},500); 2091 setTimeout(function(){ 2092 $('#'+product_id).animate({opacity:0,marginTop:20},500, function(){$(this).remove()}); 2093 },5000) 2094 } 2095 } 2096 2097 $('.add_to_cart_button').each(function(){ 2098 var add_btn = $(this); 2099 $(this).click(function(){ 2100 addi[$(this).attr('data-product_id')] = setInterval( function() {if_added(add_btn)},1000); 2101 add_btn.append('<span class="loader-container"><span id="fountainG"><span id="fountainG_1" class="fountainG"></span><span id="fountainG_2" class="fountainG"></span><span id="fountainG_3" class="fountainG"></span><span id="fountainG_4" class="fountainG"></span><span id="fountainG_5" class="fountainG"></span><span id="fountainG_6" class="fountainG"></span><span id="fountainG_7" class="fountainG"></span><span id="fountainG_8" class="fountainG"></span></span></span>'); 2102 }); 2103 }); 2104 2105 } 2106 2107 /** 2108 * Masonry, Portfolio Load More Button 2109 */ 2110 2111 function enableLoadMoreButton(){ 2112 2113 $('#load-more').click(function(event){ 2114 2115 event.preventDefault(); 2116 2117 // Variables 2118 $url = $(this).attr('href'); 2119 2120 // Load Button Loading Text 2121 $load_more_text = $(this).html(); 2122 $(this).html($(this).data('loading'));
2123 2124 $.ajax({ 2125 type: 'GET', 2126 url: $url, 2127 success: function(data, textStatus, XMLHttpRequest) { 2128 2129 // Store New Data 2130 var $new_items = $(data).find('#post-items').html(); 2131 var $next = $(data).find('#load-more').attr('href'); 2132 2133 // update Load More Button Href 2134 if ($next) { 2135 $('#load-more').attr('href',$next); 2136 } else { 2137 $('#load-more').slideUp(); 2138 } 2139 2140 // Append new posts 2141 $('#post-items').append($new_items); 2142 if (typeof $.fn.fitVids == 'function') { 2143 $(".format-video").fitVids(); 2144 } 2145 $(".project-item").show(); 2146 2147 $('.post-image-gallery:not(".slider-enabled")').flexslider({ 2148 animation: "slide", 2149 controlNav: false, 2150 prevText: "", 2151 nextText: "", 2152 }); 2153 2154 if ($('.masonry-container').length > 0) { 2155 2156 $('.masonry-container').masonry(); 2157 $('.masonry-container').masonry("reloadItems"); 2158 2159 setTimeout(function(){ 2160 $('.masonry-container').masonry(); 2161 $('.masonry-container').masonry("reloadItems"); 2162 }, 400); 2163 } 2164 2165 }, 2166 complete: function() { 2167 $('#load-more').html($load_more_text); 2168 }, 2169 error: function(MLHttpRequest, textStatus, errorThrown){ 2170 alert(errorThrown); 2171 } 2172 }); 2173 2174 2175 }); 2176 2177 } 2178 2179 2180 2181 /** 2182 * Post Like Option 2183 */ 2184 2185 function enablePostLike(){ 2186 2187 $('.project-like').click(function () { 2188 2189 $post_id = $(this).attr('data-post'); 2190 2191 //end if clicked or cookie exists 2192 if ($('.post-liked', this).length > 0 || document.cookie.indexOf('saved_post_like_' + $post_id) != -1) { 2193 return; 2194 } 2195 2196 $('.like-count', this).animate({opacity:0}
2196, 200, function(){ 2197 $(this).html(parseInt($(this).html()) + 1); 2198 $(this).animate({opacity:1}, 200); 2199 }); 2200 2201 $(this).addClass('post-liked'); 2202 2203 $current_post_like = $('.like-count', this); 2204 2205 $.ajax({ 2206 type: 'GET', 2207 url: ajaxurl, 2208 data: { 2209 action: 'save_post_like', 2210 post_id: $post_id 2211 }, 2212 success: function (data, textStatus, XMLHttpRequest) { 2213 $($current_post_like).html(data); 2214 }, 2215 error: function (XMLHttpRequest, textStatus, errorThrown) { 2216 alert(errorThrown); 2217 } 2218 }); 2219 }); 2220 2221 } 2222 2223 /** 2224 * Enable FitVids 2225 */ 2226 2227 function enableFitVids(){ 2228 2229 if (typeof $.fn.fitVids == 'function') { 2230 $(".format-video").fitVids(); 2231 } 2232 } 2233 2234 2235 /** 2236 * Enable PrettyPhoto 2237 */ 2238 2239 function enablePrettyPhoto(){ 2240 2241 if (typeof $.fn.prettyPhoto == 'function') { 2242 $("a[rel^='prettyPhoto']").prettyPhoto(); 2243 } 2244 } 2245 2246 2247 2248 2249 2250 /** 2251 * Contact Form AJAX 2252 */ 2253 2254 function enableAjaxContactForm(){ 2255 2256 $('.contact-form').submit(function (e) { 2257 $this = $(this); 2258 $('input[type="submit"]', $this).val('Sending Message...'); 2259 $.ajax({
2260 data: $(this).serialize(), 2261 type: 'POST', 2262 success: function (data) { 2263 2264 obj = jQuery.parseJSON(data); 2265 if (obj.status == 0) { 2266 $('#msg').html('').addClass('alert-box alert-danger').html(obj.message); 2267 $('input[type="submit"]', $this).val('Send Message'); 2268 } else if (obj.status == 1) { 2269 $this.fadeOut('slow'); 2270 $('#msg').html('').addClass('alert-box alert-info').html(obj.message); 2271 } 2272 2273 } 2274 }) 2275 e.preventDefault(); 2276 }); 2277 2278 } 2279 2280 2281 2282 2283 /** 2284 * Google Maps API 2285 */ 2286 2287 function enableGoogleMaps(){ 2288 2289 $('.sc-google-map').each(function(){ 2290 2291 // Get Map Settings 2292 var element = $(this), 2293 element_native = element.get(0), 2294 address = element.data('address'), 2295 zoom = element.data('zoom'), 2296 customMarker = element.data('custom-marker'); 2297 grayscaleEffect = element.data('grayscale') == 'yes' ? true : false; 2298 2299 // Adjust Zoom 2300 zoom = zoom > 20 || zoom < 1 ? 14 : zoom; 2301 2302 // Geocoder 2303 var geocoder = new google.maps.Geocoder(), 2304 mapOptions = { 2305 scrollwheel: false, 2306 mapTypeId: google.maps.MapTypeId.ROADMAP, 2307 center: new google.maps.LatLng(54.00, -3.00), 2308 zoom: zoom 2309 }, 2310 map = new google.maps.Map(element_native, mapOptions); 2311 2312 if (grayscaleEffect === true) { 2313 var map_styles = [{ 2314 featureType: "all", 2315 elementType: "all", 2316 stylers: [ 2317 { saturation: -100 } 2318 ] 2319 }]; 2320 var mapType = new google.maps.StyledMapType(map_styles, { name:"Grayscale" }); 2321 map.mapTypes.set('grayscale_map', mapType); 2322 map.setMapTypeId('grayscale_map'); 2323 } 2324 2325 geocoder.geocode({"address": address}, function(results, status) { 2326 if(status == google.maps.GeocoderStatus.OK) 2327 { 2328 result = results[0].geometry.location; 2329 map.setCenter(result); 2330 2331 // Marker Options 2332 var markerOptions = { 2333 position: result, 2334 map: map, 2335 title: address 2336 } 2337 2338 // CustomMarker Icon 2339 if(customMarker != ''){ 2340 markerOptions.icon = customMarker; 2341 } 2342 2343 // Initialize Marker 2344 var marker = new google.maps.Marker(markerOptions); 2345 } 2346 }); 2347 2348 }); 2349 2350 } 2351 2352 2353 2354 2355 2356 /** 2357 * AJAX Page Load 2358 */ 2359 2360 function enableAjaxPageLoad(){ 2361 2362 if($body.hasClass('page_transitions_enabled')){ 2363 initAjaxNav(); 2364 2365 // Enable Ajax Page Load 2366 if(history.pushState){ 2367 2368 window.onpopstate = function(){ 2369 2370 var target = location.pathname; 2371 if(ionic_current_path != target){ 2372 loadPageAJAX(target); 2373 } 2374 ionic_current_path = target; 2375 2376 } 2377 2378 } 2379 } 2380 2381 } 2382 2383 2384 function initAjaxNav(){ 2385 2386 // Get Main Navigation 2387 if($('#sidemenu').length > 0){
2388 var $navigation = $('#side-nav'); 2389 }else{ 2390 var $navigation = $('#main-nav'); 2391 if(!$navigation.length > 0){ 2392 $navigation = $('#header div.menu>ul'); 2393 } 2394 } 2395 2396 if(history.pushState){ 2397 $navigation.find('a').not('a[href*="#"]').click(function(e){ 2398 2399 e.preventDefault(); 2400 var target = $(this).attr('href'); 2401 2402 if(document.URL != target){ 2403 loadPageAJAX(target); 2404 history.pushState(null, null, target); 2405 } 2406 2407 }); 2408 } 2409 2410 } 2411 2412 2413 // Load Page AJAX 2414 function loadPageAJAX(target){ 2415 2416 var target = target, 2417 scrollTop = $(document).scrollTop(), 2418 scrollDuration; 2419 2420 ionic_current_path = target; 2421 2422 if(scrollTop > 200) 2423 scrollDuration = 800; 2424 else if(scrollTop < 200 && scrollTop != 0) 2425 scrollDuration = 300; 2426 else if(scrollTop == 0) 2427 scrollDuration = 0; 2428 2429 $('body, html').animate({scrollTop:0}, scrollDuration); 2430 2431 setTimeout(function(){ 2432 2433 $('.page-loadingstage').addClass('visible'); 2434 2435 setTimeout(function(){ 2436 2437 $.ajax({
2438 type:'post', 2439 async: true, 2440 data:{}, 2441 url:target, 2442 success:function(response){ 2443 2444 $("body").attr("class", /body([^>]*)class=(["']+)([^"']*)(["']+)/gi.exec(response.substring(response.indexOf("<body"), response.indexOf("</body>") + 7))[3]); 2445 2446 // Load Marine Content 2447 var marineContent = $(response).filter('#marine-content-wrapper').html(); 2448 $('#marine-content-wrapper').html(marineContent); 2449 2450 // Set New Title 2451 document.title = $(response).filter('title').text(); 2452 2453 2454 $('style').remove(); 2455 $(response).filter('style').each(function(){ 2456 $('head').append($(this)); 2457 }); 2458 2459 // Load WordpresAdminBar 2460 var wpAdminBar = $(response).filter('#wpadminbar').html(); 2461 if(wpAdminBar){ 2462 $('#wpadminbar').html(wpAdminBar); 2463 } 2464 2465 reinitializeAllFeatures(); 2466 2467 setTimeout(function(){ 2468 $('.page-loadingstage').removeClass('visible'); 2469 $(window).trigger('load'); 2470 $(window).trigger('resize'); 2471 }, 1200); 2472 }, 2473 error: function(MLHttpRequest, textStatus, errorThrown){ 2474 window.location = target; 2475 } 2476 }); 2477 2478 }, 600); 2479 2480 }, scrollDuration); 2481 2482 2483 } 2484 2485 2486 2487 /** 2488 * Set Full Width 2489 */ 2490 function enableFullWidth(){ 2491 2492 setFullWidth(); 2493 2494 // Set Full Width on Resize & Load 2495 $(window).bind("resize", function(){ 2496 2497 setFullWidth(); 2498 setTimeout(function(){ 2499 setFullWidth(); 2500 }, 400); 2501 2502 }); 2503 2504 } 2505 2506 // Set Full Width Function 2507 function setFullWidth(){ 2508 2509 if(!$("body").hasClass("b960") && !$("body").hasClass("b1170")){ 2510 $(".full-width").each(function(){ 2511 2512 var element = $(this); 2513 2514 // Reset Styles 2515 element.css("margin-left", ""); 2516 element.css("padding-left", "0!important"); 2517 element.css("width", ""); 2518 2519 var element_x = element.offset().left; 2520 2521 // Set New Styles 2522 element.css("margin-left", -element_x+"px"); 2523 element.css("width", $(window).width()+"px"); 2524 element.css("padding-left", ""); 2525 2526 }); 2527 } 2528 2529 } 2530 2531 }); 2532 2533})(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.