1(function($){ 2 "use strict"; 3 4 var arki_display = 'desktop'; 5 if( typeof(window.matchMedia) == 'function' ){ 6 $(window).on('resize arki-set-display', function(){ 7 if( window.matchMedia('(max-width: 419px)').matches ){ 8 arki_display = 'mobile-portrait'; 9 }else if( window.matchMedia('(max-width: 767px)').matches ){ 10 arki_display = 'mobile-landscape' 11 }else if( window.matchMedia('(max-width: 959px)').matches ){ 12 arki_display = 'tablet' 13 }else{ 14 arki_display = 'desktop'; 15 } 16 }); 17 $(window).trigger('arki-set-display'); 18 }else{ 19 $(window).on('resize arki-set-display', function(){ 20 if( $(window).innerWidth() <= 419 ){ 21 arki_display = 'mobile-portrait'; 22 }else if( $(window).innerWidth() <= 767 ){ 23 arki_display = 'mobile-landscape' 24 }else if( $(window).innerWidth() <= 959 ){ 25 arki_display = 'tablet' 26 }else{ 27 arki_display = 'desktop'; 28 } 29 }); 30 $(window).trigger('arki-set-display'); 31 } 32 33 // ref : http://unscriptable.com/2009/03/20/debouncing-javascript-methods/ 34 // ensure 1 is fired 35 var arki_debounce = function(func, threshold, execAsap){ 36 37 var timeout; 38 39 return function debounced(){ 40 41 var obj = this, args = arguments; 42 43 function delayed(){ 44 if( !execAsap ){ 45 func.apply(obj, args); 46 } 47 timeout = null; 48 }; 49 50 if( timeout ){ 51 clearTimeout(timeout); 52 }else if( execAsap ){ 53 func.apply(obj, args); 54 } 55 timeout = setTimeout(delayed, threshold); 56 }; 57 } 58 59 // reduce the event occurance 60 var arki_throttling = function(func, threshold){ 61 62 var timeout; 63 64 return function throttled(){ 65 var obj = this, args = arguments; 66 67 function delayed(){ 68 func.apply(obj, args); 69 timeout = null; 70 }; 71 72 if( !timeout ){ 73 timeout = setTimeout(delayed, threshold); 74 } 75 }; 76 } 77 78 ///////////////////////// 79 // menu handle function 80 ///////////////////////// 81 var arki_sf_menu = function( menu ){ 82 83 if( menu.length == 0 ) return; 84 85 this.main_menu = menu; 86 87 this.slide_bar = this.main_menu.children('.arki-navigation-slide-bar'); 88 this.slide_bar_val = { width: 0, left: 0 }; 89 this.slide_bar_offset = '15'; 90 if( this.slide_bar.attr('data-size-offset') ){ 91 this.slide_bar_offset = parseInt(this.slide_bar.attr('data-size-offset')); 92 } 93 94 this.slide_bar_width = 0; 95 if( this.slide_bar.attr('data-width') ){ 96 this.slide_bar_width = parseInt(this.slide_bar.attr('data-width')); 97 } 98 99 this.current_menu = this.main_menu.children('.sf-menu').children('.current-menu-item, .current-menu-ancestor').children('a'); 100 101 this.init(); 102 103 } // arki_sf_menu 104 105 arki_sf_menu.prototype = { 106 107 init: function(){ 108 109 var t = this; 110 111 // sf menu mod 112 t.sf_menu_mod(); 113 114 // init superfish menu 115 if(typeof($.fn.superfish) == 'function'){ 116 t.main_menu.superfish({ delay: 400, speed: 'fast' }); 117 118 t.sf_menu_position(); 119 $(window).resize(arki_debounce(function(){ 120 t.sf_menu_position(); 121 }, 300)); 122 } 123 124 // init the slidebar 125 if( t.slide_bar.length > 0 ){ 126 t.init_slidebar(); 127 } 128 129 }, // init 130 131 sf_menu_mod: function(){ 132 133 // create the mega menu script 134 this.main_menu.find('.sf-mega > ul').each(function(){ 135 var mega_content = $('<div></div>'); 136 var mega_row = $('<div class="sf-mega-section-wrap" ></div>'); 137 var mega_column_size = 0; 138 139 $(this).children('li').each(function(){ 140 var column_size = parseInt($(this).attr('data-size')); 141 if( mega_column_size + column_size <= 60 ){ 142 mega_column_size += column_size; 143 }else{ 144 mega_column_size = column_size; 145 mega_content.append(mega_row); 146 mega_row = $('<div class="sf-mega-section-wrap" ></div>'); 147 } 148 149 mega_row.append( $('<div class="sf-mega-section" ></div>') 150 .addClass('arki-column-' + column_size) 151 .html( $('<div class="sf-mega-section-inner" ></div>') 152 .addClass($(this).attr('class')) 153 .attr('id', $(this).attr('id')) 154 .html($(this).html()) 155 ) 156 ); 157 }); 158 159 mega_content.append(mega_row); 160 $(this).replaceWith(mega_content.html()); 161 }); 162 163 }, // sf_menu_mod 164 165 sf_menu_position: function(){ 166 167 if( arki_display == 'mobile-landscape' || arki_display == 'mobile-portrait' || arki_display == 'tablet' ) return; 168 169 // submenu of normal menu 170 var body_wrapper = $('.arki-body-wrapper'); 171 var sub_normal_menu = this.main_menu.find('.sf-menu > li.arki-normal-menu .sub-menu'); 172 173 sub_normal_menu.css({display: 'block'}
173).removeClass('sub-menu-right sub-menu-left'); 174 sub_normal_menu.each(function(){ 175 if( $(this).offset().left + $(this).width() > body_wrapper.outerWidth() ){ 176 $(this).addClass('sub-menu-right'); 177 }else if( $(this).offset().left < 0 ){ 178 $(this).addClass('sub-menu-left'); 179 } 180 }); 181 sub_normal_menu.css({display: 'none'}); 182 183 // submenu of mega menu 184 this.main_menu.find('.sf-menu > li.arki-mega-menu .sf-mega').each(function(){ 185 if( !$(this).hasClass('sf-mega-full') ){ 186 187 $(this).css({ display: 'block' }); 188 189 // set the position 190 $(this).css({ right: '', 'margin-left': -(($(this).width() - $(this).parent().outerWidth()) / 2) }); 191 192 // if exceed the screen 193 if( $(this).offset().left + $(this).width() > $(window).width() ){ 194 $(this).css({ right: 0, 'margin-left': '' }); 195 } 196 197 $(this).css({ display: 'none' }); 198 } 199 200 }); 201 202 }, // sf_menu_position 203 204 init_slidebar: function(){ 205 206 var t = this; 207 208 t.init_slidebar_pos(); 209 $(window).on('load', function(){ t.init_slidebar_pos(); }); 210 211 // animate slidebar 212 t.main_menu.children('.sf-menu').children('li').on({ 213 mouseenter: function(){ 214 var nav_element = $(this).children('a'); 215 216 if( nav_element.length > 0 ){ 217 218 if( t.slide_bar_width > 0 ){ 219 var sbw = t.slide_bar_width; 220 if( t.slide_bar.hasClass('arki-left') ){ 221 var sbl = nav_element.position().left - t.slide_bar_offset; 222 }else{ 223 var sbl = nav_element.position().left + ((nav_element.outerWidth() - sbw)/2) - t.slide_bar_offset; 224 } 225 }else{ 226 var sbw = nav_element.outerWidth() + (2 * t.slide_bar_offset); 227 var sbl = nav_element.position().left - t.slide_bar_offset; 228 } 229 230 t.slide_bar.animate({ width: sbw, left: sbl }, { queue: false, duration: 250 }); 231 } 232 }, 233 mouseleave: function(){ 234 t.slide_bar.animate({ width: t.slide_bar_val.width, left: t.slide_bar_val.left }, { queue: false, duration: 250 }); 235 } 236 }); 237 238 // window resize event 239 $(window).on('resize', function(){ t.init_slidebar_pos(); }); 240 $(window).on('arki-navigation-slider-bar-init', function(){ 241 t.current_menu = t.main_menu.children('.sf-menu').children('.current-menu-item, .current-menu-ancestor').children('a'); 242 t.animate_slidebar_pos(); 243 }); 244 $(window).on('arki-navigation-slider-bar-animate', function(){ t.animate_slidebar_pos(); }); 245 246 }, // init_slidebar 247 248 init_slidebar_pos: function(){ 249 250 if( arki_display == 'mobile-landscape' || arki_display == 'mobile-portrait' || arki_display == 'tablet' ) return; 251 252 var t = this; 253 254 if( t.current_menu.length > 0 ){ 255 if( t.slide_bar_width > 0 ){ 256 var sbw = t.slide_bar_width; 257 if( t.slide_bar.hasClass('arki-left') ){ 258 var sbl = t.current_menu.position().left - t.slide_bar_offset; 259 }else{ 260 var sbl = t.current_menu.position().left + ((t.current_menu.outerWidth() - sbw)/2) - t.slide_bar_offset; 261 } 262 }else{ 263 var sbw = t.current_menu.outerWidth() + (2 * t.slide_bar_offset); 264 var sbl = t.current_menu.position().left - t.slide_bar_offset; 265 } 266 t.slide_bar_val = { width: sbw, left: sbl }; 267 }else{ 268 t.slide_bar_val = { width: 0 } 269 270 var first_child = t.main_menu.children('ul').children('li:first-child'); 271 if( typeof(first_child.position()) != 'undefined' ){ 272 t.slide_bar_val.left = first_child.position().left; 273 }else{ 274 t.slide_bar_val.left = 0; 275 } 276 } 277 t.slide_bar.css({ width: t.slide_bar_val.width, left: t.slide_bar_val.left, display: 'block' }); 278 279 }, // set_slidebar_pos 280 animate_slidebar_pos: function(){ 281 282 if( arki_display == 'mobile-landscape' || arki_display == 'mobile-portrait' || arki_display == 'tablet' ) return; 283 284 var t = this; 285 286 if( t.current_menu.length > 0 ){ 287 if( t.slide_bar_width > 0 ){ 288 var sbw = t.slide_bar_width; 289 if( t.slide_bar.hasClass('arki-left') ){ 290 var sbl = t.current_menu.position().left - t.slide_bar_offset; 291 }else{ 292 var sbl = t.current_menu.position().left + ((t.current_menu.outerWidth() - sbw)/2) - t.slide_bar_offset ; 293 } 294 }else{ 295 var sbw = t.current_menu.outerWidth() + (2 * t.slide_bar_offset); 296 var sbl = t.current_menu.position().left - t.slide_bar_offset; 297 } 298 t.slide_bar_val = { width: sbw, left: sbl }; 299 }else{ 300 t.slide_bar_val = { width: 0 } 301 302 var first_child = t.main_menu.children('ul').children('li:first-child'); 303 if( typeof(first_child.position()) != 'undefined' ){ 304 t.slide_bar_val.left = first_child.position().left; 305 }else{ 306 t.slide_bar_val.left = 0; 307 } 308 } 309 t.slide_bar.animate({ width: t.slide_bar_val.width, left: t.slide_bar_val.left }, { queue: false, duration: 250 }); 310 311 } // set_slidebar_pos 312 313 }; // arki_sf_menu.prototype 314 315 ///////////////////////// 316 // mobile menu 317 ///////////////////////// 318 $.fn.arki_mobile_menu = function( args ){ 319 320 var menu_button = $(this).siblings('.arki-mm-menu-button'); 321 322 if( typeof(Mmenu) != 'undefined' ){ 323 324 // remove blank link for submenu 325 $(this).find('a[href="#"]').each(function(){ 326 var content = $(this).html(); 327 $('<span class="arki-mm-menu-blank" ></span>').html(content).insertBefore($(this)); 328 $(this).remove(); 329 }); 330 331 // activate mmenu 332 var menu = new Mmenu($(this).get(0), { 333 navbar: { 334 title: '<span class="mmenu-custom-close" ></span>' 335 }, 336 offCanvas: {
337 position: $(this).attr('data-slide') 338 } 339 }, { 340 offCanvas: { 341 page: { 342 selector: ".arki-body-outer-wrapper" 343 } 344 } 345 }); 346 347 var menu_api = menu.API; 348 349 // open close action 350 menu_button.on('click', function(){ 351 menu_api.open(); 352 }); 353 $(this).find('a').not('.mm-btn').on('click', function(){ 354 menu_api.close(); 355 }); 356 $(this).find('.mmenu-custom-close').on('click', function(){ 357 menu_api.close(); 358 }); 359 360 // add class active to button 361 menu_api.bind('open:after', function($panel){ 362 menu_button.addClass('arki-active'); 363 }); 364 menu_api.bind('close:after', function($panel){ 365 menu_button.removeClass('arki-active'); 366 }); 367 } 368 369 } 370 371 ///////////////////////// 372 // overlay menu 373 ///////////////////////// 374 var arki_overlay_menu = function( menu ){ 375 376 this.menu = menu; 377 this.menu_button = menu.children('.arki-overlay-menu-icon'); 378 this.menu_content = menu.children('.arki-overlay-menu-content'); 379 this.menu_close = this.menu_content.children('.arki-overlay-menu-close'); 380 381 this.init(); 382 } 383 arki_overlay_menu.prototype = { 384 385 init: function(){ 386 387 var t = this; 388 389 // add transition delay for each menu 390 var delay_count = 0; 391 t.menu_content.appendTo('body'); 392 t.menu_content.find('ul.menu > li').each(function(){ 393 $(this).css('transition-delay', (delay_count * 150) + 'ms'); 394 395 delay_count++; 396 }); 397 398 // bind the menu button 399 t.menu_button.on('click', function(){ 400 $(this).addClass('arki-active'); 401 402 t.menu_content.fadeIn(200, function(){ 403 $(this).addClass('arki-active'); 404 }); 405 406 return false; 407 }); 408 409 // bind the menu close button 410 t.menu_close.on('click', function(){ 411 t.menu_button.removeClass('arki-active'); 412 413 t.menu_content.fadeOut(400, function(){ 414 $(this).removeClass('arki-active'); 415 }); 416 t.menu_content.find('.sub-menu').slideUp(200).removeClass('arki-active'); 417 418 return false; 419 }); 420 421 // menu item click 422 t.menu_content.find('a').on('click', function(e){ 423 var sub_menu = $(this).siblings('.sub-menu'); 424 if( sub_menu.length > 0 ){ 425 if( !sub_menu.hasClass('arki-active') ){ 426 var prev_active = sub_menu.closest('li').siblings().find('.sub-menu.arki-active'); 427 if( prev_active.length > 0 ){ 428 prev_active.removeClass('arki-active').slideUp(150); 429 sub_menu.delay(150).slideDown(400, 'easeOutQuart').addClass('arki-active'); 430 }else{ 431 sub_menu.slideDown(400, 'easeOutQuart').addClass('arki-active'); 432 } 433 434 $(this).addClass('arki-no-preload'); 435 return false; 436 }else{ 437 $(this).removeClass('arki-no-preload'); 438 } 439 }else{ 440 t.menu_close.trigger('click'); 441 } 442 }); 443 444 } 445 446 }; // arki_overlay_menu.prototype 447 448 ///////////////////////// 449 // header side navigation 450 ///////////////////////// 451 var arki_header_side_nav = function( side_nav ){ 452 453 if( side_nav.length == 0 ) return; 454 455 this.prev_scroll = 0; 456 457 this.side_nav = side_nav; 458 this.side_nav_content = side_nav.children(); 459 460 this.init(); 461 462 } // arki_header_side_nav 463 464 arki_header_side_nav.prototype = { 465 466 init: function(){ 467 468 var t = this; 469 470 t.init_nav_bar_element(); 471 472 $(window).resize(function(){ 473 t.init_nav_bar_element(); 474 }); 475 476 $(window).scroll(function(){ 477 478 if( arki_display == 'mobile-landscape' || arki_display == 'mobile-portrait' || arki_display == 'tablet' ) return; 479 480 // if content longer than screen height 481 if( t.side_nav.hasClass('arki-allow-slide') ){ 482 483 var admin_bar_height = parseInt($('html').css('margin-top')); 484 var scroll_down = ($(window).scrollTop() > t.prev_scroll); 485 t.prev_scroll = $(window).scrollTop(); 486 487 // if scroll down 488 if( scroll_down ){ 489 490 if( !t.side_nav.hasClass('arki-fix-bottom') ){ 491 if( t.side_nav.hasClass('arki-fix-top') ){ 492 t.side_nav.css('top', t.side_nav.offset().top); 493 t.side_nav.removeClass('arki-fix-top'); 494 495 }else if( $(window).height() + $(window).scrollTop() > t.side_nav_content.offset().top + t.side_nav_content.outerHeight() ){ 496 if( !t.side_nav.hasClass('arki-fix-bottom') ){ 497 t.side_nav.addClass('arki-fix-bottom'); 498 t.side_nav.css('top', ''); 499 } 500 } 501 } 502 503 // if scroll up 504 }else{ 505 506 if( !t.side_nav.hasClass('arki-fix-top') ){ 507 if( t.side_nav.hasClass('arki-fix-bottom') ){ 508 var top_pos = $(window).scrollTop() + ($(window).height() - admin_bar_height) - t.side_nav_content.outerHeight(); 509 t.side_nav.css('top', top_pos); 510 t.side_nav.removeClass('arki-fix-bottom'); 511 512 }else if( $(window).scrollTop() + admin_bar_height < t.side_nav_content.offset().top ){ 513 if( !t.side_nav.hasClass('arki-fix-top') ){ 514 t.side_nav.addClass('arki-fix-top'); 515 t.side_nav.css('top', ''); 516 } 517 } 518 } 519 520 } 521 522 } 523 }); 524 525 }, 526 527 init_nav_bar_element: function(){ 528 529 if( arki_display == 'mobile-landscape' || arki_display == 'mobile-portrait' || arki_display == 'tablet' ) return; 530 531 var t = this; 532 var middle_pos = t.side_nav_content.children('.arki-pos-middle').addClass('arki-active'); 533 var bottom_pos = t.side_nav_content.children('.arki-pos-bottom').addClass('arki-active'); 534 535 // remove all additional space 536 t.side_nav_content.children('.arki-pre-spaces').remove(); 537 538 // add class depends on the screen size/content 539 if( $(window).height() < t.side_nav_content.height() ){ 540 t.side_nav.addClass('arki-allow-slide'); 541 }else{ 542 t.side_nav.removeClass('arki-allow-slide arki-fix-top arki-fix-bottom').css('top', ''); 543 544 // set the middle position 545 if( t.side_nav.hasClass('arki-style-middle') ){ 546 middle_pos.each(function(){ 547 var top_padding = parseInt($(this).css('padding-top')); 548 var prespace = ((t.side_nav.height() - (t.side_nav_content.height() - top_padding)) / 2) - top_padding; 549 550 if( prespace > 0 ){ 551 $('<div class="arki-pre-spaces" ></div>').css('height', prespace).insertBefore($(this)); 552 } 553 });
554 } 555 556 // set the bottom position 557 bottom_pos.each(function(){ 558 var prespace = t.side_nav.height() - t.side_nav_content.height(); 559 560 if( prespace > 0 ){ 561 $('<div class="arki-pre-spaces" ></div>').css('height', prespace).insertBefore($(this)); 562 } 563 }); 564 565 } 566 } 567 568 }; // arki_sf_menu.prototype 569 570 ///////////////////////// 571 // anchoring 572 ///////////////////////// 573 574 var arki_anchor = function(){ 575 576 this.anchor_link = $('a[href*="#"]').not('[href="#"]').filter(function(){ 577 578 // for mm-menu plugin 579 if( $(this).is('.arki-mm-menu-button, .mm-btn, .mm-blocker, .mm-next, .mm-prev, .mm-title, .gdlr-core-ilightbox') ){ 580 return false; 581 } 582 583 // for google review plugin 584 if( $(this).is('') ){ 585 return false; 586 } 587 588 // for additional plugins 589 if( $(this).is('.fbx-btn-transition, .ti-header') ){ 590 return false; 591 } 592 593 // for woocommerce 594 if( $(this).parent('.description_tab, .reviews_tab').length || $(this).not('[class^="arki"]').closest('.woocommerce').length ){ 595 if( !$(this).closest('.menu-item').length ){ 596 return false; 597 } 598 } 599 600 601 602 return true; 603 }); 604 605 if( this.anchor_link.length || window.location.hash.length ){ 606 this.menu_anchor = $('#arki-main-menu, #arki-bullet-anchor'); 607 this.home_anchor = this.menu_anchor.find('ul.sf-menu > li.current-menu-item > a, ul.sf-menu > li.current-menu-ancestor > a, .arki-bullet-anchor-link.current-menu-item'); 608 609 this.init(); 610 } 611 } 612 arki_anchor.prototype = { 613 614 init: function(){ 615 616 var t = this; 617 618 t.animate_anchor(); 619 t.scroll_section(); 620 621 // init bullet anchor height 622 t.menu_anchor.filter('#arki-bullet-anchor').each(function(){ 623 $(this).css('margin-top', - t.menu_anchor.height() / 2).addClass('arki-init'); 624 }); 625 626 // initialize if the page hash exists 627 // wait for all element to initialize ( eg. flexslider ) 628 var url_hash = window.location.hash; 629 if( url_hash ){ 630 setTimeout(function(){ 631 632 var current_menu = t.menu_anchor.find('a[href*="' + url_hash + '"]'); 633 if( !current_menu.is('.current-menu-item, .current-menu-ancestor') ){ 634 current_menu.addClass('current-menu-item').siblings().removeClass('current-menu-item current-menu-ancestor'); 635 636 $(window).trigger('arki-navigation-slider-bar-init'); 637 } 638 639 t.scroll_to(url_hash, false, 300); 640 }, 500); 641 } 642 }, 643 644 animate_anchor: function(){ 645 646 var t = this; 647 648 // home anchor 649 t.home_anchor.on('click', function(){ 650 651 if( window.location.href == this.href ){ 652 $('html, body').animate({ scrollTop: 0 }, { duration: 1500, easing: 'easeOutQuart' }); 653 return false; 654 } 655 656 }); 657 658 // normal anchor 659 t.anchor_link.on('click', function() { 660 if( location.hostname == this.hostname && location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') ){ 661 if( $(this).closest('#arki-main-menu').length ){ 662 $(this).parent().addClass('current-menu-item').siblings().removeClass('current-menu-item'); 663 $(window).trigger('arki-navigation-slider-bar-init'); 664 } 665 return t.scroll_to(this.hash, true); 666 } 667 }); 668 669 }, // animate anchor 670 671 scroll_to: function( hash, redirect, duration ){ 672 673 // start scrolling 674 if( hash == '#arki-top-anchor' ){ 675 var scroll_position = 0; 676 }else{ 677 678 var target = $(hash); 679 680 if( target.length ){ 681 var scroll_position = target.offset().top; 682 } 683 } 684 685 if( typeof(scroll_position) != 'undefined' ){ 686 687 // offset for wordpress admin bar 688 scroll_position = scroll_position - parseInt($('html').css('margin-top')); 689 690 // offset for fixed nav bar 691 if( arki_display == 'mobile-portrait' || arki_display == 'mobile-landscape' ){ 692 scroll_position = scroll_position - 75; 693 }else if( typeof(window.arki_anchor_offset) != 'undefined' && !isNaN(window.arki_anchor_offset) ){ 694 scroll_position = scroll_position - parseInt(window.arki_anchor_offset); 695 } 696 697 if( scroll_position < 0 ) scroll_position = 0; 698 699 $('html, body').animate({ scrollTop: scroll_position }, { duration: 1500, easing: 'easeOutQuart', queue: false }); 700 701 return false; 702 703 }else if( redirect ){ 704 705 window.location.href = $('body').attr('data-home-url') + hash; 706 707 return false; 708 } 709 710 }, // scroll to 711 712 scroll_section: function(){ 713 714 var t = this; 715 716 // have anchor in anchor menu 717 var menu_link_anchor = this.menu_anchor.find('a[href*="#"]').not('[href="#"]'); 718 if( !menu_link_anchor.length ){ return; } 719 720 // get anchor section 721 var home_anchor_section = $('#arki-page-wrapper'); 722 var anchor_section = home_anchor_section.find('div[id], section[id]'); 723 if( !anchor_section.length ){ return; } 724 725 // add data for faster query 726 menu_link_anchor.each(function(){ 727 if( $(this).closest('.sub-menu').length == 0 && $(this.hash).length ){ 728 $(this).attr('data-anchor', this.hash); 729 } 730 }); 731 732 // check section on scroll event 733 $(window).scroll(function(){ 734 735 if( arki_display == 'mobile-landscape' || arki_display == 'mobile-portrait' || arki_display == 'tablet' ) return; 736 737 if( t.home_anchor.length && $(window).scrollTop() <= home_anchor_section.offset().top ){ 738 739 t.home_anchor.each(function(){ 740 if( $(this).hasClass('arki-bullet-anchor-link') ){ 741 $(this).addClass('current-menu-item').siblings().removeClass('current-menu-item'); 742 $(this).parent('.arki-bullet-anchor').attr('data-anchor-section', 'arki-home'); 743 }else if( !$(this).parent('.current-menu-item, .current-menu-ancestor').length ){ 744 $(this).parent().addClass('current-menu-item').siblings().removeClass('current-menu-item current-menu-ancestor');
745 $(window).trigger('arki-navigation-slider-bar-init'); 746 } 747 }); 748 749 }else{ 750 var section_position = $(window).scrollTop() + ($(window).height() / 2); 751 752 anchor_section.each(function(){ 753 if( $(this).css('display') == 'none' ) return; 754 755 var top_offset_pos = $(this).offset().top; 756 757 if( (section_position > top_offset_pos) && (section_position < top_offset_pos + $(this).outerHeight()) ){ 758 var section_id = $(this).attr('id'); 759 menu_link_anchor.filter('[data-anchor="#' + section_id + '"]').each(function(){ 760 if( $(this).hasClass('arki-bullet-anchor-link') ){ 761 $(this).addClass('current-menu-item').siblings().removeClass('current-menu-item'); 762 $(this).parent('.arki-bullet-anchor').attr('data-anchor-section', section_id); 763 }else if( $(this).parent('li.menu-item').length && !$(this).parent('li.menu-item').is('.current-menu-item, .current-menu-ancestor') ){ 764 $(this).parent('li.menu-item').addClass('current-menu-item').siblings().removeClass('current-menu-item current-menu-ancestor'); 765 $(window).trigger('arki-navigation-slider-bar-init'); 766 } 767 }); 768 769 return false; 770 } 771 772 }); 773 } 774 775 }); 776 777 } // scroll section 778 779 }; 780 781 var arki_sticky_navigation = function(){ 782 783 var t = this; 784 785 // get navigation 786 t.sticky_nav = $('.arki-with-sticky-navigation .arki-sticky-navigation'); 787 t.mobile_menu = $('#arki-mobile-header'); 788 789 // set the anchor offset 790 if( t.sticky_nav.hasClass('arki-sticky-navigation-height') ){ 791 window.arki_anchor_offset = t.sticky_nav.outerHeight(); 792 $(window).resize(function(){ 793 window.arki_anchor_offset = t.sticky_nav.outerHeight(); 794 }); 795 }else if( t.sticky_nav.attr('data-navigation-offset') ){ 796 window.arki_anchor_offset = parseInt(t.sticky_nav.attr('data-navigation-offset')); 797 }else if( t.sticky_nav.length ){ 798 window.arki_anchor_offset = 75; 799 } 800 801 // init the sticky navigation 802 if( t.sticky_nav.length ){ 803 t.init(); 804 } 805 806 if( t.mobile_menu.hasClass('arki-sticky-mobile-navigation') ){ 807 t.style_mobile_slide(); 808 $(window).trigger('arki-set-sticky-mobile-navigation'); 809 } 810 811 } 812 arki_sticky_navigation.prototype = { 813 814 init: function(){ 815 816 var t = this; 817 818 if( t.sticky_nav.hasClass('arki-style-fixed') ){ 819 t.style_fixed(); 820 }else if( t.sticky_nav.hasClass('arki-style-slide') ){ 821 t.style_slide(); 822 } 823 824 $(window).trigger('arki-set-sticky-navigation'); 825 }, 826 827 style_fixed: function(){ 828 829 var t = this; 830 var placeholder = $('<div class="arki-sticky-menu-placeholder" ></div>'); 831 832 $(window).on('scroll arki-set-sticky-navigation', function(){ 833 834 if( arki_display == 'mobile-landscape' || arki_display == 'mobile-portrait' || arki_display == 'tablet' ) return; 835 836 var page_offset = parseInt($('html').css('margin-top')); 837 838 if( !t.sticky_nav.hasClass('arki-fixed-navigation') ){ 839 840 if( $(window).scrollTop() + page_offset > t.sticky_nav.offset().top ){ 841 if( !t.sticky_nav.hasClass('arki-without-placeholder') ){ 842 placeholder.height(t.sticky_nav.outerHeight()); 843 } 844 placeholder.insertAfter(t.sticky_nav); 845 $('body').append(t.sticky_nav); 846 t.sticky_nav.addClass('arki-fixed-navigation'); 847 848 setTimeout(function(){ t.sticky_nav.addClass('arki-animate-fixed-navigation'); }, 10); 849 setTimeout(function(){ 850 t.sticky_nav.css('height', ''); 851 $(window).trigger('arki-navigation-slider-bar-animate'); 852 }, 200); 853 } 854 }else{ 855 856 if( $(window).scrollTop() + page_offset <= placeholder.offset().top ){ 857 if( !t.sticky_nav.hasClass('arki-without-placeholder') ){ 858 t.sticky_nav.height(placeholder.height()); 859 } 860 t.sticky_nav.insertBefore(placeholder); 861 t.sticky_nav.removeClass('arki-fixed-navigation'); 862 placeholder.remove(); 863 864 setTimeout(function(){ t.sticky_nav.removeClass('arki-animate-fixed-navigation'); }, 10); 865 setTimeout(function(){ 866 t.sticky_nav.css('height', '');
867 $(window).trigger('arki-navigation-slider-bar-animate'); 868 }, 200); 869 } 870 } 871 }); 872 873 }, // style_fixed 874 875 style_slide: function(){ 876 877 var t = this; 878 var placeholder = $('<div class="arki-sticky-menu-placeholder" ></div>'); 879 880 $(window).on('scroll arki-set-sticky-navigation', function(){ 881 882 if( arki_display == 'mobile-landscape' || arki_display == 'mobile-portrait' || arki_display == 'tablet' ){ return; } 883 884 var page_offset = parseInt($('html').css('margin-top')); 885 886 if( !t.sticky_nav.hasClass('arki-fixed-navigation') ){ 887 888 if( $(window).scrollTop() + page_offset > t.sticky_nav.offset().top + t.sticky_nav.outerHeight() + 200 ){ 889 890 if( !t.sticky_nav.hasClass('arki-without-placeholder') ){ 891 placeholder.height(t.sticky_nav.outerHeight()); 892 } 893 placeholder.insertAfter(t.sticky_nav); 894 t.sticky_nav.css('display', 'none'); 895 896 $('body').append(t.sticky_nav); 897 t.sticky_nav.addClass('arki-fixed-navigation arki-animate-fixed-navigation'); 898 t.sticky_nav.slideDown(200); 899 $(window).trigger('arki-navigation-slider-bar-animate'); 900 } 901 }else{ 902 903 if( $(window).scrollTop() + page_offset <= placeholder.offset().top + placeholder.height() + 200 ){ 904 var clone = t.sticky_nav.clone(); 905 clone.insertAfter(t.sticky_nav); 906 clone.slideUp(200, function(){ $(this).remove(); }); 907 908 t.sticky_nav.insertBefore(placeholder); 909 placeholder.remove(); 910 t.sticky_nav.removeClass('arki-fixed-navigation arki-animate-fixed-navigation'); 911 t.sticky_nav.css('display', 'block'); 912 913 $(window).trigger('arki-navigation-slider-bar-animate'); 914 } 915 } 916 }); 917 918 }, // style_slide 919 920 style_mobile_slide: function(){ 921 922 var t = this; 923 var placeholder = $('<div class="arki-sticky-mobile-placeholder" ></div>'); 924 925 $(window).on('scroll arki-set-sticky-mobile-navigation', function(){ 926 927 if( arki_display == 'mobile-landscape' || arki_display == 'mobile-portrait' || arki_display == 'tablet' ){ 928 929 var page_offset = parseInt($('html').css('margin-top')); 930 931 if( !t.mobile_menu.hasClass('arki-fixed-navigation') ){ 932 if( $(window).scrollTop() + page_offset > t.mobile_menu.offset().top + t.mobile_menu.outerHeight() + 200 ){ 933 placeholder.height(t.mobile_menu.outerHeight()).insertAfter(t.mobile_menu); 934 $('body').append(t.mobile_menu); 935 t.mobile_menu.addClass('arki-fixed-navigation'); 936 t.mobile_menu.css('display', 'none').slideDown(200); 937 } 938 }else{ 939 if( $(window).scrollTop() + page_offset <= placeholder.offset().top + placeholder.height() + 200 ){ 940 var clone = t.mobile_menu.clone(); 941 clone.insertAfter(t.mobile_menu); 942 clone.slideUp(200, function(){ $(this).remove(); }); 943 944 t.mobile_menu.insertBefore(placeholder); 945 placeholder.remove(); 946 t.mobile_menu.removeClass('arki-fixed-navigation'); 947 t.mobile_menu.css('display', 'block'); 948 } 949 } 950 } 951 952 }); 953 954 }, // style_slide 955 956 }; 957 958 var arki_font_resize = function(){ 959 960 this.heading_font = $('h1, h2, h3, h4, h5, h6'); 961 962 this.init(); 963 964 } 965 arki_font_resize.prototype = { 966 967 init: function(){ 968 969 var t = this; 970 971 t.resize(); 972 $(window).on('resize', arki_throttling(function(){ 973 t.resize(); 974 }, 100)); 975 976 }, 977 978 resize: function(){ 979 980 var t = this; 981 982 if( arki_display == 'mobile-landscape' || arki_display == 'mobile-portrait' ){ 983 984 t.heading_font.each(function(){ 985 if( parseInt($(this).css('font-size')) > 40 ){ 986 if( !$(this).attr('data-orig-font') ){ 987 $(this).attr('data-orig-font', $(this).css('font-size')); 988 } 989 990 $(this).css('font-size', '40px'); 991 } 992 }); 993 994 // return font to normal 995 }else{ 996 997 t.heading_font.filter('[data-orig-font]').each(function(){ 998 $(this).css('font-size', $(this).attr('data-orig-font')); 999 }); 1000 1001 } 1002 } 1003 1004 }; 1005 1006 // tourmaster lightbox 1007 function arki_lightbox( content ){ 1008 1009 var lightbox_wrap = $('<div class="arki-lightbox-wrapper" ></div>').hide(); 1010 var lightbox_content_wrap = $('<div class="arki-lightbox-content-cell" ></div>'); 1011 lightbox_wrap.append(lightbox_content_wrap); 1012 lightbox_content_wrap.wrap($('<div class="arki-lightbox-content-row" ></div>')); 1013 1014 lightbox_content_wrap.append(content); 1015 1016 var scrollPos = $(window).scrollTop(); 1017 $('html').addClass('arki-lightbox-on'); 1018 $('body').append(lightbox_wrap); 1019 lightbox_wrap.fadeIn(300); 1020 1021 // do a lightbox action 1022 lightbox_wrap.on('click', '.arki-lightbox-close', function(){ 1023 $('html').removeClass('arki-lightbox-on'); 1024 $(window).scrollTop(scrollPos); 1025 lightbox_wrap.fadeOut(300, function(){ 1026 $(this).remove(); 1027 }); 1028 }); 1029 1030 } // arki_lightbox 1031 1032 //////////////////////////////// 1033 // starting running the script 1034 //////////////////////////////// 1035 $(document).ready(function(){ 1036 1037 // resize font on mobile 1038 new arki_font_resize(); 1039 1040 // init main navigation menu 1041 $('#arki-main-menu, #arki-right-menu, #arki-mobile-menu, #arki-top-bar-menu').each(function(){ 1042 if( $(this).hasClass('arki-overlay-menu') ){ 1043 new arki_overlay_menu( $(this) ); 1044 }else if( $(this).hasClass('arki-mm-menu-wrap') ){ 1045 $(this).arki_mobile_menu(); 1046 }else{ 1047 new arki_sf_menu( $(this) ); 1048 } 1049 }); 1050 1051 $('#arki-top-search, #arki-mobile-top-search').each(function(){ 1052 1053 var search_wrap = $(this).siblings('.arki-top-search-wrap'); 1054 search_wrap.appendTo('body'); 1055
1056 // bind click button 1057 $(this).on('click', function(){ 1058 search_wrap.fadeIn(200, function(){ 1059 $(this).addClass('arki-active'); 1060 }); 1061 }); 1062 1063 // bind close button 1064 search_wrap.find('.arki-top-search-close').on('click', function(){ 1065 search_wrap.fadeOut(200, function(){ 1066 $(this).addClass('arki-active'); 1067 }); 1068 }); 1069 1070 // bind search button 1071 search_wrap.find('.search-submit').on('click', function(){ 1072 if( search_wrap.find('.search-field').val().length == 0 ){ 1073 return false; 1074 } 1075 }); 1076 }); 1077 1078 $('#arki-main-menu-cart, #arki-mobile-menu-cart').each(function(){ 1079 1080 $(this).on({ 1081 mouseenter: function(){ 1082 $(this).addClass('arki-active arki-animating'); 1083 }, 1084 mouseleave: function(){ 1085 var menu_cart = $(this); 1086 menu_cart.removeClass('arki-active'); 1087 setTimeout(function(){ 1088 menu_cart.removeClass('arki-animating'); 1089 }, 400) 1090 } 1091 }); 1092 }); 1093 1094 // woocommerce top bar cart 1095 if( typeof(wc_add_to_cart_params) != 'undefined' ){ 1096 $('body').on('added_to_cart', function(){ 1097 $.ajax({
1098 type: 'POST', 1099 url: wc_add_to_cart_params.ajax_url, 1100 data: { 'action': 'top_bar_woocommerce_cart' }, 1101 dataType: 'json', 1102 error: function(jqXHR, textStatus, errorThrown){ 1103 console.log(jqXHR, textStatus, errorThrown); 1104 }, 1105 success: function(data){ 1106 if( typeof(data['title']) != 'undefined' ){ 1107 $('.arki-top-cart-title').replaceWith(data['title']); 1108 } 1109 if( typeof(data['cart-items']) != 'undefined' ){ 1110 $('.arki-top-cart-item-wrap').replaceWith(data['cart-items']); 1111 } 1112 } 1113 }); 1114 }); 1115 } 1116 1117 1118 // arki 1119 $('#arki-dropdown-arki-flag').hover(function(){ 1120 $(this).children('.arki-dropdown-arki-list').fadeIn(200); 1121 }, function(){ 1122 $(this).children('.arki-dropdown-arki-list').fadeOut(200); 1123 }); 1124 1125 // additional space for header transparent 1126 $('.arki-header-boxed-wrap, .arki-header-background-transparent, .arki-navigation-bar-wrap.arki-style-transparent').each(function(){ 1127 var header_transparent = $(this); 1128 var header_transparent_sub = $('.arki-header-transparent-substitute'); 1129 1130 header_transparent_sub.height(header_transparent.outerHeight()); 1131 $(window).on('load resize', function(){ 1132 header_transparent_sub.height(header_transparent.outerHeight()); 1133 }); 1134 }); 1135 1136 // full screen for 404 not found 1137 $('body.error404, body.search-no-results').each(function(){ 1138 1139 var wrap = $(this).find('#arki-full-no-header-wrap'); 1140 var body_wrap_offset = parseInt($(this).children('.arki-body-outer-wrapper').children('.arki-body-wrapper').css('margin-bottom')); 1141 1142 var padding = ($(window).height() - wrap.offset().top - wrap.outerHeight() - body_wrap_offset) / 2; 1143 if( padding > 0 ){ 1144 wrap.css({ 'padding-top': padding, 'padding-bottom': padding }); 1145 } 1146 1147 $(window).on('load resize', function(){ 1148 wrap.css({ 'padding-top': 0, 'padding-bottom': 0 }); 1149 padding = ($(window).height() - wrap.offset().top - wrap.outerHeight() - body_wrap_offset) / 2; 1150 if( padding > 0 ){ 1151 wrap.css({ 'padding-top': padding, 'padding-bottom': padding }); 1152 } 1153 }); 1154 }); 1155 1156 // back to top button 1157 var back_to_top = $('#arki-footer-back-to-top-button'); 1158 if( back_to_top.length ){ 1159 $(window).on('scroll', function(){ 1160 if( $(window).scrollTop() > 300 ){ 1161 back_to_top.addClass('arki-scrolled'); 1162 }else{ 1163 back_to_top.removeClass('arki-scrolled'); 1164 } 1165 }); 1166 } 1167 1168 // page preload 1169 $('body').children('#arki-page-preload').each(function(){ 1170 var page_preload = $(this); 1171 var animation_time = parseInt(page_preload.attr('data-animation-time')); 1172 1173 $('a[href]').not('[href^="#"], [href^="mailto:"], [target="_blank"], .gdlr-core-js, .strip, .sf-with-ul, .remove, .ajax_add_to_cart, .comment-reply-link').on('click', function(e){ 1174 if( e.which != 1 || $(this).hasClass('arki-no-preload') || e.ctrlKey ) return; 1175 1176 if( $(this).prop("hash") && $($(this).prop("hash")).length ) return; 1177 1178 if( window.location.href != this.href ){ 1179 page_preload.addClass('arki-out').fadeIn(animation_time); 1180 } 1181 }); 1182 1183 $(window).on('load', function(){ 1184 page_preload.fadeOut(animation_time); 1185 }); 1186 }); 1187 1188 // single nav style 2 sync height 1189 $('body.arki-blog-style-2 .arki-single-nav-area').each(function(){ 1190 var max_height; 1191 var single_nav_2 = $(this).children(); 1192 1193 max_height = 0; 1194 single_nav_2.css('min-height', '0px'); 1195 single_nav_2.each(function(){ 1196 if( max_height < $(this).outerHeight() ){ 1197 max_height = $(this).outerHeight(); 1198 } 1199 }); 1200 single_nav_2.css('min-height', max_height); 1201 1202 $(window).resize(function(){ 1203 max_height = 0; 1204 single_nav_2.css('min-height', '0px'); 1205 single_nav_2.each(function(){ 1206 if( max_height < $(this).outerHeight() ){ 1207 max_height = $(this).outerHeight(); 1208 } 1209 }); 1210 single_nav_2.css('min-height', max_height); 1211 }); 1212 }); 1213 1214 // lightbox popup 1215 $('[data-arki-lb]').click(function(){ 1216 var lb_content = $(this).siblings('[data-arki-lb-id="' + $(this).attr('data-arki-lb') + '"]'); 1217 arki_lightbox(lb_content.clone()); 1218 }); 1219 1220 // float social 1221 $('#arki-float-social').each(function(){ 1222 var float_social_item = $(this);
1223 var pb_body = $('.gdlr-core-page-builder-body'); 1224 1225 var footer = $('footer'); 1226 var content_area = $('.arki-page-wrapper'); 1227 var content_offset = 0; 1228 content_offset += parseInt($('html').css('margin-top')); 1229 1230 $(window).on('scroll float-social', function(){ 1231 1232 1233 // display 1234 if( float_social_item.hasClass('arki-display-after-title') ){ 1235 var blog_offset = 0; 1236 content_area.children('.arki-blog-title-wrap').each(function(){ blog_offset = $(this).outerHeight(); }); 1237 1238 if( float_social_item.offset().top >= content_area.offset().top + blog_offset - content_offset ){ 1239 float_social_item.animate({'opacity': 1}, {duration: 100, queue: false}); 1240 }else{ 1241 float_social_item.animate({'opacity': 0}, {duration: 100, queue: false}); 1242 } 1243 } 1244 1245 // section 1246 var section = ''; 1247 var fs_pos = $(window).scrollTop() + $(window).height() / 2; 1248 1249 if( fs_pos > footer.offset().top ){ 1250 section = 'footer'; 1251 }else{ 1252 pb_body.children().each(function(){ 1253 if( !$(this).attr('data-float-social') ) return; 1254 1255 if( fs_pos > $(this).offset().top && fs_pos < $(this).offset().top + $(this).outerHeight() ){ 1256 section = $(this).attr('data-float-social'); 1257 } 1258 }); 1259 } 1260 1261 float_social_item.attr('data-section', section); 1262 }); 1263 $(window).on('load', function(){ 1264 $(window).trigger('float-social'); 1265 }); 1266 }); 1267 1268 // side content menu 1269 $('#arki-side-content-menu').each(function(){ 1270 1271 var side_content_menu = $(this); 1272 var menu_button = $('.arki-side-content-menu-button'); 1273 menu_button.on('click', function(){ 1274 side_content_menu.fadeIn(300); 1275 side_content_menu.addClass('arki-active'); 1276 }); 1277 side_content_menu.on('click', '.arki-side-content-menu-close', function(){ 1278 side_content_menu.removeClass('arki-active'); 1279 side_content_menu.fadeOut(300); 1280 }); 1281 1282 }); 1283 1284 }); 1285 1286 // fix back button for preload 1287 $(window).on('pageshow', function(event) { 1288 $('body').children('#arki-page-preload').each(function(){ 1289 $(this).fadeOut(400); 1290 }); 1291 }); 1292 1293 $(window).on('load', function(){ 1294
1295 // fixed footer 1296 $('#arki-fixed-footer').each(function(){ 1297 var fixed_footer = $(this); 1298 var placeholder = $('<div class="arki-fixed-footer-placeholder" ></div>'); 1299 1300 placeholder.insertBefore(fixed_footer); 1301 placeholder.height(fixed_footer.outerHeight()); 1302 $('body').css('min-height', $(window).height() - parseInt($('html').css('margin-top'))); // for safari 1303 $(window).resize(function(){ 1304 placeholder.height(fixed_footer.outerHeight()); 1305 $('body').css('min-height', $(window).height() - parseInt($('html').css('margin-top'))); 1306 }); 1307 }); 1308 1309 // side navigation bar 1310 new arki_header_side_nav( $('#arki-header-side-nav') ); 1311 1312 // sticky navigation 1313 new arki_sticky_navigation(); 1314 1315 // anchoring 1316 new arki_anchor(); 1317 1318 // update woocommerce data 1319 $('body').not('.woocommerce-cart, .woocommerce-checkout').trigger('added_to_cart'); 1320 }); 1321 1322})(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.